You are on page 1of 18

8-bit microcontrollers

16 X 2 Alphanumeric LCD

4/25/2014

8 bit microcontrollers

Advantages of LCD over LED


Declining prices of LCD.
Ability to display numbers, characters and
graphics.
Ease of programming for characters and
graphics.
Relieving CPU from refreshing task of
LCD
4/25/2014

8 bit microcontrollers

8F

80

CF

C0

4/25/2014

8 bit microcontrollers

Pin Description
Pin No
1
2
3
4
5
6
7-14
15
16
4/25/2014

Description
Vss
Vcc
Contrast Voltage
RS
R/W
EN
Data Input/Output Pins (D0-D7)
Anode (K)
Cathode (K)
8 bit microcontrollers

1) Vss- Vss is connected to the ground.


2) Vcc- Vcc is connected to +5V.
3) Contrast Voltage- Vee is used

for controlling LCD


Contrast. Variable pin of Variable Resistor of 10K is connected to
this pin.

4) RS- RS is used for the selection of internal resistors of LCD.


Command Code Register It allows the user to send command
such as clear display, cursor at home etc.
Data Register It allows the user to send data to be displayed on
LCD.

If RS=0, then Command Register is selected.


If RS=1, then Data Register is selected.
4/25/2014

8 bit microcontrollers

5) R/W-

R/W input allows user to write information to


the LCD or read information from it.

R/W=1 when Reading


R/W=0 when Writing
6) EN- This enable pin is used

by the LCD to latch


information presented to its data pins.
When data is supplied to data pins, a High-to-low pulse
must be applied to this pin.

7) Pin 7-14

The 8-bit data pins, D0-D7 are used to


send information to LCD or read the contents of the
LCDs internal registers.
To Display letters and numbers, ASCII codes for letters
and numbers are sent to these pins while making RS=1.

4/25/2014

8 bit microcontrollers

Table of LCD Control Signals


RS

R/W

Command

Data

Read
Command
Read data

4/25/2014

EN

8 bit microcontrollers

Hardware Connection of 8051 With


LCD

4/25/2014

8 bit microcontrollers

LCD Command Codes


Code
(Hex)
01
02
04
06

4/25/2014

Command to LCD Instruction register

Clear display screen


Return home
Decrement cursor (shift cursor to
left)
Increment cursor (shift cursor to
right)
8 bit microcontrollers

10

LCD Command Codes


Code
(Hex)
08
0A
0C
0E

4/25/2014

Command to LCD Instruction register

Display off, cursor off


Display off, cursor on
Display on, cursor off
Display on, cursor on

8 bit microcontrollers

11

LCD Commands Codes


Code
(Hex)
0F
80
C0
38
30
4/25/2014

Command to LCD Instruction register

Display on, cursor blinking


Force cursor to beginning of 1st line
Force cursor to beginning of 2nd line
2 Lines and 5x8 matrix
1 Line and 5x8 matrix
8 bit microcontrollers

12

Program for writing Command to


LCD
mov P2,a
clr RS
clr R/W
setb EN
clr EN
acall busy
4/25/2014

8 bit microcontrollers

13

Program for writing Data to LCD


mov P2,a
setb RS
clr R/W
setb EN
clr EN
acall busy
4/25/2014

8 bit microcontrollers

14

Routine for checking LCD Busy


state
busy:
back:

4/25/2014

setb D7
setb EN
clr EN
jnb D7, back
ret

8 bit microcontrollers

15

4/25/2014

8 bit microcontrollers

16

LCD Initialising Routine


mov a,#38h
acall command
mov a, #0eh
acall command
mov a,#01h
acall command
mov a,#06h
acall command
4/25/2014

8 bit microcontrollers

17

Contd
mov a,#80h
acall command
mov a,#J
acall data
mov a,#A
acall data
mov a,#J
acall data
4/25/2014

8 bit microcontrollers

18

You might also like