STM32CubeIDE:a Step by Step Guidance to Activate the On-Board LED of STM32 Black Pill

by Jasleen_kaur in Circuits > Microcontrollers

92 Views, 1 Favorites, 0 Comments

STM32CubeIDE:a Step by Step Guidance to Activate the On-Board LED of STM32 Black Pill

Screenshot 2024-04-01 200823.png

Welcome to our comprehensive tutorial on utilizing STM32CubeIDE to control the built-in LED of the STM32 Black Pill microcontroller. This meticulously crafted guide is aimed at professionals seeking a clear and concise walkthrough, enabling them to harness the full potential of the Black Pill and showcasing the versatility of STM32CubeIDE. Throughout this tutorial, we will delve into the key aspects of embedded development, including environment configuration, understanding the hardware specifics of the Black Pill, and writing efficient code to manage the LED. This foundational exercise not only cultivates expertise in embedded systems but also establishes a solid foundation for tackling more intricate projects. Come join us as we shed light on the principles of microcontroller programming with utmost precision and professionalism.

Supplies

  1. STM32 Black Pill
  2. STMCubeIDE
  3. STMCubeProgrammer
  4. USB C Cable

Make a New Project File in STM32CubeIDE

Screenshot 2024-04-01 201726.png
Screenshot 2024-04-01 203248.png

Go to files>New>STM32 Project>>Nme the project

Add the Configurations for Your STM Board

Screenshot 2024-04-01 202054.png

Enter the Commercial Part Number :STM32F401CCU6>Select the required and then click on"Next".

Configuring the Board Settings

Screenshot 2024-03-12 152040.png
Screenshot 2024-03-12 152150.png
Screenshot 2024-03-12 152322.png

the slide will open with STM32 >select the pin (13 as GPIO_output)>>then set the oher settings (RCC Mode configuration>>high speed clock to cereamic/crystal response.

Configure the Clock

Screenshot 2024-03-12 152507.png

click on clock configuration and select the HSE in source MUX and system MUX.then Click on resolve clock issues.

Settings

Screenshot 2024-03-12 153622.png
Screenshot 2024-03-12 153850.png

Right click and the dailouge box appears choose settings from C/C++Build>>select MCU Post Build output and select the options shown in the picture.

This will appear on the left hand side of the screen.


Main.c

Screenshot 2024-04-01 204602.png

project>>core>>src>>main.c

Write the Code

Screenshot 2024-03-12 161439.png
Screenshot 2024-03-12 161421.png

Write the code in while loop or static void

I used 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);

or

HAL_TogglePin(GPIOC, GPIO_PIN_13);

HAL_Delay(500);

Debug

Screenshot 2024-04-01 210653.png

Debug the file.

Copy the Path Of.elf File

FA9KX7RLT5T3L9C.png
Screenshot 2024-04-01 211124.png

go to project .ioc file and right click on it>>go to show in>>system explore>>select the project .ioc file and copy the path of the file.

STM32CubeProgrammer

Screenshot 2024-04-01 211334.png

open STM32CubeProgrammer>>click on"+"to add the file.

Adding File

Screenshot 2024-04-01 211641.png
Screenshot 2024-04-01 211654.png

Enter the url in search bar.

Connect the STM32 Board

Connect the STM32 Board with STM32CubeProgrammer via USB and then download the file.

On Board Led Blinking

Screenshot 2024-03-11 214813.png

The on-board led is blinking.