From 8ece026f2dafe6eaefae39dece781a1a858b5df6 Mon Sep 17 00:00:00 2001 From: Martin Preuss Date: Tue, 20 May 2025 00:29:45 +0200 Subject: [PATCH] Add wait routines for milliseconds. --- avr/common/utils_wait_fixed.asm | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/avr/common/utils_wait_fixed.asm b/avr/common/utils_wait_fixed.asm index 9be3aba..f94569c 100644 --- a/avr/common/utils_wait_fixed.asm +++ b/avr/common/utils_wait_fixed.asm @@ -53,4 +53,41 @@ Utils_WaitFor100MicroSecs: +; --------------------------------------------------------------------------- +; @routine Utils_WaitFor1MilliSec @global +; +; wait for about 1ms. +; +; @clobbers r22 + +Utils_WaitFor1MilliSec: + push r21 + ldi r21, 10 +Utils_WaitFor1MilliSec_loop: + rcall Utils_WaitFor100MicroSecs ; (R22) + dec r21 + brne Utils_WaitFor1MilliSec_loop + pop r21 + ret +; @end + + + +; --------------------------------------------------------------------------- +; @routine Utils_WaitForMilliSecs @global +; +; wait for given amount of milliseconds +; @param r16 number of millisecs to wait +; @clobbers r22 + +Utils_WaitForMilliSecs: + rcall Utils_WaitFor100MicroSecs ; (R22) + dec r16 + brne Utils_WaitForMilliSecs + ret +; @end + + + +