HAL library 15- HD44780 for STM32Fxxx

HD44780 LCDs are still very popular devices in embedded project so I think you can’t without simple library for them. I’ve port my old library to HAL based libraries for these LCDs.


Read more about new HAL libraries


  • 4-bits operation mode
  • Minimum GPIOs used (6)
  • Supports different LCD sizes
  • Supports up to 8 custom characters
  • Enable/disable cursor blinking
  • Show/hide cursor
  • Shift content in ram left/right
  • Connection pins to board are user selectable
  • Automatically jumps to new line when you reach max X on LCD
  • Strings with \n, \r or \n\r
    • With \n in string LCD jumps to lower line, but X position stays the same
    • With \r in string LCD jumps to the beginning of the line
    • With \n\r in string LCD jumps to the beginning of a new line


  • HAL
    • STM32Fxxx HAL
    • defines.h
    • TM GPIO
    • TM DELAY

Default pinout

GND GND Ground
VCC +5V Power supply for LCD
V0 Potentiometer Contrast voltage. Connect to potentiometer
RS PB2 Register select, can be overwritten in your project’s defines.h file
RW GND Read/write
E PB7 Enable pin, can be overwritten in your project’s defines.h file
D0 Data 0 – doesn’t care
D1 Data 1 – doesn’t care
D2 Data 2 – doesn’t care
D3 Data 3 – doesn’t  care
D4 PC12 Data 4, can be overwritten in your project’s defines.h file
D5 PC13 Data 5, can be overwritten in your project’s defines.h file
D6 PB12 Data 6, can be overwritten in your project’s defines.h file
D7 PB13 Data 7, can be overwritten in your project’s defines.h file
A +3V3 Backlight positive power
K GND Ground for backlight

Custom settings

In case, you need to change any pin for your end project, you can open defines.h file and edit settings you need from library.

Functions and enumerations


Project is available on Github, download all libraries below.

TM STM32 Libraries

STM32 libraries based on STM32Fxxx HAL drivers.


Owner of this site. Also electronic enthusiasts, web developer, 3D printer fan, handball player and more. Big fan of STM32F4 devices. In anticipation of the new Discovery board for STM32F7 lines.

You may also like...

Read before commenting!

Before you make a new comment, make sure you agree with things listed below:

  • - Read post to make sure if it is already posted what you are asking for,
  • - Make sure you have the latest version of libraries used in your project,
  • - Make a clean and grammatically correct written message,
  • - Report as many details as possible, including what have you done so far,
  • - Do NOT post any code here. Use Pastebin,
  • - Do NOT post any error codes here. Use Pastebin,
  • - Specify STM32Fxxx family and used Discovery/EVAL/Nucleo or custom made board,
  • - Make sure your clock is set correct for PLL,
  • - If you are using my HAL drivers, please check this post how to start.
Comment will be deleted on breaking these rules without notification!
  • Pingback: All STM32 HAL libraries - STM32F4 Discovery()

  • Sergiy Tokarev

    How can I merge this LCD lib with next I2C lib? I have this LCD with connected I2C interface adapter (PCF8574T chip)

    • Hello,

      to do that, you need to add I2C librray (you can use one from me) and implement commands with it.

  • DiBurst Mars

    Thanks for porting this! Looking forward to trying it out

  • Дмитрий Борисов

    Hello! This library is really work! Thank you very much for the good stuff! Tested with 1602A 2×16 LCD Dislpay 🙂

  • dsd

    Hey can You show defines.h

    • Empty file by default.

      • Mat

        Where Can I download full project ?

  • Mat

    Can You tell me , because I have error
    ” There is not selected STM32 family used”
    what I have to do ?

    • For start, I would follow error and open file where error happens.

  • Mateusz

    Hi, I have problem beacuse I copy all libraries and I have got message :
    error in include chain stm32f4xx_hal_rcc.h unknown type uint32_t , can You look at my project and tell me what I am doing wrong.

    • Actually I can’t do that anymore. I’m pretty sure I included link to project. You can download it and open with uvision.

      • Mateusz

        When I try download Your project I have something like that:

  • Mateusz

    I open the projet from Github, and I have only one error in stm32f4xx_ll_fsmc.c :

    use of undeclared identifier FSMC_BWTR1_CLKDIV

  • PJ

    #define HD44780_E_BLINK HD44780_E_HIGH; HD44780_Delay(20); HD44780_E_LOW; HD44780_Delay(20)

    That’s an example how the defines should not be done. Have you heard about inline functions?

    • Do we have a reason why not? Only my lib uses this define so I know what Im doing and each if, while… has brackets. So it wont fail!

      You need more info regarding this?

      Probably I know better than you what they are 😉

  • Irena Hajduk

    Hello Majerle!
    How can I display on screen an integer value using this function TM_HD44780_Puts?

    • Take a look at sprintf function (Google it) on how to convert integer to string and then use Puts to print string to LCD.

      • Irena Hajduk

        thank you. It works

  • Hello Majerle!
    If I want to change APB and AHB frequencies, whitch changes should i make in your library ?

  • I think, this line is superfluous:
    #include “tm_stm32_disco.h”

  • Vijay

    Hello Majerle Tilen,

    Nice to meet you,

    1st of all I appropriate your work in embedded feild & now fan of your work !!!

    I am using HAL library 15- HD44780 for STM32F407VE.

    Please can you suggest how to scroll the message left or right ?

    I am using below board + Jlink + Keil + 16×2 LCD

    I already succeeded to download the hex & its working, but not able scroll the message
    Is there any link for API documentaion & there usage ?

    Thanks & Kind Regards
    Vijay Suryawanshi