Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/isr.asm @ 342:06299199dfb9
Fix bad max depth value (fix sub16 to avoid trashing sub_b).
author | JeanDo |
---|---|
date | Fri, 20 May 2011 01:34:59 +0200 |
parents | 2144f19fa1eb |
children | d5240792be51 |
rev | line source |
---|---|
0 | 1 |
2 ; OSTC - diving computer code | |
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
4 | |
5 ; This program is free software: you can redistribute it and/or modify | |
6 ; it under the terms of the GNU General Public License as published by | |
7 ; the Free Software Foundation, either version 3 of the License, or | |
8 ; (at your option) any later version. | |
9 | |
10 ; This program is distributed in the hope that it will be useful, | |
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ; GNU General Public License for more details. | |
14 | |
15 ; You should have received a copy of the GNU General Public License | |
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 | |
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com | |
20 ; written: 10/30/05 | |
21 ; last updated: 05/16/08 | |
22 ; known bugs: | |
23 ; ToDo: | |
24 | |
25 ; the timer1 module interrupts every 62.5ms (16x/second) | |
26 ; temperature and pressure is averaged over 4 measurements | |
27 ; flag pressure_refresh is set every 500ms | |
28 ; and provides accurate pressure (+/-1mBar stable) and temperature (0.1C stable) | |
29 | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
30 ;============================================================================= |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
31 ; Copy a 16bit value from ISR modified registers to main registers. |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
32 ; |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
33 ; Because the ISR can happend at any time, the read should be redone if bytes |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
34 ; changed inbetween. |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
35 ; |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
36 ; NOTE: Destination might be in any bank, so be BANK SAFE on b |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
37 |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
38 SAFE_2BYTE_COPY MACRO a, b |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
39 local retry |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
40 retry: |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
41 movf a+1,W ; High byte in W, (CURRENT BANK ONLY) |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
42 movff WREG,b+1 ; and destination. |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
43 movff a,b ; Copy low byte. |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
44 xorwf a+1,W ; High byte changed ??? (CURRENT BANK ONLY) |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
45 bnz retry |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
46 ENDM |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
47 |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
48 ;============================================================================= |
0 | 49 uartint: |
50 btfsc simulatormode_active ; are we in simulatormode? | |
51 bra simulator_int ; Yes, reading is depth in m! | |
52 | |
53 movff RCREG,uart1_temp | |
54 movlw d'96' | |
55 subwf uart1_temp,F | |
56 dcfsnz uart1_temp,F ; "a" | |
57 bsf dump_external_eeprom ; set flag | |
58 dcfsnz uart1_temp,F ; "b" | |
59 bsf uart_settime ; set flag | |
60 dcfsnz uart1_temp,F ; "c" | |
61 bsf simulatormode_active ; set flag | |
62 dcfsnz uart1_temp,F ; "d" | |
63 bsf internal_eeprom_write ; set flag | |
64 dcfsnz uart1_temp,F ; "e" | |
65 bsf uart_send_hash ; set flag | |
66 dcfsnz uart1_temp,F ; "f" | |
297
ceedf078b2d8
Gas Setup page 2 reworked, Texts 107, 108, 109,150, 149, 168, 42, 43, 53,54,55, 165 need update in french, spanish and german
Heinrichsweikamp
parents:
283
diff
changeset
|
67 bsf uart_reset_battery_stats ; set flag |
0 | 68 dcfsnz uart1_temp,F ; "g" |
69 bsf uart_send_int_eeprom ; set flag | |
70 dcfsnz uart1_temp,F ; "h" | |
71 bsf uart_reset_decodata ; set flag | |
72 dcfsnz uart1_temp,F ; "i" | |
73 bsf internal_eeprom_write2 ; set flag | |
74 dcfsnz uart1_temp,F ; "j" | |
75 bsf uart_send_int_eeprom2 ; set flag | |
76 dcfsnz uart1_temp,F ; "k" | |
77 bsf uart_store_tissue_data ; set flag | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
78 |
283
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
79 movlw 0xC1 |
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
80 cpfseq RCREG ; 115200Baud Bootloader request? |
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
81 bra uartint1 ; No |
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
82 bsf uart_115200_bootloader ; Yes, set Flag |
0 | 83 |
84 uartint1: | |
85 movf RCREG,w ; unload RCREG in stand-alone simulator mode | |
86 bcf PIR1,RCIF ; Clear flag | |
87 bcf RCSTA,CREN ; Clear receiver status | |
88 bsf RCSTA,CREN | |
89 return | |
90 | |
91 simulator_int: | |
92 btfsc standalone_simulator ; ignore in standalone simulator mode | |
93 bra uartint1 | |
94 | |
21 | 95 bsf LED_blue |
0 | 96 tstfsz RCREG ; =0x00? |
97 bra simulator_int1 ; No | |
98 incf RCREG,F ; Yes, so force RCREG=1 | |
99 | |
100 simulator_int1: | |
101 movf RCREG,w ; depth in m | |
102 mullw d'100' ; result will be mbar | |
103 movff PRODL,sim_pressure+0 ; stored for pressure overwrite | |
104 movff PRODH,sim_pressure+1 | |
105 bra uartint1 ; exit uart int | |
106 | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
107 ;============================================================================= |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
108 |
238 | 109 switch_left_int: |
0 | 110 bcf INTCON,INT0IF ; Clear flag |
111 | |
112 btfsc T0CON,TMR0ON ; Timer0 running? | |
113 bra timer0_restart ; Yes, restart | |
114 | |
266 | 115 ; OSTC 2N has flipped screen and exchanged switches... |
116 movff win_flags,WREG ; Get into Bank0 | |
117 btfss WREG,0 | |
0 | 118 bsf switch_left ; Set flag, button press is OK |
266 | 119 btfsc WREG,0 |
120 bsf switch_right ; Set flag, button press is OK | |
0 | 121 |
122 bsf T0CON,TMR0ON ; Start Timer 0 | |
123 return | |
124 | |
125 | |
238 | 126 switch_right_int: |
0 | 127 bcf INTCON3,INT1IF ; Clear flag |
128 | |
129 btfsc T0CON,TMR0ON ; Timer0 running? | |
130 bra timer0_restart ; Yes, restart | |
131 | |
266 | 132 ; OSTC 2N has flipped screen and exchanged switches... |
133 movff win_flags,WREG ; Get into Bank0 | |
134 btfsc WREG,0 | |
135 bsf switch_left ; Set flag, button press is OK | |
136 btfss WREG,0 | |
0 | 137 bsf switch_right ; Set flag, button press is OK |
138 | |
139 bsf T0CON,TMR0ON ; Start Timer 0 | |
140 return | |
141 | |
142 timer0_restart: | |
143 bcf INTCON,TMR0IF ; Clear flag | |
144 clrf T0CON ; Timer0 | |
145 clrf TMR0H | |
146 clrf TMR0L | |
147 bsf T0CON,TMR0ON ; Start Timer 0 | |
148 return | |
149 | |
150 timer0int: | |
151 bcf INTCON,TMR0IF ; Clear flag | |
152 bcf T0CON,TMR0ON ; Stop Timer 0 | |
153 clrf TMR0H | |
154 clrf TMR0L | |
155 return | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
156 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
157 ;============================================================================= |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
158 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
159 |
0 | 160 timer1int: |
161 bcf PIR1,TMR1IF ; Clear flag | |
162 | |
163 timer1int_debug: | |
21 | 164 bcf LED_red ; LEDr off (For charge indicator) |
0 | 165 |
166 movlw 0x08 ; Timer1 int after 62.5ms (=16/second) | |
167 cpfslt TMR1H ; Did we miss a 1/16 second? | |
168 incf timer1int_counter1,F ; Yes, add extra 1/16 second | |
169 | |
170 movlw 0x08 ; Timer1 int after 62.5ms (=16/second) | |
171 subwf TMR1H,F | |
172 | |
238 | 173 incf timer1int_counter1,F ; Increase timer1 counter |
174 | |
0 | 175 movlw d'15' ; One second 16 |
176 cpfsgt timer1int_counter1 | |
177 bra sensor_int_pre ; only pressure sensor | |
238 | 178 rcall RTCisr ; adjust time, then query pressure sensor |
0 | 179 |
180 sensor_int_pre: | |
238 | 181 btfsc sleepmode ; In sleepmode? |
182 return ; Yes | |
0 | 183 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
184 ; Sensor interput do poll the presure/temperature sensor, download results, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
185 ; compute compensations, and store results in various shared variables. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
186 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
187 ; Input: interupt (every 62.5msec == 16Hz), sensor, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
188 ; last_surfpressure:2. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
189 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
190 ; Output: amb_pressure:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
191 ; temperature:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
192 ; rel_pressure:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
193 ; and the pressure_refresh flag. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
194 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
195 ; NOTE: averaging (4 successive value, as recommended in the MS5535 datasheet) |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
196 ; is done on private variables, to avoid trashing data while reading it |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
197 ; from the main code. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
198 ; |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
199 ; NOTE: Because there is no atomic 16bits load/stores, we need to check twice |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
200 ; the read data is correct. Ie. SAFE_2BYTE_COPY is mandatory to get |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
201 ; amb_pressure, temperaturen or rel_pressure |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
202 ; |
0 | 203 sensor_int: |
204 btfsc no_sensor_int ; No sensor interrupt (because it's addressed during sleep) | |
205 return | |
206 | |
238 | 207 incf timer1int_counter2,F ; counts to eight for state maschine |
0 | 208 |
238 | 209 ; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us) |
210 ; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
211 ; State 3: Get temperature (51us) and start pressure integration (73,5us) | |
212 ; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
213 ; State 5: Get temperature (51us) and start pressure integration (73,5us) | |
214 ; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
215 ; State 7: Get temperature (51us) and start pressure integration (73,5us) | |
216 ; State 8: Get pressure (51us), start temperature integration (73,5us), calculate temperature compensated pressure (233us) and build average for half-second update of tempperature and pressure | |
217 | |
218 movff timer1int_counter2,isr_divB ; isr_divB used as temp here... | |
219 dcfsnz isr_divB,F | |
220 bra sensor_int_state1_plus_restart ; Do State 1 | |
221 dcfsnz isr_divB,F | |
222 bra sensor_int_state2 ; Do State 2 | |
223 dcfsnz isr_divB,F | |
224 bra sensor_int_state1 ; Do State 3 | |
225 dcfsnz isr_divB,F | |
226 bra sensor_int_state2 ; Do State 4 | |
227 dcfsnz isr_divB,F | |
228 bra sensor_int_state1 ; Do State 5 | |
229 dcfsnz isr_divB,F | |
230 bra sensor_int_state2 ; Do State 6 | |
231 dcfsnz isr_divB,F | |
232 bra sensor_int_state1 ; Do State 7 | |
233 ; bra sensor_int2_plus_average ; Do State 8 | |
234 | |
235 ;sensor_int2_plus_average: | |
236 rcall sensor_int_state2 | |
237 sensor_int2_plus_average2: | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
238 bcf STATUS,C ; clear carry bit. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
239 rrcf amb_pressure_avg+1 ; amb_pressure sum / 2 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
240 rrcf amb_pressure_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
241 bcf STATUS,C ; clear carry bit, twice. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
242 rrcf amb_pressure_avg+1 ; amb_pressure sum / 4 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
243 rrcf amb_pressure_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
244 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
245 movff amb_pressure_avg+1,amb_pressure+1 ; copy into actual register |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
246 movff amb_pressure_avg+0,amb_pressure+0 |
238 | 247 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
248 bcf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
249 btfsc temperature_avg+1,7 ; Copy sign bit to carry |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
250 bsf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
251 rrcf temperature_avg+1 ; Signed temperature /2 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
252 rrcf temperature_avg+0 |
0 | 253 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
254 bcf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
255 btfsc temperature_avg+1,7 ; Copy sign bit to carry |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
256 bsf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
257 rrcf temperature_avg+1 ; Signed temperature /4 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
258 rrcf temperature_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
259 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
260 movff temperature_avg+1,temperature+1 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
261 movff temperature_avg+0,temperature+0 |
0 | 262 |
263 bsf pressure_refresh ; Set flag! Temp and pressure were updated! | |
238 | 264 clrf timer1int_counter2 ; Then reset State counter |
0 | 265 |
266 btfss simulatormode_active ; are we in simulator mode? | |
267 bra comp_air_pressure ; no | |
268 | |
269 comp_air_pressure0: | |
270 movlw LOW d'1000' ; yes, so simulate 1Bar surface pressure | |
271 movwf last_surfpressure+0 | |
272 movlw HIGH d'1000' | |
273 movwf last_surfpressure+1 | |
274 | |
275 comp_air_pressure: | |
276 movf last_surfpressure+0,W ; compensate airpressure | |
277 subwf amb_pressure+0,W | |
238 | 278 movwf rel_pressure+0 ; rel_pressure stores depth! |
0 | 279 |
280 movf last_surfpressure+1,W | |
281 subwfb amb_pressure+1,W | |
282 movwf rel_pressure+1 | |
238 | 283 btfss STATUS,N ; result is below zero? |
284 return | |
285 clrf rel_pressure+0 ; Yes, do not display negative depths | |
286 clrf rel_pressure+1 ; e.g. when surface air pressure dropped during the dive | |
0 | 287 return |
238 | 288 |
289 sensor_int_state1_plus_restart: | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
290 ;;; bcf pressure_refresh ; clear flags |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
291 clrf amb_pressure_avg+0 ; pressure average registers |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
292 clrf amb_pressure_avg+1 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
293 clrf temperature_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
294 clrf temperature_avg+1 |
238 | 295 |
296 sensor_int_state1: | |
297 call get_temperature_value ; State 1: Get temperature | |
298 call get_pressure_start ; and start pressure integration. | |
299 return ; Done. | |
300 | |
301 sensor_int_state2: | |
302 call get_pressure_value ; State2: Get pressure (51us) | |
303 call get_temperature_start ; and start temperature integration (73,5us) | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
304 goto calculate_compensation ; calculate temperature compensated pressure (233us) |
238 | 305 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
306 ;============================================================================= |
0 | 307 |
308 RTCisr: | |
309 clrf timer1int_counter1 ; counts to 16 (one second / 62.5ms) | |
310 bsf onesecupdate ; we have a new second! | |
311 | |
312 bcf STATUS,Z ; are we in dive mode? | |
313 btfss divemode | |
238 | 314 bra RTCisr2 ; No, must be surface or sleepmode |
0 | 315 |
316 incf samplesecs,F ; CF20 diving seconds done | |
317 decf samplesecs_value,W ; holds CF20 value (minus 1 into WREG) | |
318 cpfsgt samplesecs | |
238 | 319 bra RTCisr1 ; no |
0 | 320 |
321 clrf samplesecs ; clear counter... | |
322 bsf store_sample ; ...and set bit for profile storage | |
238 | 323 |
0 | 324 RTCisr1: |
325 ; Increase re-setable average depth divetime counter | |
111 | 326 incf average_divesecs+0,F ; increase stopwatch registers |
0 | 327 btfsc STATUS,Z |
111 | 328 incf average_divesecs+1,F ; increase stopwatch registers |
0 | 329 |
330 btfss divemode2 ; displayed divetime is running? | |
331 bra RTCisr2 ; No (e.g. too shallow) | |
332 | |
333 incf divesecs,F ; increase divetime registers | |
334 movlw d'59' | |
335 cpfsgt divesecs | |
336 bra RTCisr1a | |
238 | 337 |
0 | 338 clrf divesecs |
339 bsf realdive ; this bit is always set (again) if the dive is longer then one minute | |
340 | |
341 incf divemins+0,F ; increase divemins | |
342 btfsc STATUS,Z | |
343 incf divemins+1,F ; and now do the realtime clock routine anyway | |
344 | |
345 RTCisr1a: | |
346 btfss FLAG_apnoe_mode ; Are we in Apnoe mode? | |
347 bra RTCisr2 ; No, skip the following | |
348 | |
349 incf apnoe_secs,F ; increase descent registers | |
350 movlw d'59' | |
351 cpfsgt apnoe_secs | |
352 bra RTCisr2 | |
353 clrf apnoe_secs | |
354 | |
355 incf apnoe_mins,F ; increase descent mins | |
356 ; Now, do the RTC routine.... | |
357 RTCisr2: | |
358 incf secs,F ; adjusts seconds, minutes, hours, day, month and year. Checks for a leap year and works until 2099! | |
359 movlw d'59' | |
360 cpfsgt secs | |
361 return | |
362 clrf secs | |
363 bsf oneminupdate | |
364 incf mins,F | |
365 movlw d'59' | |
366 cpfsgt mins | |
367 return | |
368 clrf mins | |
369 incf hours,F | |
370 movlw d'23' | |
371 cpfsgt hours | |
372 return | |
373 clrf hours | |
13 | 374 incf day,F |
43 | 375 movff time_correction_value,secs ; Correct too slow clock |
13 | 376 |
0 | 377 check_date: |
378 movff month,isr_divB ; new month? | |
379 dcfsnz isr_divB,F | |
380 movlw .31 | |
381 dcfsnz isr_divB,F | |
382 movlw .28 | |
383 dcfsnz isr_divB,F | |
384 movlw .31 | |
385 dcfsnz isr_divB,F | |
386 movlw .30 | |
387 dcfsnz isr_divB,F | |
388 movlw .31 | |
389 dcfsnz isr_divB,F | |
390 movlw .30 | |
391 dcfsnz isr_divB,F | |
392 movlw .31 | |
393 dcfsnz isr_divB,F | |
394 movlw .31 | |
395 dcfsnz isr_divB,F | |
396 movlw .30 | |
397 dcfsnz isr_divB,F | |
398 movlw .31 | |
399 dcfsnz isr_divB,F | |
400 movlw .30 | |
401 dcfsnz isr_divB,F | |
402 movlw .31 | |
403 cpfsgt day,1 | |
404 return | |
405 movlw .1 | |
406 movwf day | |
407 incf month,F | |
408 movlw .12 | |
409 cpfsgt month,1 | |
410 return | |
411 movlw .1 | |
412 movwf month | |
413 incf year,F | |
414 return |