comparison code_part1/OSTC_code_asm_part1/altimeter.asm @ 214:8a0bbe43df65

(altimeter restart: fix bank addressing)
author JeanDo
date Wed, 23 Feb 2011 00:53:56 +0100
parents d19445e0cb2f
children 6bdf80d7276c 2144f19fa1eb
comparison
equal deleted inserted replaced
213:d19445e0cb2f 214:8a0bbe43df65
21 ;============================================================================= 21 ;=============================================================================
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 ; 2011-01-31 : [jDG] Better menu: default 1013mbar, and editing by +/- 1mbar.
27 ; 2011-02-23 : [jDG] Fix restart after sleepmode.
26 ; 28 ;
27 ; Known bug: Simulator reset altitude and reference... 29 ; Known bug: Simulator reset altitude and reference...
28 30
29 altimeter_calc: 31 altimeter_calc:
30 movlb HIGH(pressureAvg) 32 movlb HIGH(pressureAvg) ; Altimeter data in bank 0.
31 33
32 movlw HIGH(4*.900) ; Is presure ref bigger than 900mbar 34 movlw HIGH(4*.900) ; Is presure ref bigger than 900mbar
33 cpfsgt pressureRef+1 35 cpfsgt pressureRef+1
34 bra altimeter_restart ; No: Should do a reset now. 36 bra altimeter_reset ; No: Should do a reset now.
35 37
36 movlw HIGH(4*.1100) ; Is ref pressure bigger than 1100mbar ? 38 movlw HIGH(4*.1100) ; Is ref pressure bigger than 1100mbar ?
37 cpfsgt pressureRef+1 39 cpfsgt pressureRef+1
38 bra altimeter_1 ; No: ok it is valid... 40 bra altimeter_1 ; No: ok it is valid...
39 41
40 ; Reset calibration value to default. 42 ; Reset calibration value to default.
41 altimeter_reset: 43 altimeter_reset:
42 movlb HIGH(pressureAvg) 44 movlb HIGH(pressureAvg) ; Altimeter data in bank 0.
43 movlw LOW(4*.1013+1) ; Init see level at 1013,25 mbar. 45 movlw LOW(4*.1013+1) ; Init see level at 1013,25 mbar.
44 movwf pressureRef+0 46 movwf pressureRef+0
45 movlw HIGH(4*.1013+1) 47 movlw HIGH(4*.1013+1)
46 movwf pressureRef+1 48 movwf pressureRef+1
47 49
48 ; Restart averaging. Eg. after a sleep, enables to faster restart with correct 50 ; Restart averaging. Eg. after a sleep, enables to faster restart with correct
49 ; values... 51 ; values...
50 altimeter_restart: 52 altimeter_restart:
53 movlb HIGH(pressureAvg) ; Altimeter data in bank 0.
51 clrf pressureSum+0 ; Init averaging area 54 clrf pressureSum+0 ; Init averaging area
52 clrf pressureSum+1 55 clrf pressureSum+1
53 clrf pressureCount 56 clrf pressureCount
54 57
55 movff amb_pressure+0,pressureAvg+0 ; And init first average. 58 movff amb_pressure+0,pressureAvg+0 ; And init first average.