Interfacing of LCD with 8051​​​​​​​ ​​​​​​​​​​​​​​​​​​​​​

Updated on 2017/08/11 11:21

 

LCD Interfacing with 8051 Microcontroller

Introduction to LCD

The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display. The interface consists of the following pins:

JHD162A-LCD-module.png

LCD Pin Description

LCD pin no.LCD pin nameLCD pin Description
1VssGround pin of the LCD module.
2VccPower to LCD module (+5V supply)
3VEEContrast adjustment pin
4RS

Register select pin
RS=0 command register.
RS=1 data register. 

5R/W

Read/Write modes
R/W=1; Read mode
R/W=1; Write mode

6ENThis pin is meant for enabling the LCD module
7-14DB0 to DB78 data pins
15LED+Anode of the back light LED
16LED-Cathode of the back light LED

The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. 

Mostly used commands or instructions for LCD
Sr.No.InstructionHex
1Function Set: 8-bit mode, 1 Line, 5x7 Dots matrix for each character display0x30
2Function Set: 8-bit mode, 2 Line, 5x7 Dots matrix for each character display0x38
3Function Set: 4-bit mode, 1 Line, 5x7 Dots matrix for each character display0x20
4Function Set: 4-bit mode, 2 Line, 5x7 Dots matrix for each character display0x28
5Clear display screen0x01
6Return Home0x02
7Decrement cursor(Shift to left)0x04
8Increment cursor(Shift to Right)0x06
9Display off Cursor off0x08
10Display on Cursor on0x0E
11Display on Cursor off0x0C
12Display on Cursor blinking0x0F
13Shift entire display left0x18
14Shift entire display right0x1C
15Move cursor left by one character0x10
16Move cursor right by one character0x14
17Clear Display (also clear DDRAM content)0x01
18Force cursor position on  first position of  first 0x80 
19Force cursor position on  first position of  second row 0xC0 

Video Proteus Simulation


Algorithm for Interfacing

Interfacing Diagram

8051_lcd.jpg

ALP for the interfacing

Question:-Draw and explain interfacing of 16x2 LCD with 8051 microcontroller in 8-bit mode and also write an ALP to display word "SANVIT".

org 0000h
mov a, #38h   ; 16x2, 8 bit,5x7 dots
acall cmd ; routine for command word
mov a, #0fh   ; LCD on, CURSOR on
acall cmd  
mov a, #06h   ; shift cursor right
acall cmd
mov a, #01h   ; clear display
acall cmd
mov a, #80h   ; cursor line 1, position 6
acall cmd   
mov a, #'S'   ; Display S
acall display ; routine for display of Character
mov a, #'A'   ; Display A
acall display
mov a, #'N'   ; Display N
acall display
mov a, #'V'   ; Display V
acall display
mov a, #'I'   ; Display I
acall display
mov a, #'T'   ; Display T
acall display
cmd: mov p1,a
clr p2.0   ; rs=0
clr p2.1   ; rw=0
setb p2.2  ; e=1
acall delay
clr p2.2   ; e=0
ret
display:mov p1,a
setb p2.0   ; rs=1
clr p2.1   ; rw=0
setb p2.2  ; e=1
acall delay
clr p2.2   ; e=0
ret  
delay: mov r2, #010h
l3: mov r3, #20h
l2: mov r4, #30h
l1: djnz r4, l1
djnz r3, l2
djnz r2, l3
ret
END

References

  • Created and developed by Prof. S.M.Wagh, SKNCOE  Pune
  • Interfacing diagram by Jayesh Gopal, Student, SKNCOE,Pune
  • WikiNote Foundation
Tags:
Created by Sujit Wagh on 2017/08/03 11:14