Section 14 Realtime Clock
Page 702 of 2108 R01UH0134EJ0400 Rev. 4.00
Sep 24, 2014
SH7262 Group, SH7264 Group
14.4.3 Reading Time
Figure 14.3 shows how to read the time.
Disable the carry interrupt
Clear the carry flag
Read all target counter registers
Carry flag = 1?
Yes
No
Yes
No
Read all target counter registers
interrupt
Disable the carry interrupt
Write 0 to CF in RCR1
(Set AF in RCR1 to 1 so that alarm
flag is not cleared.)
Write 1 to CIE in RCR1
Write 0 to CIE in RCR1
Clear the carry flag
Enable the carry interrupt
Clear the carry flag
Write 0 to CF in RCR1
(Set AF in RCR1 to 1 so that alarm
flag is not cleared.)
Read RCR1 and check CF bit
Write 0 to CIE in RCR1
(a) To read the time without using interrupts
(b) To read the time using interrupts
Figure 14.3 Reading Time
If a carry occurs while reading the time, the correct time will not be obtained, so it must be read
again. Part (a) in figure 14.3 shows the method of reading the time without using interrupts; part
(b) in figure 14.3 shows the method using carry interrupts. To keep programming simple, method
(a) should normally be used.