STM32 Real Time Clock (RTC)
All STM32 MCUs are equipped with a built-in Real time clock (or RTC).
Clock configuration
Internally, the RTC needs to be clocked by a 1 Hz signal. The source of that signal can be selected in the RTC Clock Mux:
Essentially one of 3 different sources can be seleted:
- LSI (Low Speed Internal oscillator
- LSE (Low Speed External oscillator
- HSE (High Speed External oscillator
The internal low speed oscillator is clocked around 32 kHz but it is notoriously imprecise and drift a lot with temperature.
The external low speed oscillator will typically be clocked by a 32.768 kHz crystal. These crystals are typically manufactured for clocks and watches so they are fairly precise. The somewhat odd frequency is common because it is easy to divide down to a 1 Hz frequency.
If a LSE is not available it is also typically possible to clock the RTC from the high-speed external crystal (HSE). This clock source is typically clocked by a 8-25 MHz crystal and such crystals typically are precise to within 10-20 ppm. This will result in a clock drift of less than 2 seconds per 24 hours.
Miscellaneous links
To be added