Skip to main content
kurta999
Senior
January 22, 2019
Question

STM32CubeMX5.0.1 - RTC backup register saving is handled, but SystemClock_Config always resets it

  • January 22, 2019
  • 2 replies
  • 641 views

Autogenerated code for STM32L433RB with LL takes care about skipping re-initializing RTC when first backup register has value 0x32F2. It's OK, works correctly - but this is totally useless because in SystemClock_Config RCC backup domain always reseted.

What's about adding an option for this to CubeMX to reset or kepp RTC backup SRAM?

This topic has been closed for replies.

2 replies

ST Technical Moderator
January 22, 2019

Hi @kurta999​ ,

I raised internally your feedback to CubeMx team for checking and we will come back to you as soon as possible.

Kind Regards,

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Visitor II
January 23, 2019

Hi @kurta999​ 

Older versions of cubeMX have already supported the backup option.

Given the massive demand of different customers in different times, we thought to eliminate this option in CubeMX and we left the user tag to end up the backup when needed

You find below the code to add in the user tag. 

 
 
 LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
 
 
 
 LL_PWR_EnableBkUpAccess();
 
 
 
 /*##-2- Configure LSE/LSI as RTC clock source ###############################*/
 
#ifdef RTC_CLOCK_SOURCE_LSE
 
 /* Enable LSE only if disabled.*/
 
 if (LL_RCC_LSE_IsReady() == 0)
 
 {
 
 LL_RCC_ForceBackupDomainReset();
 
 LL_RCC_ReleaseBackupDomainReset();
 
 LL_RCC_LSE_DisablePropagation();
 
 LL_RCC_LSE_Enable();
 
#if (USE_TIMEOUT == 1)
 
 Timeout = LSE_TIMEOUT_VALUE;
 
#endif /* USE_TIMEOUT */
 
 while (LL_RCC_LSE_IsReady() != 1)
 
 {
 
#if (USE_TIMEOUT == 1)
 
 if (LL_SYSTICK_IsActiveCounterFlag()) 
 
 {
 
 Timeout --;
 
 }
 
 if (Timeout == 0)
 
 {
 
 /* LSE activation error */
 
 LED_Blinking(LED_BLINK_ERROR);
 
 } 
 
#endif /* USE_TIMEOUT */
 
 }
 
 LL_RCC_SetRTCClockSource(LL_RCC_RTC_CLKSOURCE_LSE);
 
 
 
 /*##-3- Enable RTC peripheral Clocks #######################################*/
 
 /* Enable RTC Clock */ 
 
 LL_RCC_EnableRTC();
 
 }
 
#elif defined(RTC_CLOCK_SOURCE_LSI)
 
 if (LL_RCC_LSI_IsReady() == 0)
 
 {
 
 LL_RCC_ForceBackupDomainReset();
 
 LL_RCC_ReleaseBackupDomainReset();
 
 LL_RCC_LSI_Enable();
 
#if (USE_TIMEOUT == 1)
 
 Timeout = LSI_TIMEOUT_VALUE;
 
#endif /* USE_TIMEOUT */
 
 while (LL_RCC_LSI_IsReady() != 1)
 
 {
 
#if (USE_TIMEOUT == 1)
 
 if (LL_SYSTICK_IsActiveCounterFlag()) 
 
 {
 
 Timeout --;
 
 }
 
 if (Timeout == 0)
 
 {
 
 /* LSI activation error */
 
 LED_Blinking(LED_BLINK_ERROR);
 
 } 
 
#endif /* USE_TIMEOUT */
 
 }
 
 LL_RCC_SetRTCClockSource(LL_RCC_RTC_CLKSOURCE_LSI);
 
 
 
 /*##-3- Enable RTC peripheral Clocks #######################################*/
 
 /* Enable RTC Clock */ 
 
 LL_RCC_EnableRTC();
 
 }

Best Regards,

Wael