單片機打鈴器設計
st z,temp
rcall display
sbis pinb,5
rjmp cloc ;進入時間設置
dec temp3
brne BP4M2
inc temp3
dec temp4
brne BP4M2
BP4M3: ldi temp3,$ff
ldi temp4,$f
BP4M4: clr yh
ldi yl,low(DISBUF) ;設置顯示labor.
ldi temp,25
st y+,temp
ldi temp,19
st y+,temp
ldi temp,10
st y+,temp
ldi temp,11
st y+,temp
ldi temp,20
st y+,temp
ldi temp,22
st y,temp
ldi zl,low(XSDBZ)
clr zh
ldi temp,0b00100000 ;b0-5對應LED自左到右1-6位的小數(shù)點,置“1”在該位置小數(shù)點。
st z,temp
rcall display
sbis pinb,5
rjmp GNCS1 ;進入工作參數(shù)設置
dec temp3
brne BP4M4
inc temp3
dec temp4
brne BP4M4
sbic pinb,4
rjmp BP4M
rjmp res1
;****時鐘調(diào)整***********************************************
cloc: clr temp
out timsk,temp ;不許T0中斷
cli ;關中斷
rcall colodis
mov temp,r10
clr temp4
ldi temp1,20
ldi temp3,$80
cloc3: ldi yl,low(DISBUF)
add yl,temp4
sbic pinb,5 ;選擇時分秒
rjmp cloc4
dec temp1
brne cloc4
ldi temp1,80
inc temp4
inc temp4
add yl,temp4
cpi yl,$68
brmi cloc4
clr temp4
ldi yl,low(DISBUF)
cloc4: nop
sbic pinb,6 ;調(diào)整時分秒值
rjmp cloc8
dec temp3
brne cloc8
ldi temp3,$20
cloc5: cpi yl,$60
brne cloc6
inc r10
mov temp,r10
cpi temp,24
brmi cloc8
clr temp
clr r10
cloc6: cpi yl,$62
brne cloc7
inc r11
mov temp,r11
cpi temp,60
brmi cloc8
clr temp
clr r11
cloc7: cpi yl,$64
brne cloc8
inc r12
mov temp,r12
cpi temp,60
brmi cloc8
clr temp
clr r12
cloc8: cpi yl,$60
brne cloc9
ldi zl,low(XSDBZ)
clr zh
ldi temp,0b00000010 ;b0-5對應LED自左到右1-6位的小數(shù)點,置“1”在該位置小數(shù)點。
st z,temp
mov r16,r10
rjmp cloc11
cloc9: cpi yl,$62
brne cloc10
ldi zl,low(XSDBZ)
clr zh
ldi temp,0b00001000 ;b0-5對應LED自左到右1-6位的小數(shù)點,置“1”在該位置小數(shù)點。
st z,temp
mov r16,r11
cloc10: cpi yl,$64
brne cloc11
ldi zl,low(XSDBZ)
clr zh
ldi temp,0b00100000 ;b0-5對應LED自左到右1-6位的小數(shù)點,置“1”在該位置小數(shù)點。
st z,temp
mov r16,r12
cloc11: rcall bto
st y+,r3
st y,r4
rcall display
sbis pinb,4 ;退出
rjmp cloc12
rjmp cloc3
cloc12: ldi temp,$02
out timsk,temp ;允許T0中斷
sei ;開中斷
rjmp res1
;****32點打鈴器工作參數(shù)調(diào)整**********************************************************
GNCS1: clr r25 ;首個控制點
clr r22 ;r22為0顯示開關頁面,為1顯示h-xx頁面,為2顯示m-xx頁面,為3顯示c-xx頁面
ldi zl,low(XSDBZ)
clr zh
ldi r19,0b00000010
st z,r19
gncs: ldi r17,TIMECTR ;首個控制點EEPRON地址
clr r18
ldi yl,low(DISBUF) ;設置顯示緩沖區(qū)起始地址
clr yh
lsl r25
lsl r25
add r17,r25 ;取得EEPRON中控制點地址(Aj=A0+4*j),A=(r17),j=(r25)
lsr r25
lsr r25
mov r16,r25
rcall bto
st y+,r3
st y+,r4
cpi r22,0
breq kgymxs
cpi r22,1
breq hymxs
cpi r22,2
breq mymxs
cpi r22,3
breq cymxs
clr r22
rjmp gncs
kgymxs: rcall EERead
cpi r16,0
brne offxs
ldi r23,27 ;顯示xx.--on
st y+,r23
st y+,r23
ldi r23,20
st y+,r23
ldi r23,26
st y,r23
rjmp gzcsxs
offxs: ldi r23,27 ;顯示xx.-off
st y+,r23
ldi r23,20
st y+,r23
ldi r23,15
st y+,r23
st y,r23
rjmp gzcsxs
hymxs: ldi r23,28 ;顯示xx.h-aa
st y+,r23
ldi r23,27
st y+,r23
inc r17
rcall EERead
rcall bto
st y+,r3
st y+,r4
dec r17
rjmp gzcsxs
mymxs: ldi r23,26 ;顯示xx.n-aa
st y+,r23
ldi r23,27
st y+,r23
inc r17
inc r17
rcall EERead
rcall bto
st y+,r3
st y+,r4
dec r17
dec r17
rjmp gzcsxs
cymxs: ldi r23,18 ;顯示xx.c-aa
st y+,r23
ldi r23,27
st y+,r23
inc r17
inc r17
inc r17
rcall EERead
rcall bto
st y+,r3
st y+,r4
dec r17
dec r17
dec r17
gzcsxs: ldi r23,40
ldi r24,40
gzcsxs1: rcall display
sbis pinb,5 ;翻頁
rjmp fycz ;有,去翻頁
sbis pinb,6 ;變值
rjmp bzcz ;有,去變值
sbis pinb,4 ;復位
rjmp res1 ;有,去復位
rjmp gncs
評論