HELP! PIC18F452 RB port change interrupt

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

HELP! PIC18F452 RB port change interrupt

Postby boonthiam89 » Mon Mar 12, 2012 9:31 am

Guys. I would like to initiate an interrupt caused by changes of Port RB7. The following code is written by me and the LED cannot light once the state of Port RB7 is changed. I am using microC pro in programming. The RBIF is actually used read the position of motor using the quadrature encoder attached to the motor. So, there will be 2 RB ports used and interrupt will be induced if either of the RB ports changes their state.

#define LED1 PortA.F7

void interrupt(){
if(INTCON.RBIF==1)
{
LED1=1;
delay_ms(500);
LED1=0;
INTCON.RBIF=0;
}
}
void main ()
{
TRISA = 0;
TRISB = 0b10000000;
INTCON = 0b01001000;
while (1)
{

}
}
boonthiam89
Freshie
 
Posts: 4
Joined: Mon Nov 14, 2011 1:18 pm

Re: HELP! PIC18F452 RB port change interrupt

Postby Hollowaykeanho » Mon Mar 12, 2012 9:45 pm

hi boonthiam89,

LED1 PortA.F7


Not sure in MicroC but F7? Perhaps maybe A7 or RA7?

INTCON = 0b01001000;



bit-8 must be 1 (Global Interrupts Enable Bit --GIE). Something like: 0b11001000. Refer datasheet for settings. ;)
Hollowaykeanho
Newbie
 
Posts: 12
Joined: Wed Jun 22, 2011 6:39 am
Location: KL

Re: HELP! PIC18F452 RB port change interrupt

Postby sich » Sun Mar 18, 2012 5:18 pm

Hi Hollowaykeanho, good to see another problem solver here in this forum ;) Welcome!
~> How to ask QUESTIONS the SMART way in FORUM? <~
User avatar
sich
Moderator
 
Posts: 604
Joined: Tue Apr 21, 2009 2:15 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 0 guests

cron