8051---LCD display showing some other characters

Status
Not open for further replies.

gane26

Member level 1
Joined
Jan 10, 2010
Messages
33
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Visit site
Activity points
1,531
my lcd display showing
"INDI3 EO%AY"

Must show
"INDIA TODAY"

can u say what is the main problem for this... code or lcd display problem???
 

NAME LCD_ASM


LCD_var data 56H ;----> moving the lcd data

LCD_DATA data 57H

AD4 EQU 084H ; P0.4 LOW NIBBLE OF PORT 1 IS USED FOR DATA
AD5 EQU 085H ; P0.5 LOW NIBBLE OF PORT 1 IS USED FOR DATA
AD6 EQU 086H ; P0.6 LOW NIBBLE OF PORT 1 IS USED FOR DATA
AD7 EQU 087H ; P0.7 LOW NIBBLE OF PORT 1 IS USED FOR DATA
EN EQU 082H ; P0.2 LCD ENABLE LINE
RS EQU 080H ; P0.0 LCD REGISTER SELECT LINE
RW EQU 081H ; P0.1 LCD REGISTER SELECT LINE
?PR?lcd_asm?LCD_ASM SEGMENT CODE

PUBLIC Reset_LCD
PUBLIC init_lcd
PUBLIC LCD_write_command
PUBLIC LCD_write_text

RSEG ?PR?lcd_asm?LCD_ASM

org 0000
ljmp main

org 0100

main:

lcall longdelay
lcall longdelay
lcall longdelay
lcall longdelay

LCALL Reset_LCD

LCALL init_lcd
lcall longdelay
lcall longdelay

MOV A,#'G'
LCALL LCD_write_text
MOV A,#'B'
LCALL LCD_write_text
MOV A,#'C'
LCALL LCD_write_text
MOV A,#'T'
LCALL LCD_write_text
MOV A,#'E'
LCALL LCD_write_text
MOV A,#'C'
LCALL LCD_write_text
MOV A,#'H'
LCALL LCD_write_text
MOV A,#'N'
LCALL LCD_write_text
MOV A,#'O'
LCALL LCD_write_text
MOV A,#'L'
LCALL LCD_write_text
MOV A,#'O'
LCALL LCD_write_text
MOV A,#'G'
LCALL LCD_write_text
MOV A,#'Y'
LCALL LCD_write_text
okk:
ljmp okk

Reset_LCD:

lcall MDELAY

clr RS
clr RW
clr EN


clr AD7
clr AD6
setb AD5
setb AD4

setb EN ; START ENABLE PULSE
clr EN ; END ENABLE PULSE

MOV A, #4 ; DELAY 4 MILLISECONDS
lcall MDELAY

setb EN ; START ENABLE PULSE
clr EN ; END ENABLE PULSE

MOV A, #1 ; DELAY 1 MILLISECOND
lcall MDELAY

setb EN ; START ENABLE PULSE
clr EN ; END ENABLE PULSE

MOV A, #1 ; DELAY 1 MILLISECOND
lcall MDELAY

clr AD4 ; SPECIFY 4-BIT OPERATION
setb EN ; START ENABLE PULSE
clr EN ; END ENABLE PULSE

MOV A, #1 ; DELAY 1 MILLISECOND
lcall MDELAY

mov A,#0x28
lcall LCD_write_command
mov A,#0x08
lcall LCD_write_command
mov A,#0x01
lcall LCD_write_command
mov A,#0x06
lcall LCD_write_command

ret

;================ LCD Initialisation ======================

init_lcd:
clr RS ; LCD REGISTER SELECT LINE
clr RW ; READ / WRITE LINE
clr EN ; ENABLE LINE
mov A,#0x28


lcall LCD_write_command
mov A,#0x0c //0x0e
lcall LCD_write_command
mov A,#0x06
lcall LCD_write_command
mov A,#0x01
lcall LCD_write_command

ret

; **********************************************************
; SUB WRITES A COMMAND WORD TO THE LCD
; COMMAND MUST BE PLACED IN R4 BY CALLING PROGRAM
; **********************************************************

LCD_write_command:
MOV LCD_var,A
CLR EN
CLR RS ; SELECT SEND COMMAND
CLR RW ; SELECT WRITE OPERATION

