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…
Code:@ 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




Bookmarks