Get Started With STM32 Black Pill and STM Cube IDE to Blink On-board LED
by Tushar_Garg in Circuits > Microcontrollers
364 Views, 0 Favorites, 0 Comments
Get Started With STM32 Black Pill and STM Cube IDE to Blink On-board LED
Welcome embedded enthusiasts! Are you ready to light up your world (or at least your STM32 Black Pill)? This tutorial will guide you step-by-step through activating the on-board LED. Whether you're a seasoned STM32 developer or just getting started, this is a perfect entry point to learn the ropes of configuring GPIO pins and manipulating hardware on the Black Pill. Let's get that LED blinking!
Supplies
Before we dive into embedded programming, let's get your toolkit ready. We'll need to install some essential software and ensure you have the right equipment:
- Development Environment:
- A laptop or desktop computer
- STM32CubeIDE
- STM32CubeProgrammer
- Hardware:
- STM32 Black Pill development board
- Compatible USB cable
Making a New Project File in STM32CubeIDE
GOTO---->> Go to files>New>STM32 Project>>Name the project
Add the Configurations for Your STM Board
Search For Component---->> Search For Component STM32F401CCU6> Select the required and then click on "Next".
Configuring the Board Settings
The slide will open with STM32 >select the pin (13 as GPIO_output)>>then set the other settings (RCC Mode configuration>>high speed clock to ceramic/crystal response.
Configure Your Clock
Settings
Configure MCU Post-Build Outputs:
- Access Project Properties: Right-click on your project name in the Project Explorer and select "Properties."
- Navigate to C/C++ Build Settings: Within the project properties window, locate the "C/C++ Build" section and expand it. Then, select "Settings."
- Enable MCU Post-Build Outputs: Under the "Settings" tab, find the section labeled "MCU Post Build outputs." Check the boxes next to the desired output options displayed in the provided image (assuming the image shows the specific options you want to enable).
Open Main.c File
GOTO Project and find main.c file
Goto While(1) in Main() and Add Your Code
Used GPIO Pin number 13 you can use other GPIO Pins
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);
HAL_Delay(5000);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 0);
HAL_Delay(5000);
Debug
Debug the code using the option available in hammer icon in task bar.
Copy the Path Of.elf File
To copy the path of your project's .ioc file in STM32CubeIDE:
1. Find the .ioc file:
- Look for it in the Project Explorer window (left side) under your project name.
2. Right-click and copy:
- Right-click the .ioc file and choose "Copy Path" (or similar).
This copies the entire file location for pasting elsewhere.
Open STMCubeProgrammer and Connect to STM Board Via USB
Click on Open File and Paste the Copied Path
Go to Download Options (Found in Toolbar on the Left)
Configure Download Settings and Activate Automatic Downloads
On Board LED Will Start Blinking.
Congratulations! That blinking LED is a great first step in your embedded systems journey.