8051 Micro-controller

Create LCD custom characters for 16×2 alphanumeric LCD

In my previous article I have discussed about the LCD pins configuration and its mode. In this article I will discuss about the steps to generate own custom characters and in the last of the article write a “C” program to display a custom character on LCD.

Firstly we have to know about the LCD controller ( HD44780), it provides the 8 location to store the created LCD custom characters. We can use these custom character as per our requirements. Before describe the steps to generate custom character I want to discuss about the HD44780.




Note: To see the LCD configuration and its programming see this link.

Some Important registers and memory of HD44780

Here I have some registers and memory which frequently used when you create a custom characters on alphanumeric LCD.

INSTRUCTION  REGISTER (IR): It is an eight bit register and it use to store the command instruction like select address of DDRAM, clear the LCD and much more. Some people also called him command register.

DATA REGISTER (DR): Like IR register data register is also an eight bit  register and it use to write and read  the data from DDRAM or CGRAM. Actually when we write the data on DR it automatically write to DDRAM or CGRAM at the address which selected by the address command through internal operation.

Note:  IR  and DR registers are selected by RS Pin.

RS 0 Select the Instruction register.
RS 1 Select the Data register.

 

LCD BUSY FLAG: When HD44780 perform the internal operation, it does not take any instruction. It set the D7 pin high to so the busy status. So whenever we send the instruction LCD we should check the busy flag.

DISPLAY DATA RAM (DDRAM): DDRAM is stand for data dynamic ram, it store data in 8bit format and extended up to 80 characters. Data which are display currently on LCD, actually they are present in DDRAM. When you want display a character on LCD then internally ASCII value of this character load from CGROM to DDRAM. Area which is not used for display can be used as data ram.

CUSTOM GENERATOR ROM (CGROM): If you write character ‘A’ on data pin of LCD then ‘A’ will be display on the LCD at your define location. But question is that, how is the LCD get the pattern of ‘A’ because we have only write the ASCII value of ‘A’ (0x31 or 48) on LCD data pins.

Actually LCD have a CGROM which have predefined dot character patterns, these pattern access by their ASCII value. So whenever we write the ASCII value of a character on data pin of LCD then LCD fetch the predefined pattern from the CGROM to DDRAM at user define address.

Custom generator ROM, generate 5×8 and 5×10 dot character patterns from 8 bit character code. It can generate up to “208” 5×8 and “32” 5×10 dot character patterns.

CGROM

CUSTOM GENERATORS RAM (CGRAM): There are eight location, which provided by 16X2 LCD to create the user define custom character patterns. In character generator RAM user can rewrite the character patterns as per their choice, user can create eight 5X8 and four 5×10 dot character patterns.

e.g. In below image I have created the pattern (5×8) of arrow and calculate the corresponding hex and binary values

CGRAM

Steps to create custom character on LCD

  • Set the RS pin and RW pin in low state.
  • Send the address location of CGRAM, where you want to save the characters pattern.
  • Now switch the LCD in data mode to change the state of RS pin from low to high.
  • Send the desire pattern bytes on LCD data pin, like data display LCD controller automatically increment the address of CGRAM.

SOURCE CODE

In below example I have written a simple program to display arrow and betel on 16×2 alphanumeric LCD using the 8051 microcontroller.

custom character

aticleworld


Your opinion matters

Although here I have tried to describe the steps to how to create the custom characters on LCD but I would like to know your opinion. So please don’t forget to write  the comment in comment box.

 




1 Comment

  1. Aravind

    I belive it is Instruction Register not Resistor..Good article…

Leave a Reply

Theme by Anders Norén