comparison code_part1/OSTC_code_asm_part1/sleepmode.asm @ 354:cec312042b94

Fix sub16 neg detect (related to bug #44)
author JeanDo
date Tue, 07 Jun 2011 03:55:27 +0200
parents 2144f19fa1eb
children 88660a400338
comparison
equal deleted inserted replaced
353:b5b030c1ae7e 354:cec312042b94
62 btfsc enter_error_sleep ; Enter Fatal Error Routine? 62 btfsc enter_error_sleep ; Enter Fatal Error Routine?
63 call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!) 63 call fatal_error_sleep ; Yes (In Sleepmode_vxx.asm!)
64 64
65 call calc_surface_interval ; Increases Surface-Interval time 65 call calc_surface_interval ; Increases Surface-Interval time
66 call nofly_timeout60 ; check for no fly time 66 call nofly_timeout60 ; check for no fly time
67 ; adjust airpressure compensation any 15 minutes 67
68 ;---- adjust airpressure compensation any 15 minutes
68 incf divemins+1,F ; counts to 14... 69 incf divemins+1,F ; counts to 14...
69 movlw d'14' 70 movlw d'14'
70 cpfsgt divemins+1 71 cpfsgt divemins+1
71 bra onemin_sleep2 ; 15 minutes not done! 72 bra onemin_sleep2 ; 15 minutes not done!
73 clrf divemins+1 ; reset counter
72 74
73 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!) 75 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!)
74 76
75 call check_temp_extrema ; Check for temperature extremas 77 call check_temp_extrema ; Check for temperature extremas
76 78
77 call deco_calc_CNS_decrease_15min ; compute CNS decay in sleep only 79 call deco_calc_CNS_decrease_15min ; compute CNS decay in sleep only
78 movlb b'00000001' 80 movlb b'00000001'
81
79 movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure 82 movff last_surfpressure_15min+0,last_surfpressure_30min+0 ; save older airpressure
80 movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure 83 movff last_surfpressure_15min+1,last_surfpressure_30min+1 ; save older airpressure
81 SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new airpressure 84 SAFE_2BYTE_COPY amb_pressure, last_surfpressure_15min ; save new airpressure
82 85
83 clrf divemins+1 ; reset counter
84 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi 86 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi
85 movff lo,sub_a+0 ; max. "allowed" airpressure in mBar 87 movff lo,sub_a+0 ; max. "allowed" airpressure in mBar
86 movff hi,sub_a+1 88 movff hi,sub_a+1
87 movff last_surfpressure_15min+0,sub_b+0 89 movff last_surfpressure_15min+0,sub_b+0
88 movff last_surfpressure_15min+1,sub_b+1 90 movff last_surfpressure_15min+1,sub_b+1
89 call sub16 ; sub_c = sub_a - sub_b 91 call sub16 ; sub_c = sub_a - sub_b
90 btfsc neg_flag 92 btfss neg_flag ; Is 1080mbar < amb_pressure ?
91 bra onemin_sleep1 93 bra onemin_sleep2 ; NO: current airpressure is lower then "allowed" airpressure, ok!
92 bra onemin_sleep2 ; current airpressure is lower then "allowed" airpressure, ok! 94
93 onemin_sleep1: ; not ok! Overwrite with max. "allowed" airpressure 95 ; not ok! Overwrite with max. "allowed" airpressure
94 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi 96 GETCUSTOM15 d'7' ; loads max_sufpressure into lo, hi
95 movff lo,last_surfpressure_15min+0 ; max. "allowed" airpressure in mBar 97 movff lo,last_surfpressure_15min+0 ; max. "allowed" airpressure in mBar
96 movff hi,last_surfpressure_15min+1 ; max. "allowed" airpressure in mBar 98 movff hi,last_surfpressure_15min+1 ; max. "allowed" airpressure in mBar
97 99
98 onemin_sleep2: 100 onemin_sleep2:
99 ;calc_deko_sleepmode:
100 SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; LOW copy pressure to deco routine 101 SAFE_2BYTE_COPY amb_pressure, int_I_pres_respiration ; LOW copy pressure to deco routine
101 GETCUSTOM8 d'11' ; Saturation multiplier % 102 GETCUSTOM8 d'11' ; Saturation multiplier %
102 movff WREG,char_I_saturation_multiplier 103 movff WREG,char_I_saturation_multiplier
103 GETCUSTOM8 d'12' ; Desaturation multiplier % 104 GETCUSTOM8 d'12' ; Desaturation multiplier %
104 movff WREG,char_I_desaturation_multiplier 105 movff WREG,char_I_desaturation_multiplier
124 bcf LED_blue ; Clear nofly LED 125 bcf LED_blue ; Clear nofly LED
125 incf divemins+0,F ; counts to #test_pressure_in_sleep (5) 126 incf divemins+0,F ; counts to #test_pressure_in_sleep (5)
126 movlw d'5' 127 movlw d'5'
127 cpfsgt divemins+0 ; here: temp variable 128 cpfsgt divemins+0 ; here: temp variable
128 bra onesec_sleep1 ; #test_pressure_in_sleep not done yet 129 bra onesec_sleep1 ; #test_pressure_in_sleep not done yet
130 clrf divemins+0
131
129 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!) 132 rcall pressuretest_sleep_fast ; Gets pressure without averaging (faster!)
130 133
131 ; compare current ambient pressure with threshold 134 ; compare current ambient pressure with threshold CF6==1160mbar.
132 GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi 135 GETCUSTOM15 d'6' ; loads pressure threshold into lo,hi
133 movff lo,sub_a+0 ; power on if ambient pressure is greater threshold 136 movff lo,sub_a+0 ; power on if ambient pressure is greater threshold
134 movff hi,sub_a+1 137 movff hi,sub_a+1
135 SAFE_2BYTE_COPY amb_pressure, sub_b 138 SAFE_2BYTE_COPY amb_pressure, sub_b
136 call sub16 ; sub_c = sub_a - sub_b 139 call sub16 ; Is (1160mbar - amb_pressure) < 0 ?
137 bsf sleepmode 140 bsf sleepmode
138 btfsc neg_flag ; Wake up from Sleep? 141 btfsc neg_flag ; Wake up from Sleep?
139 bcf sleepmode ; amb_pressure>pressure_offset_divemode: wake up! 142 bcf sleepmode ; amb_pressure>pressure_offset_divemode: wake up!
140 clrf divemins+0 143
141 onesec_sleep1: 144 onesec_sleep1:
142 bcf onesecupdate ; all done. 145 bcf onesecupdate ; all done.
143 btfsc switch_left 146 btfsc switch_left
144 bra onesec_sleep1a 147 bra onesec_sleep1a
145 btfsc switch_right 148 btfsc switch_right
155 bcf INTCON,INT0IF ; Clear flag 158 bcf INTCON,INT0IF ; Clear flag
156 bcf INTCON3,INT1IF ; Clear flag 159 bcf INTCON3,INT1IF ; Clear flag
157 bcf switch_right 160 bcf switch_right
158 bcf switch_left 161 bcf switch_left
159 bcf T0CON,TMR0ON ; Stop Timer 0 162 bcf T0CON,TMR0ON ; Stop Timer 0
160 bcf sleepmode ; wake up! 163 bcf sleepmode ; wake up!
161 164
162 ; Restart altimeter averaging, so next averaging starts right over... 165 ; Restart altimeter averaging, so next averaging starts right over...
163 call altimeter_restart 166 call altimeter_restart
164 167
165 return 168 return