Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD intefacing for 8051 Beginner with Sch & ASM File

Status
Not open for further replies.

Medtronic

Full Member level 5
Joined
May 19, 2005
Messages
246
Helped
29
Reputation
58
Reaction score
16
Trophy points
1,318
Location
Egypt
Activity points
2,693
This is a full 8051 LCD 2X16 8 bit Interface
i hope it will help someone

Regards
 

nice work, can u explain me what is exact function of this subroutine " LCD_Com_Wrt", command write that is...
 

Awesome work man!

Medtronic, I am getting all screen black using your hex file.

Any suggestions?
Thanks
 

Dear my friend, my be you miss somthing from harsware,please reveiw your hardware and check Vcc,Gnd, and contrast pin
 

Code:
; This program is to test lcd display 
; Demo Program Scrolling continues
;P1=data pin
;P2.0 connected to RS pin
;P2.1 connected to R/W pin
;P2.2 connected to E pin
        

	;call delay1
	MOV     A,#38H   ;init. LCD 2 lines,5x7 matrix
        ACALL   COMMAND       ;issue command 
        MOV     A,#0EH        ;LCD on, cursor on
        ACALL   COMMAND       ;issue command 
        MOV     A,#01H        ;clear LCD command
        ACALL   COMMAND       ;issue command
        MOV     A,#06H        ;shift cursor right
        ACALL   COMMAND       ;issue command
	MOV     A,#0C0H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'8'        ;display letter N
        ACALL   DATA_DISPLAY	
        MOV     A,#'0'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'5'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'1'        ;display letter O	
	ACALL   DATA_DISPLAY        	
        MOV     A,#'D'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'E'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'M'        ;display letter O	
        ACALL   DATA_DISPLAY
	MOV     A,#'O'        ;display letter O
	ACALL   DATA_DISPLAY
	

	MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'4'        ;display letter N
        ACALL   DATA_DISPLAY	
	CALL DELAY
	MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'3'        ;display letter N
        ACALL   DATA_DISPLAY		
	CALL DELAY
	MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
	
        MOV     A,#'2'        ;display letter N
        ACALL   DATA_DISPLAY	
	CALL DELAY
	MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
	
        MOV     A,#'1'        ;display letter N
        ACALL   DATA_DISPLAY	
	CALL DELAY
	MOV     A,#083H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
	
        MOV     A,#'0'        ;display letter N
        ACALL   DATA_DISPLAY		
	CALL DELAY	

	MOV     A,#01H        ;clear LCD command
        ACALL   COMMAND       ;issue command
;----------------------------------------------------------------------------------------------
	
	
	 
	MOV     A,#0C0H        ;cursor: line 1, pos. 6
        ACALL   COMMAND       ;command subroutine
        MOV     A,#'8'        ;display letter N
        ACALL   DATA_DISPLAY	
        MOV     A,#'0'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'5'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'1'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#' '        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'L'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'C'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'D'        ;display letter O
	ACALL   DATA_DISPLAY
	MOV     A,#' '        ;display letter O        
        ACALL   DATA_DISPLAY
	MOV     A,#'D'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'I'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'S'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'P'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'L'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'A'        ;display letter O
        ACALL   DATA_DISPLAY
	MOV     A,#'Y'        ;display letter O
        ACALL   DATA_DISPLAY	
	HERE:	MOV     A,#18H        ;cursor: line 1, pos. 6
        ACALL   COMMAND 
	CALL DELAY1
	
	lJMP HERE  
  
	          	      ;STAY HERE
COMMAND: ACALL   READY        ;is LCD ready?
        MOV     P1,A          ;issue command code
        CLR     P2.0          ;RS=0 for command
        CLR     P2.1          ;R/W=0 to write to LCD
        SETB    P2.2          ;E=1 for H-to-L pulse
        CLR     P2.2          ;E=0 ,latch in
        RET
