In the code below, Im trying to use the interrupt that is generated when there is a change in the PORTB pins <4,5,6,7>. The datasheet says that I need to enable the interrupt in the 3rd pin(RBIE) of INTCON. And the interrupt flag is the 0th pin(RBIF) of INTCON. I've configured MPLAB to provide stimulus to the 5th pin of PORTB at the 20th instruction cycle.
When I run the program, MPLAB provides the stimulus at the 20th instruction cycle and the RBIF flag gets set since there is a change in the 5th pin, but it is not generating an interrupt. That is, the program execution continues with the next statement without jumping to "Program Counter Address" 0x04(Default location for ISR).
You also need to return from the ISR and clear the interrupt flag in software.
I would suggest to switch back to bank 0 in order to avoid future problems, if you're going to add further code.
Also clear that interrupt flag before enabling the interrupts. Change on PortB can happen at anytime which includes before you are ready for the change. If so, the moment you call NITZ the interrupt may trigger but be false. This happens because the micro or any of the external circuitry is not stable by the time the code is running. Enable power up time, too long for my taster, or call a short delay before MAIN.
Makes no real difference but will be much easier to read and debug if the subs are below MAIN.