STM32L4 Problem with HSE that switching to HSI
- October 20, 2023
- 5 replies
- 3962 views
Hi,
I developed my first board with a STM32L431RCT6 (80Mhz) but sometimes I have problems with an external 8MHz crystal (HSE switches to HSI).
I configurated the peripherals and the clock with STM32CubeMx.
This is a clock configurator page (I enabled CSS):

This is a RCC page:

The 8Mhz crystal is connected on the pins PH0 and PH1 with two capacitors of 20pF.
When I stop the firmware after the System Clock configuration the HSEON and HSERDY registers are set to a corrent value (set to one).

Then a few lines of the code after (at the beginning of the while loop) the board switches to HSI clock.

Many times the board fail to startup (HSE switches to HSI) but sometime it work fine (HSE without switching to HSI).
The CSS interrupt is never trigger..
I don't understand the error. Can someone help me?
I attached the source code and the ioc file.
Thanks,
Edo