Mastering STM32CubeIDE: a Step-by-Step Guide to Activating the On-Board LED of the STM32 Black Pill

by Arshjottt in Circuits > Microcontrollers

48 Views, 2 Favorites, 0 Comments

Mastering STM32CubeIDE: a Step-by-Step Guide to Activating the On-Board LED of the STM32 Black Pill

FW1N4AFLUGYN9IF.jpg
5895992_f4fe_3.jpg

Welcome to our technical tutorial on harnessing the capabilities of STM32CubeIDE to control the on-board LED of the STM32 Black Pill microcontroller. This guide is meticulously crafted to provide professionals with a clear and concise walkthrough for engaging the LED, demonstrating the STM32 Black Pill's functionalities and the versatility of STM32CubeIDE. As we explore the essentials of embedded development, you will learn to configure your environment, understand the Black Pill's hardware specifics, and write effective code to manage the LED. This foundational exercise is not only crucial for proficiency in embedded systems but also serves as a stepping stone for more advanced projects. Join us as we illuminate the principles of microcontroller programming with precision and professionalism.


Supplies

To commence with the embedded programming, the following equipment and software installations are essential:

1. A laptop or desktop computer equipped with STM32CubeIDE and STM32CubeProgrammer.

2. An STM32 Black Pill development board.

3. A compatible USB cable for connection and programming purposes.

Please ensure that these prerequisites are met prior to beginning the tutorial to facilitate a smooth and efficient programming experience.

Downloads

Making a New Project File in STM32CubeIDE

FEUSTEELT5T3JFL.png

GOTO---->> File>New>STM32 Project

ADD Configurations for Your STM Board

FHW0LHHLT5T3JS5.png

Search For Component- STM32F401CEY6TR click on "Next"

Configuring Your Board

FWY5BVSLT5T3K0H.png

Configure Your Clock

FMWUKHRLUGYN4TB.png

Open Main.c File

FZ8121SLT5T3KON (1).png

GOTO Project and find main.c file

Goto While(1) in Main() and Add Your Code

FXAH6TLLT5T3KUB.png

I use GPIO Pin 13 you may use other GPIO Pins

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);

HAL_Delay(500);

HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 0);

HAL_Delay(500);

Debug

F28B2SHLT5T3KZ7 (1).png

Open and Click On Debug(1)

Copy Path of .elf File Generated

FA9KX7RLT5T3L9C (1).png

Right click on Project and click on show in system explorer and copy the path.

Open STMCubeProgrammer and Connect to STM Board Via USB

FOEPK4ZLT5T3LJ0 (1).png

Click on Open File and Paste the Copied Path

FK4GRO0LT5T3LLQ.png

Go to Download Options (Found in Toolbar on the Left)

FXTQHFPLT5T3LO2.png

Change Download Options and Click on "Start Automatic Mode"

FFKBDKCLT5T3LYV (1).png

OUTPUT

Screenshot 2024-05-06 190729.png