avr: "Utils_WaitNanoSecs 100000" doesn't work at 8MHz (too many cycles).

This commit is contained in:
Martin Preuss
2024-09-13 21:40:22 +02:00
parent cdcb4e2b3e
commit 2d09e22ec6
2 changed files with 22 additions and 7 deletions

View File

@@ -11,14 +11,28 @@
; --------------------------------------------------------------------------- ; ---------------------------------------------------------------------------
; @routine Utils_WaitFor10MicroSecs @global
;
; wait for 10 microsecs (minus cycles for call and ret). ; wait for 10 microsecs (minus cycles for call and ret).
; ;
; IN: ; @clobbers r22
; - nothing
; OUT:
; - nothing
; REGS: r22
Utils_WaitFor10MicroSecs: Utils_WaitFor10MicroSecs:
Utils_WaitNanoSecs 10000, 7, r22 ; wait for 10us (minus RCALL and RET) Utils_WaitNanoSecs 10000, 7, r22 ; wait for 10us (minus RCALL and RET)
ret ret
; @end
; ---------------------------------------------------------------------------
; @routine Utils_WaitFor50MicroSecs @global
;
; wait for 50 microsecs (minus cycles for call and ret).
;
; @clobbers r22
Utils_WaitFor50MicroSecs:
Utils_WaitNanoSecs 50000, 7, r22 ; wait for 50us (minus RCALL and RET)
ret
; @end

View File

@@ -294,8 +294,9 @@ si7021MeasureAny_loop: ; (R22)
rcall twiSendByteExpectAck ; (R16, R17, R18, R22) rcall twiSendByteExpectAck ; (R16, R17, R18, R22)
brcs si7021MeasureAny_gotValue ; chip responds, receive values brcs si7021MeasureAny_gotValue ; chip responds, receive values
dec r14 dec r14
breq si7021MeasureAny_error ; timeout breq si7021MeasureAny_error ; timeout
Utils_WaitNanoSecs 100000, 0, r22 rcall Utils_WaitFor50MicroSecs ; wait for 100usecs total
rcall Utils_WaitFor50MicroSecs
rjmp si7021MeasureAny_loop rjmp si7021MeasureAny_loop
si7021MeasureAny_gotValue: si7021MeasureAny_gotValue: