STM32 RTC – How RTC Keeps Time Accurately Using LSI as Clock Source

embeddedmicrocontrolleroscillatorrtcstm32

I am working on an application that must keep track of time (using a RTC), and will be uploaded on a STM32L052K8.

When I was making my hardware I just assumed that I will use the low speed internal (LSI) clock of the MCU. However, now that I am writing the code I saw something that really worries me.

According to the datasheet of the MCU the LSI oscillator characteristics are:

LSI oscillator characteristics

If this is indeed the case then does that mean that my time base clock will be anywhere between 26kHz and 56kHz? If this is the case, then the RTC is completely useless. If this is not the case then how does ST manage to get the a high accuracy RTC which runs on such an oscillator? Also according to the datasheet the nominal frequency of the LSI oscillator is 38kHz, but according to STM32CubeMX it is 37kHz as seen in this picture below.

RTC setup STM32CubeMX

What is the nominal frequency I should assume?

I really hope this has some solution with an acceptable accuracy (even +/- 1% is enough for me).

Best Answer

The LSI cannot keep the time accurately.

Accurate timekeeping always requires a crystal.

All RTCs typically use a 32768 Hz crystal for that, be it a separate crystal or a crystal molded into same plastic package as a complete module.

The evaluation boards from ST are no exception to this, there usually is a crystal already mounted on boards or at least a place for mounting it if needed.

I am actually a bit surprised it is possible to select something else than LSE for RTC timing.