; PUSH ACC ; SAVE ACCUMULATOR

MOV A,LCD_var ; PUT DATA BYTE IN ACC

MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV AD4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV AD5, C
MOV C, ACC.6
MOV AD6, C
MOV C, ACC.7
MOV AD7, C
SETB EN ; PULSE THE ENABLE LINE
CLR EN
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV AD4, C
MOV C, ACC.1
MOV AD5, C
MOV C, ACC.2
MOV AD6, C
MOV C, ACC.3
MOV AD7, C

SETB EN ; PULSE THE ENABLE LINE
CLR EN

LCALL PULSEEWAIT4 ; PULSE THE ENABLE LINE...
; AND WAIT FOR BUSY FLAG TO CLEAR
lcall MDELAY
RET

; **********************************************************
; SUB TO WRITE A DATA WORD TO THE LCD
; DATA MUST BE PLACED IN R4 BY CALLING PROGRAM
; **********************************************************

LCD_write_text:

MOV LCD_var,A
CLR EN
SETB RS ; SELECT SEND DATA
CLR RW ; SELECT WRITE OPERATION

MOV A, LCD_var ; PUT DATA BYTE IN ACC

MOV C, ACC.4 ; LOAD HIGH NIBBLE ON DATA BUS
MOV AD4, C ; ONE BIT AT A TIME USING...
MOV C, ACC.5 ; BIT MOVE OPERATOINS
MOV AD5, C
MOV C, ACC.6
MOV AD6, C
MOV C, ACC.7
MOV AD7, C
SETB EN ; PULSE THE ENABLE LINE
CLR EN
MOV C, ACC.0 ; SIMILARLY, LOAD LOW NIBBLE
MOV AD4, C
MOV C, ACC.1
MOV AD5, C
MOV C, ACC.2
MOV AD6, C
MOV C, ACC.3
MOV AD7, C

SETB EN ; PULSE THE ENABLE LINE
CLR EN

LCALL PULSEEWAIT41 ; PULSE THE ENABLE LINE...
; AND WAIT FOR BUSY FLAG TO CLEAR
lcall MDELAY
RET
;===========================================================

MDELAY:
PUSH ACC
MOV A,#0A6H
MD_OLP:
INC A
NOP
NOP
NOP
NOP
NOP
NOP
NOP
NOP
JNZ MD_OLP
NOP
POP ACC

ret

;============== Sort delay for lcd display ======================

srtdelay:
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
ret

longdelay:
mov r1,0x0ff
sss:
mov r2,0x0ff
dfd:
djnz r2,dfd
djnz r1,sss
ret

;==================== pulsewait ========================

PULSEEWAIT4:
clr EN
setb EN ; PULSE THE ENABLE LINE
clr EN
mov LCD_DATA, #0FH ; PREPARE PORT FOR INPUT
setb RW ; PREPARE R/W FOR READ OPERATION
mov A,#80h
orl A,RW
mov RW,A
mov dptr,#0c002h
movx @dptr,A

PEW:
setb EN ; START THE ENABLE PULSE
mov A, LCD_DATA ; READ STATUS NIBBLE
clr EN ; END ENABLE PULSE
setb EN ; PRETEND READING STATUS LOW NIBBLE
clr EN
JB ACC.7, PEW ; LOOP WHILE BUSY FLAG IS SET

ret


PULSEEWAIT41:
clr EN
setb EN ; PULSE THE ENABLE LINE
clr EN
mov LCD_DATA, #2FH ; PREPARE PORT FOR INPUT
setb RW ; PREPARE R/W FOR READ OPERATION
mov A,#80h
orl A,RW
mov dptr,#0c002h
movx @dptr,A
mov RW,A
PEW1:
setb EN ; START THE ENABLE PULSE
mov A, LCD_DATA ; READ STATUS NIBBLE
clr EN ; END ENABLE PULSE
setb EN ; PRETEND READING STATUS LOW NIBBLE
clr EN
JB ACC.7, PEW1 ; LOOP WHILE BUSY FLAG IS SET

ret

END

;;;;;;;;;;;;;;;;;;;;;;;;;;end of code;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 

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…