Why the RTC reset when MCU reset ? (with VBAT still up and RTC_init cleaned)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-19 7:39 AM
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,
- Labels:
-
RTC
-
STM32CubeMX
-
STM32WB series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-19 8:03 AM
> tried to use a light initialization (NVIC and clocks) when the backup register flag is set
​
Show.
​
Make sure there is no backup domain reset before that, e.g. related to LSE setup.
​
Or simply ditch Cube altogether and write your own program.​
​
JW​
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-19 8:07 AM
I just did the same thing that HAL_RTC_MSpInit() does :
__HAL_RCC_RTC_ENABLE();
__HAL_RCC_RTCAPB_CLK_ENABLE();
/* RTC interrupt Init */
HAL_NVIC_SetPriority(RTC_WKUP_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(RTC_WKUP_IRQn);
HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2022-10-19 11:17 AM
