Skip to main content
DTeuc.1
Associate II
June 15, 2026
Question

STM32F746G DISCO, RTC calibration

  • June 15, 2026
  • 2 replies
  • 78 views

Starting with the http server example i inserted LwIP SNTP and RTC based on medium-high LSE and smooth calibration with a PI controller. After some hours of SNTP comparisons every 120 seconds the calibrator settles at -12.3 units. My firmware implements fractional calibration by tracking remainders. The running average over 10 consecutive time comparisons exhibits < 1 msec rms. A nice result.

Then i modified predivider setup from standard 127/255 to 31/1023 in order to improve resulation. After a backup domain reset the new setup works and delivers consistent time comparisons. I also unsoldered R11 in order to separate PC13 from the “SD card present” switch in order to look at the RTC calibration output.

  • The calibration output shows 4 Hz instead of 1 Hz. I may try an RTC alarm to get the 1 second output pulse.
  • The smooth calibration feature no longer works as expected. Apparently the mapping between CALR register settings and what the circuit really does no longer follows the reference manual description. What is known about this?

2 replies

JCAIL
ST Employee
June 15, 2026

Hello,

4 Hz instead of 1 Hz is expected with LSE 32768Hz, asynchronous prescaler = 31 and synchronous prescaler = 1023.
 

RTC_CALIB is not the final 1 Hz calendar output. It is an internal prescaler tap selected by RTC_CR.COSEL:

  • COSEL = 0 → 6th stage of the asynchronous prescaler
  • COSEL = 1 → 8th stage of the synchronous prescaler

With LSE = 32.768 kHz and RTC_PRER = 31/1023, the RTC calendar time base is still 1 Hz:

32768 / (32 * 1024) = 1 Hz

But with COSEL = 1, the calibration output is taken from the 8th synchronous stage, which gives:

32768 / (32 * 256) = 4 Hz

So the 4 Hz output is normal for this configuration.

DTeuc.1
DTeuc.1Author
Associate II
June 15, 2026

Thank you. Yes, the description of the RTC_CR.COSEL bit in the reference manual says that the calibration output frequency depends on crystal frequency and on predivider setup.

Meanwhile i got the 1 second pulse using RTC AlarmA, with everything masked except the subsecond low 10 bits. The HAL provided interrupt routine resets the alarm flag within 400 nsec. Next i need to trigger a one-shot timer to adjust the pulse length.

The smooth calibration issue turned out to be a transient failure and after several more backup domain resets everything appears to be fine again. The improved RTC resolution helps.