.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
rcall LCDIni
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数据传送到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:
;忙位检测
cbi ddra,7 ;设置PA的第七位为读入
cbi portc,rs
sbi portc,rw
sbi portc,en
c_lp:
sbIC PINa,7 ;为零时就退出
rjmp c_lp
cbi portc,en
sbi ddra,7
ret
;-----------------------------------------
上一篇:AVR串口中断模式程序实例
下一篇:12864(ICCAVR程序)
推荐阅读最新更新时间:2024-03-16 15:49