Does stm32cubemx generate an incorrect SystemClock_Config() when using the RCC LL driver?
Are the LL drivers for RCC ready for production code (I plan to use the STOP mode using the LL drivers ...)?
There seems an issue with stm32cubemx 6.8.0 generated code for the NUCLEO L476 dev. board in SystemClock_Config() when selecting RCC LL drivers: it blocks in a while loop. The code is as follows:
__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOS(void)
{
return ((READ_BIT(PWR->SR2, PWR_SR2_VOSF) == (PWR_SR2_VOSF)) ? 1UL : 0UL);
}
void SystemClock_Config(void)
{
LL_FLASH_SetLatency(LL_FLASH_LATENCY_0);
while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_0)
{
}
LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1);
while (LL_PWR_IsActiveFlag_VOS() == 0)
{
}
...LL_PWR_IsActiveFlag_VOS() returns 1 while the regulator is adjusting itself according to the data specification:
Bit 10 VOSF: Voltage scaling flag
A delay is required for the internal regulator to be ready after the voltage scaling has been
changed. VOSF indicates that the regulator reached the voltage level defined with VOS bits
of the PWR_CR1 register.
0: The regulator is ready in the selected voltage range
1: The regulator output voltage is changing to the required voltage level
Seems in my case regulator is adjusted quickly and so zero is returned, which ends up in a endless loop. A similar check, when using the HAL RCC driver, does the opposite:
...
wait_loop_index = ((PWR_FLAG_SETTING_DELAY_US * SystemCoreClock) / 1000000U) + 1U;
while ((HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF)) && (wait_loop_index != 0U))
{
wait_loop_index--;
}
if (HAL_IS_BIT_SET(PWR->SR2, PWR_SR2_VOSF))
{
return HAL_TIMEOUT;
}
...