cancel
Showing results for 
Search instead for 
Did you mean: 

RTC smooth calibration and verification?

suads
Associate III

Hi,

I m using the smooth calibration

tim1 is using an external clock 1Hz from signal generator and channel 1 is working in output compare mode generating interrupt every 32 seconds, tim2 is using LSE and channel 1 is in input capture mode.

When the interrupt from tim1 triggers, I m reading the captured data CCR1 and calculate the difference from the expected value and calling the HAL_RTCEx_SetSmoothCalib function.

expected value=1048576

captured=1048505

When the interrupt triggers again, I get a close value again shouldn't it be near 0 when it is calibrated?

And what is the idea calibration out pin 512 Hz as far as I understand it should be stable at 512 Hz, but my values change 512.7 Hz, 511.9 Hz 512.3 Hz it is not stable. 

How Do I know it is calibrated?

2 REPLIES 2

Which STM32?

> When the interrupt triggers again, I get a close value again shouldn't it be near 0 when it is calibrated?

The RTC smooth calibration does *not* change the LSE frequency. Rather, it changes the way how output pulses of LSE are counted in RTC.

In other words, you cannot "see" the effect of RTC smooth calibration using the two timers which compare external 1Hz with LSE. You would need the RTC output for that - and you appear to describe just that in the second part of the post.

> And what is the idea calibration out pin 512 Hz as far as I understand it should be stable at 512 Hz, but my values change 512.7 Hz, 511.9 Hz 512.3 Hz it is not stable.

The RTC smooth calibration is applied across a 32s period (or 8s or 16s if set to non-default values), so you need to measure the 512Hz output with an exactly 32s window (or multiples of it). One way to do it is to use your first setup but feed the 512Hz output as external clock into TIM2, instead of LSE (if the chip you are using allows this).

JW

Hi thanks for your help.

I was not able to use the same timer because it is a custom board stm32wb55ceu6, So I used another board nucleo f072rb. I feed one timer with the calibrated 512 Hz and other timer with the same signal generator 1Hz, And triggering interrupt 32s and capturing the CNT register. So the expected value should be 32*512=16384

and I am getting a very close value, but sometimes the value is not even close !

1st captured value 16383

2nd catured value 16384,

3rd catured value 16219

4th catured value 16385

...

Could it be a Hardware issue? I m soldering a wire on a Test point(512 Hz pin PB2) on my custom board to feed nucleo f072rb with this clock.