Skip to main content
Associate III
Mar 13, 2025 2:49 PM UTC
Solved

STM32WL5MOCH - Error when using HSE as clock source for SYSCLK

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

This topic has been closed for replies.
biobuilderBest answer
Associate III
Mar 13, 2025 2:57 PM UTC

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
Mar 13, 2025 2:57 PM UTC

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.