2025-04-26 1:55 AM - last edited on 2025-04-26 2:29 AM by Andrew Neil
I’ve just started learning STM32 and I’m currently using the STM32F411E-Discovery board. I loaded the default code provided by the Board Selector in STM32CubeIDE and was trying to get a simple LED blink working. It works fine when using the internal HSI clock, but it doesn’t seem to work when I switch to the external HSE clock. The only different is:
HSI:
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLM = 16;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 7;
HSE:
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLM = 8;
RCC_OscInitStruct.PLL.PLLN = 336;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV4;
RCC_OscInitStruct.PLL.PLLQ = 7;
2025-04-26 2:28 AM - edited 2025-04-26 2:31 AM
Welcome to the forum.
@Duc_Tran wrote:it doesn’t seem to work when I switch to the external HSE clock.
What do you mean by, "doesn’t seem to work"? Please describe the symptoms you see.
Have you used the debugger to see what's happening?
Does that board have a crystal for HSE, or is it clocked from the ST-Link?
Details should be in the User Manual ...
I've edited you post to apply the proper source code formatting - please see How to insert source code for future reference.
See also: How to write your question to maximize your chances to find a solution.