diff src/wait.asm @ 623:c40025d8e750

3.03 beta released
author heinrichsweikamp
date Mon, 03 Jun 2019 14:01:48 +0200
parents ca4556fb60b9
children 4050675965ea
line wrap: on
line diff
--- a/src/wait.asm	Wed Apr 10 10:51:07 2019 +0200
+++ b/src/wait.asm	Mon Jun 03 14:01:48 2019 +0200
@@ -1,6 +1,6 @@
 ;=============================================================================
 ;
-;   File wait.asm														V2.98c
+;   File wait.asm                             combined next generation V3.02.1
 ;
 ;   Wait routines
 ;
@@ -13,39 +13,41 @@
 
 #include "hwos.inc"
 
-wait		CODE
-
-
-; ==========================================================
-; WAIT 1 second (Warning: Do not use for time critical routines. Can be between 0 and 1 sec!)
-; ==========================================================
-	global	wait_1s
-wait_1s:
-	; Wait until "next second" flag is set
-	bcf		onesecupdate
-	btfss	onesecupdate
-	bra		$-2
-	return
+wait	CODE
 
 
 ; =============================================================================
-; WAIT 1 MILLISECOND   (Not exact: 1,008ms +/- 30,5µs + worst case ISR latency)
+; WAIT 1 second
+; Warning: Do not use for time critical routines - can be between 0 and 1 sec!
+; =============================================================================
+
+	global	wait_1s
+wait_1s:
+	bcf		trigger_full_second	; clear any left-over trigger
+	btfss	trigger_full_second	; did a new trigger occurred?
+	bra		$-2					; NO  - loop
+	return						; YES - done
+
+
+; =============================================================================
+; WAIT for multiples of 1 Millisecond
+; Remark: not exact: 1.008 ms +/- 30.5 µs + worst case ISR latency
 ; =============================================================================
 
 	global	WAITMSX
 WAITMSX:
-	movwf	wait_counter
+	movwf	wait_counter		; store number of milliseconds to wait
 WAITMSX2:
-	setf	TMR5H
-	movlw	.255-.32 			; 32 x 31,5µs = 1,008ms
-	movwf	TMR5L
-	bcf		PIR5,TMR5IF			; clear flag
+	setf	TMR5H				; initialize timer 5, high byte first
+	movlw	.255-.32 			; 32 x 31.5 µs = 1.008 ms
+	movwf	TMR5L				; initialize timer 5, low  byte thereafter
+	bcf		PIR5,TMR5IF			; clear timer 5 overrun flag
 WAITMSX3:
-	btfss	PIR5,TMR5IF
-	bra		WAITMSX3			; wait loop
-	decfsz	wait_counter,F
-	bra		WAITMSX2
-	return
+	btfss	PIR5,TMR5IF			; did timer 5 overrun?
+	bra		WAITMSX3			; NO  - repeat inner loop
+	decfsz	wait_counter,F		; YES - decrement number of milliseconds to do, done?
+	bra		WAITMSX2			;       NO  - repeat outer loop
+	return						;       YES - done
 
 ;=============================================================================