Page 1 of 1

PS2 Control Using MCU

PostPosted: Sat Jan 19, 2013 11:58 pm
by jahanzeb
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 :

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

Re: PS2 Control Using MCU

PostPosted: Sun Jan 20, 2013 8:25 am
by shahrul
You checked UART on debug mode. Did you test send UART to the Hyperterminal?
Because I never use UART on dsPIC yet, so I don't know the function. This is an example use SKPS using PIC16/PIC18.

Re: PS2 Control Using MCU

PostPosted: Sun Jan 20, 2013 9:12 pm
by ober
What is the interfacing voltage of dsPIC33F?

Re: PS2 Control Using MCU

PostPosted: Sun Jan 20, 2013 10:32 pm
by jahanzeb
Yes i checked the transmission of uart on hyper-terminal. dspic33f needs 3.3v to power up. I am giving 3.3v to dspic and 5v to skps, both grounds are common. Now when i pressed the button of ps2, blue LED on skps blinks (which means it decodes the key successfully) , dnt know where the problem is.

Now i am building the development board of 18f and test it as well.