Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/altimeter.asm @ 213:d19445e0cb2f
BUGFIX Altimeter reset when exiting sleep mode (bug#&6).
author | JeanDo |
---|---|
date | Wed, 23 Feb 2011 00:18:41 +0100 |
parents | f5e9db793dd3 |
children | 8a0bbe43df65 |
comparison
equal
deleted
inserted
replaced
212:275befc5f39d | 213:d19445e0cb2f |
---|---|
29 altimeter_calc: | 29 altimeter_calc: |
30 movlb HIGH(pressureAvg) | 30 movlb HIGH(pressureAvg) |
31 | 31 |
32 movlw HIGH(4*.900) ; Is presure ref bigger than 900mbar | 32 movlw HIGH(4*.900) ; Is presure ref bigger than 900mbar |
33 cpfsgt pressureRef+1 | 33 cpfsgt pressureRef+1 |
34 bra altimeter_reset ; No: Should do a reset now. | 34 bra altimeter_restart ; No: Should do a reset now. |
35 | 35 |
36 movlw HIGH(4*.1100) ; Is ref pressure bigger than 1100mbar ? | 36 movlw HIGH(4*.1100) ; Is ref pressure bigger than 1100mbar ? |
37 cpfsgt pressureRef+1 | 37 cpfsgt pressureRef+1 |
38 bra altimeter_1 ; No: ok it is valid... | 38 bra altimeter_1 ; No: ok it is valid... |
39 | 39 |
40 ; Reset computation. Eg. after a sleep, enables to faster restart with correct | 40 ; Reset calibration value to default. |
41 ; values... | |
42 altimeter_reset: | 41 altimeter_reset: |
43 movlb HIGH(pressureAvg) | 42 movlb HIGH(pressureAvg) |
44 movlw LOW(4*.1013+1) ; Init see level at 1013,25 mbar. | 43 movlw LOW(4*.1013+1) ; Init see level at 1013,25 mbar. |
45 movwf pressureRef+0 | 44 movwf pressureRef+0 |
46 movlw HIGH(4*.1013+1) | 45 movlw HIGH(4*.1013+1) |
47 movwf pressureRef+1 | 46 movwf pressureRef+1 |
48 | 47 |
48 ; Restart averaging. Eg. after a sleep, enables to faster restart with correct | |
49 ; values... | |
50 altimeter_restart: | |
49 clrf pressureSum+0 ; Init averaging area | 51 clrf pressureSum+0 ; Init averaging area |
50 clrf pressureSum+1 | 52 clrf pressureSum+1 |
51 clrf pressureCount | 53 clrf pressureCount |
52 | 54 |
53 movff amb_pressure+0,pressureAvg+0 ; And init first average. | 55 movff amb_pressure+0,pressureAvg+0 ; And init first average. |
358 bra altimeter_menu_2 | 360 bra altimeter_menu_2 |
359 | 361 |
360 ;---- Reset sea level pressure to reference ---------------------------------- | 362 ;---- Reset sea level pressure to reference ---------------------------------- |
361 alt_menu_reset: | 363 alt_menu_reset: |
362 rcall altimeter_reset | 364 rcall altimeter_reset |
363 movlb 1 ; Go back to normal bank1 | |
364 bra altimeter_menu_2 | 365 bra altimeter_menu_2 |
365 | 366 |
366 ;---- Increment sea level pressure ------------------------------------------- | 367 ;---- Increment sea level pressure ------------------------------------------- |
367 alt_menu_plus1: | 368 alt_menu_plus1: |
368 movlb HIGH(pressureRef) ; Setup our own ram bank | 369 movlb HIGH(pressureRef) ; Setup our own ram bank |