#Microcontrollers 8051 8-bit LCD Programming in Assembly


ORG 0000h

ACALL INITLCD

MOV A, #'M'

ACALL LCDDATA

MOV A,#82h

ACALL LCDCMD

MOV DPTR,#TEXT1

ACALL LCDSTRING

MOV A,#0C0h

ACALL LCDCMD

MOV DPTR,#TEXT2

ACALL LCDSTRING

HERE: SJMP HERE


DELAY:

MOV R0,#04h

Label1: MOV R1,#28h

Label2: MOV R2,#0Bh

DJNZ R2, $

DJNZ R1, Label2

DJNZ R0, Label1

RET


INITLCD:

MOV A,#38h

ACALL LCDCMD

MOV A,#0Ch

ACALL LCDCMD

MOV A,#06h

ACALL LCDCMD

MOV A,#80h

ACALL LCDCMD

RET


LCDCMD:

MOV P2, A

CLR P1.0 ;RS=0

CLR P1.1 ;RW=0

CLR P1.2 ;EN=0

ACALL DELAY

SETB P1.2 ;EN=1

RET


LCDDATA:

MOV P2, A

SETB P1.0 ;RS=1

CLR P1.1 ;RW=0

CLR P1.2 ;EN=0

ACALL DELAY

SETB P1.2 ;EN=1

RET


LCDSTRING: 

CLR A

MOVC A,@A+DPTR

JZ EXIT1

INC DPTR 

ACALL LCDDATA 

SJMP LCDSTRING 

EXIT1: RET 


TEXT1: DB "Hello Assembly",0 

TEXT2: DB "Program of 8051",0

END

Comments