51测试网 单片机教程XL2000开发板 单片机学习 自制编程器 单片机资料 软件下载 电子技术产品介绍如何购买 进入论坛

1602液晶屏驱动源程序15

察看本站的产品全家福和网站介绍      本站产品正式流水线工艺生产情况          庆祝本站5年来首页点击量突破500万!

<>12232驱动程序   <>12832驱动程序   <>12864驱动源程序   <>1602 驱动程序   <>0802 液晶驱动程序  <>回液晶主页



;30h-3fh is the second line sbuffer.
;50h-5fh is the first line sbuffer.
;70h is the second line counter .
;62h is the first line counter.

rs bit p2.6
r_w bit p2.5
enable bit p2.7
db0_db7 data p1 
org 0000h
ljmp main
org 0030h
main:
lcall initial
lcall cls
mov dptr,#tab
mov 61h,#16
mov 70h,#00
mov 69h,#11
mov 6ah,#11
lcall loop
qq:
lcall main1
inc 70h
djnz 61h,qq
ww:
lcall initiala
lcall loopa
mov 67h,#04
inc 70h
lcall main1
mov 62h,#00
lcall main1a
qqa:
inc 62h
lcall main1a
inc 70h
lcall main1
djnz 67h,qqa
inc 70h
lcall main1
mov 68h,69h
qq1:
inc 62h
lcall main1a
djnz 68h,qq1
lcall initial
lcall loop
inc 62h
lcall main1a
mov 70h,#00
lcall main1
mov 67h,#04
qqb:
inc 62h
lcall main1a
inc 70h
lcall main1
djnz 67h,qqb
inc 62h
lcall main1a

mov 68h,69h
qqb1:
inc 70h
lcall main1
djnz 68h,qqb1

ljmp ww



main1:
mov a,70h
push acc
lcall yw
pop 3fh
lcall display
lcall ttd
ret
main1a:
mov a,62h
push acc
lcall ywa
pop 50h
lcall displaya
lcall ttd
ret 
ttd:
mov 65h,#0e0h
ttd1:
lcall delay
djnz 65h,ttd1
ret

yw:
mov r1,#31h
mov r0,#30h
yw1:
mov a,@r1
mov @r0,a
inc r1
inc r0

cjne r0,#40h,yw1
ret
ywa:
mov r1,#60h
mov r0,#5fh
yw1a:
mov a,@r0
mov @r1,a
dec r1
dec r0

cjne r0,#4fh,yw1a
ret


display:
mov r2,#0c0h
mov r0,#30h
display1:
mov a,@r0
movc a,@a+dptr
push acc
mov a,r2
lcall write_instruction
pop acc
lcall writelcddata
inc r2
inc r0

cjne r0,#40h,display1
ret
displaya:
mov r3,#8fh
mov r0,#5fh
display1a:
mov a,@r0
movc a,@a+dptr
push acc
mov a,r3
lcall write_instruction
pop acc
lcall writelcddata
dec r3
dec r0

cjne r0,#4fh,display1a
ret



loop:
mov r0,#30h

loop1:
mov a,#0bh
mov @r0,a
inc r0
mov a,r0
cjne a,#40h,loop1
ret
loopa:
mov r0,#50h

loop1a:
mov a,#0bh
mov @r0,a
inc r0
mov a,r0
cjne a,#60h,loop1a
ret

cls:
mov a,#01h
lcall write_instruction
ret
initial:
mov a,#00001100b
lcall write_instruction
mov a,#00000110b
lcall write_instruction
mov a,#00111000b
lcall write_instruction
mov a,#00000001b
lcall write_instruction
ret
initiala:
mov a,#00001100b
lcall write_instruction
mov a,#00000100b
lcall write_instruction
mov a,#00111000b
lcall write_instruction

ret
checkbusy:
push acc
checkbusyloop:
clr enable 
setb r_w
clr rs
setb enable
mov a,db0_db7
clr enable
jb acc.7,checkbusyloop
pop acc
call delay
ret
write_instruction:
call checkbusy
clr enable
clr r_w
clr rs
setb enable
mov db0_db7,a
clr enable
ret
writelcddata:
call checkbusy
clr enable
clr r_w
setb rs
setb enable
mov db0_db7,a
clr enable
ret
delay:
mov r6,#5
d1:
mov r7,#248
djnz r7,$
djnz r6,d1
ret
tab:
db 30h,20h,31h,20h,32h,20h,20h,20h,20h,20h,20h,20h,20h,20h
db 20h,20h,20h,20h,20h,20h,20h,20h,20h

end