cancel
Showing results for 
Search instead for 
Did you mean: 

HAL resets RTC SSR counter in binary mode on init, thus losing date/time

gbesnard
Associate

Hi,

Currently working on a STM32U575, I was happy to see that the RTC now have a binary mode option.
I've done some experimenting using the HAL (generated through CubeMX 1.15.1), and I'm intrigued about its init behavior, is it expected, buggy or lacking?
What I have seen is, when using the RTC in BCD Mode, the HAL_RTC_INIT function checks if the RTC calendar was previously initialized to avoid a new re-initializing, and thus avoiding losing the date and time. The check is done using:

 

if (__HAL_RTC_IS_CALENDAR_INITIALIZED(hrtc) == 0U)

 

which is a macro that checks if the RTC_ICSR_INITS flag is set.

But this check inevitably fails when using the RTC in Binary Mode only. Indeed the RTC_ICSR_INITS flag cannot be true, as it depends on the year field, which stays at its Backup domain reset default value (0x00). And thus, the RTC SSR register used in Binary Mode is always restored to 0xFFFFFFFF on a MCU reset, even though the RTC didn't lose power.
I may find an alternative doing this initialization myself or modifying the HAL file on my project, but I would have liked not to resort to this. Is there maybe something I'm missing? Maybe using a mixed BCD/Binary mode with calendar enabled? Or could this be a potential feature to upstream into the HAL?

Thanks,

2 REPLIES 2
SHs
ST Employee

Hello @gbesnard ,

Your reported issue is being taken into consideration and has been assigned the internal ticket number 185361 for a detailed investigation.

It is an internal tracking number and is not accessible or usable by customers.

 

Please close this topic by clicking on “Accept as solution" button if it fully answered your question.
SHs
ST Employee

Hello @gbesnard ,

The issue has been successfully resolved and the fix will be included in the upcoming U5 release.

Thank you for your report.

 

Regards,

Please close this topic by clicking on “Accept as solution" button if it fully answered your question.