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.

18 REPLIES 18

>>so i think my board have an external crystal

You can add one as an option

Usually you can get an 8 MHz from the ST-LINK/V2-1, so HSE in BYPASS mode

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

yes, i did it from beginning

Hello @studentof and welcome to the community,

You have two projects in the zip file you attached:

mALLEm_0-1752835439748.png

And the Drivers folder has "BSP" folder:

mALLEm_1-1752835486428.png

Not clear how that was generated by CubeIDE? did you copy and did some changes in the folder structure?

I've attached a project where 4 user LEDs are toggling. No need to add BSP or other stuff.

If you need to add EXTI function you need to add it in the CubeMx: activate GPIO as GPIO EXTI and enable the  related NVIC line.

Hope that helps.

 

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.

Sorry but i didn't attach any zip file, my project:

studentof_0-1752845114678.png

 

- i used your code but it didn't work, i still have to disable USB_OTG and select HSI to BLINK successfully

 

In the project I've attached previously select Crystal for HSE:

mALLEm_0-1752846118504.png

Comment out MX_USB_HOST_Process()

and keep:

	  HAL_GPIO_TogglePin(GPIOD, LD4_Pin|LD3_Pin|LD5_Pin|LD6_Pin);
	  HAL_Delay(500);


 

@studentof wrote:

Sorry but i didn't attach any zip file, my project


Maybe I confused with another thread...

 

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.

i still have to disable USB_OTG (commenting out MX_USB_HOST_Process() doesn't allow select HSI, only disable  USB_OTG can help me to select HSI), i have to select HSI to Blink successfully, not HSE.

I ran the same code as you on a STM32F407VG-DISC board it it works, even with MX_USB_HOST_Process(); in place.

The LED's are on the same PD12-PD15 pins. Being it's the same family, it uses the same FW. I'm currently using STM32Cube FW_F4 V1.28.2

 

You've mentioned that the LED only blinks in HSI. Go back to using HSE and use an oscilloscope to verify if you see clocking on PH0 pin of the STM32.

 

Also make sure R25 and R24 resistors are in place.  

KarlYamashita_0-1752855682554.png

 

Who turned off the lights?
FBL
ST Employee

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.


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 Venmo
Up vote any posts that you find helpful, it shows what's working..