PS2 Control Using MCU
Posted: Sat Jan 19, 2013 11:58 pm
Hi i bought PS2 Controller Starter Kit, i am using dspic33fj64mc802 controller for serial communication. I configured the uart correctly and checked twice in debug mode , it receives and transmits the chars successfully. Now when i connected the skps to read the buttons my controller always stucks on get function.
i.e i checked using run-time debug, it successfully transmits the char and then wait for the skps to receive response.
Anu idea how this issue can be resolved. Below is the code :
Thanks
i.e i checked using run-time debug, it successfully transmits the char and then wait for the skps to receive response.
Anu idea how this issue can be resolved. Below is the code :
- CODE: SELECT_ALL_CODE
char a='d'; //check char
int main()
{
clk();
config();
INIT_UART2();
while(1)
{
if(GET_PS2(p_left)==0)
{
a='g';
while(1);
}
}
/////
void TRANSMIT_C2(unsigned char value)
{
while(!U2STAbits.TRMT);
U2TXREG = value;
__delay32(100); //Little Delay
while(!U2STAbits.TRMT);
_U2RXIF=0;
__delay32(100); //Little Delay
}
/////// stucks in this function /////
unsigned char GET_C2(void)
{
__delay32(100); //Little Delay
while (_U2RXIF==0); // Wait and Receive One Character /// Here in this loop
_U2RXIF=0;
return U2RXREG;
__delay32(100); //Little Delay
}
unsigned char GET_PS2(unsigned char value)
{
TRANSMIT_C2(value);
return GET_C2();
}
Thanks