ORG 0000H
SETB TR0 ;启动T0
CLR P1.2
SETB P1.3
LP1:
MOV R2, #50 ;定时计数初值
LOOP:
MOV TH0, #(8192 - 5000) / 32 ;定时10ms
MOV TL0, #(8192 - 5000) MOD 32
JNB TF0, $ ;等待8ms
CLR TF0
DJNZ R2, LOOP ;每隔10ms,R2减一次一
CPL P1.2 ;R2为0则LED亮灭转换
CPL P1.3 ;R2为0则LED亮灭转换
LJMP LP1
END
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#01H
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB ET0
SETB EA
SETB TR0
CLR P1.2
SETB P1.3
MOV R2,#5
SJMP $
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
DJNZ R2,T0E
MOV R2,#5
CPL P1.2
CPL P1.3
T0E:
RETI
END