cancel
Showing results for 
Search instead for 
Did you mean: 

RTC (re)initialization with Cube generated LL project

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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.

View solution in original post

1 REPLY 1

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.