lcdinterfacing

Custom HD44780U characters

TELL A FRIEND

This webpage describes a simple technique to display characters from both internal character generator and user designed chracters on an LCD. The Hitachi HD44780U or a compatible controller is used here in 8-bit interface mode. The program code given here defines the custom characters and loads it into the character generator RAM (CGRAM).

What is CGRAM ?

In the character generator RAM, the user can rewrite character patterns by program. That is we can define our own character patterns by programming the CGRAM.CG RAM is 64 bytes, allowing for eight 5*8 pixel, character patterns to be defined.

Making Custom characters

The characters are defined as eight bytes, one for each horizontal row in the 5x8 LCD character.

The character size is 5x8,so the three highest bits in each byte should be set to zero.

Also note that the bottom line is normally used by the cursor and should be probably not be used unless the cursor is turned off.

Examples of custom character

Smiley

0x00H . . . . . . . .

0x0AH . . . . # . # .

0x00H . . . . . . . .

0x04H . . . . . # . .

0x11H . . . # . . . #

0x0EH . . . . # # # .

0x00H . . . . . . . .

0x00H . . . . . . . . cursor row

Frowny

0x00H . . . . . . . .

0x0AH . . . . # . # .

0x00H . . . . . . . .

0x04H . . . . . # . .

0x00H . . . . . . . .

0x0EH . . . . # # # .

0x11H . . . # . . . #

0x00H . . . . . . . . cursor row

8051 to LCD circuit description

AT89C51 microcontroller is connected to 16x2 LCD having HD44780U compatible display driver.LCD is Initialized in 8-bit mode. Port 0 with pull up 10k resistor is data/command bus and port 2 pins controls the RS (p2.0)and E(p2.1) pins of LCD.R/W grounded.

HD44780U 8-bit LCD Initialization commands

1. Wait for more than 1second after VCC rises to 4.5 V

2. Function set Interface is 8-bit long 38h

3. Function set Interface is 8-bit long 38h

4. Function set Interface is 8-bit long 38h

5. Display on cursor off blink OFF 0ch

6. Entry mode set cursor in increment position shift invisible 06h

7. Clears entire display and sets DDRAM address 0 in address counter 01h

Working with CGRAM

Set CGRAM address sets the CGRAM address binary AAAAAA into the address counter (40h). After a write, the address is automatically incremented or decremented by 1 according to the entry mode.

CGRAM_UPLOAD function loads the character generation RAM of the display with a custom-defined character.

Each byte in the bitmap corresponds to one row in the 5x8 character, and only the lowest five bytes are loaded in CGRAM

Custom characters are displayed on the LCD when ASCII values 0-7 are sent to the LCD, the actual character image is taken from the CGRAM instead of the fixed character ROM.

Output on HD44780U display driver compatible 16x2 LCD

The first line of the LCD contains inbuilt characters. The second line of the LCD contains user defined custom characters.

Source Code: custom_lcd.asm

Acceptance of ignorance is true path of knowledge -Pujya Dadashri

© 2010 LCD Interfacing.