Task 2.2C

by AryAAnSaini in Circuits > Arduino

50 Views, 0 Favorites, 0 Comments

Task 2.2C

Screenshot 2024-04-15 233400.png

In this tutorial, we'll dive into the basics of programming the STM32 Black Pill development board using the STM32CubeIDE and the Hardware Abstraction Layer (HAL) library. We'll walk through setting up the development environment, configuring the GPIO pins, and writing code to blink the on-board LED.

Supplies

  • STM32 Black Pill development board (STM32F103C8T6)
  • USB to UART converter (if not built-in)
  • STM32CubeIDE installed on your computer
  • USB cable

Setting Up STM32CubeIDE

Screenshot 2024-04-15 233647.png
  1. Download and install STM32CubeIDE from the STMicroelectronics website.
  2. Launch STM32CubeIDE and create a new STM32 project.
  3. Select the appropriate board (STM32F103C8) and configure your project settings.


Configuring GPIO Pins

Screenshot 2024-04-15 233808.png
  1. In the "Pinout & Configuration" tab of STM32CubeIDE, configure the GPIO pin connected to the on-board LED (usually PA5 on the Black Pill) as an output.
  2. Save the pin configuration.


Writing HAL Code

  1. Navigate to the "Src" folder in your project and open the main.c file.
  2. Include the necessary HAL libraries at the top of the file:

#include "main.h"

#include "stm32f1xx_hal.h"

Build and Flash

  1. Build your project in STM32CubeIDE to ensure there are no errors.
  2. Connect your STM32 Black Pill board to your computer using a USB cable.
  3. Press the "Run" button in STM32CubeIDE to flash the code onto the board.


TESTING

Once the code is flashed onto the STM32 Black Pill board, the on-board LED should start blinking at a 1-second interval.

Conclusion

In this tutorial, we've covered the basics of setting up STM32CubeIDE, configuring GPIO pins, and writing HAL library to blink the on-board LED of the STM32 Black Pill development board. This serves as a great starting point for further exploration into embedded systems development with STM32 microcontrollers.