DATA_DISPLAY:
        ACALL   READY         ;is LCD ready?
        MOV     P1,A          ;issue data  
        SETB    P2.0          ;RS=1 for data
        CLR     P2.1          ;R/W=0 to write to LCD
        SETB    P2.2          ;E=1 for H-to-L pulse
        CLR     P2.2          ;E=0, latch in 
        RET

READY:
     SETB    P1.7             ;make P1.7 input port
     CLR     P2.0        ;RS=0 access command reg
     SETB    P2.1        ;R/W=1 read command reg
BACK:CLR     P2.2        ;E=1 for H-to-L pulse
     SETB    P2.2        ;E=0 H-to-L pulse
     JB      P1.7,BACK        ;stay until busy flag=0
     RET

delay:
mov r7, #0fh
up4: mov r6, #060h
up3: mov r5, #00h
djnz r5, $
djnz r6, up3
djnz r7, up4
ret



;-------------------delay program------------------------			
DELAY1:
       			
	  MOV  TMOD,#010H     
          MOV  R3,#04H					;95        
TES:      MOV  TL1,#00H					;00        
          MOV  TH1,#00H					;00        
          SETB TR1           
T  :      JNB  TF1,T  
          CLR  TR1            
	  CLR  TF1               				 
          DJNZ R3,TES
          RET 
;---------------------end-------------------------------------                  

END			         
[/img]\[find datasheet of lcd  on net and connect as per it,
all the best\]
 

#include<reg51.h>
void lcddata(unsigned char value);
void lcdcmd(unsigned char value);
void delay( unsigned int itime);
sfr ldata=0x90;
sbit rs= P2^0;
sbit rw =P2^1;
sbit en=P2^2;

void main()
{
lcdcmd(0x38);
delay(50);

lcdcmd(0x0E);
delay(50);

lcdcmd(0X01);
delay(50);

lcdcmd(0X06);
delay(50);

lcdcmd(0XC0); //LINE2 POSITION 1
delay(50);

lcddata('A');
delay(50);
lcddata('N');
delay(50);
lcddata('K');
delay(50);
lcddata('I');
delay(50);
lcddata('T');
delay(50);
lcddata('-');
delay(50);
lcddata('T');
delay(50);
lcddata('h');
delay(50);
lcddata('e');
delay(50);
lcddata(' ');
delay(50);
lcddata('C');
delay(50);
lcddata('O');
delay(50);
lcddata('D');
delay(50);
lcddata('E');
delay(50);
lcddata('R');
delay(50);
}

void lcdcmd(unsigned char value)
{
ldata=value;
rs=0;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcddata(unsigned char value)
{
ldata=value;
rs=1;
rw=0;
en=1;
delay(1);
en=0;
return;
}
void delay( unsigned int itime)
{
unsigned int i,j;
for(i=0;i<itime;i++)
for(j=0;j<1275;j++);
}




//CONNECT D0-D7 TO PORT P1
//2.0 TO RO
//2.1 TO RW
//2.2 TO EN
Thats t :)
 
Last edited:

hi can tell me how i can send data from hyperterminal to lcd via 89c51 .
i have done all hardware connection as well as try some code but they r not working can u suggest me bcz i m newr for 8051.
 

thank you very much, i think i can learn a lot of knowledge from the passage
 

You have to send the data to MCU from hyperterminal and MCU will display it on LCD. Do you want C code or ASM code? Whether it is C or ASM you have to write a routine to send character to LCD and then call it as many times as the length of the string with incrementing the pointer to string.
 

yes i want C code .any text will show in LCD 16x2 using 89c51 with rs232
 

but i want code for 89c51 controller
pls help me i was facing that code problem since 1month i ddn't get any breakout
 

hy jay
i was downloade ur code in 89c51 via hex file.but there is no moment in lcd. i.e i was writing in hyper terminal that in not saw on lcd.
and i am using NSK devlopment board that u can see in below link.**broken link removed**
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top