Skip to main content
NSirm.1
Associate II
November 11, 2020
Question

Need help to blink LED with STM32F2

  • November 11, 2020
  • 2 replies
  • 1400 views

Hello all i am trying to implement a simple thing that is trying to blink LED using a function. Below attached are main.c, project.c and project.h. If i try the same thing without using a function it works fine but if i use the function it doesnot blink.

This topic has been closed for replies.

2 replies

Technical Moderator
November 11, 2020

Hello @NSirm.1​ ,

You should check your GPIO configuration. Did you start the GPIO Clock ?

I recommend you to follow step by step tutorial that can help you to blink a led on your board.

You can also review the example within STM32CubeF2: STM32Cube_FW_F2_V1.9.2\Projects\NUCLEO-F207ZG\Examples\GPIO\GPIO_IOToggle. This sample code shows how to initialize and use GPIO HAL API to toggle LED1, LED2, LED3 and LED4 IOs.

STM32CubeF2/Projects/NUCLEO-F207ZG/Examples/GPIO/GPIO_IOToggle/Src/main.c

I hope that this brings some help.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Tesla DeLorean
Guru
November 11, 2020

Posting code snippets using the </> button, rather than screen shots

Don't break out the while() loop, no need for void there, consider toggling the LED so you can actually scope the pin. Add a delay so it would be visible to the eye.

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