电路图
代码如下
ORG 0000H
LJMP MAIN
ORG 0003H
LJMP PINT0
ORG 000BH
LJMP T0INT
ORG 0040H
COUNT EQU 30H
MAIN: MOV SP,#40H
SETB EA
SETB IT0
AGAIN:MOV P1,#0FFH
CLR P3.6
CLR F0
JB P3.0,$
SETB EX0
SETB P3.6
MOV COUNT,#00H
MOV TMOD,#01H
MOV TH0,#3CH
MOV TL0,#0B0H
SETB TR0
SETB ET0
WAIT: JB F0,AGAIN
MOV A,COUNT
CLR C
SUBB A,#200
JC WAIT
CLR TR0
SJMP AGAIN
T0INT: MOV TH0,#3CH
MOV TL0,#0B0H
INC COUNT
RETI
PINT0: CLR EX0
CLR P3.6
SETB F0
MOV P1,P2
LCALL DELAY
RETI;中断返回,并且清空中断标志位
DELAY: MOV R5,#20
D1:MOV R6,#200
D2:MOV R7,#248
DJNZ R7,$
DJNZ R6,D2
DJNZ R5,D1
RET
END