need help to figure out the problem with the interrupt code for pic 16f873a.

Status
Not open for further replies.

rosh6270

Newbie level 1
Joined
Mar 5, 2013
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,280
Activity points
1,280
The led connected to portc behaves funny when connected to the pic and doesnt seem to acknowledge the interrupt.


unsigned char presence=0;

void ISR(void)
{
if(INTCON.RBIF==1)
{
presence=1;
INTCON.RBIF=0;
}
}

void main(void)
{
TRISB=0x20;// rb5 is pir input
TRISC=0x00;

INTCON.GIE=1;
INTCON.RBIE=1;

while(1)
{
if(presence) // PIR Sensor
{
PORTC=~PORTC; // led output
delay_ms(500);

}

}
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…