2023-10-20 02:26 PM - edited 2023-10-20 02:27 PM
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
Solved! Go to Solution.
2023-10-23 09:26 AM
Your program runs in the System memory (built-in bootloader, 0x1fffxxxx).
Check BOOT0 pin. If you don't use the built-in bootloader, you can prevent entering it by programming option bytes appropriately.
JW
2023-10-20 03:25 PM
The chip starts with MSI or HSI typically.
If HSE doesn't start due to electrical characteristic issues it will fall back to using the clock it started with.
You can export the clock via MCO PA8 pin, you should check HSE via that. Putting scope probes directly on the OSC pins will change the circuit characteristics.
Check the app note calculation with your crystal, don't just blind copy other designs which might use other parts. Check ST's BOM's for specific componentry they use. Change capacitors if necessary.
2023-10-20 04:21 PM
If you place an infinite loop just after the place where you've shown HSE working, will it switch to HSI?
JW
2023-10-23 06:16 AM
Thanks @Tesla DeLorean and @waclawek.jan for your reply.
I enabled the MCO clock output Pin.
I did some tests with HSE and HSI, but the result is the same.
With this code and HSE enable:
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
SystemClock_Config();
volatile uint32_t SysClockFreq = HAL_RCC_GetSysClockFreq();
__NOP();
while (1)
{
}
}
When I stopped at the breakpoint I saw the 80 MHz clock output:
When I run the program the MCO clock output stops:
The function SysTick_Handler(void) is never called..
Any ideas?
2023-10-23 09:26 AM
Your program runs in the System memory (built-in bootloader, 0x1fffxxxx).
Check BOOT0 pin. If you don't use the built-in bootloader, you can prevent entering it by programming option bytes appropriately.
JW
2023-10-24 12:00 AM
Thanks @waclawek.jan
I forgot the pulldown resistor in the BOOT0 pin.