unsigned short temp = 0; // variable to use as PORTB dump
void interrupt(void){
if (INTCON.RBIF == 1)
{
PORTA = ~PORTA; // invert PORTD
temp = PORTB; //Read PORTB to clear mismatch
INTCON.RBIF = 0; // Clear interrupt flag
}//end intcon.RBIF if
}//end ISR
void main() {
OPTION_REG = 0x80; // set internal PORTB pulls ON
TRISA = 0; // PORTD as output
PORTA = 0; // Set PORTD to 0101 0101 pattern
TRISB = 0xFF; // PORTB as input
// temp = PORTB; // read PORTB not actually required at this point
INTCON.RBIF = 0; // Clear interrupt flag prior to enable
INTCON.RBIE = 1; // enable on change interrupts
INTCON.GIE = 1; // enable Global interrupts
do{
Delay_ms(10); // just an empty loop
// to keep code running
}while(1);
}// main