@SLEEP and the 12f683


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Sep 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    WDT_OFF you need to change that to WDT_ON

    Sleep uses the watch dog timer

    SLEEP Period

    Place microcontroller into low power mode for Period seconds. Period is 16-bits, so delays can be up to 65,535 seconds (just over 18 hours). SLEEP uses the Watchdog Timer so it is independent of the actual oscillator frequency. The granularity is about 2.3 seconds and may vary based on device specifics and temperature. This variance is unlike the BASIC Stamp. The change was necessitated because when the PICmicro executes a Watchdog Timer reset, it resets many of the internal registers to predefined values. These values may differ greatly from what your program may expect. By running the SLEEP command uncalibrated, this issue is sidestepped.

    Example

    SLEEP 60 ' Sleep for about 1 minute

    See Also

  2. #2
    Join Date
    Sep 2010
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    The PBP SLEEP command is not the same as assembly SLEEP

    With the watchdog timer on the chip won't go into real sleep mode, it will just sleep for a set period of time. I want the chip to hibernate until there is a change on GPIO.3 not sleep for a specific amount of time, and for this from what I have read the watchdog has to be off.

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Try this...

    Here's a sample snippet of what I use on a PIC16F677 so you can ignore some of the extra not pertaining to the PIC12F683.
    Code:
    '=========================================================================
    '                           SLEEP Mode
    ' This routine provides an Ultra Low power consumtion until a button is
    ' pressed. All I/O's are setup for the PORTA/B Interrupt On Change function
    ' prior to going into standby condition. Any state change detected to these
    ' PORTs starts main loop and directs to proper routine.        
    '=========================================================================
     Sleep_mode:
        OPTION_REG.7 = 0    ' Global weak pull-up enable bit enabled
        WPUA = %00011111    ' Weak pull-ups enable on PORTA inputs except RA5
        WPUB = %00000000    ' Weak pull-ups disabled on PORTB
        TXEN = 1            ' Transmitter Vcc OFF
        SEND = 0            ' Turn OFF MS encoder SEND input
        Action = 0          ' Turn OFF all outputs
        m = 0               ' Mode counter reset to zero
        IOCA = %00010000    ' Mode input pin configured for IOC
        IOCB = %10000000    ' ID_new input pin configured for IOC
        Store_A = PORTA     ' Reads PORTA
        Store_B = PORTB     ' Reads PORTB
        INTCON = %00001000  ' RABIE (RA and RB Interupt Enabled)
        @ SLEEP             ; Goes mimi until a change of state is detected
        @ NOP               ; 1 instruction cycle
    
    '=========================================================================    
    woke_up: ' goes on from here then will go back to sleep with no activity
    I basically set everything OFF first then set the IOC, in your case it would be IOC=%000010000.
    Take a snapshot of the port to detect a difference.
    Set the INTCON and go to Sleep.
    Code:
    all_my_outputs = 0  ' you want to make sure there's no parasitic currents 
                        ' in your circuit of course
    all_my_vars = 0     ' zero out your counters if needed               
    IOC=%00001000       ' Sets GPIO.3 only for Interupt On Change
    Store_GPIO = GPIO   ' Snapshot of current port state
    INTCON.7=1          ' From data sheet: Global Interrupt Enable (GIE) must 
                        ' be enabled for individual interrupts to be recognized.
    @ SLEEP             ; Goes to sleep until a change of state is detected
    @ NOP               ; 1 instruction cycle - Bruce and others have explained 
                        ' why this was needed but I forget why at the moment.
    Hope this gets you going.
    Louie

  4. #4
    Join Date
    Sep 2009
    Posts
    7


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by crueheads View Post
    The PBP SLEEP command is not the same as assembly SLEEP

    With the watchdog timer on the chip won't go into real sleep mode, it will just sleep for a set period of time. I want the chip to hibernate until there is a change on GPIO.3 not sleep for a specific amount of time, and for this from what I have read the watchdog has to be off.
    You didn't say any thing about asm in your first post you said
    @sleep function
    PBP has a sleep function The wdt has to be on for it to work

    Glad you have it all worked out hope you have a good day

    I was going to post how to do it in asm but I'd go with LinkMTech code

  5. #5
    Join Date
    Sep 2010
    Posts
    3


    Did you find this post helpful? Yes | No

    Default

    You didn't say any thing about asm in your first post you said
    "@sleep function "
    Actually yes I did, the @ is PBP's insert one line of assembly notation. So asking about @SLEEP is asking about assembly sleep and not PBP native.

    LinkMTech thanks I'll give it a test tonight and see how it goes.

    Also after more searching last night I came across this thread http://www.picbasic.co.uk/forum/arch...hp/t-5676.html and the example Bruce posted appears to work.

Members who have read this thread : 0

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