无法实现喂狗过程,实在找不出那里的错误,请求各位帮助!!
org 0000h
ajmp main
org 0003h
ajmp YKJC
c_1 EQU 91h
b_bit EQU 92h
djs EQU 93h
shuzhi EQU 94h
jishu EQU 95h
d0 bit P1.1
d1 bit P1.2
d2 bit P1.3
d3 bit P1.4
d4 bit P1.6
d5 bit P1.7
wdog bit P1.5 看门狗喂狗引脚
org 001Bh
dingshi: clr EA
push Acc
push PSW
mov TH1,#0ech ;5ms定时重装初值 定时器1中断喂狗程序
mov TL1,#78h
setb wdog
setb TR1
setb ET1
clr TF1
lcall Delay
clr wdog
pop PSW
pop Acc
setb EA
RETI
org 0030h
main: mov P1,#00h
setb P3.2
mov TMOD,#10h
mov TH1,#0ech ;5ms定时
mov TL1,#78h
setb EA
setb TR1
setb ET1
clr TF1
setb EX0
setb IT0
;Traffic lights 5 conditions
Traffic: mov c_1,#4
CONDIT1: ;nanbei hong dongxi hong
mov P2,#6ch
mov djs,c_1
acall Shuxian
acall Shuxian
djnz c_1,CONDIT1
mov djs,#0
acall Shuxian
acall Shuxian
mov c_1,#40
CONDIT2: ;nanbei lv dongxi hong
mov P2,#0cch
mov djs,c_1
acall Shuxian
acall Shuxian
dec c_1
mov R0,c_1
cjne R0,#3,CONDIT2
next2: mov djs,c_1
mov P2,#0ech
acall Shuxian
mov P2,#0cch
acall Shuxian
djnz c_1,next2
mov djs,#0
mov P2,#0ech
acall Shuxian
mov P2,#0cch
acall Shuxian
mov c_1,#3
CONDIT3: ;nanbei huang dongxi hong
mov P2,#0ach
mov djs,c_1
acall Shuxian
acall Shuxian
djnz c_1,CONDIT3
mov djs,#0
acall Shuxian
acall Shuxian
mov c_1,#40
CONDIT4: ;nanbei hong dongxi lv
mov P2,#78h
mov djs,c_1
acall Shuxian
acall Shuxian
dec c_1
mov R1,c_1
cjne R1,#3,CONDIT4
next4: mov djs,c_1
mov P2,#7ch
acall Shuxian
mov P2,#78h
acall Shuxian
djnz c_1,next4
mov djs,#0
mov P2,#7ch
acall Shuxian
mov P2,#78h
acall Shuxian
mov c_1,#3
CONDIT5: ;nanbei hong dongxi huang
mov P2,#74h
mov djs,c_1
acall Shuxian
acall Shuxian
djnz c_1,CONDIT5
mov djs,#0
acall Shuxian
acall Shuxian
ljmp main
Shuxian: mov shuzhi,djs
Loop: mov A,shuzhi
mov B,#10
DIV AB
mov b_bit,A
mov jishu,#10
del_1s: mov TMOD,#01h
mov TH0,#3ch
mov TL0,#0b0h
SETB EA
SETB TR0
acall Display
JNB TF0,$
clr TF0
DJNZ jishu,del_1s
ret
TAB: DB 0c0h,0f9h,0a4h,0b0h,99h
DB 92h,82h,0f8h,80h,90h
Delay: mov R5,#02h ;1ms延时子程序
delay1: mov R4,#0ffh
delay2: DJNZ R4,delay2
DJNZ R5,delay1
ret
Display:mov R6,#4 ;显示部分
Dis: mov DPTR,#TAB
mov A,b_bit
movc A,@A+DPTR
mov P0,A
setb P3.6
acall Delay
clr P3.6
mov A,B
mov DPTR,#TAB
movc A,@A+DPTR
mov P0,A
setb P3.7
acall Delay
clr P3.7
DJNZ R6,Dis
ret
YKJC: clr EA 遥控控制部分,外部中断0
push Acc
push PSW
jb d0,CONDIT
jb d1,CONDIT
jb d2,CONDIT
jb d3,CONDIT
jb d4,CONDIT
jb d5,CONDIT
ajmp next
CONDIT: mov P2,#6ch
next: pop PSW
pop Acc
setb EX0
setb IT0
setb EA
RETI
end |