2024年2月17日发(作者:硕访儿)
FLAG EQU 31H
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP TIMER0
INIT:
MOV P1,#00H
CLR FLAG
MOV A,#00
MOV 30H,#01H
MOV TMOD,#01H
MOV TH0,#0FFH
MOV TL0,#0FH
SETB EA
SETB ET0
SETB TR0
RET
MAIN:
LCALL INIT
HERE:
INC 30H
MOV R2,30H
LCALL DELAY
CJNE R2,#0AH,HERE
DECHE:
DEC 30H
MOV R3,30H
LCALL DELAY
CJNE R3,#01H,DECHE
LJMP HERE
TIMER0:
MOV TH0,#0FFH
MOV TL0,#0FH
INC A
JB FLAG ,KK
CJNE A,30H,L
KK:
SETB FLAG
MOV P1,#0FFH
CJNE A,#0AH,RE
MOV A,#00H
CLR FLAG
LJMP QING
L:
MOV P1,#00H
LJMP QING
RE:
MOV TH0,#0FFH
MOV TL0,#0FH
QING:
NOP
RETI
DELAY:
MOV R6,#0bfH
DELAY1:
MOV R5,#0fFH
LOOP:
DJNZ R5,LOOP
DELAY2:
MOV R7,#0FFH
DJNZ R7,$
DJNZ R6,DELAY1
RET
END
2024年2月17日发(作者:硕访儿)
FLAG EQU 31H
ORG 0000H
LJMP MAIN
ORG 000BH
LJMP TIMER0
INIT:
MOV P1,#00H
CLR FLAG
MOV A,#00
MOV 30H,#01H
MOV TMOD,#01H
MOV TH0,#0FFH
MOV TL0,#0FH
SETB EA
SETB ET0
SETB TR0
RET
MAIN:
LCALL INIT
HERE:
INC 30H
MOV R2,30H
LCALL DELAY
CJNE R2,#0AH,HERE
DECHE:
DEC 30H
MOV R3,30H
LCALL DELAY
CJNE R3,#01H,DECHE
LJMP HERE
TIMER0:
MOV TH0,#0FFH
MOV TL0,#0FH
INC A
JB FLAG ,KK
CJNE A,30H,L
KK:
SETB FLAG
MOV P1,#0FFH
CJNE A,#0AH,RE
MOV A,#00H
CLR FLAG
LJMP QING
L:
MOV P1,#00H
LJMP QING
RE:
MOV TH0,#0FFH
MOV TL0,#0FH
QING:
NOP
RETI
DELAY:
MOV R6,#0bfH
DELAY1:
MOV R5,#0fFH
LOOP:
DJNZ R5,LOOP
DELAY2:
MOV R7,#0FFH
DJNZ R7,$
DJNZ R6,DELAY1
RET
END