STM32F103 SPL Tutorial 7 – Interfacing LCD16x2

LCD16x2

LCD16x2 is a popular display module and commonly used in various devices. In this tutorial, I will explain about how to use LCD16x2 with STM32F103 microcontroller. If you want to know the detail how LCD16x2 works, you can follow this tutorial. To interface the LCD with STM32F103, you need the library files (lcd16x2.h and lcd16x2.c). You can get the library files and from here.

STM32F103 LCD16x2

Continue reading “STM32F103 SPL Tutorial 7 – Interfacing LCD16x2”

Share this:

LCD16x2 HD44780 Tutorial 6 – 4-bit Mode

LCD16x2 4-bit Mode

LCD16x2 can be used in 4-bit mode or 8-bit mode. Since the first tutorial until previous tutorial, we only use the 8-bit mode. In 8-bit mode, we need 8 wire from D7 to D0 in order to send command or data. In this tutorial, I will explain how to use LCD16x2 in 4-bit mode. This mode is useful when we want to control the LCD from microcontroller, because it uses less GPIO pins. In 4-bit mode, only 4 wire from D7 to D4 is used, D3 to D0 is not used. The transfer method is high nibble first, then followed by low nibble.

This is the procedure how to use 4-bit mode to display character ‘A’:

  1. Send command: 0b0010 xxxx (Set 4-bit mode).
  2. Send command: 0b0010 xxxx (high nibble of function set).
  3. Send command: 0b1000 xxxx (low nibble of function set).
  4. Send command: 0b0000 xxxx (high nibble of display on, underline on, and blinking on).
  5. Send command: 0b1111 xxxx (low nibble of display on, underline on, and blinking on).
  6. Send data: 0b0100 xxxx (high nibble of  ‘A’).
  7. Send data: 0b0001 xxxx (low nibble of ‘A’).

Thank you for reading this LCD tutorial.

LCD thank you

Share this:

LCD16x2 HD44780 Tutorial 5 – Create Custom Characters

LCD16x2 CGROM and CGRAM

In this tutorial, I will explain how to create and display custom characters on LCD16x2. The first thing you must know is that on the LCD there are two type memories that store defined characters, CGROM and CGRAM. CGROM is used for storing all permanent font that can be displayed by using their ASCII code. For example, if we write 0x41 then on the display will show character ‘A’. CGROM memory is non-volatile and can’t be modified. CGRAM is another memory that can be used for storing user defined characters. This memory is volatile and can be modified any time. This memory can store up to 8 user defined characters. Characters that are stored in CGRAM can be accessed from code 0x00 to 0x07. This table below show character codes and character patterns for CGRAM and CGROM.

Char codes

Continue reading “LCD16x2 HD44780 Tutorial 5 – Create Custom Characters”

Share this: