2019-01-22 05:08 AM
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?
2019-01-22 05:56 AM
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
2019-01-23 06:30 AM
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