Watchdog timers are implemented in various ways. Some electronic WDTs (e.g., Analog Devices MAX6324) use linear timing circuits that operate without a digital clock signal. Other electronic WDTs, and software WDTs, typically employ digital counters as timers and rely on a clock signal for proper operation.
Electronic watchdogs Electronic WDTs are usually implemented either as a stand-alone
integrated circuit (IC) or as part of a more complex IC. Some stand-alone implementations contain only a WDT, whereas others bundle a WDT with other functions (e.g.
supply voltage supervisors) in a common IC. Many microcontrollers have a watchdog "module" consisting of a digital WDT and mechanisms for controlling and monitoring the WDT. Such modules typically include related control and status registers, circuitry for qualifying restart triggers ("kicks"), and routing control logic for the timeout signal. Some microcontrollers provide an analog WDT in lieu of a digital WDT. For example, Texas Instruments' TMS470 microcontroller has an analog WDT that employs an external capacitor and resistor to program the watchdog interval.
Digital watchdogs In microcontrollers and other complex digital ICs, a digital WDT is typically instantiated by synthesizing it from a description written in
VHDL,
Verilog or some other
hardware description language. For example, the following VHDL code describes a simple WDT: entity watchdog_timer is port ( CLK : in std_logic; -- clock INIT : in std_logic; -- initialize watchdog KICK : in std_logic; -- restart timer INTERVAL : in unsigned(31 downto 0); -- timer interval in clocks TIMEOUT : out std_logic; -- timeout indicator ); end watchdog_timer; architecture behavioral of watchdog_timer is process(CLK) variable elapsed : std_logic; -- timeout register variable counter : unsigned(31 downto 0); -- remaining clocks until timeout begin if rising_edge(CLK) then -- upon rising clock edge if INIT = '1' then -- if watchdog is being initialized counter
Analog watchdogs Analog WDTs have a
kick input and
timeout output, but lack the clock input signal found in digital electronic watchdogs. Circuitry and components vary widely among analog watchdogs, but in general, analog WDTs typically base their timing functions on
capacitor charging rates. For example, in the analog watchdog circuit shown to the right, electric current
i gradually charges capacitor
C, causing voltage
VC to ramp up (rise at a constant rate). In normal operation, periodic "kick" pulses are applied to the kick input. Each kick causes capacitor
C to discharge, thus restarting the voltage ramp-up. However, if the kicks cease or become spaced too far apart in time,
VC will rise above the voltage comparator's threshold voltage
VTH and, as a result, the
voltage comparator will assert the
timeout signal.
Software watchdogs Some software watchdog timers are implemented as standard software modules. Examples of these include "Softdog", a
virtual device driver which emulates an electronic WDT and conforms to the
Linux watchdog API, and
MathWorks' Software Watchdog Timer, a retriggerable one-shot timer which can be instantiated by dragging its GUI representation onto a block diagram. Other software WDTs are typically custom-designed to meet specific requirements. Every software WDT depends on a timing reference to allow it to accurately track the passage of time. Various mechanisms are commonly available for this purpose. Depending on the computer, and if used, the
operating system (OS), such mechanisms may include programmable interval timers, kernel timers, the
system clock, and synchronization objects (e.g.,
semaphores) that support timed waits. The design of a software WDT can be influenced by a number of factors, including the length of the watchdog interval, the time references available for WDT use, CPU loading, how soon the WDT must be kicked after relevant conditions have been met, whether the computer is running an OS and, if so, whether the WDT is intended to run in user or kernel mode. For example, in bare metal applications (program running without an OS), timing references are often limited to
programmable interval timers (PIT). In such cases, the WDT might be implemented with a PIT in a fashion similar to the
flowchart shown below: In the above example, if the application program fails to kick the watchdog (by restarting the PIT), the PIT will reach the end of the watchdog interval and generate an interrupt request (IRQ). The associated interrupt service routine (ISR) will then execute and take corrective action via programmed I/O, system calls, or other software-controlled operations. ==See also==