AN2604
Application note
STM32F101xx and STM32F103xx RTC calibration
Introduction
The real-time clock (RTC) precision is a requirement in most embedded applications, but due to external environment – temperature change, frequency variation of the crystal that clocks the RTC – the RTC precision may not be as accurate as expected.
The RTC embedded in the STM32F101xx and STM32F103xx comes with a digital clock calibration circuit suitable for manufacturing environments, that allows applications to compensate for crystal and temperature variations. This application note discusses the RTC calibration basics and explains how RTC calibration can be used to improve timekeeping accuracy.
August 2007 |
Rev 1 |
1/14 |
www.st.com
Contents |
AN2604 - Application note |
|
|
Contents
1 |
RTC calibration basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
. 5 |
|
|
1.1 |
Crystal accuracy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
5 |
|
1.2 |
Methodology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
6 |
2 |
Calculating the needed amount of calibration . . . . . . . . . . . . . . . . . . . |
10 |
|
3 |
Calculating calibration over a temperature range . . . . . . . . . . . . . . . . |
11 |
|
4 |
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
12 |
|
5 |
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . |
13 |
2/14
AN2604 - Application note |
List of tables |
|
|
List of tables
Table 1. Calibration table: compensation values in ppm and seconds per month (30 days) . . . . . . . 7 Table 2. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3/14
List of figures |
AN2604 - Application note |
|
|
List of figures
Figure 1. Typical crystal accuracy plotted against temperature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Figure 2. RTC calibration clock output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Figure 3. Crystal accuracy over a temperature range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4/14
AN2604 - Application note |
RTC calibration basics |
|
|
The term “quartz-accurate” has become a familiar phrase used to describe the accuracy of many time keeping functions. Quartz oscillators provide an accuracy far superior to that of other conventional oscillator designs, but they are not perfect. Quartz crystals are sensitive to temperature variations. Figure 1 shows the relationship between accuracy (acc), temperature (T) and curvature (K) for a typical 32.768 kHz crystal. The curve follows the general formula given below:
acc = k × ( T – To)2 , where:
●To = 25 °C ± 5 °C
●K = –0.040 ppm/°C2
Note: |
The variable K is crystal-dependent, the value indicated here is for the crystal mounted on |
|
the STM3210B-EVAL board. Refer to the crystal manufacturer for more details on this |
|
parameter. |
The clocks used in most applications require a high degree of accuracy, and there are several factors involved in achieving this accuracy. Typically most crystals are compensated for by adjusting the load capacitance of the oscillator. This method, though effective, has several disadvantages:
1.it requires external components (trim capacitors)
2.it can increase the oscillator current (a major factor in battery-supported applications)
Instead of this crude analog method, STM32F10xxx products use a digital calibration feature that gives the user software control over the calibration procedure, and make it userfriendly.
|
|
|
40 |
|
|
|
|
|
|
|
|
|
|
|
20 |
|
|
|
|
|
|
|
|
|
|
|
0 |
|
|
|
|
Temperature (˚C) |
|||
–30 |
–20 |
–10 |
0 |
10 |
20 |
30 |
40 |
50 |
60 |
70 |
80 |
|
|||||||||||
|
|
–20 |
|
|
|
|
|
|
|
|
|
|
|
–40 |
|
|
|
|
|
|
|
|
|
|
|
–60 |
|
|
|
|
|
|
|
|
|
|
|
–80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
Accuracy (ppm) |
|
|
|
|
|
|
|
|
|
–100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ai14625 |
5/14