To Get Start With STM32 Black Pill and STM Cube IDE to Implement a Sequence Where Three LEDs Blink in Various Combinations.

by taniya_4561 in Circuits > Microcontrollers

19 Views, 0 Favorites, 0 Comments

To Get Start With STM32 Black Pill and STM Cube IDE to Implement a Sequence Where Three LEDs Blink in Various Combinations.

Screenshot 2024-05-07 001155.png

The STM32 Black Pill, paired with the STM32CubeIDE, offers an excellent platform for learning embedded systems development. In this tutorial, we'll explore how to implement a sequence where three LEDs blink in various combinations. These combinations will include patterns such as 100, 010, 001, 110, and others, totaling nine distinct combinations. We'll achieve this using HAL (Hardware Abstraction Layer) programming, which simplifies low-level hardware access and configuration on STM32 microcontrollers. By following this tutorial, you'll gain hands-on experience in configuring GPIO pins, controlling LEDs, and creating custom sequences, laying a solid foundation for more complex embedded systems projects. Let's dive in and start blinking those LEDs in exciting patterns!



Supplies

  1. STM32 Black Pill
  2. Bread Board
  3. Male-Male jumper connector cables
  4. LED (3 nos.)
  5. C Type cable


Making a New Project File in STM32CubeIDE

Screenshot 2024-05-07 000544.png

GOTO---->> File>New>STM32 Project

Step 2: ADD Configurations to STM 32Board


Search For Component- STM32F401CEY6TR 


Step 3: Configuring Your Board

configure your stm32bord as shown:-

Step 4: Configure Your Clock

configure the clock as shown:-

Step 5: Open Main.c File


GOTO Project and find main.c file

Step 6: Goto While(1) in Main() and Add Your Code

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,0);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,0);

HAL_Delay(400);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_13,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_14,1);

HAL_GPIO_WritePin(GPIOC,GPIO_PIN_15,1);

HAL_Delay(400);


Step 7: Debug


Open and Click On Debug(1)

Step 8:Copy Path of .elf File Generated

Right click on Project and click on show in system explorer and copy the path

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


Step 10:

Open STMCubeProgrammer and Connect to STM Board Via USB


Step 11:

Go to Download Options


Step 12:

Change Download Options and Click on "Start Automatic Mode"