现在问题是,上电能显示654321,可当按下P1.3口接的按键时,6 个数码管都不会亮了,程序哪里出了问题
org 0000h
jmp start
org 0003h
reti
org 000bh
reti
org 0013h
jmp wzd1
org 001bh
reti
org 0023h
reti
wzd1: push psw ;外中断入口
push acc
clr ea
clr ex1
jnb p1.3,key3 1.3为0时转KEY3
wzdfh:pop acc ;外中断返回
pop psw
setb ea
setb ex1
reti
key3:call delay10ms
jb p1.3,wzdfh
l1: jnb p1.3,$
inc 31h 1.3松开时31H加1
mov a,#10
cjne a,31h,wzdfh ;31H中不等于10中断返回
clr a
mov 31h,a ;31H中的数据清0并对下一地址中的数据加一
inc 32h
mov a,#10
cjne a,32h,wzdfh
clr a
mov 32h,a
inc 33h
mov a,#10
cjne a,33h,wzdfh
clr a
mov 33h,a
inc 34h
mov a,#10
cjne a,34h,wzdfh
clr a
mov 34h,a
inc 35h
mov a,#10
cjne a,35h,wzdfh
clr a
mov 35h,a
inc 36h
mov a,#10
cjne a,36h,wzdfh
clr a
mov 36h,a
jmp wzdfh
start:mov 31h,#1
mov 32h,#2
mov 33h,#3
mov 34h,#4
mov 35h,#5
mov 36h,#6
clr p1.5
setb ea
setb ex1
start1:call display
jmp start1
display:mov r1,#31h
mov r2,#00000001
play: mov p0,#0ffh
mov a,r2
mov p2,a
mov a,@r1
mov dptr,#tab
movc a,@a+dptr
mov p0,a
call delay1ms
inc r1
mov a,p2
jb acc.5,endout
rl a
mov r2,a
mov p2,#0h
jmp play
endout:mov p0,#0ffh
mov p2,#0
ret
delay1ms:mov r3,#2
d1: mov r4,#250
d2: djnz r4,$
djnz r3,d1
ret
delay10ms: call play ;10ms子程序,调用一次显示子程序约6ms,调两次约12ms
call play
ret
tab:db 48h,0ebh,52h,62h,0e1h,64h,44h,0eah,40h,60h
end |
|