PDA

View Full Version : Can't @sleep



MOUNTAIN747
- 30th December 2010, 16:05
I thought I had this figured out, famous last words! Returning to a project after being side tracked for six months I find that the @sleep command was never working. 12F683 set up with GP2 ext interrupt to wake from sleep. Test code for @sleep instruction uses LED to monitor sleep state. MCLR is set to off. There is a line in the data sheet that says that if Watchdog Timer is enabled, MCLR pin must be at a logic high, I am turning off WDT before @sleep. I can’t find the problem. Comments please…


@ DEVICE PIC12F683,MCLR_OFF,WDT_ON,BOD_OFF
@ DEVICE PWRT_ON,FCMEN_OFF,IESO_OFF,PROTECT_OFF
OSCCON=%1110000
Define OSC 8
VRCON = 0
ADCON0 = 0
OPTION_REG = %01000000 ;rising edge interrupt
ANSEL = 0 ;digital all
CMCON0 = 7
INTCON = %10010000 ;GlE set, INTE set, INTF clr
GPIO = 0
TRISIO = %00001100 ;GPIO.2 input for external interrupt
;-------- Variables & Constants ------------------------------------------------
Avar VAR BYTE ;general variable
; Inerrupt on GPIO.2
Blink var GPIO.4
TX var GPIO.5
;-------- Program --------------------------------------------------------------
Main:
for Avar=1 to 5
HIGH blink
pause 40
low blink
pause 100
next Avar
Downtime:
WDTCON=0 ;Watchdog timmer off
@sleep ;Sleep in low power state until interrupted
@nop
INTCON.4 = 0 ;clear external interrupt flag bit
Serout2 tx, 84, [" We have a wake up from sleep or it never went to sleep",13,10,13,10]
for Avar=1 to 5
HIGH blink
pause 50
low blink
pause 2000
next Avar
goto main
end

Darrel Taylor
- 30th December 2010, 17:13
There should be white space (space or tab) between the @ and sleep. Same with nop.

@ sleep

MOUNTAIN747
- 30th December 2010, 17:18
I found a statement in the data sheet that addresses WDT under software control. I have now turned off WDT in the config to use SWDTEN bit properly. Still no luck. No rest for the weary.

MOUNTAIN747
- 30th December 2010, 17:29
Thanks Darrel,
Space did the trick. I'm up and running.