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

The STM32 Black Pill, a popular microcontroller, offers a cost effective and versatile platform for embebde system development.

In this guide , we'll explore how to display Your Name on a 16x2 LCD without an I@C module using Hal programming with STM32 Cube IDE and STM 32 blackpill.

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 LiquideCrystal Library

The liquidCrystal library simplifies the process of interfacing with the LCD display. 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 STM32 Cube 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

PIN out Selection

Step 4: I2C Configuration

Configure the I2C under connection menu

Step 5: Configure 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("Ayush");

HD44780_SetCursor(0,1);

HD44780_PrintStr("2310994514");

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"