Z80
LCD
PIC
8051
Opera
Software
Files
Bookstore
Links
About me

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

INTRODUCTION

Any parallelly interfaced character LCD you get these days will have a Hitachi HD44780 chip or a different one compatible with the HD44780. These usually have 14 pins as shown below.

  • D0-D7 is the bi-directional data bus
  • R/W determines if we read from or write to the LCD
  • RS stands for "register select".RS=0 means that the instruction register is selected. RS=1 means that the data register is selected. In other words, according to the status of RS pin, the data on the data bus is treated either as a command or character data.
  • E pin enables or disables the LCD module. When Enable is low the LCD is disabled and the status of RS,R/W and the data bus will be ignored. When Enable pin is high the LCD is enabled and the status of the other control pins and data bus will be processed by the LCD. NOTE: When writing to the display, data is transferred only on the high to low transition of this signal. However, when reading from the display, data will become available shortly after the low to high transition and remain available until the signal falls low again.
  • Vo pin is for adjusting the contrast of the display. Usually, when this pin is grounded the pixels will be the darkest.
  • Vdd and Vss are the power supply pins

Essentials:

Display Data RAM (DDRAM)

Display data RAM (DDRAM) is where you send the characters (ASCII code) you want to see on the LCD screen. It stores display data represented in 8-bit character codes. Its capacity is 80 characters (bytes). Bonus: The area in display data RAM (DDRAM) that is not used for display can be used as general data RAM. DD RAM address is the position of the cursor (i.e. where the data you sent will be displayed). Below you see DD RAM address layout of a 2*16 LCD.

DD RAM address for a 2*16 LCD

Character Generator RAM (CGRAM)

In the character generator RAM, the user can define his/her own character patterns by program. CG RAM is 64 bytes ,allowing for eight 5*8 pixel,character patterns to be defined. See my "Defining custom characters" and "Creating Animations" pages for more info on CG RAM.

Registers

The HD44780 has two 8-bit registers, an instruction register (IR) and a data register (DR). The IR stores instruction codes, such as display clear and cursor shift, and address information for display data RAM (DDRAM) and character generator RAM (CGRAM). The DR temporarily stores data to be written into DDRAM or CGRAM and temporarily stores data to be read from DDRAM or CGRAM. Data written into the DR is automatically written into DDRAM or CGRAM by an internal operation. The DR is also used for data storage when reading data from DDRAM or CGRAM. These two registers can be selected by the register selector (RS) signal. See the table below:

Register Selection
RS
R/W
Operation
0
0
IR write as an internal operation (display clear, etc.)
0
1
Read busy flag (DB7) and address counter (DB0 to DB6)
1
0
DR write as an internal operation (DR to DDRAM or CGRAM)
1
1
DR read as an internal operation (DDRAM or CGRAM to DR)

 

Busy Flag (BF)

When the busy flag is 1, the HD44780U is in the internal operation mode, and the next instruction will not be accepted. When RS = 0 and R/W = 1 (see the table above), the busy flag is output to DB7 (MSB of LCD data bus). The next instruction must be written after ensuring that the busy flag is 0.

Address Counter (AC)

The address counter (AC) assigns addresses to both DDRAM and CGRAM. When a "set DD RAM/CG RAM address" instruction is written into the IR, the address information is sent from the IR to the AC. Selection of either DDRAM or CGRAM is also determined concurrently by the instruction. After writing into (or reading from) DDRAM or CGRAM, the AC is automatically incremented (or decremented) by 1 . The AC contents are output to DB0 to DB6 when RS = 0 and R/W = 1 (see the table above). To see the effects of setting the address counter to increment or decrement , see the HD44780 commands page.

To display a character,

positional data is written into IR (DDRAM address). A character code is then written into DR and the LCD unit displays the corresponding pattern at the specified location. The LCD unit can either increment or decrement the display position after each character entry (see the entry mode set command), so that only successive character codes need to be entered to display a continuos character string. See the Z80 Examples page for examples in Z80 assembly.

Prior to writing characters to the display, it must be initialized. To initialize the display you must learn about the commands first.