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](/proxy/?url=https://content.instructables.com/FO5/0I5A/LUGYMWMP/FO50I5ALUGYMWMP.png&filename=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
- STM32 Black Pill
- STMCubeIDE
- STMCubeProgrammer
- USB C Cable
Make a New Project File in STM32CubeIDE
![Screenshot 2024-04-01 201726.png](/proxy/?url=https://content.instructables.com/FU7/F2J5/LUGYMWQ4/FU7F2J5LUGYMWQ4.png&filename=Screenshot 2024-04-01 201726.png)
![Screenshot 2024-04-01 203248.png](/proxy/?url=https://content.instructables.com/FPG/WL4S/LUGYMXR3/FPGWL4SLUGYMXR3.png&filename=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](/proxy/?url=https://content.instructables.com/FFO/6UDI/LUGYMWVM/FFO6UDILUGYMWVM.png&filename=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](/proxy/?url=https://content.instructables.com/F6L/XXZ0/LUGYMWY0/F6LXXZ0LUGYMWY0.png&filename=Screenshot 2024-03-12 152040.png)
![Screenshot 2024-03-12 152150.png](/proxy/?url=https://content.instructables.com/FEX/Z5XW/LUGYMX1L/FEXZ5XWLUGYMX1L.png&filename=Screenshot 2024-03-12 152150.png)
![Screenshot 2024-03-12 152322.png](/proxy/?url=https://content.instructables.com/F5A/8ZF3/LUGYMX1Z/F5A8ZF3LUGYMX1Z.png&filename=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](/proxy/?url=https://content.instructables.com/FHY/TW28/LUGYMXEF/FHYTW28LUGYMXEF.png&filename=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](/proxy/?url=https://content.instructables.com/FOU/QG5H/LUGYMY1O/FOUQG5HLUGYMY1O.png&filename=Screenshot 2024-03-12 153622.png)
![Screenshot 2024-03-12 153850.png](/proxy/?url=https://content.instructables.com/F02/L4AK/LUGYMYHE/F02L4AKLUGYMYHE.png&filename=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](/proxy/?url=https://content.instructables.com/FNC/N3XJ/LUGYMZ0E/FNCN3XJLUGYMZ0E.png&filename=Screenshot 2024-04-01 204602.png)
project>>core>>src>>main.c
Write the Code
![Screenshot 2024-03-12 161439.png](/proxy/?url=https://content.instructables.com/FSG/RAJL/LUGYMZIH/FSGRAJLLUGYMZIH.png&filename=Screenshot 2024-03-12 161439.png)
![Screenshot 2024-03-12 161421.png](/proxy/?url=https://content.instructables.com/FW9/8HTS/LUGYMZJC/FW98HTSLUGYMZJC.png&filename=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](/proxy/?url=https://content.instructables.com/FN4/GWL4/LUGYN07R/FN4GWL4LUGYN07R.png&filename=Screenshot 2024-04-01 210653.png)
Debug the file.
Copy the Path Of.elf File
![FA9KX7RLT5T3L9C.png](/proxy/?url=https://content.instructables.com/FRZ/5D3K/LUGYN0HX/FRZ5D3KLUGYN0HX.png&filename=FA9KX7RLT5T3L9C.png)
![Screenshot 2024-04-01 211124.png](/proxy/?url=https://content.instructables.com/F4S/N3YZ/LUGYN0Z4/F4SN3YZLUGYN0Z4.png&filename=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](/proxy/?url=https://content.instructables.com/FTS/EI6I/LUGYN1PL/FTSEI6ILUGYN1PL.png&filename=Screenshot 2024-04-01 211334.png)
open STM32CubeProgrammer>>click on"+"to add the file.
Adding File
![Screenshot 2024-04-01 211641.png](/proxy/?url=https://content.instructables.com/FMS/7AWW/LUGYN2IT/FMS7AWWLUGYN2IT.png&filename=Screenshot 2024-04-01 211641.png)
![Screenshot 2024-04-01 211654.png](/proxy/?url=https://content.instructables.com/F96/XVR0/LUGYN2K3/F96XVR0LUGYN2K3.png&filename=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](/proxy/?url=https://content.instructables.com/F18/7C0N/LUGYN3ON/F187C0NLUGYN3ON.png&filename=Screenshot 2024-03-11 214813.png)
The on-board led is blinking.