elcielo
Full Member level 6
- Joined
- Jun 13, 2002
- Messages
- 383
- Helped
- 15
- Reputation
- 30
- Reaction score
- 8
- Trophy points
- 1,298
- Activity points
- 3,250
avr delay loop 1 us
1uS delay routine
1uS delay routine
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
;---------------> It is for AVRA assembler compiler.
.macro wait
.if @0 > 660
.error "Wait macro : too high wait value."
.endif
.if @0 == 1
nop
.endif
.if @0 == 2
rjmp loc0a
loc0a:
.endif
.if @0 == 3
rjmp loc1a
loc1a:
nop
.endif
.if @0 == 4
rjmp loc2a
loc2a: rjmp loc2b
loc2b:
.endif
.if @0 == 5
rjmp loc30
loc30: rjmp loc3a
loc3a:
nop
.endif
.if @0 == 6
rjmp loc4
loc4: rjmp loc4a
loc4a: rjmp loc4b
loc4b:
.endif
.if @0 == 7
rcall QRX07
.endif
.if @0 == 8
rcall QRX08
.endif
.if @0 == 9
rcall QRX09
.endif
.if @0 == 10
rcall QRX10
.endif
.if @0 > 10
ldi LAG,(@0-7)/3
.if (@0-7)%3==0
rcall make_lag0
.endif
.if (@0-7)%3==1
rcall make_lag1
.endif
.if (@0-7)%3==2
rcall make_lag2
.endif
.endif
.endmacro
make_lag2:
nop
make_lag:
nop
make_lag0:
dec LAG
brne make_lag0
ret
QRX10:
nop
QRX09:
nop
QRX08:
nop
QRX07:
ret
wait 10 ;you get 10 takts, T=1 uS
wait 541 ;you get 541 takts, T=54.1 uS
;....
rcall QRX10
;....
QRX10:
nop
nop
nop
ret
; 10 uS delay for Ft=10 MHz
nop
nop
nop
nop
nop ;5
nop
nop
nop
nop
nop ;10