RTC Calendar resets in CubeMX generated Init function
Hi everyone !
first time poster, hope I'm doing it right.
I'm working with an STM32F107VCT and using CubeMX to generate code.
I have an issue with the RTC calendar, it goes back to 0 every reset which, if I'm not mistaken, it should not on a soft reset.
I've found that in the MX_RTC_Init function, the date and time are set to the default values (see the CubeMX generated code below).
/** Initialize RTC and set the Time and Date
*/
sTime.Hours = 0x0;
sTime.Minutes = 0x0;
sTime.Seconds = 0x0;
if (HAL_RTC_SetTime(&hrtc, &sTime, RTC_FORMAT_BCD) != HAL_OK) {
Error_Handler();
}
DateToUpdate.WeekDay = RTC_WEEKDAY_MONDAY;
DateToUpdate.Month = RTC_MONTH_JANUARY;
DateToUpdate.Date = 0x1;
DateToUpdate.Year = 0x0;
if (HAL_RTC_SetDate(&hrtc, &DateToUpdate, RTC_FORMAT_BCD) != HAL_OK) {
Error_Handler();
}Removing this piece of code solves the issue but since it is not user code, it is back every time I need to re-generated code.
Am I missing something or is this a CubeMX Issue ?
