To Start With STM32 Black Pill and STM Cube IDE to Display “YOUR NAME” on 16x2 LCD Without I2C Module Using HAL Programming.

by taniya_4561 in Circuits > Microcontrollers

123 Views, 1 Favorites, 0 Comments

To Start With STM32 Black Pill and STM Cube IDE to Display “YOUR NAME” on 16x2 LCD Without I2C Module Using HAL Programming.

Screenshot 2024-05-06 200726.png

The STM32 Black Pill, a popular STM32 development board, offers a cost-effective and versatile platform for embedded systems development. Coupled with STM32CubeIDE, an integrated development environment (IDE) from STMicroelectronics, developers can harness the power of Hardware Abstraction Layer (HAL) programming to efficiently utilize the STM32 microcontroller's capabilities.

In this guide, we'll explore how to display "YOUR NAME" on a 16x2 LCD without an I2C module using HAL programming with the STM32 Black Pill and STM32CubeIDE. This tutorial serves as a primer for beginners looking to embark on embedded development with STM32 microcontrollers.

Supplies

  1. STM32 Black Pill
  2. LCD with I2C
  3. Female to Female Jumpers
  4. STMCubeIDE
  5. STMCubeProgrammer
  6. USB C Cable

Step 1: Downloading

The LiquidCrystal library simplifies the process of interfacing with character LCD displays, making it accessible for hobbyists and professionals alike. By providing an easy-to-use interface and abstracting away hardware complexities, it enables developers to focus on building creative projects without getting bogged down in low-level details. Whether you're displaying sensor data, creating custom interfaces, or adding visual feedback to your projects, the LiquidCrystal library is a valuable tool in the Arduino ecosystem.

Download the file from- https://github.com/eziya/STM32_HAL_I2C_HD44780/blob/master/Src/liquidcrystal_i2c.h

or you can download it from any search engine you like.

Step 2: Configure Your STM32Cube IDE


Open the IDE and head over to a new project.Then for the target selection, specify the STM32 BlackPill board number. After that click on any column as shown in the picture below.


Step 3: PIN Mode Selection

Pinout Selection


Step 4: I2C Configuration

Configure the I2C mode to I2C under Connections Menu


Step 5:

Step 5: Configuring the Clock


Step 6: Adding the Code

#include "main.h"

#include "liquidcrystal_i2c.h"


I2C_HandleTypeDef hi2c1;


void SystemClock_Config(void);

static void MX_GPIO_Init(void);

static void MX_I2C1_Init(void);


int main(void)

{

HAL_Init();

SystemClock_Config();

MX_GPIO_Init();

MX_I2C1_Init();


HD44780_Init(2);

HD44780_Clear();

HD44780_SetCursor(0,0);

HD44780_PrintStr("taniya");

HD44780_SetCursor(0,1);

HD44780_PrintStr("sharma");

HAL_Delay(2000);

}

Step 7: Debug and Building Binary File

Click on debug (On top left corner) to debug and generate binary file.



Step 8: Opening the .elf File Created in System Explorer


Right click on the project and click on show in system explorer and copy its path


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



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


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



Step 12: Change Download Options and Click on "Start Automatic Mode"