2023-03-28 04:58 PM
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?
2023-03-28 09:06 PM
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
2023-03-29 07:19 AM
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.
2023-03-29 08:16 AM
> I'm not sure what you mean by LSE
This:
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.
JW
2023-03-29 10:51 AM
Thank you! We're using a 32.768 Khz crystal connected to pins 8 and 9. That is our time base source.
2023-03-29 10:52 PM
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