cancel
Showing results for 
Search instead for 
Did you mean: 

Can't Blink Led in STM32F411 Discovery board

studentof
Associate II

I create A project for STM32F411 Discovery board with STM32CubeIDE 1.19.0

and coding :

 
while (1)
{
  /* USER CODE END WHILE */
  MX_USB_HOST_Process();
  HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
  HAL_Delay(500);
  /* USER CODE BEGIN 3 */
} 

and don't set anything else.

(I saw that the connection settings for the leds were automatically created when Creating project)

i Build and Run code sucessfully but i dont see led Blink. Thanks


Edited to apply source code formatting - please see How to insert source code for future reference.

16 REPLIES 16
Karl Yamashita
Principal

Run in debug mode to see if it's stepping through your code or hanging somewhere, particularly in MX_USB_HOST_Process.

If you FIFO doesn't work, then it's called GIGO.
TimerCallback tutorial! | UART and DMA Idle with multiple UART instances tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.
Imen.D
ST Employee

Hello @studentof ,

Please follow the steps in this tutorial: STM32StepByStep:Step2 Blink LED - stm32mcu

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

I see that my code hanging at  SystemClock_Config(); So i changed the settings according to the images below

studentof_0-1752772773382.png

studentof_1-1752772787073.png

But the same issue still occurred


@studentof wrote:

I see that my code hanging at  SystemClock_Config(); So i changed the settings according to the images below

studentof_0-1752772773382.png


So you've configured it to use an external crystal.

Does your Discovery board actually have an external crystal?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.

in tutorial: STM32StepByStep:Step2 Blink LED - stm32mcu

There is a error when i follow the directions:

studentof_2-1752773128090.png

 

in user manual  Discovery kit with STM32F411VE MCU i see:

studentof_0-1752773722347.png

so i think my board have an external crystal

 

Did you start with a new Board project? 

Screenshot 2025-07-17 120811.png

 

 

If you do, you have the option for STM32CubeIDE to configure the peripherals for you, including the clock.

KarlYamashita_0-1752779603102.png

 

 

If you ever mess up the clock configuration, you can always get STM32CubeIDE to resolve the clock issue to a working state. Then you can custom configure the peripherals clocks again.

KarlYamashita_0-1752780076522.png

 

If you FIFO doesn't work, then it's called GIGO.
TimerCallback tutorial! | UART and DMA Idle with multiple UART instances tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.

- In the previous response, I meant that I couldn’t select HSI because the IDE said: "PLL mux should have HSE as input."

- I found other posts related to the problem, and I realized that I only needed to disable USB_OTG_FS. After that, I successfully blinked the LED regardless of using HSE or HSI.
But in the future, if I need to use USB_OTG_FS, what should I do? What exactly caused the issue?

Again, did you configure the board using the Board Selector? 

If you FIFO doesn't work, then it's called GIGO.
TimerCallback tutorial! | UART and DMA Idle with multiple UART instances tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.