
IV PERIPHERAL MODULES 2 (TIMERS): WATCHDOG TIMER (WDT)
IV-2-4
EPSON
S1C33E07 TECHNICAL MANUAL
IV.2.4 Control of the Watchdog Timer
IV.2.4.1 Setting Up the Watchdog Timer
Selecting the count clock
The internal clock (MCLK) or external clock (EXCL0) can be selected as the count clock for the 30-bit up-
counter by using CLKSEL (D6/0x300662).
CLKSEL: Watchdog Timer Input Clock Select Bit in Watchdog Timer Enable Register (D6/0x300662)
Setting CLKSEL (D6/0x300662) to 0 (default) selects the internal clock (MCLK); setting it to 1 selects the
external clock (EXCL0). Therefore, before an external clock can be used, the function of the pin set as an I/O
port by default must be switched to EXCL0 (external clock input for 16-bit timer 0) by using the Port Function
Select Register. For details about pin functions and how to switch over, see Section I.3.3, “Switching Over the
Multiplexed Pin Functions.”
For details about MCLK generation and control, see Section III.1, “Clock Management Unit (CMU).”
Setting the NMI/reset generation cycle
The watchdog timer has a 30-bit comparison data register that can be used to set a cycle in which to generate an
NMI or reset signal.
CMPDT[15:0]: 16 Low-order Comparison Data Bits in the Watchdog Timer Comparison Data Setup
Register 0 (D[15:0]/0x300664)
CMPDT[29:16]: 14 High-order Comparison Data Bits in the Watchdog Timer Comparison Data Setup
Register 1 (D[13:0]/0x300666)
The data set in these register bits is compared with the up-counter value. When both match, a specified NMI or
reset signal is output. The up-counter is reset to 0 at this time.
The NMI/reset generation cycle can be calculated from the equation below.
CMPDT + 1
NMI generating cycle = ———— [sec]
fWDTIN
where
CMPDT = value set in CMPDT[29:0] (D[13:0]/0x300666, D[15:0]/0x300664)
fWDTIN = MCLK or EXCL0 input clock frequency [Hz]
For example, the specifiable maximum NMI/reset generation cycle is about 21.47 seconds at 50-MHz MCLK
input.
Note: Do not set a value equal to or less than 0x0000001F in the comparison data register.
Selecting the NMI/reset generation function
To output an NMI signal when the watchdog timer is not reset within a specified cycle, set NMIEN (D1/
0x300662) to 1. To output a reset signal instead, set RESEN (D0/0x300662) to 1.
NMIEN: Watchdog Timer NMI Enable Bit in the Watchdog Timer Enable Register (D1/0x300662)
RESEN: Watchdog Timer RESET Enable Bit in the Watchdog Timer Enable Register (D0/0x300662)
Setting both bits to 0 (default) generates neither an NMI signal nor a reset signal, although the up-counter re-
mains active and can output a clock.
Setting both bits to 1 outputs both an NMI signal and a reset signal. In this case, however, reset exception han-
dling is executed since it has priority over the NMI exception handling.
The NMI and reset signals are both output as pulses of 32 MCLK clocks in width.
Note: Depending on the counter and comparison register values, an NMI or reset signal may be gener-
ated after the NMI or reset function is enabled here (or even when the watchdog timer has not yet
been started). Always be sure to set comparison data and reset the watchdog timer before writing
1 to NMIEN (D1/0x300662) or RESEN (D0/0x300662).