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

by Gurnoor_Singh in Circuits > Microcontrollers

318 Views, 5 Favorites, 0 Comments

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

1.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

Screenshot 2024-02-28 174252.png

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

ADD Configurations for Your STM Board

Screenshot 2024-02-28 184854.png

Search For Component- STM32F401CEY6TR click on "Next"

Configuring Your Board

Screenshot 2024-02-28 174933.png

Configure Your Board As Shown

Configure Your Clock

Screenshot 2024-02-28 174924.png

Open Main.c File

Screenshot 2024-02-28 191917.png

GOTO Project and find main.c file

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

Screenshot 2024-02-28 192310.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

Screenshot 2024-02-28 192450.png

Open and Click On Debug(1)

Copy Path of .elf File Generated

Screenshot 2024-02-28 192645.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

Screenshot 2024-02-28 193639.png

Click on Open File and Paste the Copied Path

Screenshot 2024-02-28 193729.png

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

Screenshot 2024-02-28 193801.png

Change Download Options and Click on "Start Automatic Mode"

Screenshot 2024-02-28 193843.png

Congrats

WhatsApp Image 2024-02-20 at 18.59.28_4faf77bf.jpg

We are done!!!!

On board LED is Blinking