PDA

View Full Version : Watchdog Timer



barkerben
- 24th January 2005, 21:31
Hi,

I wrote some code wich works fine - but someone asked be why it didn't constantly reset due to the WDT. I didn't know, and was a bit worried. Maybe my code shouldn't be working after all, in which case why was it...I searched the forum and found:

"WDT is handled automatically for you by PBP in background - you don't have to do anything. If you look at the Assembler listing of any of your compiled programs, you will see a liberal sprinkling of CLRWDT instructions throughout. PBP puts them there to keep resetting the WDT so you don't have to."

Posted by Melanie a while back.

What then is the advantage of using the WDT at all - would it not save code space to disable it in config bits, or is it sometimes useful?

Cheers,


Ben

barkerben
- 24th January 2005, 21:36
P.S

I've seen in the manual that the WDT is used in sleep commands, which may be why it is not completely disabled. But if the compiler is constantly clearing the timer to stop it overflowing, how can it be put to good use for the sleep commands ....?

Archilochus
- 24th January 2005, 23:20
I'd guess that PBP does not clear the WDT (except as needed to do its timing duties) while executing a SLEEP command.

The WDT is still useful in that if your code hangs (and the WDT stops being cleared), you'll get a WDT reset to reboot your software.

barkerben
- 25th January 2005, 01:06
Yes, although any use made of the WDT can't allow it to overflow, because as soon as it does it resets the pic. Maybe the sleep commands are just advanced with each advance of the WDT - assuming the reset doesn't introduce a delay, then
the sleep commands would still work - they would still get a pulse every period ...?