PIC16F677 IOC in CCS PICC

For the PIC16F677, you may be tempted to use both the #INT_RB and the #INT_RA interrupts since the part certainly seems to have both of these covering RA5:0 and RB7:4... DON'T DO IT!

As part of the Interrupt On Change (IOC) handler, you are required to read the ports to get a fresh image of the pins, thus preventing the IOC from continuously interrupting the processor.  Even though there are handlers for both RA and RB gladly supplied by PICC, only the RBIOC is decoded in the PICC as there is only one bit for both ports called the "RABIF".
//This is the right way to do it for PICC!
#int_RB
void RB_isr(void){
unsigned int8 temp;
temp=porta;
temp=portb;
}

//This will certainly break your spirit!
//The RA code never gets executed, even if RA was the
//interrupting port

#int_RA

void RA_isr(void){
unsigned int8 temp;
temp=porta;
}

//With one IOC bit, RB is the only handler called.
//If RA was the interrupting port then this interrupt
//gets called until the WDT resets the part!

#int_RB
void RB_isr(void){
unsigned int8 temp;
temp=portb;
}

Any questions or comments?
 This page last updated on May 04, 2009