Arduino Projects    |   Raspberry Pi  |     Electronic Circuits   |   Electronics Reference Design Library  |   AVR    |    PIC    |    8051    |    Electronic Projects

How to interface Graphics LCD with 8051 Microcontroller (AT89C52)

Summary

Developed By: 
Himanshu Choudhary
 
User friendly visual displays are used nowadays to keep track of working of any device. Such a visual display can be anything ranging from old Analog meters to new and smart Digital meters. In digital world to keep track of devices, LCDs are very commonly used. LCDs are easy to program and prove to be a better display unit as compared to other devices like seven segments and LED display units.
 
The graphics LCDs are preferred over the character LCDs for those applications where both character and graphical representation are required. This article explains the basics of a 128x64 Graphics LCD and how it can be interfaced with AT89C52 to display basic shapes.

 

Interfacing Graphical LCD (GLCD) with 8051 Microcontroller (AT89C51)

Description

To interface this LCD with microcontroller, two registers (Input and Output register) are provided in the LCD. These registers are selected by the combination of RS and RW signals. These combinations are given in the following Table1.
 
Input Register:
Input Register is used while giving instructions and writing data to LCD. It holds the data/instruction temporarily before writing to DDRAM (Data Display RAM). When the LCD is in active mode (CS1 and CS2 high), the Input register can be selected by sending bits on RS and RW pins as shown in the following table. The data of input register is latched in at the falling edge (from high to low) of EN (Enable) signal and written into DDRAM automatically through internal operation.
 
Output Register:
Output Register is used to read data from DDRAM and to check status data (busy check). When the LCD is in active mode (CS1 and CS2 high), the Output register can be selected by sending bits on RS and RW pins as shown in the following table. When R/W and RS are high, data is latched into output register and when R/W=H, RS=L, status data (busy check) can be read out.
 
R/W
RS
Function
L
L
Send Instruction
H
Data Write (From Input Register to DDRAM)
H
L
Status Check (Busy Read)
H
Data Read (From DDRAM to Output Register)
Table1
 
The basic operation with graphical LCD requires following steps:
1.      LCD Initialization
2.      Page Selection
3.      Column Selection
4.      Data Display
 
All these steps have been explained in the following sections with corresponding instruction sets.
 
1.    LCD Initialization
Before displaying anything on graphics LCD, it must be initialized, i.e., display must be put on and column/page selection be made. This is achieved by giving proper instructions to the LCD. To make Display On\Off the following set of instructions must be followed in order:
 
a)    Put these values in Data Register
 
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
0
0
1
1
1
1
1
D
 
Data appears when D=1 and disappears when D=0.  When the display is off, there is no effect on the data which is stored in DDRAM.
b)   CS1=1,CS2=1(to activate display of both halves of LCD)
c)    RS=0, R/W=0 (to select the instruction mode)
d)   EN=1
e)    Delay
f)    EN=0 (to latch data into the input register)
Display on/off function can also be used to blink data continuously on the LCD by switching the display with some delay.
 
2.    Page selection
Before writing any data, the page of LCD must be selected. Page can be selected through following steps:
 
a)    Put these values in Data Register
 
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
1
0
1
1
1
X3
X2
X1
 
Since there are a total of 8 pages (0–7), a particular page is selected by setting three bits (X1-X3).
b)   CS1=1, CS2=1(to activate display of both halves of LCD)
c)    RS=0, R/W=0 (to select the instruction mode)
d)   EN=1 
e)    Delay
f)    EN=0 (to latch data into the input register)
For example, if X3=0, X2=1 and X1=0, then the second page is selected. Reading or writing operation is done on this page until next page is set. Depending on the column selection, the page is selected from either left or right half of the graphics LCD.
 
3.    Column selection
There are 128 [64 (=26) columns per half] in graphics LCD and they are automatically incremented. This means that after selecting a column, it increases on its own by one, after each write cycle. So it is easier to write data column by column. A column can be chosen through following instructions:
 
a)    Put these values in Data Register
 
DB7
DB6
DB5
DB4
DB3
DB2
DB1
DB0
0
1
Y5
Y4
Y3
Y2
Y1
Y0
 
 The corresponding controller (CS1 or CS2) is selected depending on the Column number as shown below.
 
Graphics LCD Column Selection
b)   RS=0, R/W=0 (to select the instruction mode)
c)    EN=1
d)   Delay
e)    EN=0 (to latch data into the input register)
For example, if Page address is 0 and Column address is 0, then 0th column of page 0 is selected, i.e., the first pixel will be selected which is highlighted in the following diagram.
 

 
 
4.    Display data
After page and column selection, data can be sent to LCD for display. The programming steps for display data are as given below:
 
a)         Put the data values in Data Register. With every write cycle, data is written in one column and the column then gets auto-incremented. A high data bit (DBx = 1) corresponds to activated (dark) pixel and low data bit (DBx = 0) corresponds to deactivated (light) pixel. Here MSB corresponds to 8th row in column and LSB to 1st row of column.
b)        If column<63 then (CS1=1 & CS2=0) else (CS1=0 & CS2=1)
c)        RS=1 and R/W=0 (to select write mode of LCD)
d)       EN=1
e)        Delay
f)         EN=0 (to latch data into the input register)
 
If data port is given value ‘0x99’ or ‘10011001’ then column takes the values as shown below.
 
 
The following points can be included in above programming steps for efficient programming:
1.        While sending data to be written with array, one can specify the array limit as well. This limit signifies the number of columns one wants to write at once. If the limit is 8, eight columns will be written at once and if it is 7, seven columns will be written in one go.
2.        The condition ‘if (column >127)’ can be used to return the control back to the main function if the limit exceeds the number of columns present in the LCD.
3.        The function for setting column should be called again if array limit condition doesn’t fit in left page and has to be extended to right page too.
4.        Though column address increases itself by one but one variable should be taken to check the conditions (ii) & (iii) explained above.
 
To use above functions, a simple experiment can be done to display alphabetic characters in different fonts. Here, the alphabet ‘A’ is being displayed in different fonts.
 
These shapes can be displayed by using their corresponding bitmap values shown in the above diagram. The connection of graphical LCD with AT89C52 is shown in circuit diagram. Also learn to display text/string and display image on Graphics LCD.

 

Circuit Diagram

Video

Code

This Code is only visible to Registered users. Please Login/Register

 

Components

Graphical LCD | GLCD Module Image
Graphics LCD

The 16x2 Character LCDs have their own limitations; they can only display characters of certain dimensions. The Graphical LCDs are thus used to display customized ch...
AT89C52 Microcontroller Image
AT89C52 Microcontroller
 
AT89C52 is an 8-bit microcontroller and belongs to Atmel's...

Free TI Design & Simulation Tools

 

WEBENCH Design Center

WEBENCH Design Environments are unique and powerful software tools that deliver customized power, lighting, filtering, clocking and sensing designs in seconds. These easy-to-use tools help you generate, optimize and simulate designs that conform to your unique specifications. They allow you to make value-based tradeoffs at a design, system and supply chain level before your design is committed to production.


Design & Simulation Tools

Power Design

 


Sensors, Filter, Clock and Amplifier Design


Download Tools, Models and Symbols


Resources

 

You are here