2017-11-10 12:03 PM
Hi,
I need to calibrate my RTC crystal that is drifting about 7 seconds every 18014 that according to my calculations is about 389 ppm. I Tryed to perform the calibration with the following initialization code, but regardless of the HAL_RTCEx_SetSmoothCalib function, the drift is the same. Is there any special procedure to proper perform the calibration?
static void rtc_config(void)
{ hrtc.Instance = RTC; if(hrtc.Instance->ISR & RTC_ISR_INITS) { hrtc.Init.HourFormat = RTC_HOURFORMAT_24; hrtc.Init.AsynchPrediv = 127; hrtc.Init.SynchPrediv = 255; hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; if (HAL_RTC_Init(&hrtc) != HAL_OK) { Error_Handler(); }/* Get the RTC current Time */
rtc_get_real_time();
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 2048, RTC_WAKEUPCLOCK_RTCCLK_DIV16) != HAL_OK) { //Error_Handler(); }} else { MX_RTC_Init(); /* Get the RTC current Time */ rtc_set_time(946684800); } while(hrtc.Instance->ISR & RTC_ISR_INITF);HAL_RTCEx_SetSmoothCalib(&hrtc, RTC_SMOOTHCALIB_PERIOD_32SEC, RTC_SMOOTHCALIB_PLUSPULSES_SET, 133);
}Thank you for the help;