Question
Why the RTC reset when MCU reset ? (with VBAT still up and RTC_init cleaned)
CubeIDE : 1.7.0
CubeMX : 6.3
BSP : 1.12.1
chip : STM32WB55
I'm using the internal RTC of the STM32WB55. When the MCU is running the RTC works normally : the calendar can be set and the time is running correctly. When i shut the MCU power down (but still have the VBAT up), and turn it up again, the calendar of the RTC is reset.
I have cleaned the init generated by cubeMX and tried to use a light initialization (NVIC and clocks) when the backup register flag is set but nothing worked:
static void MX_RTC_Init(void)
{
hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = CFG_RTC_ASYNCH_PRESCALER;
hrtc.Init.SynchPrediv = CFG_RTC_SYNCH_PRESCALER;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}
)RTC config :
What should I have in my MX_RTC_Init() ?
Thanks,
