Code: Select all
__STATIC_INLINE void lse_init(void) {
#if STM32_LSE_ENABLED
/* LSE activation.*/
#if defined(STM32_LSE_BYPASS)
/* LSE Bypass.*/
RCC->BDCR |= STM32_LSEDRV | RCC_BDCR_LSEON | RCC_BDCR_LSESYSEN | RCC_BDCR_LSEBYP;
#else
/* No LSE Bypass.*/
RCC->BDCR |= STM32_LSEDRV | RCC_BDCR_LSEON | RCC_BDCR_LSESYSEN;
#endif
while ((RCC->BDCR & (RCC_BDCR_LSESYSRDY | RCC_BDCR_LSERDY)) !=
(RCC_BDCR_LSESYSRDY | RCC_BDCR_LSERDY)) {
}
#endif
}
should be:
Code: Select all
__STATIC_INLINE void lse_init(void) {
#if STM32_LSE_ENABLED
/* LSE activation.*/
#if defined(STM32_LSE_BYPASS)
/* LSE Bypass.*/
RCC->BDCR |= STM32_LSEDRV | RCC_BDCR_LSEON | RCC_BDCR_LSESYSEN | RCC_BDCR_LSEBYP;
#else
/* No LSE Bypass.*/
RCC->BDCR |= STM32_LSEDRV | RCC_BDCR_LSEON | RCC_BDCR_LSESYSEN;
while ((RCC->BDCR & (RCC_BDCR_LSESYSRDY | RCC_BDCR_LSERDY)) !=
(RCC_BDCR_LSESYSRDY | RCC_BDCR_LSERDY)) {
}
#endif
#endif
}
In other words, the busy wait should only occur in the case where an external clock is not used. The reason is that the external clock might depend upon hardware that needs to be "brought" up during initialization. It's not clear that the wait is meaningful.
For my application, I copied the (edited) stm32_lse.inc into an include folder that is searched before the system folders, so no harm no foul. But it did take some time to identify the issue when it occurred in 20.0.3 .