Can't @sleep


Closed Thread
Results 1 to 4 of 4

Thread: Can't @sleep

  1. #1
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219

    Default Can't @sleep

    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

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    There should be white space (space or tab) between the @ and sleep. Same with nop.
    Code:
    @  sleep
    DT

  3. #3
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default WDT and software control

    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.

  4. #4
    Join Date
    Jan 2009
    Location
    Alabama,USA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default It's the little things that get you every time!

    Thanks Darrel,
    Space did the trick. I'm up and running.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts