View previous topic :: View next topic |
Author |
Message |
Ringo42
Joined: 07 May 2004 Posts: 263
|
sleep and wake up once a second |
Posted: Wed Mar 25, 2009 7:49 am |
|
|
I'm using a pic16f876A and 3.249. Is there a way for the pic to sleep for a certain amount of time then wake up? I see you can wake up from an external event but I want to wake up, check some stuff and go back to sleep.
I'm thinking maybe wake up once a second or so.
Ringo _________________ Ringo Davis |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Mar 25, 2009 9:10 am |
|
|
You can use the WDT to wake up from sleep.
You can either use the hardware WD which cannot be turned off so you need to kick it while the prog is running and just before going to sleep.
I use the software WD,
turn it on -> sleep -> (WDT) -> wakeup -> turn it off. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Wed Mar 25, 2009 9:13 am |
|
|
ok, I know how to set up the watchdog to go off after a second a that will reboot the board, if you are sleeping does it wake you up instead of rebooting, or is there something special to do to wake up instead?
Ringo _________________ Ringo Davis |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Mar 25, 2009 10:31 am |
|
|
The WDT will wake the pic up from a sleep but reset if the pic was awake
Check the datasheet on the pic you are using. If I remember the info is in there but a bit subtle |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Mar 25, 2009 10:34 am |
|
|
Page 155, 14.13
"During normal operation, a WDT time-out generates a
device Reset (Watchdog Timer Reset). If the device is
in Sleep mode, a WDT time-out causes the device to
wake-up and continue with normal operation (Watchdog
Timer Wake-up)" |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Wed Mar 25, 2009 10:45 am |
|
|
Cool, but this looks too easy :-) _________________ Ringo Davis |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Wed Mar 25, 2009 1:57 pm |
|
|
It is actually easy. Of course the WDT hasn't a precise timing, it's not suitable as a real time clock.
If RTC like precision is required, SEC_IDLE mode with PIC18 can use a watch crystal as time base, but power consumption is considerably higher than with an external RTC chip, that also can provide an 1 Hz wakeup signal. |
|
|
Ringo42
Joined: 07 May 2004 Posts: 263
|
|
Posted: Wed Mar 25, 2009 1:58 pm |
|
|
Thanks, I'm not using it for timing, just power saving so this will be just fine.
Thanks again _________________ Ringo Davis |
|
|
|