2020-01-21 10:29 PM
Hi,
I want to calibrate RTC(which is powered through LSE-32.768KHz) in stm32F051 and want to know how CALM value is calculated in RTC calibration register(RTC->CALR).
Thank you.
2020-01-22 12:15 AM
2020-01-22 02:35 AM
Hi,
Thanks for quick reply. Can you explain why CALM=32*32768*(32/T32-1)?
Thank you
2020-01-22 09:57 PM
Hi,
I followed the link you sent and calibrated RTC and kept RTC running for 15 hours,But there is lag of 2 seconds in RTC.
Steps followed :
3. Since T32(31.9848) is less than 32,I added pulses using RTC_SmoothCalibConfig(RTC_SmoothCalibPeriod_32sec,RTC_SmoothCalibPlusPulses_Set,524);
Please let me know if I have done anything wrong in configuration.
Thank you.
2020-01-23 02:07 AM
> 15 hours,But there is lag of 2 seconds
That's 2/(15*3600) = 37ppm. Not that bad at all.
> Summed 32 seconds periods of 1Hz calib output
You want to actually measure the 32 periods. Or, if there's no calibration yet, it's OK to measure the 1Hz output, but you have to measure it with an instrument which provides you both adequate resolution and precision. For say 10ppm calibration you want both resolution and precision of the instrument (typically a frequency counter) to be better than 10ppm, and at 1Hz/1s that's 10us. Having 999.9ms appears the used resolution is only 100us (i.e. 100ppm), and I doubt such instrument has a precision below those 100ppm, so you won't be able to calibrate better than that using that instrument.
If you don't have such precise instrument, simply let the RTC run long enough
> 32*999.9mSec = 31.9848
No. 32*999.9ms = 31.9968s and then 32*32768*(32/31.9968-1) = 104.868
> Since T32(31.9848) is less than 32,
I made mistake in the linked thread (will correct it there) - if the measured time before correction is below 32s, you'll need to renive pulses i.e. CALP=0.
I don't use any library so I don't know what exactly the function you used, exactly does, in terms of CALM/CALP.
JW
2020-01-23 02:09 AM
As I wrote in the linked thread, for the RTC to generate exact 32 s you need 32*32768*32/T32 LSE periods instead of the 32*32768 periods of the uncalibrated RTC. So you want the RTC with the real imperfect crystal, to skip the difference between these two numbers of periods, i.e. 32*32768*32/T32 - 32*32768 = 32*32768*(32/T32-1).
JW
2020-01-23 03:21 AM
Thanks for the clarification.
I made mistake in calculating T32,it was supposed to be 104.
This function does RTC smooth calibration ->
RTC_SmoothCalibConfig(RTC_SmoothCalibPeriod_32sec,RTC_SmoothCalibPlusPulses_Set,104);
here,
RTC_SmoothCalibPeriod_32sec - 32 second calibration window
RTC_SmoothCalibPlusPulses_Set - add pulses(i.e CALP=1 or CALP=0)
104- CALM
> That's 2/(15*3600) = 37ppm. Not that bad at all.
I think it is 41 PPM. Is not it?( (41/10^6)*15*3600) == 2 second
Thank you.