cancel
Showing results for 
Search instead for 
Did you mean: 

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

STM32L0Fan
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

> 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

View solution in original post

9 REPLIES 9

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

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

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 ...

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

JW

STM32L0Fan
Associate II

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

> 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

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 II

[to be removed]

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

JW