R01UH0823EJ0100 Rev.1.00
Page 796 of 1823
Jul 31, 2019
RX23W Group
28. Realtime Clock (RTCe)
28.3.6
Alarm Function
shows how to use the alarm function.
Figure 28.7
Using Alarm Function
In calendar count mode, an alarm can be generated by any one of year, month, date, day-of-week, hour, minute or second,
or any combination of those. 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.
In binary count mode, an alarm can be generated in any bit combination of 32 bits. Write 1 to the ENB bit of the alarm
enable register corresponding to the target bit of the alarm, and set the alarm time to the alarm register. For bits that are
not target of the alarm, write 0 to the ENB bit of the alarm enable register.
When the counter and the alarm time match, the IR flag corresponding to the ALM interrupt is set to 1. Alarm detection
can be confirmed by reading this bit, but an interrupt should be used in most cases. If 1 has been set in the interrupt
request enable bit corresponding to the ALM interrupt, an alarm interrupt is generated in the event of alarm, enabling the
alarm to be detected.
Writing 0 sets the IR flag corresponding to the ALM interrupt to 0.
When the counter and the alarm time match in a low power consumption state, the MCU returns from the low power
consumption state.
Write 0 to the ICU.IERm.IENj bit corresponding to the ALM interrupt
Wait until two periodic interrupts are generated
Set the ICU.IRn.IR flag corresponding to the ALM interrupt to 0 in case
the flag becomes 1 during the alarm time setting
Write 1 to the ICU.IERm.IENj bit corresponding to the ALM interrupt
Confirm that the RCR2.START bit is 1 (the clock is operating)
Set the RCR1.AIE bit to 1 and set an interrupt generation period of a
periodic interrupt to the RCR1.PES[3:0] bits
Wait for the generation of an alarm interrupt or until the ICU.IRn.IR flag
corresponding to the ALM interrupt becomes 1
Set the alarm time and enable the alarm at the same time or later
Check if the clock is operationg
Disable an alarm interrupt request on ICU side
Set the time of the alarm
Enable an alarm interrupt request on RTC side
and set an interrupt generation period
Wait until the setting of alarm time is
completed
Clear the interrupt status flag
Enable an alarm interrupt request on ICU side
Monitor the alarm set time
(Wait for an interrupt,
or poll the interrupt status flag)
AIE = 1 and
PES[3:0] = the set value?
Yes
No
Wait until the RCR1.AIE bit becomes 1 and the RCR1.PES[3:0] bits
become the set value