I have a PIC16f877 with PORTB configured as follows:
RB0 Output
RB1 Output
RB2 Output
RB3 Output
RB4 Input
RB5 Input
RB6 Output
RB7 Output
RB4..5 are used for detecting 2 simple push button switches, and I want to make used of the RBIF interrupt flag to handle the event of a button press, rather than polling.
Looking at the datasheet on page 31, is says this:
The user, in the Interrupt Service Routine, can clear the interrupt in the following manner:
a) Any read or write of PORTB. This will end the mismatch condition.
b) Clear flag bit RBIF.
A mismatch condition will continue to set flag bit RBIF. Reading PORTB will end the mismatch condition and allow flag bit RBIF to be cleared.
My concern is that it specifically says "Any WRITE of portb". The other pins on PORTB that are set to output are used for PWM dimmed LEDs, and therefore written to very frequently. I don't want an input change on RB4 or RB5 occurring a few cycles before a PORTB write to clear a mismatch condition and not fire the interrupt.
However, the datasheet contradicts itself in the previous paragraph:
Only pins configured as inputs can cause this interrupt to occur (i.e., any RB7:RB4 pin configured as an output is excluded from the interrupt on-change comparison).
Which would mean I'm gonna be ok and not have to worry about writes to PORTB affecting the interrupt.
Is this something I need to worry about? I can't move the outputs to another port as I don't have enough spare pins on the chip.