Blinking an External LED Using STM32CubeIDE by STM32 Black Pill on Breadboard.

by bsimrat02 in Circuits > Microcontrollers

12 Views, 0 Favorites, 0 Comments

Blinking an External LED Using STM32CubeIDE by STM32 Black Pill on Breadboard.

Screenshot 2024-03-02 122604.png

Microcontrollers are the backbone of countless embedded systems, powering devices from simple sensors to complex industrial machinery. Programming them to perform specific tasks is a fundamental skill in the field of embedded systems development. One common task is controlling external peripherals such as LEDs.

In this guide, we'll walk through the process of blinking an external LED using STM32CubeIDE, a powerful integrated development environment (IDE) for STM32 microcontrollers, specifically on the STM32 Black Pill board. The Black Pill board, based on the STM32F103 microcontroller, is a popular choice for hobbyists and professionals alike due to its affordability and versatility.

Supplies

Screenshot 2024-04-14 132905.png
Screenshot 2024-04-14 132832.png
Screenshot 2024-04-14 132812.png

Hardware:

  • STM32 Black Pill board
  • Jumper wires
  • LED
  • USB-C
  • Breadboard (optional)

Software:

  • STM32CubeIDE
  • STM32CubeProgrammer

Create Project on STM32CubeIDE

Screenshot 2024-04-14 131137.png

Select "File"

Click New to start with new project.

Select Board

Screenshot 2024-03-02 125049.png

STM32 Black Pill uses either STM32F401CC or STM32F401CE micro-controller.

Clock Configuration

  • Check any GPIO pin in the pinout view. Refer the attachment of STM32 Black Pill pinout.
  • I have chosen Port B, pin number 10 [PB10].
  • I used the default clock for this task.
  • Press Ctrl + S or Alt + K to generate code.


Code

  • Go to line 95, in "while(1)"
  • Write the code to send a HIGH [digital 1] output, then add a delay and send a LOW [digital 0] output to the LED.
  • Finally, press the debug button from the menu bar or use F11 shortcut key.



Setup STM Cube Programmer

  • Enter boot-loader mode by the steps in the attachment. Refresh until it shows up and press "Connect.".
  • Press on "Open file" and choose the .elf file from STM32 project directory.
  • Press download.
  • Finally, press on "Start automatic mode."
  • Once a message saying "Please disconnect device n:1 and connect the next..." shows up reconnect your STM32 board.


Ouput

Screenshot 2024-04-14 132122.png

LED starts blinking.