Blinking an External LED Using STM32CubeIDE by STM32 Black Pill on Breadboard.
by bsimrat02 in Circuits > Microcontrollers
15 Views, 0 Favorites, 0 Comments
Blinking an External LED Using STM32CubeIDE by STM32 Black Pill on Breadboard.
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
Hardware:
- STM32 Black Pill board
- Jumper wires
- LED
- USB-C
- Breadboard (optional)
Software:
- STM32CubeIDE
- STM32CubeProgrammer
Create Project on STM32CubeIDE
Select "File"
Click New to start with new project.
Select Board
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
LED starts blinking.