Using the Watchdog Interrupt
In the event that the watchdog timer is not reset within the configured amount of time, the watchdog
will trigger a "Watchdog Interrupt." The watchdog interrupt is a new interrupt introduced in the
DS80C320.
The interrupt is enabled by setting the EWDI bit in the new EIE (Extended Interrupt Enable)
SFR at E8h:
| SFR Bit |
Bit Label |
Bit Number |
Description |
| EIE.4 |
EWDI |
EBh |
Enable Watchdog Interrupt. When this bit is set, an interrupt through vector 63h will be
triggered when WDCON.4 is set. |
When EWDI is set, a Watchdog Interrupt will be triggered when WDCON.3 (Watchdog Interrupt
Flag) is set. The Watchdog Interrupt vector is 63h.
The Watchdog Interrupt Flag (WDCON.3) is set 128 instruction cycles prior to the watchdog
initiating a reboot. However, this does not necessarily mean that your interrupt routine has 128
instruction cycles available to it. WDCON.3 is set exactly 128 instruction cycles prior to
reboot, but the Watchdog Interrupt has the lowest polling interrupt priority. If another interrupt
of higher priority is executing--or if another interrupt of the same priority occurs at the same
instant--the other interrupt will execute first. If the other interrupt requires more than 128
instruction cycles, your Watchdog Interrupt routine will never have a chance to execute prior to reboot.
Thus, if it is critical that your application be informed of an imminent reboot, it is suggested that
you give your Watchdog Interrupt a high priority and all other interrupts a low priority. You can
modify the priority of the Watchdog Interrupt by modifying the corresponding bit in the new EIP
(Extended Interrupt Priority) SFR at F8h:
| SFR Bit |
Bit Label |
Bit Number |
Description |
| EIP.4 |
PWDI |
FBh |
Watchdog Interrupt Priority. When this bit is set, the watchdog interrupt is assigned
high priority. When this bit is clear the watchdog interrupt is assigned low priority. |
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.
(C) Copyright 1997 - 2008 by Vault Information Services LLC. All Rights Reserved.
Information provided "as-is" without warranty. Please see details.
Contact us for usage and copy permission.