Lec10 LCD Interface
-
Upload
sanam-nisar -
Category
Documents
-
view
225 -
download
0
Transcript of Lec10 LCD Interface
-
8/10/2019 Lec10 LCD Interface
1/15
Interfacing LCD
(Liquid Crystal Display)
Interface a 2-line x 20
character LCD module withthe built-in HD44780controller to I/O ports of the8051 microcontroller
-
8/10/2019 Lec10 LCD Interface
2/15
Converting to ASCII
The LCD can represent characters in ASCII
For example number 08H must be converted to 38H
-
8/10/2019 Lec10 LCD Interface
3/15
Interfacing LCD
Hardware
20 x 2-line LCD displays (twolines with 20 characters perline)
LCD has a display Data RAM(registers) that stores data in8-bit character code.
Each register in Data RAMhasits own address thatcorresponds to its position on
the line. The address rangefor Line 1 is
00 to 13H and Line 2 is 40H to53H.
0x38
0x39
0x00
2x20
0x013
0x38
0x014
0x040
0x053
8
8
-
8/10/2019 Lec10 LCD Interface
4/15
Interfacing LCD
Driver HD77480 Three control signals:
RS Register Select (RA3)
R/W Read/Write (RA2)
E Enable (RA1)
Three power connections Power, ground, and the variable register to control
the brightness
-
8/10/2019 Lec10 LCD Interface
5/15
Interfacing LCD
Driver (HD77480) has two 8-bit internal registers Instruction Register (IR) to write instructions to set up
LCD
Data Register (DR) to write data (ASCII characters)
IR REGISTER
DR REGISTER
-
8/10/2019 Lec10 LCD Interface
6/15
Interfacing LCD
LCD Operation When the MPU writes an instruction to IR or data to DR,
the controller: Sets the data line DB7 high as a flag indicating that the
controller is busy completing the operation
Sets the data line DB7 low after the completion of theoperation
The MPU should always check whether DB7 is low beforesending an instruction or a data byte
After the power up, DB7 cannot be checked for the first
two initialization instructions.
-
8/10/2019 Lec10 LCD Interface
7/15
Interfacing LCD
Writing to or reading from LCD
The MPU: Asserts RSlow to select IR
Reads from LCD by asserting the R/W signal high
Asserts the E signal high and then low (toggles) to latch a data
byte or an instruction
Asserts RShigh to select DR
Writes into LCD by asserting the R/W signal low
Asserts the E signal high and then low (toggles) to latch a databyte or an instruction
-
8/10/2019 Lec10 LCD Interface
8/15
HD44780 Bus Timing
Read timing diagram
Write timing diagram
-
8/10/2019 Lec10 LCD Interface
9/15
Interfacing LCD (Write)
Software To write into the LCD, the program should:
Send the initial instructions (commands) before it cancheck DB7 to set up the LCD in the 4-bit or the 8-bitmode.
Check DB7 and continue to check until it goes low.
Write instructions to IR to set up the LCD parameters
such as the number of display lines and cursorstatus.
Write data to display a message.
-
8/10/2019 Lec10 LCD Interface
10/15
-
8/10/2019 Lec10 LCD Interface
11/15
-
8/10/2019 Lec10 LCD Interface
12/15
-
8/10/2019 Lec10 LCD Interface
13/15
Subroutine to check Busy FLAG of LCD.
CHKBSY:CLR RS ;RS=0SETB RW ;R/W=1(READ)
SETB EN ;E=1MOV C,P1.7CLR EN ;E=0JC CHKBSY
RET
-
8/10/2019 Lec10 LCD Interface
14/15
Subroutine to Write LCD Instruction
INSWR:ACALL CHKBUSYCLR RS ;RS=0CLR RW ;R/W=0SETB EN ;E=1MOV P1,ACLR EN ;E=0RET
-
8/10/2019 Lec10 LCD Interface
15/15
Subroutine to Write LCD Character
DTWR:ACALL CHKBUSYSETB RS ;RS=1CLR RW ;R/W=1SETB ENMOV P1,ACLR ENRET