|
;这个算下来也只有0.998抄
T_0: MOV R7,#10;
D1: MOV R6,#200;
D2: MOV R5,#248;
DJNZ R5,$
DJNZ R6,D2;
DJNZ R7,D1;
RET
;这样算下来应该是1.000011秒
T_0: MOV R7,#10;
D1: MOV R6,#200;
D2: NOP
MOV R5,#248;
DJNZ R5,$
DJNZ R6,D2;
DJNZ R7,D1;
RET
DELAY_2S: ;10MS(11.0592mhz)
MOV R3,#200
JMP DELAY10MS
DELAY_100MS: ;100MS(11.0592mhz)
MOV R3,#10
JMP DELAY10MS
DELAY_10MS:
MOV R3,#1
DELAY10MS: ;去抖动10MS
(11.0592mhz)
MOV R4,#20
DELAY10MSA:
MOV R5,#247
DJNZ R5,$
DJNZ R4,DELAY10MSA
DJNZ R3,DELAY10MS
RET
DELAY_500MS: ;500500MS
MOV R2,#208
JMP DELAY_MS
DELAY_175MS: ;175MS
MOV R2,#73
JMP DELAY_MS
delaY_120MS: ;120MS
MOV R2,#50
JMP DELAY_MS
delay_60ms: ;60ms
MOV R2,#25
JMP DELAY_MS
delay_30ms: ;30ms
MOV R2,#12
JMP DELAY_MS
DELAY_5MS: ;5MS
MOV R2,#2
;===================================
DELAY_MS:
CALL DELAY2400
DJNZ R2,DELAY_MS
RET
;===================================
DELAY2400: ;10x244+4=2447
/1.024=2390
MOV R0,#244 ;1
DELAY24001:
MUL AB ;4
MUL AB ;4
DJNZ R0,DELAY24001 ;2
RET
DELAY: ;延时子程序(1秒)
MOV R0,#0AH
DELAY1: MOV R1,#00H
DELAY2: MOV R2,#0B2H
DJNZ R2,$
DJNZ R1,DELAY2
DJNZ R0,DELAY1
RET
MOV R2,#10 ;延时1秒
LCALL DELAY
MOV R2,#50 ;延时5秒
LCALL DELAY
DELAY: ;延时子程序
PUSH R2
PUSH R1
PUSH R0
DELAY1: MOV R1,#00H
DELAY2: MOV R0,#0B2H
DJNZ R0,$
DJNZ R1,DELAY2 ;延时 100 mS
DJNZ R2,DELAY1
POP R0
POP R1
POP R2
RET |
|