comparison code_part1/OSTC_code_asm_part1/altimeter.asm @ 132:49bb155ddfbf

Fix altimeter after simulator (zero divide -> 32767m)
author JeanDo
date Wed, 05 Jan 2011 00:14:44 +0100
parents 2907b42c195b
children 48f12271eb18
comparison
equal deleted inserted replaced
131:03df42de03e1 132:49bb155ddfbf
22 ; HISTORY 22 ; HISTORY
23 ; 2010-12-15 : [jDG] First prototype with quadratic polynomial ant tp°. 23 ; 2010-12-15 : [jDG] First prototype with quadratic polynomial ant tp°.
24 ; 2010-12-28 : [jDG] Use MPLAB Math and C libraries for FP32 computations. 24 ; 2010-12-28 : [jDG] Use MPLAB Math and C libraries for FP32 computations.
25 ; 2011-01-02 : [jDG] Edit reference pressure by 0.25 mbar. 25 ; 2011-01-02 : [jDG] Edit reference pressure by 0.25 mbar.
26 ; 26 ;
27 ; Known bug: Simulator reset altitude and reference...
28
27 altimeter_calc: 29 altimeter_calc:
28 movlb HIGH(pressureAvg) 30 movlb HIGH(pressureAvg)
29 31
30 movf pressureRef+0,W ; Already initialized ? 32 movf pressureRef+0,W ; Already initialized ?
31 iorwf pressureRef+1,W 33 iorwf pressureRef+1,W
42 movlb HIGH(pressureAvg) 44 movlb HIGH(pressureAvg)
43 clrf pressureSum+0 ; Init averaging area 45 clrf pressureSum+0 ; Init averaging area
44 clrf pressureSum+1 46 clrf pressureSum+1
45 clrf pressureCount 47 clrf pressureCount
46 48
47 clrf altitude+0 ; Mark as not computed yet.
48 clrf altitude+1
49
50 movff amb_pressure+0,pressureAvg+0 ; And init first average. 49 movff amb_pressure+0,pressureAvg+0 ; And init first average.
51 movff amb_pressure+1,pressureAvg+1 50 movff amb_pressure+1,pressureAvg+1
52 51
53 movlw 4 ; And multiply AVG by 16 to be coherent. 52 movlw 4 ; And multiply AVG by 16 to be coherent.
54 altimeter_reset_1: 53 altimeter_reset_1:
55 bcf STATUS,C 54 bcf STATUS,C
56 rlcf pressureAvg+0 55 rlcf pressureAvg+0
57 rlcf pressureAvg+1 56 rlcf pressureAvg+1
58 decfsz WREG 57 decfsz WREG
59 bra altimeter_reset_1 58 bra altimeter_reset_1
59
60 rcall compute_altitude
60 61
61 movlb 1 ; Back to normal bank1. 62 movlb 1 ; Back to normal bank1.
62 return 63 return
63 64
64 altimeter_1: 65 altimeter_1:
208 ; 209 ;
209 ; Edit reference (where altitude = 0) pressure, while displaying corresponding 210 ; Edit reference (where altitude = 0) pressure, while displaying corresponding
210 ; altitude. 211 ; altitude.
211 ; 212 ;
212 altimeter_menu: 213 altimeter_menu:
214 movff pressureRef+0,WREG ; Make sure it is initialized...
215 movff pressureRef+1,fA
216 iorwf fA
217 bnz altimeter_menu_1 ; Yes: skip reset...
218 rcall altimeter_reset
219
220 altimeter_menu_1:
213 call PLED_ClearScreen ; Menu header. 221 call PLED_ClearScreen ; Menu header.
214 call PLED_standard_color 222 call PLED_standard_color
215 call PLED_topline_box 223 call PLED_topline_box
216 WIN_INVERT .1 ; Init new Wordprocessor 224 WIN_INVERT .1 ; Init new Wordprocessor
217 WIN_FONT .0 225 WIN_FONT .0