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

by ayush4514be23 in Circuits > Arduino

106 Views, 0 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.

download.jpg

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


Downloading the LiquideCrystal Library

download.png

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.

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.

PIN Mode Selection

PIN out Selection

I2C Configuration

Configure the I2C under connection menu

Configure the Clock

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

}


Debug and Building Binary File

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

Opening the .elf File Created in System Explorer

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


Open STMCubeProgrammer and Connect to STM Board Via USB

Click on Open File and Paste the Copied Path

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

Change Download Options and Click on "Start Automatic Mode"