#include <sfr51.inc>
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0_ISR
ORG 0003H
LJMP E0_ISR
ORG 001BH
LJMP T1_ISR
ORG 0030H
MAIN: MOV TMOD,#12H
SETB IP.3
MOV TH0,#(-13)
SETB TR0
SETB EA
SETB ET0
SETB EX0
SETB IT0
CLR P1.4
MOV R7,#0
MOV R5,#100
LOOP: MOV A,R7
MOV B,#10
DIV AB
MOV DPTR,#LUT
MOVC A,@A+DPTR
MOV P0,A
clr P1.7
setb p1.6
ACALL DELAY
setb p1.7
MOV A,B
MOV DPTR,#LUT
MOVC A,@A+DPTR
MOV P0,A
clr p1.6
ACALL DELAY
setb p1.6
SJMP LOOP
RET
T0_ISR: CPL P1.5
RETI
E0_ISR: INC R7
CJNE R7,#20,TIEP
ACALL TIEPTUC
TIEP: CJNE R7,#40,TIEP1
ACALL TIEPTUC
TIEP1: CJNE R7,#60,TIEP2
ACALL TIEPTUC
TIEP2: CJNE R7,#80,TIEP3
ACALL TIEPTUC
TIEP3: CJNE R7,#100,EXIT
MOV R7,#0
ACALL TIEPTUC
EXIT: RETI
DELAY: MOV R0,#200
la:mov r6,#70
la1:
DJNZ R6,la1
djnz r0,la
RET
;SETB ET1
TIEPTUC:
SETB P1.4
SETB ET1
MOV TH1,#HIGH(-50000)
MOV TL1,#LOW(-50000)
SETB TR1
RET
T1_ISR:
CLR TR1
DJNZ R5,THOAT
CLR ET1
CLR P1.4
MOV R5,#100 ; 100x50ms =5s
ljmp kt
THOAT:
MOV TH1,#HIGH(-50000) ; 50ms
MOV TL1,#LOW(-50000)
setb tr1
kt:
RETI
LUT: DB 03H,9FH,25H,0DH,99H,49H,41H,1FH,01H,09H
END
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0_ISR
ORG 0003H
LJMP E0_ISR
ORG 001BH
LJMP T1_ISR
ORG 0030H
MAIN: MOV TMOD,#12H
SETB IP.3
MOV TH0,#(-13)
SETB TR0
SETB EA
SETB ET0
SETB EX0
SETB IT0
CLR P1.4
MOV R7,#0
MOV R5,#100
LOOP: MOV A,R7
MOV B,#10
DIV AB
MOV DPTR,#LUT
MOVC A,@A+DPTR
MOV P0,A
clr P1.7
setb p1.6
ACALL DELAY
setb p1.7
MOV A,B
MOV DPTR,#LUT
MOVC A,@A+DPTR
MOV P0,A
clr p1.6
ACALL DELAY
setb p1.6
SJMP LOOP
RET
T0_ISR: CPL P1.5
RETI
E0_ISR: INC R7
CJNE R7,#20,TIEP
ACALL TIEPTUC
TIEP: CJNE R7,#40,TIEP1
ACALL TIEPTUC
TIEP1: CJNE R7,#60,TIEP2
ACALL TIEPTUC
TIEP2: CJNE R7,#80,TIEP3
ACALL TIEPTUC
TIEP3: CJNE R7,#100,EXIT
MOV R7,#0
ACALL TIEPTUC
EXIT: RETI
DELAY: MOV R0,#200
la:mov r6,#70
la1:
DJNZ R6,la1
djnz r0,la
RET
;SETB ET1
TIEPTUC:
SETB P1.4
SETB ET1
MOV TH1,#HIGH(-50000)
MOV TL1,#LOW(-50000)
SETB TR1
RET
T1_ISR:
CLR TR1
DJNZ R5,THOAT
CLR ET1
CLR P1.4
MOV R5,#100 ; 100x50ms =5s
ljmp kt
THOAT:
MOV TH1,#HIGH(-50000) ; 50ms
MOV TL1,#LOW(-50000)
setb tr1
kt:
RETI
LUT: DB 03H,9FH,25H,0DH,99H,49H,41H,1FH,01H,09H
END
Comment