
APPLICATION
2.3 Timers
2-20
4551 Group User’s Manual
2.3.3 Timer application examples
(1)
Timer operation: measurement of constant period
The constant period by the setting timer count value can be measured.
Outline: The constant period by the timer 1 underflow signal can be measured.
Specifications: Timer 1 and prescaler divides the system clock frequency f(XIN) = 3.6 MHz, and the
timer 1 interrupt request occurs every 4 ms.
Figure 2.3.2 shows the setting example of the constant period measurement.
(2)
Timer operation: constant period counter by timer 2
The constant period by the setting timer count value can be measured.
Outline: The correct time can be measured and the clock which has high-accuracy can be set up
by using a 32.768 kHz quartz-crystal oscillator.
Specifications: Timer 2 divides the sub-clock frequency f(XCIN) = 32.768 kHz, and the timer 2
interrupt request occurs every 250 ms.
Figure 2.3.3 shows the setting example of constant period counter by timer 2.
(3)
Watchdog timer
Watchdog timer provides a method to reset the system when a program run-away occurs.
In the 4551 Group, the bit 12 of timer 2 is used for the watchdog timer.
Accordingly, when the watchdog timer function is set to be valid, execute the WRST instruction at
a certain cycle which consists of timer 2’s 8191 counts or less.
Outline: Execute the WRST instruction in timer 2’s 8192 count at the normal operation. If program
runs wild, the WRST instruction is never executed and system reset occurs.
Specifications: System clock frequency f(XIN) = 3.6 MHz, sub-clock frequency f(XCIN) = 32.768 kHz
are used, and program run-away is detected by executing the WRST instruction in
250 ms.
Figure 2.3.1 shows the watchdog timer function, and Figure 2.3.4 shows the example of watchdog
timer.
Fig. 2.3.1 Watchdog timer function
3FFF16
0000 16
1FFF16
Timer 2 value
WEF flag
WDF flag
Internal reset signal
System reset
“1”
“0”
“1”
“0”
“H”
“L”
WRST
instruction
execution
WRST
instruction
execution