RTC hrtc.Init.AsynchPrediv & hrtc.Init.SynchPrediv = 10 Registers
Can somebody please help me.
The code below is initializing the RTC.
The clock works I can set and read time and date no problem.
Somehow if I change these register:
hrtc.Init.AsynchPrediv = 131;
hrtc.Init.SynchPrediv = 10;
It has no impact on the clock accuracy I keep on gaining time.
I would have thought by "tweaking" the values it will either speed up or slow down the RTC.
Code was generated by using the STM32 cube IDE.
/** Initialize RTC */
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 131;
hrtc.Init.SynchPrediv = 10;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN Check_RTC_BKUP */
/* USER CODE END Check_RTC_BKUP */
/** Initialize RTC and set the Time and Date
*/
sTime.Hours = 13;
sTime.Minutes = 58;
sTime.Seconds = 0;
sTime.DayLightSaving = RTC_DAYLIGHTSAVING_NONE;
sTime.StoreOperation = RTC_STOREOPERATION_RESET;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}
sDate.WeekDay = RTC_WEEKDAY_WEDNESDAY;
sDate.Month = RTC_MONTH_NOVEMBER;
sDate.Date = 19;
sDate.Year = 25;
if (HAL_RTC_SetDate(&hrtc, &sDate, RTC_FORMAT_BIN) != HAL_OK)
{
Error_Handler();
}