R01UH0823EJ0100 Rev.1.00
Page 798 of 1823
Jul 31, 2019
RX23W Group
28. Realtime Clock (RTCe)
[Example 2] Sub-clock running at 32.766 kHz
Adjustment procedure:
When the sub-clock is running at 32.766 kHz, 1 second elapses every 32,766 clock cycles. The RTC is meant to run at
32,768 clock cycles, so the clock runs slow by two clock cycles every second. The time on the clock is slow by 20 clock
cycles every 10 seconds, so adjustment can take the form of setting the clock forward by 20 cycles every 10 seconds.
Register settings: (when RCR2.CNTMD = 0)
RCR2.AADJP = 1 (adjustment every 10 seconds)
RADJ.PMADJ[1:0] = 01b (adjustment is performed by the addition to the prescaler.)
RADJ.ADJ[5:0] = 20 (14h)
[Example 3] Sub-clock running at 32.764 kHz
Adjustment procedure:
At 32.764 kHz, 1 second elapses on 32,764 clock cycles. Since the RTC operates for 32,768 clock cycles as 1 second, the
clock is delayed for four clock cycles per second. In 8 seconds, the delay is 32 clock cycles, so correction can be made by
proceeding the clock for 32 clock cycles every 8 seconds.
Register settings when the RCR2.CNTMD bit is 1
RCR2.AADJP = 1 (adjustment every 8 seconds)
RADJ.PMADJ[1:0] = 01b (adjustment is performed by the addition to the prescaler.)
RADJ.ADJ[5:0] = 32 (20h)
28.3.8.2
Adjustment by Software
Enable adjustment by software by setting the RCR2.AADJE bit to 0.
Adjustment by software is the addition or subtraction of the value counted by the prescaler to or from the value in the
RADJ register at the time of execution of an instruction for writing to the RADJ register.
An example is shown below.
[Example 1] Sub-clock running at 32.769 kHz
Adjustment procedure:
When the sub-clock is running at 32.769 kHz, 1 second elapses every 32,769 clock cycles. The RTC is meant to run at
32,768 clock cycles, so the clock runs fast by one clock cycle every second. The time on the clock is fast by one clock
cycle per second, so adjustment can take the form of setting the clock back by one cycle every second.
Register settings:
RADJ.PMADJ[1:0] = 10b (adjustment is performed by the subtraction from the prescaler.)
RADJ.ADJ[5:0] = 1 (01h)
This is written to the RADJ register once per 1-second interrupt.