OK guys... got it going. Here is the snippet of the the code around the sleep command. Works like a charm.
What I've done is I gave it a delay of 3 seconds from the closure of the switch to make sure PortB is undisturbed, then I took a snapshot of PortB (read it into a dummy variable), set up the interrupt and put the PIC to sleep. Once awoken, I read PortB again and cleared the flag.
Now here is another question... I'm also running Darrel Taylor's interrupt routine based on TMR1. I use it to flash a LED if a battery is low.
However, once the chip awakens from sleep, it would appear that this interrupt isn't working anymore (ie. no flashing).
I've noticed the same thing happens if I try to declare INTCON=00001000 at the top of the program... does this make sense?
Code:
pause 3000
dummyread=PortB
intcon=%00001000
@ sleep
@ nop
dummyread=PortB
intcon.0=0
Bookmarks