Watchdog System Resets
If the watchdog timer is allowed to run out and no action is taken to reset the timer in the Watchdog Interrupt, the watchdog will automatically reset the system.
A reset caused by the watchdog is like any other reset with one exception: The WTRF bit (WDCON.2) will be set. That is to say, if WTRF is clear it means the system is booting due to some other non-watchdog related reason. If the bit is set, the boot is due to the watchdog.
You can use this information in your application to execute special code in the event a watchdog reset occurs. Take the following psuedo-code, for example:
ORG 0000h
JNB WTRF,NORMAL
PRINT "The system locked up and was rebooted by the watchdog."
PRINT "Skipping normal device initialization."
LJMP MAIN
NORMAL: LCALL INITIALIZE_LCD
LCALL INITIALIZE_XRAM_VARIABLES
MAIN: (continue normal program execution)
Note that if you put all your variables in Extended RAM, a watchdog reset will not erase them. Observe in the above psuedo-code that if the system is booting due to a watchdog reset, it skips the LCD and variable initialization routines. Thus, when program execution resumes at MAIN, all variables in XRAM will still be intact.