cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F446 RTC Accuracy

gokhannsahin
Associate II
Posted on April 16, 2018 at 16:09

Hi everyone,

I have been trying to set 1ppm RTC clock for two days.I have read the datasheet and manual. They are recommended to use 2 timers and an external oscillator. Also, with using HAL_RTCEx_SetSmoothCalib function, says that we can calibrate it easily. I set the RTC routed output as calibration 512Hz, but the frequency of it is 511.96Hz. After that, I read a manual that is

http://www.st.com/content/ccc/resource/technical/document/application_note/ff/c1/4f/86/4e/29/42/d1/CD00167326.pdf/files/CD00167326.pdf/jcr:content/translations/en.CD00167326.pdf

 for STM32F1s. As it says, I have calculated the ppm error. 

512-511.96=0.04Hz => 0.04/511.96=7.81e-5 => ppm=78.13, the manual recommends the using 83 for the calibration value.

And then called the smooth calibration function this value. Thus;

HAL_RTCEx_SetSmoothCalib(&hrtc, RTC_SMOOTHCALIB_PERIOD_32SEC, RTC_SMOOTHCALIB_PLUSPULSES_RESET, 83);

However, although the calibration value has been changed, the routed value is still the 511.96Hz. Why doesn't it change? 

#stm32f4-rtc
1 REPLY 1
Posted on April 16, 2018 at 16:23

This depends on the method used to measure the frequency of the 512Hz output. As the calibration inserts/removes pulses within a 32-second cycle, you really should use a method which accumulates measurement during those 32 seconds.

If your measurement method measures duration of one pulse, in the 512Hz output, most of the pulses are still 1/512 seconds long, and here and there there are shorter, 1/520 second long pulses, compensating in the long run the total frequency error.

JW