Nevermind! GPIO.2 was tied high due to a wiring error. Datasheet says this will interrupt SLEEP, regardless of INTCON settings. Works O.K. now.
Nevermind! GPIO.2 was tied high due to a wiring error. Datasheet says this will interrupt SLEEP, regardless of INTCON settings. Works O.K. now.
O.K., I give up. The name of this thread should be 12f629 wakes up unexpectedly. Here is the latest code:
CMCON = %00000111
TRISIO = %001100
OPTION_REG = %10000000
PIR1 = 0
GPIO = $000000
@ DEVICE MCLR_OFF, INTRC_OSC, WDT_OFF, BOD_OFF, PWRT_ON, PROTECT_OFF
'GPIO.0 =
'GPIO.1 = LED HIGH OUT
'GPIO.2 = SWITCH HIGH INPUT
'GPIO.3 = MCLR TIED HIGH
'GPIO.4 =
'GPIO.5 =
GPIO.1 = 1
PAUSE 100
INTCON = %00000000
FLAGS = 0
@SLEEP
NOP
GPIO.1 = 0
I have checked all pins with a scope, added decoupling capacitors on the +5 volt and MCLR pins, and the result is always the same. If the last line of the program is present, the LED goes out. So clearly something is causing the PIC to wakeup. What am I missing?
Bookmarks