View previous topic :: View next topic |
Author |
Message |
fa24
Joined: 14 Sep 2004 Posts: 2 Location: London UK
|
stoping 16F876 watchdog during sleep |
Posted: Wed Dec 15, 2004 5:41 am |
|
|
Hi,
I am trying to write some code that will put the PIC to sleep (>5 min) until an interrupt on RB0/INT, this works ok but when I enable the watchdog it keeps wakes up.
Can the watchdog timer be disabled during sleep or will I have to stop using it all together ![Question](images/smiles/icon_question.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Dec 15, 2004 1:46 pm |
|
|
Quote: | Can the watchdog timer be disabled during sleep or will I have to
stop using it all together. | You can't do this with the 16F876.
You will need to use another PIC, such as the 16F88 or the 18F452,
which have the ability to enable or disable the WDT under software
control, with a bit in the WDTCON register. See the data sheets
for details.
One other option is to simply put the PIC back to sleep again.
Read this post for some details on this topic:
http://www.ccsinfo.com/forum/viewtopic.php?t=20869 |
|
![](templates/subSilver/images/spacer.gif) |
fa24
Joined: 14 Sep 2004 Posts: 2 Location: London UK
|
|
Posted: Wed Dec 15, 2004 2:00 pm |
|
|
Ok,
thanks
Tony |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: stoping 16F876 watchdog during sleep |
Posted: Wed Dec 15, 2004 3:52 pm |
|
|
fa24 wrote: | Hi,
I am trying to write some code that will put the PIC to sleep (>5 min) until an interrupt on RB0/INT, this works ok but when I enable the watchdog it keeps wakes up.
Can the watchdog timer be disabled during sleep or will I have to stop using it all together ![Question](images/smiles/icon_question.gif) |
I'd suggest implementing a watchdog 'counter'.
On your wake up, have a 'nop' (remember the 'next' instruction, is 'pre-fetched' when you sleep), then test the interrupt flag. If this is set branch to the handler. If not, increment a counter, and if it has not reached a 'limit' value, loop and sleep again. If the limit value is reached, you can have a handler for the trigger not having appeared. This way the watchdog will recover from certain types of processor 'hang', that can still occur when asleep, and can be left enabled throughout the code.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|