R01UH0823EJ0100 Rev.1.00
Page 795 of 1823
Jul 31, 2019
RX23W Group
28. Realtime Clock (RTCe)
28.3.5
Reading 64-Hz Counter and Time
shows how to read the 64-Hz counter and time.
Figure 28.6
Reading Time
If a carry occurs while the 64-Hz counter and time are being read, the correct time will not be obtained, so they must be
read again. The procedure for reading the time without using interrupts is shown in (a) in
, and the procedure
using carry interrupts in (b). To keep the program simple, method (a) should be used in most cases.
Read the counter
Disable a carry interrupt request on RTC side
Clear the interrupt status flag
Enable a carry interrupt request on RTC side
Clear the interrupt status flag
Read the counter
IR flag = 1?
Interrupt?
Enable a carry interrupt request on RTC side
Clear the interrupt status flag
Write 1 to the RCR1.CIE bit
Write 0 to the ICU.IRn.IR flag corresponding to
the CUP interrupt
(a) To read the time without using interrupt
Yes
(b) To read the time using interrupts
Write 1 to the RCR1.CIE bit
Write 0 to the RCR1.CIE bit*
1
Yes
No
Read the counter again when the IR flag
corresponding to the CUP interrupt is 1
Write 0 to the ICU.IRn.IR flag corresponding to
the CUP interrupt
Write 0 to the ICU.IRn.IR flag corresponding to
the CUP interrupt
Disable a carry interrupt request on ICU side
Write 0 to the ICU.IERm.IENj bit corresponding to
the CUP interrupt
Enable a carry interrupt request on ICU side
Write 1 to the ICU.IERm.IENj bit corresponding to
the CUP interrupt
No
Note 1. Disable the interrupt if necessary.