
Section 11 Realtime Clock (RTC)
SH7751 Group, SH7751R Group
Page 312 of 1128
R01UH0457EJ0301 Rev. 3.01
Sep 24, 2013
11.3 (a), and the procedure using carry interrupts in figure 11.3 (b). The method without using
interrupts is normally used to keep the program simple.
11.3.3
Alarm Function
The use of the alarm function is illustrated in figure 11.4.
Clock runnin
g
Disable alarm interrupts
Set alarm time
Clear alarm fla
g
Enable alarm interrupts
Monitor alarm time
(Wait for interrupt or check
alarm fla
g
)
Clear RCR1.AIE to prevent erroneous interrupts
Be sure to reset the fla
g
as it may have been
set durin
g
alarm time settin
g
Set RCR1.AIE to 1
Figure 11.4 Example of Use of Alarm Function
An alarm can be generated by the second, minute, hour, day-of-week, day, month, or year
(SH7751R only) value, or a combination of these. Write 1 to the ENB bit in the alarm registers
involved in the alarm setting, and set the alarm time in the lower bits. Write 0 to the ENB bit in
registers not involved in the alarm setting.
When the counter and the alarm time match, RCR1.AF is set to 1. Alarm detection can be
confirmed by reading this bit, but normally an interrupt is used. If 1 has been written to
RCR1.AIE, an alarm interrupt is generated in the event of alarm, enabling the alarm to be
detected.
The alarm flag remains set while the counter and alarm time match. If the alarm flag is cleared by
writing 0 during this period, it will therefore be set again immediately afterward. This needs to be
taken into consideration when writing the program.