Skip to main content
KIbra.3
Associate II
April 12, 2023
Solved

RTC drift

  • April 12, 2023
  • 6 replies
  • 6320 views

I am currently working on an RTOS application that includes RTC, and have observed that there is a clock drift of approx. 25 to 32 seconds after a 24-hour measurement cycle. Additionally, the drift seems to be not linear.

I've measured the RTC frequency and it was around 32.78KHz.

I would appreciate if anyone could provide any suggestions on how to improve the RTC performance.

This topic has been closed for replies.
Best answer by waclawek.jan

Which STM32?

What hardware?

What is the RTC clock source?

Does the "drift" increase with number of resets?

JW

6 replies

waclawek.jan
waclawek.janBest answer
Super User
April 12, 2023

Which STM32?

What hardware?

What is the RTC clock source?

Does the "drift" increase with number of resets?

JW

KIbra.3
KIbra.3Author
Associate II
April 13, 2023

I am using Discovery kit with STM32L4R9AI MCU and the RTC clock source is LSE 32.768KHZ.

I have to investigate whether the drift increases with reset, but the drift also appears without reset.

waclawek.jan
Super User
April 13, 2023

This is way too much error for LSE, and I don't assume the Disco would have problematic crystal/PCB layout.

Read out and check/post content of RCC_BDCR register, and possibly content of RTC registers too.

JW

KIbra.3
KIbra.3Author
Associate II
April 13, 2023

I noticed a significant increase in the drift when resetting the board many times. Do you think it would be advisable for me to check the RCC_BDCR?

waclawek.jan
Super User
April 13, 2023

> I noticed a significant increase in the drift when resetting the board many times.

What is "significant"? Is it in average about half a second per reset? If yes, resort to the link I've posted above.

JW

KIbra.3
KIbra.3Author
Associate II
April 13, 2023

The issue has been resolved in HAL_RTC_Init() looses time · Issue #24 · STMicroelectronics/STM32CubeH7 · GitHub as the number of times I reset the MCU had an impact on the drift.

Thanks for indicating the main cause of the problem.