cancel
Showing results for 
Search instead for 
Did you mean: 

Should HAL_RTCEx_SetSmoothCalib() behave same with 16s and 32s window periods ?

mcu_
Associate

I'm working on RTC smooth digital calibration on an STM32U575 board using the HAL function HAL_RTCEx_SetSmoothCalib(). I'm using the LSE (32.768kHz) as the RTC clock source.

What I'm trying to do:

I want to adjust a known RTC drift (e.g., 500ms) over time using the RTC’s smooth calibration feature. I understand that I can configure the calibration window to 32s, 16s, or 8s using the SmoothCalibPeriod parameter, and that I can add or subtract pulses (each approx 30.5µs) to speed up or slow down the RTC.

What I expected:

With a 32s window, each call to HAL_RTCEx_SetSmoothCalib() can adjust ~15.6ms max (512 pulses × 30.5µs). So, it should take about 1024s (500 / 15.6 = 32 calls every 32s) to fully adjust 500ms. With a 16s window, I expected the correction rate to double, since the same pulse change should now apply over a shorter time, and thus the 500ms adjustment should take ~512s (500/15.6 = 32 calls every 16s).

What I’m observing:

When I call the function with RTC_SMOOTHCALIB_PERIOD_32SEC, it behaves as expected (takes ~1024s to fully correct 500ms). But when I change the calibration window to RTC_SMOOTHCALIB_PERIOD_16SEC, the total correction over the same number of calls is less than expected. it adjusts only ~250ms instead of 500ms. It seems like the effective correction rate remains the same as 32s, and/or the settings aren’t applied each time as expected.

My Question:

Is there any internal hardware limitation in STM32U575 (or STM32 in general) that causes 16s/8s window settings to behave like 32s? If so, what's the correct way to apply faster or more frequent RTC calibration?





3 REPLIES 3
TDK
Super User

The rate of correction is the same regardless of period, according to the reference manual. You cannot increase the correction rate by reducing the duration.

TDK_0-1761008177027.png

 

TDK_1-1761008192098.png

 

If you want to change it faster, consider using HAL_RTCEx_SetSynchroShift.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks for the clarification @TDK , that the correction rate remains constant regardless of the calibration period.

As a follow-up, what’s the practical significance of the 8s and 16s calibration windows then?
If reducing the window length (from 32s → 16s → 8s) doesn’t actually make the RTC correct faster, in what scenarios would we want to use the shorter periods?

If your window is 32 s, you will have to wait 32 s before the clock has been fully adjusted. If you select an 8s window, you will only have to wait 8 s. It's giving you options.

If your correction is small, any window can work.

If you feel a post has answered your question, please click "Accept as Solution".