Activating the On-Board LED of the STM32 Black Pill: a Simple Guide
by Bhumika_Chawla in Circuits > Microcontrollers
165 Views, 1 Favorites, 0 Comments
Activating the On-Board LED of the STM32 Black Pill: a Simple Guide
Welcome to our step-by-step guide on using STM32CubeIDE to control the built-in LED of the STM32 Black Pill microcontroller. We've designed this tutorial to be easy to follow, even if you're new to embedded development. You'll learn how to set up your environment, get to know the Black Pill's hardware, and write code to control the LED. This basic exercise is essential for getting started with microcontroller programming. Let's dive in and explore together!
Supplies
Before we get started with embedded programming, make sure you have the following:
1. A laptop or desktop computer with STM32CubeIDE and STM32CubeProgrammer installed.
2. An STM32 Black Pill development board.
3. A USB cable that works with your board for connection and programming.
Having these ready will ensure a smooth and hassle-free programming experience. Let's dive in!
Making a New Project File in STM32CubeIDE
OPEN File>New>STM32 Project
ADD Configurations
Find and select your STMboard
In our case we will be using STM32F401CCU6
Configuring Your Board and Clocks
Once Done With These Steps Press CTRL+S to generate "main.c" File
Entering the Code
Locate and Open the main.c file (located in Core>>SRC>>main.c) & and add the above code in While(1) Loop
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 1);
HAL_Delay(500);
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, 0);
HAL_Delay(500);
Here we have used Pin 13 beacuse it has the internal LED Connected to it
Debug
Click on Debug
Locate File Locate in System
Right click on Project and click on show in system explorer and copy the path
Open STMCubeProgrammer
Connect the STM Board using USB