diff code_part1/OSTC_code_asm_part1/altimeter.asm @ 162:fdebc43c8372

Fix altimeter auto-reset
author JeanDo
date Fri, 21 Jan 2011 01:48:40 +0100
parents 48f12271eb18
children 80de93d72a17
line wrap: on
line diff
--- a/code_part1/OSTC_code_asm_part1/altimeter.asm	Tue Jan 18 23:57:33 2011 +0100
+++ b/code_part1/OSTC_code_asm_part1/altimeter.asm	Fri Jan 21 01:48:40 2011 +0100
@@ -29,10 +29,15 @@
 altimeter_calc:
         movlb   HIGH(pressureAvg)
         
-        movf    pressureRef+0,W         ; Already initialized ?
-        iorwf   pressureRef+1,W
-        bnz     altimeter_1             ; Yes...
-            
+        movlw   HIGH(4*.1100)           ; Is presure ref lower than 900mbar
+        cpfslt  pressureRef+1
+        bra     altimeter_1             ; No: ok it is valid...
+        
+        movlw   HIGH(4*.1100)           ; Is ref pressure bigger than 1100mbar ?
+        cpfsgt  pressureRef+1
+        bra     altimeter_1             ; No: ok it is valid...
+
+altimeter_0:            
         movlw   LOW(4*.1013+1)          ; Init see level at 1013,25 mbar.
         movwf   pressureRef+0
         movlw   HIGH(4*.1013+1)