ORG 00H
AJMP MAIN
ORG 0BH
AJMP T0INT
ORG 30H
MAIN:
ACALL T0INIT
AJMP $
T0INIT:
MOV TMOD,#01H
MOV TH0,#0FFH
MOV TL0,#058H
SETB EA
SETB ET0
SETB TR0
RET
T0INT:
JB P1.0,SW_1
SETB P1.0
SW_9:
MOV TH0,#0FFH
MOV TL0,#58H ;358us
AJMP RTI
SW_1:
CLR P1.0
MOV TH0,#0FFH ;42us
MOV TL0,#0F7H
RTI:
RETI
END
;下列程序经过仿真试验,符合题目要求.
ORG 0000H
SJMP START
ORG 000BH
CLR P1.0
DJNZ R2, T0_END
MOV R2, #10
SETB P1.0
T0_END:
RETI
START:
MOV TMOD, #02H
MOV TH0, #(256 - 20) ;定时40us
MOV TL0, #(256 - 20)
SETB TR0
MOV IE, #82H
MOV R2, #10
SJMP $
END