Sign In

Published by on

In this article I will discuss my small library for interfacing hd44780 based alphanumeric LCD module with latest STM32F0 series of 32 bit ARM based MCUs. I have used Keil uVision 5 IDE for compilation of this project. This library depends on new HAL libraries from ST. For those who are familiar with STM32 Std Peripheral library, this HAL lib is newer library equivalent to Std Peripheral library recommended by ST for newer projects. This project is for STM32F051C8 chip which is a member of access line of STM32F0 series. This chip has 48 pins and 64KB flash memory, costs less than US$2! This makes it perfect for all kind of small projects where we used Atmel AVR 8 bit MCUs.

The audience of this article is assumed to know what is a hd44780 based LCD and how they are helpful in embedded system, thus I do not spend more time on those and get straight to the schematic and code. But if you need intro then you may refer to this LCD Module Intro video on you tube.

  • The library supports 4 bit interface mode to the LCD
  • Print strings
  • Print integer numbers
  • Move cursor to specified x,y coordinate
  • Clear the display
  • Easy to change the GPIO port pins used for interface.
  • Custom character support.

Please see this page on more information on functions of LCD library.


STM32 LCD Interface Schematic hd44780

Here I have used a basic development board for STM32F051C8, it has integrated 3.3v regulator, 8MHz crystal oscillator and other basic connections to make the MCU run. It can be power from a micro USB cable which can be connected to a PC or mobile phone charger. The GPIO pins are available on male headers for easy connection to external modules. The RV1 (variable) resistor is very important in the circuit. You need to adjust it to make the text visible on LCD screen. R1 provide current limiting to the backlight of LCD. It is required or the backlight won't turn on, making it difficult to see anything on LCD.

I have chosen the GPIO considering the following :-

  1. It should be easy to route PCB tracks.
  2. Only 5v tolerant input pins should be connected to LCD data line. This is because LCD runs at 5v while STM32 runs at 3.3v and many i/o pins are NOT 5v tolerant. If you connect those to LCD data pin, 5v coming out from the LCD will damage the MCU.
  3. I/O pins of some important peripherals like ADC, PWM, I2C, SPI, USART should be free for other purposes.


The program is written in C language and compiled using the ARM Toolchain by Keil. It is a high end commercial compiler but a demo version is available free of charge. The whole software development environment which include the compiler and the IDE is know as MDK-ARM and can be downloaded from the link. For burning the code to MCU you can use a SWD based debugger like ST-Link or a generic JTAG for ARM like ULINK2. Discussion of the topic is out of scope of this article.

STM32 HD44780 LCD Interface

If you have any doubt regarding the article you can post a comment.

If you didn't had any doubts and move on to practicals but faced some problems in getting proper results then please post your problem here in details.

We cordially thanks the following peoples who shared this page on various social networks and insprided us to develop more quality contents!