RTC_B Operation
696
SLAU367P – October 2012 – Revised April 2020
Copyright © 2012–2020, Texas Instruments Incorporated
Real-Time Clock B (RTC_B)
...
; Task starts here
RETI
; Back to main program
5
RT1PSIFG_HND
; Vector A: RT1PSIFG Flag
...
; Task starts here
RETI
; Back to main program
5
RTCOFIFG_HND
; Vector C: RTCOFIFG Flag
...
; Task starts here
RETI
; Back to main program
5
28.2.5 Real-Time Clock Calibration
The RTC_B module has calibration logic that allows for adjusting the crystal frequency in approximately
+4-ppm or –2-ppm steps, allowing for higher time keeping accuracy from standard crystals. The RTCCALx
bits are used to adjust the frequency. When RTCCALS is set, each RTCCALx LSB causes an
approxi4-ppm adjustment. When RTCCALS is cleared, each RTCCALx LSB causes an
approximately –2-ppm adjustment.
Calibration is accomplished by periodically adjusting the RT1PS counter based on the RTCCALS and
RTCCALx settings. The RT0PS divides the nominal 37268-Hz low-frequency (LF) crystal clock input by
256. A 60-minute period has 32768 cycles/sec × 60 sec/min × 60 min = 117964800 cycles. Therefore, a
–2-ppm reduction in frequency (down calibration) approximately equates to adding an additional 256
cycles every 117964800 cycles (256/117964800 = 2.17 ppm). This is accomplished by holding the RT1PS
counter for one additional clock of the RT0PS output within a 60-minute period. Similarly, a +4-ppm
increase in frequency (up calibration) approximately equates to removing 512 cycles every 117964800
cycle (512/117964800 = 4.34 ppm). This is accomplished by incrementing the RT1PS counter for two
additional clocks of the RT0PS output within a 60-minute period. Each RTCCALx calibration bit causes
either 256 LF crystal clock cycles to be added every 60 minutes or 512 LF crystal clock cycles to be
subtracted every 60 minutes, giving a frequency adjustment of approximately –2 ppm or +4 ppm,
respectively.
To calibrate the frequency, the RTCCLK output signal is available at a pin. RTCCALF bits can be used to
select the frequency rate of the output signal, either no signal, 512 Hz, 256 Hz, or 1 Hz.
The basic flow to calibrate the frequency is as follows:
1. Configure the RTCCLK pin.
2. Measure the RTCCLK output signal with an appropriate resolution frequency counter; that is, within the
resolution required.
3. Compute the absolute error in ppm: Absolute Error (ppm) = |10
6
× ( f
MEASURED
– f
RTCCLK
) / f
RTCCLK
|, where
f
RTCCLK
is the expected frequency of 512 Hz, 256 Hz, or 1 Hz.
4. Adjust the frequency:
a. If the frequency is too low, set RTCALS = 1 and apply the appropriate RTCCALx bits, where
RTCCALx = ((Absolute Error) / 4.069 ) – 1, rounded to the nearest integer.
b. If the frequency is too high, clear RTCALS = 0 and apply the appropriate RTCCALx bits, where
RTCCALx = ((Absolute Error) / 2.035 ) – 1, rounded to the nearest integer.
For example, assume that RTCCLK is output at a frequency of 512 Hz. The measured RTCCLK is
511.9658 Hz. The frequency error is approximately 66.8 ppm low. To increase the frequency by 66.8 ppm,
RTCCALS would be set, and RTCCAL would be set to 15 ((66.8 / 4.069) – 1). Similarly, assume that the
measured RTCCLK is 512.0125 Hz. The frequency error is approximately 24.4 ppm high. To decrease the
frequency by 24.4 ppm, RTCCALS would be cleared, and RTCCAL would be set to 11 ((24.4 / 2.035) – 1).
The calibration corrects only initial offsets and does not adjust for temperature and aging effects. These
effects can be managed by periodically measuring the temperature and using the crystal's charateristic
curve to adjust the ppm based on temperature as required. In counter mode (RTCMODE = 0), the
calibration logic is disabled.