PDA

View Full Version : Multiple interrupt source determination



PickyBiker
- 5th April 2010, 17:05
I need to use the bit change interrupt feature on a PIC16F76 and determine which of 4 inputs (RB4-RB7) actally changed. I looked through a multitude of sample interrupt programs but didn't find any that deal with multiple inputs. When a bit change interrupt occurs, I don't see an easy way of determining which specific port bit changed, so the following logic seems necessary.

Store the state of all 4 (RB4-RB7) inputs

' interrupt routine
compare the 4 ports to the saved state to determine which one changed
save the input state for the next interrupt
do something in response to the bit that changed
reset the interrupt flag
resume

Is this the right way to determine which of the 4 inputs caused the interrupt?

Thanks,

PickyBiker

rmteo
- 5th April 2010, 17:17
Correct. You have to read the port anyway (comparing it to the state variable will do it) to clear the mismatch condition.

PickyBiker
- 5th April 2010, 17:32
Thanks RMTEO.