Mình viết đaọn code hiện chữ tren lcd nhung nó không mô phổng được mình đã xem nhùi lần ko biết sai chổ nào anh em coi giúp giùm
;************************************************* ***
en bit p0.2
rw bit p0.1
rs bit p0.0
databus equ p1
;************************************************* ***
org 00h
main:
Acall lcdinit
mp1:
Acall disp_fline
acall disp_sline
sjmp $
lcdinit:
Clr rs
clr rw
setb en
mov databus,#38h
acall sendcommand
mov th0,#high(-4100)
mov tl0,#low(-4100)
acall delay
mov databus,#38h
acall sendcommand
mov th0,#high(-100)
mov tl0,#low(-100)
acall delay
mov databus,#38h
acall sendcommand
mov databus,#0ch
acall sendcommand
mov databus,#01h
acall sendcommand
mov databus,#06h
acall sendcommand
ret
sendcommand:
Clr rs
sjmp pulse_en
senddata:
Setb rs
nop
pulse_en:
Clr rw
clr en
nop
setb en
nop
mov databus,#0ffh
setb rw
clr rs
clr en
nop
setb en
nop
busy:
Mov a,databus
jb acc.7,busy
busy2:
Mov a,databus
jb acc.7,busy2
clr rw
ret
disp_fline:
Mov databus,#80h
acall sendcommand
mov dptr,#fline_data
acall write
ret
disp_sline:
Mov databus,#0c0h
acall sendcommand
mov dptr,#sline_data
acall write
ret
write:
Mov a,#0
movc a,@a+dptr
cjne a,#99h,write_cont
write_cont:
Mov databus,a
acall senddata
inc dptr
sjmp write
delay:
Mov tmod,#01h
setb tr0
jnb tf0,$
clr tr0
clr tf0
ret
fline_data:
Db 'micro-controller'
db 99h
sline_data:
Db 'designed by: Pqt'
db 99h
end
;************************************************* ***
en bit p0.2
rw bit p0.1
rs bit p0.0
databus equ p1
;************************************************* ***
org 00h
main:
Acall lcdinit
mp1:
Acall disp_fline
acall disp_sline
sjmp $
lcdinit:
Clr rs
clr rw
setb en
mov databus,#38h
acall sendcommand
mov th0,#high(-4100)
mov tl0,#low(-4100)
acall delay
mov databus,#38h
acall sendcommand
mov th0,#high(-100)
mov tl0,#low(-100)
acall delay
mov databus,#38h
acall sendcommand
mov databus,#0ch
acall sendcommand
mov databus,#01h
acall sendcommand
mov databus,#06h
acall sendcommand
ret
sendcommand:
Clr rs
sjmp pulse_en
senddata:
Setb rs
nop
pulse_en:
Clr rw
clr en
nop
setb en
nop
mov databus,#0ffh
setb rw
clr rs
clr en
nop
setb en
nop
busy:
Mov a,databus
jb acc.7,busy
busy2:
Mov a,databus
jb acc.7,busy2
clr rw
ret
disp_fline:
Mov databus,#80h
acall sendcommand
mov dptr,#fline_data
acall write
ret
disp_sline:
Mov databus,#0c0h
acall sendcommand
mov dptr,#sline_data
acall write
ret
write:
Mov a,#0
movc a,@a+dptr
cjne a,#99h,write_cont
write_cont:
Mov databus,a
acall senddata
inc dptr
sjmp write
delay:
Mov tmod,#01h
setb tr0
jnb tf0,$
clr tr0
clr tf0
ret
fline_data:
Db 'micro-controller'
db 99h
sline_data:
Db 'designed by: Pqt'
db 99h
end