cancel
Showing results for 
Search instead for 
Did you mean: 

For STM32L4S5, how to access the calibration register and how to calculate what values to store in that register? We're having a problem with the calibration of the real-time clock. It's significantly off-time over a period of several days.

EHD
Associate II

We believe there is a register setting to calibrate it, how can we debug this issue please? What are the steps to calculate the calibration register value and how do we get them into the register?

5 REPLIES 5

Are you talking about the RTC? At you running it from LSE?

> It's significantly off-time over a period of several days.

How much?

JW

EHD
Associate II

I'm not sure what you mean by LSE but the time keeping in the CPU is about 400 ppm different from actual time. So over the course of a day it's many seconds off. Thanks.

> I'm not sure what you mean by LSE

This:

0693W00000bh8BBQAY.png 

i.e. externally connected 32.768kHz crystal, or externally connected 32.768kHz crystal oscillator.

If you run RTC from the LSI i.e. the internal low-speed RC oscillator, note, that it's principially imprecise and not stable for precise timekeeping purposes.

0693W00000bh8BQQAY.png 

JW

EHD
Associate II

Thank you! We're using a 32.768 Khz crystal connected to pins 8 and 9. That is our time base source.

It's highly unusual to have 400ppm deviation with the standard 32.768kHz crystal, so that indicates that you either don't run RTC off that crystal (and by mistake run it out off LSI), or there is some serious hardware problem with the crystal oscillator itself.

Read out the RCC_BDCR register content and check if RTCSEL field is set to 0b01 for LSE. Check if LSECSSON+LSECSSD are not set.

Read out RTC registers content and check if prescaler values in RTC_PRER match the expected total division value (the default value of PREDIV_A=0x7F and PREDIV_S=0xFF are OK for 32768).

Read AN2867 for hints about hardware. Note, that you cannot measure LSE oscillations using common oscilloscope probe, as it's an extremely low power circuit; you'd need to set output of LSE onto LSCO pin and measure there.

For reference, you could/should try to run the RTC on a "known good" hardware such as the Nucleo or Disco board.

JW