Hi All,

I wrote a little routine for putting PIC18F47J13 to Sleep and Waking Up from a key press. Works fine. Interested in the need to read PortB before @ Sleep? Reading various articles, I think the idea is to perform the read establishing the Before condition for the PortB Interrupt on Change function will work. After doing the read in these articles, nothing subsequently is done with the "Dummy" var. Although that makes some sense, it works with and without. Mostly trying to understand the rules here as otherwise it will bite me in the nose at some inconvenient time.

Dummy = PortB ' Read PortB to support Interrupt on Change Starting Reference?


WakeSleep:
' Get Ready for Sleep
INTCON.7 = 1 ' Enable GIE (Global Interrupt Enable)
INTCON.3 = 1 ' Enable RBIE (PortB Change Interrupt Enable)
INTCON.0 = 0 ' Clear RBIF (PortB Interrupt Flag)


@ Sleep
' Stop using Interrupts (So as not be interrupted!)
INTCON.7 = 0 ' Disable GIE (Global Interrupt Enable)
INTCON.3 = 0 ' Disable RBIE (PortB Change Interrupt Enable)
INTCON.0 = 0 ' Clear RBIF (PortB Interrupt Flag)


If swCoast = 0 Then ' Do Stuff Here
LED = 1
Pause 1000
LED = 0
EndIf


GoTo WakeSleep