2021-06-21 06:15 AM
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)
Solved! Go to Solution.
2021-06-24 04:00 AM
> 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.
If this is the case, try to WUCKSEL to 0b10x.
JW
2021-06-21 06:26 AM
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
2021-06-21 06:53 AM
Thank you for your answer, I am not sure If this what you wanted.
My frequency counter is precise 9 digits and (it's the HM8123 frequency counter) resolution of 10^-8 for this application I think.
Léo
2021-06-23 01:44 AM
I added a mask to propely view the value.I 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 ...
2021-06-23 04:16 PM
What signal do you exactly measure and what readings do you get?
JW
2021-06-24 01:45 AM
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 :
x: 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
2021-06-24 04:00 AM
> 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.
If this is the case, try to WUCKSEL to 0b10x.
JW
2021-06-24 08:29 AM
Thank you JW that was it, indeed now I can see the effet of the calibration.
I 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
2021-10-27 06:30 AM
[to be removed]
2021-10-27 02:03 PM
Please start a new thread with your problem, as it's unrelated to the original thread.
JW