14 REAL-TIME CLOCK (RTC)
S1C17F13 TeChniCal Manual
Seiko epson Corporation
14-3
(Rev. 1.0)
Operations
14.4
Time Setting
14.4.1
Follow the sequence shown below to set time to RTC.
1. Set the following RTCCTL register bits:
- Write 0 to the RTCCTL.RTCRUN bit. (Stop RTC)
- RTCCTL.BCDMD bit
(Select binary/BCD mode)
- RTCCTL.RTC24H bit
(Select 24H/12H mode)
2. Check to see if the RTCCTL.RTCST bit = 0 (RTC is idle). If the RTCCTL.RTCST bit = 1 (RTC is operating),
wait until it is set to 0.
3. Write a time to the control bits listed below.
- RTCMIN.RTCSEC[6:0] bit
(Second)
- RTCMIN.RTCMIN[6:0] bit
(Minute)
- RTCHUR.RTCHUR[5:0] bit
(Hour)
- RTCHUR.AMPM bit
(AM/PM) (effective when RTCCTL.RTC24H bit = 1)
4. Write 1 to the interrupt flags in the RTCINTF register.
(Clear interrupt flags)
5. Write 1 to the interrupt enable bits in the RTCINTE register. (Enable interrupts)
6. Write 1 to the RTCCTL.RTCRUN bit. (Start RTC)
Write 0 to the
RTCCTL.RTCRUN bit
Write data to the RTCMIN and
RTCHUR registers
Write 1 to the
RTCCTL.RTCRUN bit
No
Yes
Counter setting
END
RTCCTL.RTCST = 0?
4.1.1 Counter Setting Procedure
Figure 14.
Notes:
•
An initial reset does not initialize the second/minute/hour counter values. Be sure to initialize
the counters via software.
•
Do not set the counters while the RTC is running (RTCCTL.RTCST bit = 1), as proper settings
to the counters cannot be guaranteed.
•
Counter values to be set must be within the effective range according to binary/BCD mode.
The counter will be undefined if a value out of the range is written.
•
Depending on the value set, an interrupt may occur immediately after starting the RTC.
•
The divider that generates F256 (256 Hz regulated clock) is reset when the RTC starts run-
ning (when 1 is written to the RTCCTL.RTCRUN bit). This affects the count operations of
other timers that use F256, as new F256 cycle begins from that point.
•
After an initial reset, the RTCCTL.RTCRUN bit is set to 0 and the RTC idles. The OSC1 oscil-
lator circuit is also idle. Therefore, resetting the IC suspends the RTC operation for the period
shown below.
RTC idle time = [#RESET = low period] + [Boot clock oscillation stabilization time] +
[Time until OSC1 is started] + [OSC1 oscillation stabilization time] +
[Time until RTC is restarted]