Skip to main content
Csu.11
Associate II
December 23, 2021
Question

WB5MMG RTC Inaccurate

  • December 23, 2021
  • 7 replies
  • 3243 views

0693W00000HpcCBQAZ.png0693W00000HpcCeQAJ.pngWB5MMG RTC Inaccurate, RTC increase by 1s requires 10s or more in reality.

32.768 LSE has been used.

 	RTC_TimeTypeDef sTime = {0};
 	HAL_RTC_GetTime(&hrtc, &sTime, RTC_FORMAT_BIN);
 	RTC_DateTypeDef sDate = {0};
 	HAL_RTC_GetDate(&hrtc, &sDate, RTC_FORMAT_BIN);
 
 	Send_Log("%d %d %d %d% d %d", sDate.Year,sDate.Month,sDate.Date,sTime.Hours,sTime.Minutes,sTime.Seconds);

This topic has been closed for replies.

7 replies

Peter BENSCH
ST Technical Moderator
December 23, 2021

The RTC is just as precise as its settings and clock sources. But since you haven't added any details about your implementation (crystal type, load capacities, layout, LSE settings, clock tree, HAL/LL/direct programming etc.), little information can be given.

Regards

/Peter

In order 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.
Csu.11
Csu.11Author
Associate II
December 23, 2021

Thank you for your reply, I have added some information about my settings.

Peter BENSCH
ST Technical Moderator
December 23, 2021

OK, where did you assign which value to

  • CFG_RTC_ASYNCH_PRESCALER and
  • CFG_RTC_SYNCH_PRESCALER?

What are your RCC settings for LSE?

In order 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.
Csu.11
Csu.11Author
Associate II
December 24, 2021

RCC settings for LSE is here. I have tried every option of LSE Driver, but it didn’t work.0693W00000HpiHGQAZ.pngCFG_RTC_ASYNCH_PRESCALER and

CFG_RTC_SYNCH_PRESCALER is an option of CubeIde, and there are no other options to choose.

#define CFG_RTC_ASYNCH_PRESCALER (0x0F)
#define CFG_RTC_SYNCH_PRESCALER (0x7FFF)

0693W00000HpiHBQAZ.png 

Peter BENSCH
ST Technical Moderator
December 24, 2021
Prescalers of 0x0F = 16 (-1) and 0x7FFF = 32768 (-1) would result in 32768Hz /(2^4*2^15) = 1/16 Hz --> 16s period. It looks like this is what you see, right?
Please change the asynchronous prescaler to 128-1, i.e. 0x7F and the synchronous one to 256-1, i.e. 0xFF, to get the correct 1Hz pulses.
You can check RM0434, section 29 for more information about the RTC and the energy efficient usage of the prescalers.
In order 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.
Csu.11
Csu.11Author
Associate II
December 27, 2021

According to your answer, I solved this problem smoothly, thank you very much.

JWieb
Associate III
December 29, 2021