RTC smooth digital calibration in STM32F4 with HSE
Hello,
I am taking the liberty of writing to you for information on the calibration of the RTC.
At present the RTC uses the HSE clock. The HSE clock is derived from a 25MHz quartz and then divided to be at 1MHz. This quartz has a tolerance of 20ppm.
The microcontroller is a STM32F4.
I want to calibrate the RTC to cancel the quartz drift but I can't do it.
Here is the configuration of the RTC on the clock side:
PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC;
PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_HSE_DIV25;
RTC_handle.Init.AsynchPrediv = 124;
RTC_handle.Init.SynchPrediv = 7999;
With this configuration the RTC clock is at 1Hz (ck_spre).
To quantify the error on the HSE clock, I count the number of milliseconds of the timer TIM1 which is at 1ms
For a period of 32 seconds, so I have 32.293s, an error of 293ms.
Is the method good?
How to calculate the compensation ?
How to use the HAL_RTCEx_SetSmoothCalib function?
Thank you in advance
Best Regards