Skip to main content
Visitor II
July 17, 2025
Question

Can't Blink Led in STM32F411 Discovery board

  • July 17, 2025
  • 4 replies
  • 1462 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.

    This topic has been closed for replies.

    4 replies

    Graduate II
    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.

    studentofAuthor
    Visitor 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

    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?

    Technical Moderator
    July 17, 2025

    Hello @studentof ,

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

    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.
    Graduate II
    August 13, 2025

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