Skip to main content
Associate III
March 13, 2025
Solved

STM32WL5MOCH - Error when using HSE as clock source for SYSCLK

  • March 13, 2025
  • 1 reply
  • 433 views

The STM32CubeMX code generator allows you to enable the internal HSE and use it as the system clock source. However, when attempting to run the code, the system always fails into the Error Handler.

Capture.PNG

Best answer by biobuilder

The STM32WL5MOCH has an internal HSE TCXO, not a regular crystal.  Hence the initialization code from CubeMX is incorrect (as of 3/13/2025). 

 

In the function SystemClock_Config(), You need to change the HSEState from:

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

To:

RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS_PWR;

 

If the system does not start, check all the clock configurations closely.

1 reply

biobuilderAuthorBest answer
Associate III
March 13, 2025

The STM32WL5MOCH has an internal HSE TCXO, not a regular crystal.  Hence the initialization code from CubeMX is incorrect (as of 3/13/2025). 

 

In the function SystemClock_Config(), You need to change the HSEState from:

RCC_OscInitStruct.HSEState = RCC_HSE_ON;

To:

RCC_OscInitStruct.HSEState = RCC_HSE_BYPASS_PWR;

 

If the system does not start, check all the clock configurations closely.