COUNT_INT EQU 30H
ORG 0000H
LJMP START
ORG 000BH
LJMP Timer0Interrupt
START:
MOV SP,#60H
LCALL InitTimer0
SETB P1.1;拉高
LOOP:
LJMP LOOP
InitTimer0:
MOV TMOD,#02H;t0方式2 定时200us@12MHz
MOV TH0,#00H
MOV TL0,#38H
SETB EA
SETB ET0
SETB TR0
RET
Timer0Interrupt:
PUSH DPH
PUSH DPL
PUSH ACC
MOV TH0,#00H
MOV TL0,#38H
;========================
INC COUNT_INT ;200US加1
MOV A,COUNT_INT
CJNE A,#2,Timer0Interrupt2
CLR P1.1;开始拉低
AJMP Timer0Interrupt_EXIT
Timer0Interrupt2:
CJNE A,#5,Timer0Interrupt_EXIT
MOV COUNT_INT,#0
SETB P1.1;开始拉高
AJMP Timer0Interrupt_EXIT
Timer0Interrupt_EXIT:
;========================
POP ACC
POP DPL
POP DPH
RETI
END