How to make a 16f628 Sleep and Wakeup ?


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237

    Angry How to make a 16f628 Sleep and Wakeup ?

    Hi All

    Simple Question I know... But I cannot figure it out...

    Both Sleep and nap seem to be for short time durations.....???

    What I am looking for is basically an alarm function using the rtcxu.pbp code...

    The RTC to be running all the time... The PIC to wake up latch an alarm for X Seconds then go back to sleep.

    Ultimately saving me battery power.

    Originally I was thinking of using the Hours and Mins VARs as a trigger. But the PIC needs to be awake for this to happen !

    Arghhhhhhhhhh......... Hardware is easy ... Software not so.

    Any Ideas or links to examples help welcome. I have looked,

    Andy

  2. #2
    Join Date
    May 2013
    Location
    australia
    Posts
    2,489


    Did you find this post helpful? Yes | No

    Default Re: How to make a 16f628 Sleep and Wakeup ?

    looks like the max wdt sleep is 2.3 sec ,so the only other way is via a wake up from an interrupt source (int_INT or rbc_INT).
    if you use a different rtc chip (like a pcf8563 ) that has an alarm driven interrupt output the world is your oyster

  3. #3
    Join Date
    Jun 2009
    Location
    Sc*nthorpe, UK
    Posts
    333


    Did you find this post helpful? Yes | No

    Default Re: How to make a 16f628 Sleep and Wakeup ?

    Quote Originally Posted by andybarrett1 View Post
    Hi All

    Simple Question I know... But I cannot figure it out...

    Both Sleep and nap seem to be for short time durations.....???

    What I am looking for is basically an alarm function using the rtcxu.pbp code...

    The RTC to be running all the time... The PIC to wake up latch an alarm for X Seconds then go back to sleep.

    Ultimately saving me battery power.

    Originally I was thinking of using the Hours and Mins VARs as a trigger. But the PIC needs to be awake for this to happen !

    Arghhhhhhhhhh......... Hardware is easy ... Software not so.

    Any Ideas or links to examples help welcome. I have looked,

    Andy
    This could be an interesting project for me I can help with the software. Richard's pcf8563 and interrupts look good to me.

  4. #4
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: How to make a 16f628 Sleep and Wakeup ?

    Wake up once per second, check the time, if not alarm time go back to sleep.
    The time you are awake is so small, you are still asleep well over 99% of the time.

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    953


    Did you find this post helpful? Yes | No

    Default Re: How to make a 16f628 Sleep and Wakeup ?

    Quote Originally Posted by andybarrett1 View Post
    Hi All
    Both Sleep and nap seem to be for short time durations.....???
    You could cheat by using the ASM sleep directive thus.
    Code:
    asm
            sleep
            nop
            nop
    endasm
    See section 14.8.1 (Wake-up from sleep) in the datasheet to understand why you may need nops.

    This way you can make the processor sleep indefinitely

  6. #6
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: How to make a 16f628 Sleep and Wakeup ?

    You can use watchdog reset to wakeup the MCU from sleep. Since you can establish the time delay for the watchdog reset ( setting the prescaler) you can increment a word variable at each wakeup and go to sleep again. When the count reach the Allarm setpoint then you will service the Allarm, reset the count and return to sleep.

    Cheers

    Al.
    All progress began with an idea

  7. #7
    Join Date
    May 2012
    Location
    Merseyside, UK
    Posts
    237


    Did you find this post helpful? Yes | No

    Default Re: How to make a 16f628 Sleep and Wakeup ?

    Thank you all….

    I sorted it … Well with an old post from Melanie I found….Where is she now !!

    I was missing some setup options for the int

    Working now :-)

Similar Threads

  1. Watchdog periodic wakeup
    By jimbostlawrence in forum General
    Replies: 3
    Last Post: - 15th August 2012, 13:44
  2. Replies: 11
    Last Post: - 29th December 2010, 11:24
  3. Trying to add a sleep function or pretend to sleep
    By lilimike in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 9th May 2010, 19:10
  4. Please help me make an ASK Rx/Tx pair
    By financecatalyst in forum Schematics
    Replies: 0
    Last Post: - 7th February 2009, 20:58
  5. Replies: 1
    Last Post: - 12th May 2008, 14:33

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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