cancel
Showing results for 
Search instead for 
Did you mean: 

RTC hrtc.Init.AsynchPrediv & hrtc.Init.SynchPrediv = 10 Registers

erastusC
Associate III

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();

}
1 ACCEPTED SOLUTION

Accepted Solutions
Gyessine
ST Employee

hello @erastusC 
Based on AN4759, RTC prescalers are used to adjust power consumption. Tweaking them can reduce power consumption. The RTC is programmed to provide a precise time-of-day clock.
BR
Gyessine

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Gyessine
ST Employee

hello @erastusC 
Based on AN4759, RTC prescalers are used to adjust power consumption. Tweaking them can reduce power consumption. The RTC is programmed to provide a precise time-of-day clock.
BR
Gyessine

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Many thanks I did not understand it properly.

Thanks

waclawek.jan
Super User

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.

How do you know this has no impact on clock accuracy?

JW