昨天闷头敲了一个下午的代码,信心满满的用protues仿真,结果成了这么个模样,虽然没有报错,但根本不是我要的结果!!本人设计电路的功能:8个数码管完成时间的显示;按左下角的第一个按钮可将小时(hour)上调,按第二个按钮可将hour下调;按第三个按钮可将分钟(minute)上调;按第四个按钮可将 minute下调。
但是在现示时,8个管都是先同时显示1,然后过一段时间就显示图中的1,四个按钮按下了也没用;本人自觉应该与中断有关,但不知是哪里的错误
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
minute equ 41h
hour equ 42h
second_gewei equ 43h
second_shiwei equ 44h
minute_gewei equ 45h
minute_shiwei equ 46h
hour_gewei equ 47h
hour_shiwei equ 48h
;------------------------------------------
org 0000h
ajmp start
org 000bh
ljmp t0_zhongduan
org 0030h
;--------------初始化----------------------
start: mov sp, #60h
mov second, #0
mov minute, #0
mov hour, #12
mov 30h, #0
mov dptr, #table
mov tmod, #00000001b
mov tcon, #00010000b
mov th0, #003ch
mov tl0, #00b0h
setb et0
setb ea
;------引脚初始化----------
mov p0, #0ffh
mov p1, #0ffh
mov p2, #0ffh
;---------------主程序--------------------
main: call key
call process
call display
sjmp main
;-----------------------------------------
key: jnb p1.4, hour_jia
jnb p1.5, hour_jian
jnb p1.6, minute_jia
jnb p1.7, minute_jian
fanhui: ret
hour_jia: call delay
jb p1.4, fanhui
panduan1: jnb p1.4, dis1
mov a, hour
cjne a, #24,jixu1
sjmp fanhui
jixu1: inc hour
ret
dis1: call display
sjmp panduan1
hour_jian: call delay
jb p1.5, fanhui
panduan2: jnb p1.5, dis2
mov a, hour
cjne a, #0, jixu2
sjmp fanhui
jixu2: dec hour
ret
dis2: call display
sjmp panduan2
minute_jia: call delay
jb p1.6, fanhui
panduan3: jnb p1.6, dis3
mov a, minute
cjne a, #60, jixu3
sjmp fanhui
jixu3: inc minute
ret
dis3: call display
sjmp panduan3
minute_jian: call delay
jb p1.7, fanhui
panduan4: jnb p1.7, dis4
mov a, minute
cjne a, #0, jixu4
sjmp fanhui
jixu4: dec minute
ret
dis4: call display
sjmp panduan4
;-------------------------------------
process: mov a, hour
mov b, #10
div ab
mov hour_shiwei, a
mov hour_gewei, b
mov a, minute
mov b, #10
div ab
mov minute_shiwei, a
mov minute_gewei, b
mov a, second
mov b, #10
div ab
mov second_shiwei, a
mov second_gewei, b
ret
;------------------------------------
display: mov a, hour_shiwei
movc a, @a+dptr
mov p2, #11111110b
mov p0, a
call delay
mov p2, #11111111b
mov a, hour_gewei
movc a, @a+dptr
mov p2, #11111101b
mov p0, a
call delay
mov p2, #11111111b
mov p2, #11111011b
mov p0, #11111101b
call delay
mov p2, #11111111b
mov a, minute_shiwei
movc a, @a+dptr
mov p2, #11110111b
mov p0, a
call delay
mov p2, #11111111b
mov a, minute_gewei
movc a, @a+dptr
mov p2, #11101111b
mov p0, a
call delay
mov p2, #11111111b
mov p2, #11011111b
mov p0, #11111101b
call delay
mov p2, #11111111b
mov a, second_shiwei
movc a, @a+dptr
mov p2, #10111111b
mov p0, a
call delay
mov p2, #11111111b
mov a, second_gewei
movc a, @a+dptr
mov p2, #01111111b
mov p0, a
call delay
mov p2, #11111111b
ret
;-----------------------------------------------
t0_zhongduan: push acc
inc 30h
mov a, 30h
cjne a, #20, jixu
mov 30h, #0
inc second
mov a, second
cjne a, #60, jixu
mov second, #0
inc minute
mov a, minute
cjne a, #60, jixu
mov minute, #0
inc hour
mov a, hour
cjne a, #24, jixu
mov hour, #0
jixu: pop acc
mov th0, #3ch
mov tl0, #0b0h
reti
;------------------------------------------------
delay: mov r7, #5
d1: mov r6, #10
d2: djnz r6, d2
djnz r7, d1
;------------------------------------------------
table: db 0c0h, 0f9h, 0a4h, 0b0h
db 99h, 92h, 82h, 0f8h
db 80h, 90h
end
一周热门 更多>