how to use interrupt with SKPS PS2 controller?

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

how to use interrupt with SKPS PS2 controller?

Postby gorgom » Wed Nov 16, 2011 10:04 am

I need to use interrupt when the PS2 controller button is pushed. Can anybody show me the example hi-tech C code?
gorgom
Newbie
 
Posts: 13
Joined: Sat Oct 15, 2011 11:11 pm

Re: how to use interrupt with SKPS PS2 controller?

Postby shahrul » Wed Nov 16, 2011 11:13 am

gorgom WROTE:I need to use interrupt when the PS2 controller button is pushed. Can anybody show me the example hi-tech C code?

Here the code using Hi-Tech for the SKPS PS2.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: how to use interrupt with SKPS PS2 controller?

Postby gorgom » Wed Nov 16, 2011 12:53 pm

thanks shahrul.

static void interrupt isr(void)
{
if(RCIF==1) status[DATA]=RCREG;
}

From the interrupt function above, can you explain status[DATA]=RCREG; instruction more detail because the declared variable is unsigned char DATA,status[31];. Sorry, I'm quite new with PIC. :D
gorgom
Newbie
 
Posts: 13
Joined: Sat Oct 15, 2011 11:11 pm

Re: how to use interrupt with SKPS PS2 controller?

Postby shahrul » Wed Nov 16, 2011 1:20 pm

gorgom WROTE:thanks shahrul.

static void interrupt isr(void)
{
if(RCIF==1) status[DATA]=RCREG;
}

From the interrupt function above, can you explain status[DATA]=RCREG; instruction more detail because the declared variable is unsigned char DATA,status[31];. Sorry, I'm quite new with PIC. :D

Store the status of SKPS protocol. Refer SKPS datasheet, I gather information data 0-28
CODE: SELECT_ALL_CODE
   if(DATA<28) DATA++;
   else DATA=0;
   uart_transmit(DATA);
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: how to use interrupt with SKPS PS2 controller?

Postby gorgom » Wed Nov 16, 2011 2:45 pm

Thanks. I get it now. There is int read_a2d(unsigned char channel); function in the provided source code. But it seem not use in the main program. Can I just delete the function.
gorgom
Newbie
 
Posts: 13
Joined: Sat Oct 15, 2011 11:11 pm

Re: how to use interrupt with SKPS PS2 controller?

Postby shahrul » Wed Nov 16, 2011 4:26 pm

gorgom WROTE:Thanks. I get it now. There is int read_a2d(unsigned char channel); function in the provided source code. But it seem not use in the main program. Can I just delete the function.

Yes, you just delete that on re-compile either error or not.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 4 guests

cron