RL78/G13 Safety Function (Frequency Detection)
1. Specifications
The frequency detection function described in this application note compares the frequencies of the high-speed on-chip
oscillator clock and the low-speed on-chip oscillator clock. This allows detection of any abnormal clock frequencies.
More specifically, this function measures the pulse interval under the conditions below to detect an abnormal
frequency.
The high-speed on-chip oscillator clock (HOCO clock) is selected as a count clock for timer array unit 0 (TAU0).
The low-speed on-chip oscillator clock (15 kHz) should is selected as a timer input for channel 5 of TAU0.
To judge whether the frequency is normal or abnormal, the pulse interval is checked to see if it is within the tolerable
range specified by constants. If the frequency is normal, the LED turns off. If not, the LED blinks.
The count clock for TAU0 is selected by setting the value of the high-speed on-chip oscillator frequency select register
(HOCODIV) to one of predefined constants.
Table 1.1 lists the peripheral functions to be used and their uses. Figure 1.1 outlines the frequency detection.
Table 1.1 Peripheral Functions to be Used and their Uses
Peripheral Function Use
External interrupt input (INTP0) Switch input
Changes the count clock (HOCO clock) frequency for
TAU0.
Channel 5 of timer array unit 0
Low-speed on-chip oscillator clock
Measures pulse intervals.
Bit 2 in port 6 Displays the frequency detection result on the LED.
Bit 3 in port 6 Displays the selected HOCO clock on the LED.
R01AN0956EJ0100 Rev. 1.00 Page 4 of 70
Feb. 27, 2012
Figure 1.1 Outline of Frequency Detection
Channel 5 of timer array unit 0
f
IL
5
z
Coun
t clock
f
IH
32 MHz
*Can be
changed by
constants.
Counting
Capture start
Counting
Capture end timer
interrupt occurs.
Get count value
Counting Counting
Capture end timer
interrupt occurs.
Capture end timer
interrupt occurs.
Get count value
Get count value
Get count value
Normal fre
uenc
1836 2535
Abnormal
fre
uenc
Abnormal
fre
uenc
Detection of normal
frequency
Detection of
abnormal frequency
Detection of
abnormal frequency
Count value gotten
through one time of
capture
*
A count value is gotten
when f
IH
is 32 MHz.
Capture end timer
interrupt occurs.