Using TMSTM 32 for LED Blinking

by pranjal4570_be23 in Circuits > Arduino

72 Views, 1 Favorites, 0 Comments

Using TMSTM 32 for LED Blinking

1.jpg

Hey there, embedded aficionados! Ready to infuse some life into your STM32 Black Pill? This tutorial is your roadmap to illuminating the onboard LED. Whether you're a seasoned STM32 guru or just dipping your toes into the hardware pool, this guide provides a smooth entry point to mastering GPIO pin configuration and hardware manipulation on the Black Pill. Let's roll up our sleeves and get that LED pulsing!




Downloads

Supplies

2.jpg

Before delving into embedded programming, let's prepare your arsenal. Let's ensure you have the necessary tools and software:

Development Environment:

  • A laptop or desktop computer
  • STM32CubeIDE
  • STM32CubeProgrammer

Hardware:

  • STM32 Black Pill development board
  • USB cable that's compatible with the board




Making a New Project in STM32 CUBE IDE

FS8BPZ3LV0YSW2F.png

Navigate to the "Files" tab, then select "New" followed by "STM32 Project". Assign a unique name to your project to continue.

Adding Configuration to STM Board

FCBH494LV0YSWUY.png

Locate the component "STM32F401CCU6" in the search bar. Once found, select the necessary component and proceed by clicking "Next".

Let's Configure the Board Settings:

Screenshot (24).png
  1. In the STM32 slide, choose "STM32".
  2. Select pin 13 as GPIO output.
  3. Proceed to configure the other settings.
  4. Set the RCC Mode configuration.



The Next Step Is to Configure the Clock Settings:

Screenshot (26).png

Choose the high-speed clock and set it to ceramic/crystal response.


Configuring MCU Post-Build Outputs:

F62DA9PLV0YSY07.png

Here's how to configure MCU Post-Build Outputs:

  1. Access Project Properties: Right-click on your project name in the Project Explorer and choose "Properties."
  2. Navigate to C/C++ Build Settings: In the project properties window, find the "C/C++ Build" section, expand it, and select "Settings."
  3. Enable MCU Post-Build Outputs: Within the "Settings" tab, locate the "MCU Post Build outputs" section. Tick the boxes next to your preferred output options, as demonstrated in the provided image if available.




Code Configuration

Screenshot (27).png
  1. Go to the "Project" tab.
  2. Find and open the main.c file.
  3. Locate the main() function within the file.
  4. Inside the main() function, find the while(1) loop.
  5. Add your code within the while(1) loop.




Code Building

Screenshot (28).png

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

> Upload the code and wait for it to build properly and check for any error or bug!!

Debugging

Screenshot (27).png

Debug the code with the help of the in hammer icon in task bar.

Copying the Path of Elf File

  1. Locate the .ioc file:
  2. Search for it in the Project Explorer on the left side, listed under your project name.
  3. Copy the file path:
  4. Right-click on the .ioc file and select the option to copy its path.
  5. This action copies the complete file location, ready for pasting wherever needed.




Connect Board to Programmer

Screenshot (29).png
  1. Connect your STM board to your computer via USB cable.
  2. In STM32CubeProgrammer, locate and select the option to connect to the board.
  3. Ensure that the connection is successful and the board is recognized by the software.


Configure Download Settings and Activate Automatic Downloads

Screenshot (30).png

LED Blinks

Capture.PNG