I have a pic16F688 and I am trying to call an interrupt when the RA5 pin changes. I've read the datasheet, searched the web, and looked at this forum and all the info I got seemed to be saying that I'm doing it right... But it doesn't work. I have the pickit2 and I am using hi-tech pro lite. Any help would be great.
Code:
#define LED RC5
int on = 0;
void main ()
{
OSCCON = 0b01111100;
DelayMs(200);
// ADC off, all digital I/O
ANSEL = 0;
CMCON0=0x07;
// PORT direction register
TRISA = 0b00111000;
TRISC = 0b00000000;
//Interupt on change
GIE = 1;
ei(); //Global Interrupts
RAIF = 0;
IOCA5 = 1;
int x = PORTA; //read port
while (run == 1)
{
if (on==0)
{
LED=1;
}
else
{
LED=0;
}
}
}
void interrupt isr(void)
{
on=1;
int x = PORTA; //read the port
RAIF = 0; // clear flag
}