Product categories

Have You Seen

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

B0505S-1WR3 MORNSUN Isolated DC - DC Converter

Mornsun B0505S-1WR3 DC-DC Isolated ConverterMORNSUN B0505S 1WR3 1 watt, 5 Volts Isolated DC to DC Po..

Rs.106.20 (inc GST)
Rs.90.00 + GST

SKU: 2969 | DAE663
Stock: 100
XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)

XL1509-Adj E1 Buck DC to DC Converter IC (SOP8L Package)XL1509-Adj E1 Buck DC to DC Converter IC, Ad..

Rs.25.96 (inc GST)
Rs.22.00 + GST

SKU: 3657 | DAF397
Stock: 79

LCD Interfacing To 8051 in 4bit mode



Liquid Crystal Display also called as LCD is very helpful in providing user interface as well as for debugging purpose. The most common type of LCD controller is HITACHI 44780 which provides a simple interface between the controller & an LCD. These LCD's are very simple to interface with the controller as well as are cost effective.

The LCD requires 3 control lines (RS, R/W & EN) & 8 (or 4) data lines. The number on data lines depends on the mode of operation. If operated in 8-bit mode then 8 data lines plus 3 control lines i.e. total 11 lines are required.

In case of 4-bit mode only 4 data lines are required & the 8-bit data is sent by first sending the higher nibble followed by the lower nibble. Since we are operating the LCD in 4 bit mode only 7 port pins are required. Here is a program for interfacing a LCD through 8051 in 4 bit mode. The Higher 4 bits of P0 are connected to the higher 4 bits of the LCD i.e. P0.4 – P0.7 are connected to D4 – D7.

 

lcd_interfacing_4bit_mode

 

The three control lines are RS, RW & Enable.

RS: Register Select. When RS = 0 the command register is selected. When RS=1 the data register is selected.

RW: Read or Write. When RW=0 write to LCD. When RW=1 read from LCD.

Enable: Used to Latch data into the LCD. A HIGH TO LOW edge latches the data into the LCD.

  • RS: Register Select. When RS = 0 the command register is selected. When RS=1 the data register is selected.

 

LCD_RS BIT P2.5
LCD_RW BIT P2.6
LCD_E BIT P2.7
LCD_PORT EQU P0                 //the higher nibble i.e. P0.4 - P0.7 is used
ORG 0000h
mov a,#20h

call lcd_command

mov a,#28h

call lcd_command

mov a,#06h

call lcd_command

mov a,#01h

call lcd_command

mov a,#0ch

call lcd_command

mov a,#86h

call lcd_command

//1st line 6th character

mov a,#'D'

call lcd_datadisplay

mov a,#'N'

call lcd_datadisplay

mov a,#'A'

call lcd_datadisplay

mov a,#0c3h

call lcd_command //2nd Line 3rd character

mov a,#'T'

call lcd_datadisplay

mov a,#'E'

call lcd_datadisplay

mov a,#'C'

call lcd_datadisplay

mov a,#'H'

call lcd_datadisplay

mov a,#'N'

call lcd_datadisplay

mov a,#'O'

call lcd_datadisplay

mov a,#'L'

call lcd_datadisplay

mov a,#'O'

call lcd_datadisplay

mov a,#'G'

call lcd_datadisplay

mov a,#'Y'

call lcd_datadisplay

loop:

ajmp loop

lcd_command:

mov b,a

call lcd_ready

clr lcd_rw

clr lcd_rs

orl lcd_port,#0f0h

mov a,b

orl a,#0fh

anl lcd_port,a

setb lcd_e

clr lcd_e

orl lcd_port,#0f0h

mov a,b

swap a

orl a,#0fh

anl lcd_port,a

setb lcd_e

clr lcd_e

ret

lcd_datadisplay:

mov b,a

call lcd_ready

clr lcd_rw

setb lcd_rs

orl lcd_port,#0f0h

mov a,b

orl a,#0fh

anl lcd_port,a

setb lcd_e

clr lcd_e

orl lcd_port,#0f0h

mov a,b

swap a

orl a,#0fh

anl lcd_port,a

setb lcd_e

clr lcd_e

ret

lcd_ready:

clr lcd_e

orl lcd_port,#0f0h

clr lcd_rs

setb lcd_rw

setb lcd_e

mov a,lcd_port

clr lcd_e

anl a,#0f0h

mov temp,a

orl lcd_port,#0f0h

setb lcd_e

mov a,lcd_port

clr lcd_e

anl a,#0f0h

swap a

orl a,temp

jb acc.7,lcd_ready

ret

.

Written by Administrator

Administrator

Administrator