Skip to main content
After Forever
Senior III
July 31, 2019
Solved

RTC (re)initialization with Cube generated LL project

  • July 31, 2019
  • 1 reply
  • 891 views

The "MX_RTC_Init" function called by default from the main.c resets the RTC's date and time to zero values (by default) or to some other predefined constant values.

The standard practice is to set a bit in one of the backup registers after setting the date and time and to check the existence of the bit after enabling the backup domain and RTC - if the bit is set then don't touch the date and time.

There are no user code sections in MX_RTC_Init to try and change its logic, so what is the recommended way of implementing "don't change the date and time if it is already set" in a Cube generated LL project with RTC enabled?

Thank you.

This topic has been closed for replies.
Best answer by After Forever

Ah never mind, as it usually happens you find a solution just after posting the question :)

I'll just disable the "Activate Calendar" checkbox so Cube will stop generating date/time reset code, then I can write my own function and call it after MX_RTC_Init is called.

1 reply

After Forever
After ForeverAuthorBest answer
Senior III
July 31, 2019

Ah never mind, as it usually happens you find a solution just after posting the question :)

I'll just disable the "Activate Calendar" checkbox so Cube will stop generating date/time reset code, then I can write my own function and call it after MX_RTC_Init is called.