Skip to main content
Associate II
July 17, 2025
Question

Can't Blink Led in STM32F411 Discovery board

  • July 17, 2025
  • 4 replies
  • 1463 views

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.

4 replies

Karl Yamashita
Principal
July 17, 2025

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

If a reply has proven helpful, click on Accept as Solution so that it'll show at top of the post.CAN Jammer an open source CAN bus hacking toolCANableV3 Open Source
studentofAuthor
Associate II
July 17, 2025

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

Andrew Neil
Super User
July 17, 2025

@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.
Technical Moderator
July 17, 2025

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"".ThanksImen"
Technical Moderator
August 13, 2025

Hi @studentof 

About your observations : 

  1. The clock configuration function SystemClock_Config() hangs if I select the external crystal (HSE).
    FBL_0-1755099987782.pngmake sure your HW setup is properly configured: Check SB14, SB16 OFF  –  R25 ON – R66 OFF

  2. The project only blinks the LED successfully when I disable USB_OTG_FS and switch to the internal oscillator (HSI). When USB_OTG_FS is enabled, I cannot select HSI as the PLL input because the MX requires HSE for USB. Disabling USB_OTG_FS allows me to select HSI and blink the LED.
    > I would recommend to describe your goal then your issue. Do you want to develop USB Host application using this F411 disco board? Did you test this example STM32CubeF4/Projects/STM32F412G-Discovery/Applications/USB_Host/HID_Standalone at master · STMicroelectronics/STM32CubeF4
    USB OTG full-speed controller requires a dedicated 48 MHz clock that is generated by a PLL connected to the HSE oscillator as it is mentioned in datasheet section 3.27

  3. I suspect the USB host process MX_USB_HOST_Process() or clock configuration is causing the issue.
    > If so, you should have something not correctly configured in USB initialization to hang in MX_USB_HOST_Process() If still having issue, you can consider attaching your IOC file or your project.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.Best regards,FBL
Tesla DeLorean
Guru
August 13, 2025

Need to check SysTick is firing, break-point SysTick_Handler and check SCB->VTOR is being set properly in SystemInit()

 

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..