Watch Dog Timers

Wagner Lipnharski says:

...you can think about the WDT as a real dog that wants to bite your leg if you don't feed him every certain time.... :) It means what? If you leave your house [ed:or your mind], the next intruder will have severe leg dog marks...

The main reason of the WDT is that software sometimes got lost, enter in infinite loops, some unexpecetd situation puts a routine to go crazy and all. The WDT unique intention is to reset the machine if certain programmable timer expires. So, your "normal operative" software should "reset" the WDT before it resets the machine, so if you program the WDT to 1 second, you should reset (CLRWDT [ed:on the pic, clr !wdt on the SX]) before that happens. If you routine gets lost, the WDT will reset your machine in one second, so not much is wasted. [ed: unless the machine gets lost in a loop that clears the WDT... think about it before you write it...]

The best WDT I ever seen, was an interrupt that run 10 times faster than the WDT timer. Several routines actually update their respectively flags at one especific memory position. The interrupt routine check those flags and clear them. Some flags should be set by its routines much often than others. The interrupt routine knew that and act accordingly. If by some reason one routine fails to update its flag, the interrupt routine was able to reset the memory pointers and data for that particular routine and reset it without needing to reset the entire processor. If the failing routine doesn't restart nicely, then the interrupt routine propositaly fails to clear the WDT, it resets the entire processor.

Harold Hallikainen says:

In terms of computers (including PICs and SXs), I don't think it's a question of IF they will crash, but more a question of WHEN they will crash. Having a WDT allows the system to recover from the crash. I once had to drive 100 miles through Kansas in the middle of the night to hit reset on a system I built to control broadcast transmitters so the station could go back on the air at 6am. EVERYTHING I've built from then on includes a watchdog timer...

You can also use the PIC and SX WDTs to measure Temperature

Questions:

See: