Introduction: 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

Step 1: Making a New Project File in STM32CubeIDE

GOTO---->> Go to files>New>STM32 Project>>Name the project

Step 2: Add the Configurations for Your STM Board

Search For Component---->> Search For Component STM32F401CCU6> Select the required and then click on "Next".

Step 3: 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.

Step 4: Configure Your Clock

Step 5: Settings

Configure MCU Post-Build Outputs:

  1. Access Project Properties: Right-click on your project name in the Project Explorer and select "Properties."
  2. Navigate to C/C++ Build Settings: Within the project properties window, locate the "C/C++ Build" section and expand it. Then, select "Settings."
  3. 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).


Step 6: Open Main.c File

GOTO Project and find main.c file

Step 7: 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);

Step 8: Debug

Debug the code using the option available in hammer icon in task bar.

Step 9: 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.

Step 10: Open STMCubeProgrammer and Connect to STM Board Via USB

Step 11: Click on Open File and Paste the Copied Path

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

Step 13: Configure Download Settings and Activate Automatic Downloads

Step 14: On Board LED Will Start Blinking.

Congratulations! That blinking LED is a great first step in your embedded systems journey.