
RM0453 Rev 2
RM0453
Real-time clock (RTC)
1049
The formula to calculate the effective calibrated frequency (F
CAL
) given the input frequency
(F
RTCCLK
) is as follows:
F
CAL
= F
RTCCLK
x [1 + (CALP x 512 - CALM) / (2
20
+ CALM - CALP x 512)]
Caution:
PREDIV_A must be greater or equal to 3.
Calibration when PREDIV_A < 3
The CALP bit can not be set to 1 when the asynchronous prescaler value (PREDIV_A bits in
RTC_PRER register) is less than 3. If CALP was already set to 1 and PREDIV_A bits are
set to a value less than 3, CALP is ignored and the calibration operates as if CALP was
equal to 0.
It is however possible to perform a calibration with PREDIV_A less than 3 in BCD mode, the
synchronous prescaler value (PREDIV_S) should be reduced so that each second is
accelerated by 8 ck_cal clock cycles, which is equivalent to adding 256 clock cycles every
calibration cycle. As a result, between 255 and 256 clock pulses (corresponding to a
calibration range from 243.3 to 244.1 ppm) can effectively be added during each calibration
cycle using only the CALM bits.
With a nominal RTCCLK frequency of 32768 Hz, when PREDIV_A equals 1 (division factor
of 2), PREDIV_S should be set to 16379 rather than 16383 (4 less). The only other
interesting case is when PREDIV_A equals 0, PREDIV_S should be set to 32759 rather
than 32767 (8 less).
If PREDIV_S is reduced in this way, the formula given the effective frequency of the
calibrated input clock is as follows:
F
CAL
= F
RTCCLK
x [1 + (256 - CALM) / (2
20
+ CALM - 256)]
In this case, CALM[7:0] equals 0x100 (the midpoint of the CALM range) is the correct
setting if RTCCLK is exactly 32768.00 Hz.
Verifying the RTC calibration
It is recommended to verify the RTC calibration with LPCAL=0, in order to have a 32 second
calibration cycle.
RTC precision is ensured by measuring the precise frequency of RTCCLK and calculating
the correct CALM value and CALP values. An optional 1 Hz output is provided to allow
applications to measure and verify the RTC precision.
Measuring the precise frequency of the RTC over a limited interval can result in a
measurement error of up to 2 RTCCLK clock cycles over the measurement period,
depending on how the digital calibration cycle is aligned with the measurement period.
However, this measurement error can be eliminated if the measurement period is the same
length as the calibration cycle period. In this case, the only error observed is the error due to
the resolution of the digital calibration.
•
By default, the calibration cycle period is 32 seconds.
Using this mode and measuring the accuracy of the 1 Hz output over exactly 32 seconds
guarantees that the measure is within 0.477 ppm (0.5 RTCCLK cycles over 32 seconds,
due to the limitation of the calibration resolution).
•
CALW16 bit of the RTC_CALR register can be set to 1 to force a 16- second calibration
cycle period.