Schematic Assembly Language program for LCD code | Controller Circuit

Sunday, December 4, 2011

Schematic Assembly Language program for LCD code

In this post some routine in Assembly language are written to interface lcd with microcontroller 8051.Most projects you create with the 8051 CPU or any other microcontroller  require some form of display. The display may be LED or LCD. But now use of LCD is increasing/ The most common way to accomplish this is with the LCD (Liquid Crystal Display). LCDs have become a cheap and easy way to get text display for an embedded system Common displays are set up as 16 to 20 characters by 1 to 4 lines. variate of LCD are available and most of them can work on thees ways describes in the sub routines.

Data to be Displayed on LCD using micro controller requires following set of instructions in the form of code as follows.
 lcd_datadisplay: // this is a part of main program call sub routine, the function of this sub routine is to display //data on lcd.
SETB RS //Telling the LCD that the data which is being send is to be displayed
MOV P1,A //Character to be displayed is in Acc
SETB EN // the enable pin of lcd is set to logic one
CLR EN //High to Low pulse on EN to latch the data
CALL DELAY //Delay so that LCD finishes its internal operations
 ret // return from this routine is called
Command or Special Instruction.
 lcd_command: // in this sub-routine of lcd program, how different commands are sent to lcd is shown
CLR RS //Telling the LCD that the data which is being send is a command
MOV P1,A //Character to be displayed is in Acc
SETB EN
CLR EN //High to Low pulse on EN to latch the data
CALL DELAY //Delay so that LCD finishes its internal operations
ret // returning to the main code from where this sub-routine was called
Busy flag checking
ready:  // In this sub-routine the busy flag is checked
setb P1.7 ;D7 as input
clr P3.6 ;RS=0 cmd
setb P3.5 ;RW=1 for read
again:
setb P3.7 ;H->L pulse on E
clr P3.7
jb P1.7, again
ret // returning back to main program where this function is called
Data write Routine
data: // in this sub-routine how data will be written on lcd is shown
mov P1, A ;//move acc. data to port
setb P3.6 ;RS=1 data
clr P3.5 ;RW=0 for write
setb P3.7 ;H->L pulse on E
clr P3.7
lcall ready
ret // end of this sub-routine
Command write Routine
command: // this is another sub-routine showing how to write commands on lcd, you can use any of these //cammand subroutine
mov P1, A ;move acc. data to port
clr P3.6 ;RS=0 for cmd
clr P3.5 ;RW=0 for write
setb P3.7 ;H->L pulse on E
clr P3.7
lcall ready
ret
Initialization of LCD
initialization: // in this sub-routine initialization of LCD is described

mov A, #38H ; Initialize, 2-lines, 5X7 matrix.
lcall Command
mov A, #0EH ; LCD on, cursor on
lcall Command
mov A, #01H ; Clear LCD Screen
lcall Command
mov A, #06H ; Shift cursor right
lcall Command
Display clear
clear: // this is sub-routine to clear the display of LCD
setb p3.7 ;enable EN
clr 3.6 ;RS=0 for cmd.
mov DATA,#01h
clr p3.7 ;disable EN
lcall ready
RET

Note- As we need to clear the LCD frequently and not the whole initialisation , it is better to use this routine separately.

Displaying "HI Friends"

lcall initialization
lcall clear
mov A,#'H'
acall data
mov A,#'I'
lcall data
mov A,#'F'
lcall data
mov A,#'r'
lcall data
lcall data
mov A,#'i'
lcall data
mov A,#'e'
lcall data
mov A,#'n'
lcall data
mov A,#'d'
lcall data
mov A,#'s'
ret
Now following is complete ASSEMBLY LANGUAGE code to show something on LCD
lcall Initialization
lcall clear
mov a,#'H'
lcall data
mov a,#'I'
lcall data
mov a,#8ah
lcall command
mov a,#'8'
lcall data
mov a,#'0'
lcall data
mov a,#'5'
lcall data
mov a,#'1'
lcall data
mov a,#'M'
lcall data
mov a,#'C'
lcall data
end

BACK to Content Page

. Next Page

.   Previous Page
flash programmer for at89c51,up counter based project,up counter chip manufacture with assembly language using 89c51 microcontroller,correlation flow METER 8051,program of 7 segment in 8515,4 CHANNEL RTC,RFID door access software flow diagram,Microcontroller into a Walt Meter assembly download,Microcontroller into a Watt Meter assembly download,AT89S52 PC PROJECTS,MICROCONTROLLER AT89C2051 BASED COUNT DOWN TIMER

No comments:

Post a Comment