PS2 Control Using MCU

Autonomous Robot, Manual Robot, DC Motor Driver, Stepper Motor Driver, Servo, Multi PWM chip.....

PS2 Control Using MCU

Postby jahanzeb » 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 :

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
jahanzeb
Greenhorn
 
Posts: 2
Joined: Sat Jan 19, 2013 11:49 pm

Re: PS2 Control Using MCU

Postby shahrul » Sun Jan 20, 2013 8:25 am

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.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: PS2 Control Using MCU

Postby ober » Sun Jan 20, 2013 9:12 pm

What is the interfacing voltage of dsPIC33F?
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: PS2 Control Using MCU

Postby jahanzeb » Sun Jan 20, 2013 10:32 pm

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.
jahanzeb
Greenhorn
 
Posts: 2
Joined: Sat Jan 19, 2013 11:49 pm


Return to Robot Controller

Who is online

Users browsing this forum: No registered users and 15 guests

cron