Help with PORTB Interrupt On Change Please
Hi All,
I am looking to use PORTB Interrupt On Change on a PIC18F26J50 but can't get my head around how to determine which pin (PORTB.4 - 7) caused the interrupt.
I would like to set up four momentary action switches to each of the four PORTB IOC pins (with associated pull up resistors) and then action different sections of code depending on which switch was activated.
I have searched the FORUM looking for examples but haven't found anything which answers my questions.
Any assistance and/or guidance would be greatly appreciated.
Cheers
Barry
VK2XBP
Re: Help with PORTB Interrupt On Change Please
one way
oldportb var byte
pbchange var byte
in main before isr enabled
oldportb=portb
in isr {portb must have changed to get here}
pbchange = portb ^ oldportb ; xor portb with last known state and set bits that changed
oldportb=portb ;update state
pbchange=pbchange>>4 ; shift result to low byte
int returm
Re: Help with PORTB Interrupt On Change Please
Thanks Richard.
It was the xor process that I was missing.
Cheers
Barry
VK2XBP