汇编程序如下,本来是要等P3.5引脚有下降沿信号,计数器T1加1溢出 才进入中断, 现在单片上电复位运行该程序,P3.5是高电平,并没有输入低电平下降沿信号,结果发现已经进入中断,P1口一直输出A0H。
想了几天,不知道是什么原因。
MOV 20H,#00H
MOV 21H,#00H
MOV P1,#0C0H
ORG 1BH
AJMP IT1P
MOV TMOD,#60H
MOV TL1,#0FFH
MOV TH1,#0FFH
SETB ET1
SETB EA
SETB TR1
SJMP $ ;程序踏步,等待单片机P3.5引脚由高电平到低电平下降沿的到来
FAN1: LJMP FAN
IT1P: JB P3.7,FAN1
JB 00H,LOOP0
JB 01H,LOOP1
JB 02H,LOOP2
JB 03H,LOOP3
JB 04H,LOOP4
JB 05H,LOOP5
JB 06H,LOOP6
JB 07H,LOOP7
LOOP0: CLR TR1
MOV P1,#0D0H
MOV 20H,#02H
MOV 21H,#40H
LCALL DEL1S
AJMP QUIT
LOOP1: CLR TR1
MOV P1,#090H
MOV 20H,#04H
MOV 21H,#20H
LCALL DEL1S
AJMP QUIT
LOOP2: CLR TR1
MOV P1,#0B0H
MOV 20H,#08H
MOV 21H,#10H
LCALL DEL1S
AJMP QUIT
LOOP3: CLR TR1
MOV P1,#030H
MOV 20H,#10H
MOV 21H,#08H
LCALL DEL1S
AJMP QUIT
LOOP4: CLR TR1
MOV P1,#070H
MOV 20H,#20H
MOV 21H,#04H
LCALL DEL1S
AJMP QUIT
LOOP5: CLR TR1
MOV P1,#060H
MOV 20H,#40H
MOV 21H,#02H
LCALL DEL1S
AJMP QUIT
LOOP6: CLR TR1
MOV P1,#0E0H
MOV 20H,#80H
MOV 21H,#01H
LCALL DEL1S
AJMP QUIT
LOOP7: CLR TR1
MOV P1,#0C0H
MOV 20H,#01H
MOV 21H,#80H
LCALL DEL1S
AJMP QUIT
FAN: JB 08H,LOOQ0
JB 09H,LOOQ1
JB 0AH,LOOQ2
JB 0BH,LOOQ3
JB 0CH,LOOQ4
JB 0DH,LOOQ5
JB 0EH,LOOQ6
JB 0FH,LOOQ7
LOOQ0: CLR TR1
MOV P1,#0A0H
MOV 21H,#02H
MOV 20H,#40H
LCALL DEL1S
AJMP QUIT
LOOQ1: CLR TR1
MOV P1,#0E0H
MOV 21H,#04H
MOV 20H,#20H
LCALL DEL1S
AJMP QUIT
LOOQ2: CLR TR1
MOV P1,#0C0H
MOV 21H,#08H
MOV 20H,#10H
LCALL DEL1S
AJMP QUIT
LOOQ3: CLR TR1
MOV P1,#0D0H
MOV 21H,#10H
MOV 20H,#08H
LCALL DEL1S
AJMP QUIT
LOOQ4: CLR TR1
MOV P1,#050H
MOV 21H,#20H
MOV 20H,#04H
LCALL DEL1S
AJMP QUIT
LOOQ5: CLR TR1
MOV P1,#070H
MOV 21H,#40H
MOV 20H,#02H
LCALL DEL1S
AJMP QUIT
LOOQ6: CLR TR1
MOV P1,#030H
MOV 21H,#80H
MOV 20H,#01H
LCALL DEL1S
AJMP QUIT
LOOQ7: CLR TR1
MOV P1,#0B0H
MOV 21H,#01H
MOV 20H,#80H
LCALL DEL1S
QUIT: SETB TR1
RETI
DEL1S:MOV R7,#10
D1:MOV R6,#200
D2:MOV R5,#250
DJNZ R5,$
DJNZ R6,D2
DJNZ R7,D1
RET
END |