Sunday, October 4, 2009

LCD INTERFACING WITH 89S52 MICROCONTROLLER


LCD displays are most widely used in electronic systems. Hence it is necessary to have knowledge about how to use lcd displays. This lcd display uses Hitachi controller i.e. HD44780.

The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus). Here we are using 8bit mode as it is simple for programming.


PIN DIAGRAM OF LCD:

CONTROL LINES:

1.EN(PIN6): This is called "enable ". This is used to tell lcd that you are sending data to lcd. A low(0) to high(1) pulse should be give to en pin to latch data.


2.RS(PIN4): This is called "Register Select". It is used to select data or command register. When RS=0 command register is selected and when RS=1 data register is selected.


3.RW(PIN5): This is called as "read/write" pin. When RW=0 data is written on lcd. and when RW=1 data can be efficiently read from lcd. data reading is used to check busy status of lcd.


DATALINES(D0-D7):

The data bus consist of 8 or 4 lines(depending upon operation selected.). In case of 8bit mode all D0-D7 pins are used. D7 pin is busy flag when D7=1 lcd is busy and when D7=0 lcd is ready.


ALGORITHM FOR PROGRAMMING LCD:

To initialise lcd:

  1. Specify Function 8bit or 4bit(38h for 8bit mode 5x7 dot character format)
  2. Display on-off control(0eh for display cursor blinking).
  3. Entry mode set(06h for automatic right shifting).
  4. Clear display(01h for clear display).
  5. Select line 1(80h for selecting line 1).
To write lcd:
  1. Check busy flag of lcd.
  2. Make RW low.
  3. Make RS=0 if data is command and RS=1 if data is data to be display.
  4. Give Enable pulse(H to L) on EN pin to latch data.
EXAMPLE OF INTERFACING LCD WITH 89S52.
Interfacing of 89s52 microcontroller and lcd is shown in fig.

Datalines: D0-D7 are connected to P2.0 to P2.7 respectively.

Control Lines: RS=P0.0, RW=P0.1, EN=P0.

Preset is used to change contrast of lcd.

Pin 15&16 are used for backlight of lcd.



Circuit and Program can be download from following link.

Password:lcdinterfacing

http://www.freefilehost.co.uk/266389

Just enter password and download design.

No comments:

Post a Comment