Skip to main content
Associate II
Jul 14, 2025 1:12 PM UTC
Solved

STM32WB15x - LSE get stuck at startup

Hi,

We're faced to a problem when dealing with LSE clock to handle RTC backup using a supercapa connected to the VBAT pin.

 

The LSE configuration under STM32CubeIDE:

freecoder_0-1752497125995.png

 

freecoder_1-1752497197333.png

 

The Clock Configuration function:

void SystemClock_Config(void)
{
 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

 /** Configure LSE Drive Capability
 */
 HAL_PWR_EnableBkUpAccess();
 __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);

 /** Initializes the RCC Oscillators according to the specified parameters
 * in the RCC_OscInitTypeDef structure.
 */
 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI1
 |RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 RCC_OscInitStruct.LSEState = RCC_LSE_ON;
 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
 RCC_OscInitStruct.LSIState = RCC_LSI_ON;
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 {
 Error_Handler();
 }

 /** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
 */
 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK4|RCC_CLOCKTYPE_HCLK2
 |RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
 |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSE;
 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 RCC_ClkInitStruct.AHBCLK2Divider = RCC_SYSCLK_DIV1;
 RCC_ClkInitStruct.AHBCLK4Divider = RCC_SYSCLK_DIV1;

 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK)
 {
 Error_Handler();
 }
}

 

And when we started the program we get stuck at this line and then it goes in a timeout error:

freecoder_2-1752497788124.png

We noticed that we get this issue only when the VBAT pin is set to 3v. 

Can you please give us a feedback and tell us we figure out the issue.

 

Thanks by advance.

Regards,

 

 

 

 

This topic has been closed for replies.
freecoderBest answer
Associate II
Jul 20, 2025 6:15 PM UTC

Hi @STTwo-32 , 

It looks like when using these parameters it no more get stuck (disable the LSI):

 /** Initializes the RCC Oscillators according to the specified parameters
 * in the RCC_OscInitTypeDef structure.
 */
 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE
 |RCC_OSCILLATORTYPE_LSE;
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 RCC_OscInitStruct.LSEState = RCC_LSE_ON;
 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 

Regards,

4 replies

STTwo-32
ST Technical Moderator
Jul 14, 2025 10:12 PM UTC

Hello @freecoder 

On the clock configuration function, could you please try to change 

__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW);

To

__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
freecoderAuthor
Associate II
Jul 14, 2025 11:48 PM UTC

Hello @STTwo-32 ,

Thank you for your response.

We made changes as you asked but nothing happened and still get stuck at same line of code.

 

Best Regards,

freecoderAuthor
Associate II
Jul 16, 2025 5:50 PM UTC

Hi,

Is there any updates ?

Thanks,

Best regards

freecoderAuthorBest answer
Associate II
Jul 20, 2025 6:15 PM UTC

Hi @STTwo-32 , 

It looks like when using these parameters it no more get stuck (disable the LSI):

 /** Initializes the RCC Oscillators according to the specified parameters
 * in the RCC_OscInitTypeDef structure.
 */
 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSE
 |RCC_OSCILLATORTYPE_LSE;
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 RCC_OscInitStruct.LSEState = RCC_LSE_ON;
 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)

 

Regards,