.include "8515def.inc"
.equ rs=0
.equ rw=1
.equ en=2
.org $000
rjmp reset
reset:
.org $010
ldi r16,low(ramend)
ldi r17,high(ramend)
out spl,r16
out sph,r17
main:
ser r16
out ddra,r16
out porta,r16
out ddrc,r16
out portc,r16
rcallLCDIni
ldi r16,$84
rcall WrOp
ldi r16,'a'
rcall WrDat
ldi r16,'b'
rcall WrDat
ldi r16,'c'
rcall WrDat
ldi r16,$c4
rcall WrOp
ldi r16,'d'
rcall WrDat
ldi r16,'e'
rcall WrDat
ldi r16,'f'
rcall WrDat
ldi r16,'g'
rcall WrDat
me:
rjmp me
;end of main
;------------------------------------------
LcdIni:
ldi r16,$38
rcall WrOp
nop
nop
ldi r16,$06
rcall WrOp
ldi r16,$0c
rcall WrOp
ret
;------------------------------------------
WrOp:
;將R16命令字傳送到LCD
rcall check
cbi portc,rs
cbi portc,rw
cbi portc,en
out porta,r16
sbi portc,en
ldi r16,200
wo_lp:
dec r16
brne wo_lp
cbi portc,en
ret
;------------------------------------------
WrDat:
;將R16數(shù)據(jù)傳送到LCD
rcall check
sbi portc,rs
cbi portc,rw
cbi portc,en
out porta,r16
sbi portc,en
ldi r16,200
wd_lp:
dec r16
brne wd_lp
cbi portc,en
ret
;-----------------------------------------
check:
;忙位檢測(cè)
cbi ddra,7;設(shè)置PA的第七位為讀入
cbi portc,rs
sbi portc,rw
sbi portc,en
c_lp:
sbICPINa,7;為零時(shí)就退出
rjmp c_lp
cbi portc,en
sbi ddra,7
ret
;-----------------------------------------