Skip to main content
STM32L0Fan
Associate II
Jun 21, 2021 1:15 PM UTC
Solved

RTC digital smooth calibration doesn't seems to work (stm32l083rz)

To read the frequency I am using a timer to output frequency then I am reading the value using a frequence counter. I am using the stm32l083rz chip. I have a gate time of 32 seconds on my frequence counter.

I am trying to compensate the drift due to the temperature of a 32.768kHz quartz.

I have tried to use the hal function but I don't see any difference on my frequence counter.

if (HAL_RTCEx_SetSmoothCalib(timeMgr.rtcHandle,

RTC_SMOOTHCALIB_PERIOD_8SEC,

RTC_SMOOTHCALIB_PLUSPULSES_SET,

0x00000FF

) != HAL_OK)

{

Error_Handler();

}

I also tried to use the code exemple given in the STM32L0x3 REFERENCE MANUEL. But same result, the frequency doesn't seem to be recalibrated.

Any thoughts ?

The configuration I use to measure frequency. (TIM22 with LSE)

0693W00000BbYZNQA3.png

This topic has been closed for replies.
waclawek.jan
waclawek.janBest answer
Super User
Jun 24, 2021 11:00 AM UTC

> I set the rtc to have an interuption every second

Using wakeup (RTC_WUTR)? And if yes, then how is RTC_CR.WUCKSEL set? If to 0b0xx, then that's the problem: wakeup is derived from the raw RTC clock source, avoiding the calibration.

0693W00000BbtaWQAR.png 

If this is the case, try to WUCKSEL to 0b10x.

JW

9 replies

waclawek.jan
Super User
Jun 21, 2021 1:26 PM UTC

Read out and check/post the RTC registers content before and after the calibration.

How precise is your frequency counter and what is its resolution?

JW

STM32L0Fan
Associate II
Jun 21, 2021 1:53 PM UTC

Thank you for your answer, I am not sure If this what you wanted.

0693W00000BbZ0JQAV.png0693W00000BbZ0EQAV.pngMy frequency counter is precise 9 digits and (it's the HM8123 frequency counter) resolution of 10^-8 for this application I think.

Léo

STM32L0Fan
Associate II
Jun 23, 2021 8:44 AM UTC

I added a mask to propely view the value.0693W00000BblD0QAJ.pngI don't know why the calibration don't apply maybe there is something to initialize to make it work ? I don't know I'm still stuck ...

waclawek.jan
Super User
Jun 23, 2021 11:16 PM UTC

What signal do you exactly measure and what readings do you get?

JW

STM32L0Fan
Associate II
Jun 24, 2021 8:45 AM UTC

I set the rtc to have an interuption every second and I am changing the value of a GPIO pin, that's the best way I found to read the RTC frequency.

Here are my readings :

0693W00000BbsQuQAJ.pngx: time in minutes

y: frequency in mHz

nb: for the 3 graphs on top I put the max value in : HAL_RTCEx_SetSmoothCalib(timeMgr.rtcHandle,

RTC_SMOOTHCALIB_PERIOD_8SEC,

RTC_SMOOTHCALIB_PLUSPULSES_RESET,

0x1FF

)

and for the min graphs I put 0x000

Léo

waclawek.jan
waclawek.janBest answer
Super User
Jun 24, 2021 11:00 AM UTC

> I set the rtc to have an interuption every second

Using wakeup (RTC_WUTR)? And if yes, then how is RTC_CR.WUCKSEL set? If to 0b0xx, then that's the problem: wakeup is derived from the raw RTC clock source, avoiding the calibration.

0693W00000BbtaWQAR.png 

If this is the case, try to WUCKSEL to 0b10x.

JW

STM32L0Fan
Associate II
Jun 24, 2021 3:29 PM UTC

Thank you JW that was it, indeed now I can see the effet of the calibration.

0693W00000Bbvs3QAB.pngI started to wonder If i was obligated to use the pin PC13 to have the result I wanted. But it seems that your way is working too.

Thank you very much !

Léo

LRegn.11
Associate
Oct 27, 2021 1:30 PM UTC

[to be removed]

waclawek.jan
Super User
Oct 27, 2021 9:03 PM UTC

Please start a new thread with your problem, as it's unrelated to the original thread.

JW