diff code_part1/OSTC_code_asm_part1/wait.asm @ 486:c7b663939737

making waitms speed-independent, desat-time fix
author heinrichsweikamp
date Sat, 15 Oct 2011 15:03:53 +0200
parents e83f883c96b2
children 33abbc08f01e
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/wait.asm	Sat Oct 15 13:45:15 2011 +0200
+++ b/code_part1/OSTC_code_asm_part1/wait.asm	Sat Oct 15 15:03:53 2011 +0200
@@ -81,66 +81,22 @@
 			goto	WAIT10USX2
 			return
 ; ==========================================================
-; 	WAIT 1 MILLISECOND  -  16 MHZ
+; 	WAIT 1 MILLISECOND  -  Working with TMR1
 ; ==========================================================
-	IFDEF	SPEED_16MHz
-WAITMS		macro	waitms_temp
-			movlw	waitms_temp
-			call WAITMSX
-			endm
-	ENDIF
-
-	IFDEF	SPEED_32MHz
 WAITMS		macro	waitms_temp
 			movlw	waitms_temp
-			call WAITMSX
-			movlw	waitms_temp
-			call WAITMSX
+			call 	WAITMSX
 			endm
-	ENDIF
+
+WAITMSX		movwf	waitms_temp			; Holds number of ms to wait
 
-WAITMSX		movwf	waitms_temp
-			goto	JumpInMSX
-WAITMSX2	nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-JumpInMSX:
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			nop
-			WAIT10US d'99'
-			decfsz	waitms_temp,1
-			goto	WAITMSX2
+WAITMSX1:
+			movf	TMR1L,W
+			addlw	d'66'				; 66*15,26µs ~ 1ms
+
+WAITMSX2	cpfseq	TMR1L
+			bra		WAITMSX2			; loop here...
+
+			decfsz	waitms_temp,F
+			bra		WAITMSX1
 			return
\ No newline at end of file