
R01UH0218EJ0110 Rev.1.10
Page 170 of 664
Sep 12, 2011
R32C/142 Group and R32C/145 Group
11. Watchdog Timer
11. Watchdog Timer
The watchdog timer is used to detect program runaway. The 15-bit watchdog counter decrements with the
cycle which is the peripheral bus clock frequency or on-chip oscillator clock frequency divided by the
prescaler.
Select either an interrupt request or a reset with the CM06 bit in the CM0 register for when the watchdog
timer underflows. Once the CM06 bit is set to 1 (reset), it cannot be changed to 0 (watchdog timer interrupt)
by a program. It can be set to 0 only by a reset.
The watchdog timer contains two types of prescaler: an on-chip oscillator clock prescaler and a general
prescaler. The former is the on-chip oscillator clock divided by 1, 2, 4 or 8. The divide ratio is selected by
setting bits WDK3 and WDK2 in the WKD register. The latter is the peripheral bus clock divided by 16 or
128. The divide ratio is selected by setting the WDC7 bit in the WDC register.
The count source for the watchdog timer is set by the PM22 bit in the PM2 register. When the peripheral bus
clock is selected as the count source, the watchdog timer is stopped in wait mode, stop mode, or when the
HOLD signal is driven low. It resumes counting from the value held when exiting the mode or state. When
the on-chip oscillator clock is selected, the watchdog timer does not stop.
The general formula to calculate a watchdog timer period is:
or
For example, when the peripheral bus clock is selected as the count source and it is 1/2 of 64 MHz CPU
clock and the prescaler has a divide-by-16 operation, the watchdog timer period is approximately 16.4 ms.
Note that marginal errors within one prescaler output cycle may occur in the watchdog timer period.
The watchdog timer is initialized when a write operation to the WDTS register is performed or when a
watchdog timer interrupt request is generated. The prescaler is initialized only when the MCU is reset.
After a reset, the watchdog timer starts counting automatically if the OFS area of the flash memory are
preset. When the WDTON bit in the OFS area is set to 1, both the watchdog timer and the prescaler are
stopped. They start counting when a write operation to the WDTS register is performed. When the WDTON
bit is set to 0, both the watchdog timer and the prescaler automatically start counting after a reset.
Figure 11.1 shows a block diagram of the watchdog timer. Figure 11.2 to Figure 11.5 show registers
associated with the watchdog timer.
Watchdog timer period = Prescaler divisor (16 or 128) × 32768
Peripheral bus clock frequency
----------------------------------------------------------------------------------------------------
Watchdog timer period = Prescaler divisor (1, 2, 4, or 8) × 2048
On-chip oscillator clock frequency
------------------------------------------------------------------------------------------------------