I am working with a PIC16F877A on a simulator on MPLABX 5.35 with XC8 compiler ver 2.32. I am trying to understand and work with the external interrupt, I am facing a few issues while debugging.
#include <xc.h>
#define _XTAL_FREQ 1000000
void __interrupt() check(void){
__delay_ms(4);
INTCONbits.INTF = 0;
return;
}
void main(void){
TRISBbits.TRISB0 = 1; //setting RB0 for input
OPTION_REGbits.INTEDG = 0; //setting falling edge trigger
INTCONbits.INTE = 1; //setting external interrupt (RBO) to on
INTCONbits.GIE = 1; //setting enabling global interrupts
INTCONbits.INTF = 0; //setting external interrupts flags to off
while(1){
}
}
I'm looping a while loop and fire check()
when there is a change in RB0
.
I am using stimulus to change the RB0 value to fire the ISR. To check whether it's firing I placed a breakpoint at __delay_ms(4
). But when I debug, for some reason it does not fire the ISR. During debug mode, it just seems to be stuck in the while loop. I tried to use the SLEEP();
macro but that did not work as it would just go to the end of the main function (I am not sure if that is sleep macro, I am assuming that it's the end of the program).
When I fire the low pulse through the stimulus, it does not change to the check function, its just stuck in the while loop. What am is supposed to do the debug the interrupt so I can get seeable output.