LCD program :help required

Status
Not open for further replies.

kiranmayik

Newbie level 4
Joined
Jan 14, 2007
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,373
lcd_send_command( hd44780

hi everyone,
i tried interfacing at89c51 with 20X2 lcd display(ODM-20216S).
i have connected port1 to LCD and P3.0 to RS, P3.1 to R/W, P3.2 to E.
but the LCD is not showing any output.
this is the code:



;communicating with lcd
;checking busy flag before sending data, command to lcd
; P1= data pin, P3.0=RS, P3.1=R/W, P3.2=E pins
ORG 0H

MOV A,#38H ;initialize lcd 2 lines
ACALL COMMAND ;issue command

MOV A,#0EH ;lcd on, cursor on
ACALL COMMAND
MOV A,#02H ;return home
ACALL COMMAND
MOV A,#01H ;clear lcd command
ACALL COMMAND
MOV A,#06H ;shift cursor right
ACALL COMMAND
MOV A,#80H ;cursor:line 1,position 0
ACALL COMMAND
MOV A,#'L' ;display letter L
ACALL DATADISP
MOV A,#'C'
ACALL DATADISP
MOV A,#'D'
ACALL DATADISP
HERE:
SJMP HERE ;stay here


COMMAND:
ACALL READY ;check if lcd ready
MOV P1,A ;issue command code
CLR P3.0 ;RS=0 for command
CLR P3.1 ;R/W=0 to write to lcd
SETB P3.2 ;E=1 for H-to-L pulse
ACALL DELAY
CLR P3.2 ;E=0, latch in
RET


DATADISP:
ACALL READY ;check if lcd ready
MOV P1,A ;issue data
SETB P3.0 ;RS=1 for data
CLR P3.1 ; R/W=0 to write to lcd
SETB P3.2 ;E=1 for H-to-L pulse
ACALL DELAY ;give lcd some time
CLR P3.2 ;E=0, latch in
RET


READY:
SETB P1.7 ;make P1.7 input port
CLR P3.0 ;RS=0 access commang register
SETB P3.1 ;R/W=1 read command register
;read command register and check busy flag
BACK:
CLR P3.2 ;E=0 for L-to-H pulse
ACALL DELAY ;give lcd some time
SETB P3.2 ;E=1 L-to-H pulse
JB P1.7,BACK ;stay until busy flag=0
RET


DELAY:
MOV R3,#50
HERE1: MOV R4,#255
HERE2: DJNZ R4,HERE2
DJNZ R3,HERE1
RET
END


i'm not sure how much delays to give.do i have to give delay at the starting for power on.if so how much?and approximately how much delay is required for the enable pin.

please help.
thank you.
 

hi everyone,
i tried interfacing at89c51 with 16X2 lcd display (hd44780)
i have connected port1 to LCD and P1.0 to RS, P1.1 to R/W, P1.2 to E.
but the LCD is not showing any output

Added after 2 minutes:

hi everyone,
i tried interfacing at89c51 with 16X2 lcd display (hd44780)
i have connected port1 to LCD and P1.0 to RS, P1.1 to R/W, P1.2 to E.
but the LCD is not showing any output


any one please help to complete my lcd circuit
 

Also put some delays between the write enale signals..ten chk the pot for the contrast adjustment...
 

    kiranmayik

    Points: 2
    Helpful Answer Positive Rating
dear
this is source code of developed program used for lcd 16*1
Code:
;LCD interface 89s52
;LCD		8952
;D7  14		p1.7
;D6  13		p1.6
;D5  12		P1.5
;D4  11		p1.4
;EN  6		p1.3
;RS  4		p1.2	
;GND 1,3,5		
;VCC  2

#INCLUDE "8051EQU.INC"
LCD_DATA_4 .equ P1.4
LCD_DATA_5 .equ P1.5
LCD_DATA_6 .equ P1.6
LCD_DATA_7 .equ P1.7
LCD_RS .equ P1.2
LCD_EN .equ P1.3

; RESET
   .ORG   0H
   AJMP   START
; INTERRUPTS  (not used)        ;place interrupt routines at appropriate
                                ;memory locations
   .ORG   03H                   ;external interrupt 0
    RETI
   .ORG   0BH                   ;timer 0 interrupt
    RETI
   .ORG   13H                   ;external interrupt 1
    RETI
   .ORG   1BH                   ;timer 1 interrupt
    RETI
   .ORG   23H                   ;serial port interrupt
    RETI
   .ORG   25H                   ;locate beginning of rest of program
INITIALIZE:                     ;set up control registers

    MOV   R4,#00H
    MOV   A,#00H
    MOV   TCON,#00H
    MOV   TMOD,#00H
    MOV   PSW,#00H             
    MOV   IE,#00H               ;disable interrupts
    RET
LCD_INITIALIZE:
    NOP
	mov P1, #20h
	CLR LCD_RS
	SETB LCD_EN
	ACALL DELAYMS
	CLR LCD_EN
	ACALL DELAYMS
	mov a, #28h
	ACALL LCD_SEND_COMMAND
	mov a, #0ch
	ACALL LCD_SEND_COMMAND
	mov a, #02h
	ACALL LCD_SEND_COMMAND
	RET

LCD_SEND_COMMAND:
	mov 20H,a
	ACALL LCD_DATA
	clr LCD_RS
	setb LCD_EN
	ACALL DELAYMS
	clr LCD_EN
	ACALL DELAYMS

	mov a,20H
	swap a
	ACALL LCD_DATA
	clr LCD_RS
	setb LCD_EN
	ACALL DELAYMS
	clr LCD_EN
	ACALL DELAYMS
	ret

LCD_SEND_DATA:
	mov 20H,a
	ACALL LCD_DATA
	setb LCD_RS
	setb LCD_EN
	ACALL DELAYMS
	clr LCD_EN
	ACALL DELAYMS

	mov a,20H
	swap a
	ACALL LCD_DATA
	setb LCD_RS
	setb LCD_EN
	ACALL DELAYMS
	clr LCD_EN
	ACALL DELAYMS
	ret

LCD_DATA: 
	clr c
	mov 20h,a
	mov c,4h
	mov LCD_DATA_4, c
	mov c,5h
	mov LCD_DATA_5, c
	mov c,6h
	mov LCD_DATA_6, c
	mov c,7h
	mov LCD_DATA_7, c
; MOV   20H,A         ;Save A for low nibble
; ORL   P1,#0F0h    ;Bits 4..7 <- 1
; ORL   A,#0Fh        ;Don't affect bits 0-3
; ANL   P1,A        ;High nibble to display
; MOV   A,20H
 	RET

LCD_CLEAR:
	MOV a,#01H
	ACALL LCD_SEND_COMMAND
	RET

LCD_SEND_SPACES:
	MOV R4,#20H
LOOP_SPACES:
	MOV A,#' '
	ACALL LCD_SEND_DATA
	DJNZ R4,LOOP_SPACES
	RET	


DELAYMS:                        ;millisecond delay routine
   MOV   R7,#00H
LOOPA:                          
   INC   R7
   MOV   A,R7
   CJNE   A,#0FFH,LOOPA
   RET

DELAYHS:                        ;half second delay above millisecond delay
   MOV   R6,#00H
   MOV   R5,#002H
LOOPB:
   INC   R6
   ACALL   DELAYMS
   MOV   A,R6
   JNZ   LOOPB
   DEC   R5
   MOV   A,R5
   JNZ   LOOPB
   RET

DELAY1S:                        ;one second delay above millisecond delay
   MOV   R6,#00H
   MOV   R5,#004H
LOOPC:
   INC   R6
   ACALL   DELAYMS
   MOV   A,R6
   JNZ   LOOPC
   DEC   R5
   MOV   A,R5
   JNZ   LOOPC 
   RET

DELAY5S:		;5 SECONDS DELAY
   MOV   R6,#00H
   MOV   R5,#010H
LOOPD:
   INC   R6
   ACALL   DELAYMS
   MOV   A,R6
   JNZ   LOOPD
   DEC   R5
   MOV   A,R5
   JNZ   LOOPD 
   RET

DELAY20S:		;20 SECONDS DELAY
   MOV   R6,#00H
   MOV   R5,#030H
LOOPE:
   INC   R6
   ACALL   DELAYMS
   MOV   A,R6
   JNZ   LOOPE
   DEC   R5
   MOV   A,R5
   JNZ   LOOPE 
   RET

WRITE_MOBISERVE:
	mov a, #'M'
	ACALL LCD_SEND_DATA
	mov a, #'O'
	ACALL LCD_SEND_DATA
	mov a, #'B'
	ACALL LCD_SEND_DATA
	mov a, #'I'
	ACALL LCD_SEND_DATA
	mov a, #'S'
	ACALL LCD_SEND_DATA
	mov a, #'E'
	ACALL LCD_SEND_DATA
	mov a, #'R'
	ACALL LCD_SEND_DATA
	mov a, #'V'
	ACALL LCD_SEND_DATA

	ACALL LCD_SEND_SPACES

	mov a, #'E'
	ACALL LCD_SEND_DATA
	mov a, #'-'
	ACALL LCD_SEND_DATA
	mov a, #'E'
	ACALL LCD_SEND_DATA
	mov a, #'g'
	ACALL LCD_SEND_DATA
	mov a, #'y'
	ACALL LCD_SEND_DATA
	mov a, #'p'
	ACALL LCD_SEND_DATA
	mov a, #'t'
	ACALL LCD_SEND_DATA



	RET
;************************* program entry *********************************************
START:                          ;main program (on power up, program starts at this point)
	ACALL INITIALIZE
	ACALL LCD_INITIALIZE
	ACALL LCD_CLEAR
	ACALL WRITE_MOBISERVE
	MOV P1,#01H
	ACALL DELAY1S
FREEZ:
	NOP
	CPL P1.1
	CPL P1.0
	ACALL DELAY1S
	AJMP FREEZ

.END
 

    kiranmayik

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…