16F690... How to wake from sleep?


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427

    Default 16F690... How to wake from sleep?

    Hey group,

    I am trying to impliment some power savings on a battery powered project.
    I would like to put the 16F690 to SLEEP or (@ sleep). I know there is a difference between these two, but I'm not clear on WHAT that difference is.

    I would then like to wake the PIC up using an interrupt from PortA.3 or PortA.4
    I believe I have been successful doing this using the @ sleep command.

    Here is the problem...

    I would also like the PIC to wake up, say every 60 seconds, performe some small task and then go back to sleep again for 60 seconds. I have looked at the timers and it appears that they can not interrupt (wake up) the PIC unless I have an external osc. to feed the timer. I do not have available an external osc.

    How about using the WDT??

    What is the difference between PBP SLEEP and @ sleep??

    Thanks for any ideas
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: 16F690... How to wake from sleep?

    Hi,
    That's weird, we just had a similar discussion here
    PBP's SLEEP statement accepts and expects a time, in seconds. It then uses the WDT to keep track of the time and continue your PBP program after the number of seconds you specify, roughly.
    Code:
    Main:
    'Do this
    'Do that
    SLEEP 60
    Goto Main
    During those 60 seconds sleep the PIC will wake up briefly, each time the WDT times out, look at the watch and decide if it's time to go to work or if it can go back to sleep. Once it has woken up enough times to "accumulate" 60 seconds it will continue.

    EDIT: Oh, both PBP's SLEEP and @ SLEEP puts the PIC to sleep and the WDT (or an interrupt) wakes the PIC up in both cases. The difference is that the PBP statement has that built in accumulator, basically keeping track of the number of wake-ups, which allows you specify the amount of time you wish to sleep. With @ SLEEP it's one WDT period - period.
    /Henrik.
    Last edited by HenrikOlsson; - 5th July 2011 at 19:40.

  3. #3
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Thumbs up Re: 16F690... How to wake from sleep?

    Thanks Henrik,

    I usually read most posts that seem to have something I could use... but that one slipped my notice.

    quote:
    With @ SLEEP it's one WDT period - period.
    But it seems to me that if you use the "@ sleep", doesn't the PIC go to sleep perminantly, unless "interrupted" awake?? Whereas if you use the PBP SLEEP you need to specify how many seconds.

    Also if you use the PBP SLEEP command It cannot be interrupted awake until the completion of the sleep time period? (at least that is what the manual leads me to understand.) Therefore if you want the PIC to sleep for 60 seconds... you cannot wake it up with ANY type of interrupt untill the 60 seconds expires. So you must sleep in very short periods checking for an interrupt in between sleep times.

    My ultimate goal is to get the PIC to sleep and ONLY wake up if PortA.3 or PortA.4 is taken low OR if 60 seconds has elapsed. A.3 and A.4 are pushbuttons and I would like decent response time on these buttons so I may have to use the PBP "NAP" statement and take say 120 x 500ms naps.

    That is where I was hoping the WDT could wake me up after 60 seconds.

    Thanks again
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: 16F690... How to wake from sleep?

    Hi,
    But it seems to me that if you use the "@ sleep", doesn't the PIC go to sleep perminantly, unless "interrupted" awake??
    Yes, if the WDT is disabled and no interrupt occurs it will sleep "permanently" but SLEEP will make it do the same thing under those circumstances.

    Whereas if you use the PBP SLEEP you need to specify how many seconds.
    Correct, but like I said, it doesn't actually sleep for 60 seconds straight (or whatever) it sleeps for one WDT period (around 2 seconds I think), wakes up, goes to sleep for one WDT period, wakes up, goes to sleep and so on untill the accumulated sleep time equals 60 seconds (or whatever). If the WDT was disabled it would go to sleep and never wake up because the "alarm clock" is disabled.

    Also if you use the PBP SLEEP command It cannot be interrupted awake until the completion of the sleep time period?
    That's probably true for ON INTERRUPT. It's likely NOT the case when using DT-INTS or ASM interrupts where a real hardware interrupt is actually tripped.

    Really, the PBP statement SLEEP uses the assembler instruction SLEEP in a loop. It calculates the number of WDT periods needed for the specified number of seconds then it goes to sleep, wakes up, counts down, determines if it's done and if not it goes back to sleep. Because ON INTERRUPT doesn't generate a real interrupt (it just polls the interrupt flag before the SLEEP statement and then again after the SLEEP statement) it won't "see" the "interrupt" untill the 60 seconds have passed (same as ON INTERRUPT with ANY PBP statement really).

    My ultimate goal is to get the PIC to sleep and ONLY wake up if PortA.3 or PortA.4 is taken low OR if 60 seconds has elapsed. A.3 and A.4 are pushbuttons and I would like decent response time on these buttons so I may have to use the PBP "NAP" statement and take say 120 x 500ms naps.
    See above, use DT-INTS or interrupts in pure ASM - it should work.
    With that said I'm not sure which PICs have any sort of interrupt capabilities on PortA.3 and PortA.4. Obviously you need to connect the buttons to inputs which is capable of generating an interrupt or make an wired OR circuit or whatever to PortB.0.

    /Henrik.

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