Skip to main content
Associate
June 3, 2025
Solved

STM32WBA 32MHz HSE. Can't Initialize HSE

  • June 3, 2025
  • 1 reply
  • 498 views

Hi,

I made a custom PCB with a STM32WBA54CGU6 to act as a Bluetooth LE Audio transmitter. This was going to be first "real" PCB since before I have only made much simpler designs (I know I was very ambitious). For the HSE, I used this document to decide on the NX1612SA crystal oscillator. 

The problem I am facing is that I can't seem to get passed the SystemClock_Config() function call, more specifically, the HAL_RCC_OscConfig() function returns HAL_TIMEOUT in this part indicating that the HSE is not getting ready.

 /* Wait till HSE is ready */
 while (READ_BIT(RCC->CR, RCC_CR_HSERDY) == 0U)
 {
 if ((HAL_GetTick() - tickstart) > HSE_TIMEOUT_VALUE)
 {
 return HAL_TIMEOUT;
 }
 }
 }

 I know I have to trim the clock using the registers on the STM32 but I was unable to find how the value in the register maps to a specific capacitance. This led me trying every single possible value (0-63) but that made no difference. I have already resoldered a new crystal and a new STM32 so I am now believing the I have a layout issue in my PCB that's causing the crystal to not start. 

Pablo04_0-1748819756112.png

(The four pad footprint is the crystal connected to pins 40 and 41)

This is my layout and after some more research, I now think that I needed a ground "ring" and more vias returning to the ground plane around the crystal as recommended in this document. 

 

I also have confirmed the proper settings for the HSE setting to "Crystal/Ceramic Resonator" and to set the HSE clock to 32MHz in the Clock Configuration Tab of STM32CubeIDE.

 

I am asking for confirmation on my suspicions or ideas on other things I could test to get this to work. 

 

Thanks in advance.

Best answer by Pablo04

Thanks for your response.

I saw the section in AN5042 about the HSETUNE[5:0] register already. What I meant by "a specific capacitance" was how the values, 0-63, correspond to a capacitance in pF. (Like how its stated for the STM32WL) Pablo04_0-1749092003158.png

Anyways, from your comment about power, I double checked my schematic and realized I made a dumb mistake by forgetting to power up VDDRF which powers the HSE. 

Pablo04_1-1749092137754.png

I haven't been able to add a bodge wire yet but I'm assuming it will fix my problem.

 

Thanks for the help.

1 reply

AScha.3
Super User
June 3, 2025

Hi,

your crystal + layout looks ok.

>but I was unable to find how the value in the register maps to a specific capacitance

-> Refer to AN5042 for the HSE trimming procedure.

ok, just see rm :

AScha3_0-1748930062758.png

(I dont have this chip...) Is there nothing to set the HSE in Cube ?

If not : set a value with "average" values , i would try : 

- before the start of the hse

- unlock register

AScha3_1-1748930419194.png

- write 0x2FA0   (just guessing...try. or 2FF0, max drive) to RCC_HSECR

-> read AN2867 “Oscillator design guide for STM8S, STM8A and STM32

+ all voltage levels ok ? smps ...working?

 

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
Pablo04AuthorBest answer
Associate
June 5, 2025

Thanks for your response.

I saw the section in AN5042 about the HSETUNE[5:0] register already. What I meant by "a specific capacitance" was how the values, 0-63, correspond to a capacitance in pF. (Like how its stated for the STM32WL) Pablo04_0-1749092003158.png

Anyways, from your comment about power, I double checked my schematic and realized I made a dumb mistake by forgetting to power up VDDRF which powers the HSE. 

Pablo04_1-1749092137754.png

I haven't been able to add a bodge wire yet but I'm assuming it will fix my problem.

 

Thanks for the help.