Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/isr.asm @ 526:d445f0627e86
2.07beta release - 2.08beta start
author | heinrichsweikamp |
---|---|
date | Sat, 10 Dec 2011 16:20:48 +0100 |
parents | 06db5dd9149f |
children | 77c8ff191cd7 |
rev | line source |
---|---|
402 | 1 |
0 | 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 | |
398
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
392
diff
changeset
|
28 ; and provides accurate pressure (+/-1mbar stable) and temperature (0.1C stable) |
0 | 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 ; |
343
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
36 ; Trashes: WREG and TABLAT |
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
37 ; NOTE: Destination might be in any bank, so be BANK SAFE. |
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
38 ; |
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
39 SAFE_2BYTE_COPY MACRO from, to |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
40 local retry |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
41 retry: |
343
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
42 movff from+1,WREG ; High byte in W. |
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
43 movff WREG,to+1 ; and destination. |
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
44 movff from+0,to+0 ; Copy low byte. |
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
45 movff from+1,TABLAT ; another bank-safe read. |
d5240792be51
BUGFIX Altimeter random value (SAFE_2BYTE_COPY was not bank safe).
JeanDo
parents:
341
diff
changeset
|
46 xorwf TABLAT,W ; High byte changed ? |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
47 bnz retry |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
48 ENDM |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
49 |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
50 ;============================================================================= |
0 | 51 uartint: |
52 btfsc simulatormode_active ; are we in simulatormode? | |
53 bra simulator_int ; Yes, reading is depth in m! | |
54 | |
55 movff RCREG,uart1_temp | |
56 movlw d'96' | |
57 subwf uart1_temp,F | |
58 dcfsnz uart1_temp,F ; "a" | |
59 bsf dump_external_eeprom ; set flag | |
60 dcfsnz uart1_temp,F ; "b" | |
61 bsf uart_settime ; set flag | |
62 dcfsnz uart1_temp,F ; "c" | |
63 bsf simulatormode_active ; set flag | |
64 dcfsnz uart1_temp,F ; "d" | |
65 bsf internal_eeprom_write ; set flag | |
66 dcfsnz uart1_temp,F ; "e" | |
67 bsf uart_send_hash ; set flag | |
68 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
|
69 bsf uart_reset_battery_stats ; set flag |
0 | 70 dcfsnz uart1_temp,F ; "g" |
71 bsf uart_send_int_eeprom ; set flag | |
72 dcfsnz uart1_temp,F ; "h" | |
73 bsf uart_reset_decodata ; set flag | |
74 dcfsnz uart1_temp,F ; "i" | |
75 bsf internal_eeprom_write2 ; set flag | |
76 dcfsnz uart1_temp,F ; "j" | |
77 bsf uart_send_int_eeprom2 ; set flag | |
78 dcfsnz uart1_temp,F ; "k" | |
79 bsf uart_store_tissue_data ; set flag | |
330 | 80 dcfsnz uart1_temp,F ; "l" |
81 bsf uart_dump_screen ; set flag | |
283
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
82 |
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
83 movlw 0xC1 |
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
84 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
|
85 bra uartint1 ; No |
4ec488f046f4
Battery sign color coded, work on new uart-started 115200Baud bootloader (Do NOT use yet!)
heinrichsweikamp
parents:
266
diff
changeset
|
86 bsf uart_115200_bootloader ; Yes, set Flag |
0 | 87 |
88 uartint1: | |
89 movf RCREG,w ; unload RCREG in stand-alone simulator mode | |
90 bcf PIR1,RCIF ; Clear flag | |
91 bcf RCSTA,CREN ; Clear receiver status | |
92 bsf RCSTA,CREN | |
93 return | |
94 | |
95 simulator_int: | |
345 | 96 movlw 'l' ; Received 'l' dump-screen command ? |
97 xorwf RCREG,W | |
98 bnz simulator_int2 ; NO: skip | |
99 bsf uart_dump_screen ; YES: set flag | |
100 bra uartint1 ; and this is not a depth... | |
101 | |
102 simulator_int2: | |
0 | 103 btfsc standalone_simulator ; ignore in standalone simulator mode |
104 bra uartint1 | |
105 | |
21 | 106 bsf LED_blue |
0 | 107 tstfsz RCREG ; =0x00? |
108 bra simulator_int1 ; No | |
109 incf RCREG,F ; Yes, so force RCREG=1 | |
110 | |
111 simulator_int1: | |
112 movf RCREG,w ; depth in m | |
347 | 113 movwf PRODL ; Copy |
114 | |
115 movlw d'140' ; Limit to 130m | |
116 cpfslt PRODL ; compare with value in UART | |
117 movwf PRODL ; Overwrite reading | |
118 | |
119 movf PRODL,w ; depth in m | |
0 | 120 mullw d'100' ; result will be mbar |
121 movff PRODL,sim_pressure+0 ; stored for pressure overwrite | |
122 movff PRODH,sim_pressure+1 | |
123 bra uartint1 ; exit uart int | |
124 | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
125 ;============================================================================= |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
126 |
238 | 127 switch_left_int: |
0 | 128 bcf INTCON,INT0IF ; Clear flag |
129 | |
130 btfsc T0CON,TMR0ON ; Timer0 running? | |
131 bra timer0_restart ; Yes, restart | |
132 | |
266 | 133 ; OSTC 2N has flipped screen and exchanged switches... |
134 movff win_flags,WREG ; Get into Bank0 | |
135 btfss WREG,0 | |
0 | 136 bsf switch_left ; Set flag, button press is OK |
266 | 137 btfsc WREG,0 |
138 bsf switch_right ; Set flag, button press is OK | |
0 | 139 |
140 bsf T0CON,TMR0ON ; Start Timer 0 | |
141 return | |
142 | |
143 | |
238 | 144 switch_right_int: |
0 | 145 bcf INTCON3,INT1IF ; Clear flag |
146 | |
147 btfsc T0CON,TMR0ON ; Timer0 running? | |
148 bra timer0_restart ; Yes, restart | |
149 | |
266 | 150 ; OSTC 2N has flipped screen and exchanged switches... |
151 movff win_flags,WREG ; Get into Bank0 | |
152 btfsc WREG,0 | |
153 bsf switch_left ; Set flag, button press is OK | |
154 btfss WREG,0 | |
0 | 155 bsf switch_right ; Set flag, button press is OK |
156 | |
157 bsf T0CON,TMR0ON ; Start Timer 0 | |
158 return | |
159 | |
160 timer0_restart: | |
161 bcf INTCON,TMR0IF ; Clear flag | |
162 clrf T0CON ; Timer0 | |
163 clrf TMR0H | |
164 clrf TMR0L | |
165 bsf T0CON,TMR0ON ; Start Timer 0 | |
166 return | |
167 | |
168 timer0int: | |
169 bcf INTCON,TMR0IF ; Clear flag | |
170 bcf T0CON,TMR0ON ; Stop Timer 0 | |
171 clrf TMR0H | |
172 clrf TMR0L | |
173 return | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
174 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
175 ;============================================================================= |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
176 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
177 |
0 | 178 timer1int: |
179 timer1int_debug: | |
21 | 180 bcf LED_red ; LEDr off (For charge indicator) |
0 | 181 |
390 | 182 btfsc TMR1L,0 ; Wait for low clock cycle |
183 bra $-2 | |
391 | 184 btfss TMR1L,0 ; Still high? |
390 | 185 bra $-2 ; max. loop time: 61µs |
378 | 186 |
0 | 187 movlw 0x08 ; Timer1 int after 62.5ms (=16/second) |
391 | 188 cpfslt TMR1H ; Did we miss a 1/16 second? |
189 incf timer1int_counter1,F ; Yes, add extra 1/16 second | |
190 | |
191 movlw 0x08 ; Timer1 int after 62.5ms (=16/second) | |
0 | 192 subwf TMR1H,F |
391 | 193 bcf PIR1,TMR1IF ; Clear flag |
0 | 194 |
238 | 195 incf timer1int_counter1,F ; Increase timer1 counter |
196 | |
0 | 197 movlw d'15' ; One second 16 |
198 cpfsgt timer1int_counter1 | |
199 bra sensor_int_pre ; only pressure sensor | |
238 | 200 rcall RTCisr ; adjust time, then query pressure sensor |
0 | 201 |
202 sensor_int_pre: | |
238 | 203 btfsc sleepmode ; In sleepmode? |
204 return ; Yes | |
0 | 205 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
206 ; Sensor interput do poll the presure/temperature sensor, download results, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
207 ; compute compensations, and store results in various shared variables. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
208 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
209 ; Input: interupt (every 62.5msec == 16Hz), sensor, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
210 ; last_surfpressure:2. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
211 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
212 ; Output: amb_pressure:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
213 ; temperature:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
214 ; rel_pressure:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
215 ; and the pressure_refresh flag. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
216 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
217 ; 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
|
218 ; 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
|
219 ; from the main code. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
220 ; |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
221 ; 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
|
222 ; the read data is correct. Ie. SAFE_2BYTE_COPY is mandatory to get |
344 | 223 ; amb_pressure, temperature or rel_pressure |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
224 ; |
0 | 225 sensor_int: |
226 btfsc no_sensor_int ; No sensor interrupt (because it's addressed during sleep) | |
227 return | |
228 | |
238 | 229 incf timer1int_counter2,F ; counts to eight for state maschine |
0 | 230 |
238 | 231 ; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us) |
232 ; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
233 ; State 3: Get temperature (51us) and start pressure integration (73,5us) | |
234 ; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
235 ; State 5: Get temperature (51us) and start pressure integration (73,5us) | |
236 ; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
237 ; State 7: Get temperature (51us) and start pressure integration (73,5us) | |
238 ; 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 | |
239 | |
240 movff timer1int_counter2,isr_divB ; isr_divB used as temp here... | |
241 dcfsnz isr_divB,F | |
242 bra sensor_int_state1_plus_restart ; Do State 1 | |
243 dcfsnz isr_divB,F | |
244 bra sensor_int_state2 ; Do State 2 | |
245 dcfsnz isr_divB,F | |
246 bra sensor_int_state1 ; Do State 3 | |
247 dcfsnz isr_divB,F | |
248 bra sensor_int_state2 ; Do State 4 | |
249 dcfsnz isr_divB,F | |
250 bra sensor_int_state1 ; Do State 5 | |
251 dcfsnz isr_divB,F | |
252 bra sensor_int_state2 ; Do State 6 | |
253 dcfsnz isr_divB,F | |
254 bra sensor_int_state1 ; Do State 7 | |
255 ; bra sensor_int2_plus_average ; Do State 8 | |
256 | |
257 ;sensor_int2_plus_average: | |
258 rcall sensor_int_state2 | |
259 sensor_int2_plus_average2: | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
260 bcf STATUS,C ; clear carry bit. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
261 rrcf amb_pressure_avg+1 ; amb_pressure sum / 2 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
262 rrcf amb_pressure_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
263 bcf STATUS,C ; clear carry bit, twice. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
264 rrcf amb_pressure_avg+1 ; amb_pressure sum / 4 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
265 rrcf amb_pressure_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
266 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
267 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
|
268 movff amb_pressure_avg+0,amb_pressure+0 |
238 | 269 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
270 bcf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
271 btfsc temperature_avg+1,7 ; Copy sign bit to carry |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
272 bsf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
273 rrcf temperature_avg+1 ; Signed temperature /2 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
274 rrcf temperature_avg+0 |
0 | 275 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
276 bcf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
277 btfsc temperature_avg+1,7 ; Copy sign bit to carry |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
278 bsf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
279 rrcf temperature_avg+1 ; Signed temperature /4 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
280 rrcf temperature_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
281 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
282 movff temperature_avg+1,temperature+1 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
283 movff temperature_avg+0,temperature+0 |
0 | 284 |
285 bsf pressure_refresh ; Set flag! Temp and pressure were updated! | |
238 | 286 clrf timer1int_counter2 ; Then reset State counter |
0 | 287 |
288 btfss simulatormode_active ; are we in simulator mode? | |
289 bra comp_air_pressure ; no | |
290 | |
291 comp_air_pressure0: | |
398
ab962c4b19d6
Fixing issue 50, correct "Bar" to "bar" in texts and comments
heinrichsweikamp
parents:
392
diff
changeset
|
292 movlw LOW d'1000' ; yes, so simulate 1bar surface pressure |
0 | 293 movwf last_surfpressure+0 |
294 movlw HIGH d'1000' | |
295 movwf last_surfpressure+1 | |
296 | |
297 comp_air_pressure: | |
298 movf last_surfpressure+0,W ; compensate airpressure | |
299 subwf amb_pressure+0,W | |
238 | 300 movwf rel_pressure+0 ; rel_pressure stores depth! |
0 | 301 |
302 movf last_surfpressure+1,W | |
303 subwfb amb_pressure+1,W | |
304 movwf rel_pressure+1 | |
238 | 305 btfss STATUS,N ; result is below zero? |
306 return | |
307 clrf rel_pressure+0 ; Yes, do not display negative depths | |
308 clrf rel_pressure+1 ; e.g. when surface air pressure dropped during the dive | |
0 | 309 return |
238 | 310 |
311 sensor_int_state1_plus_restart: | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
312 ;;; bcf pressure_refresh ; clear flags |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
313 clrf amb_pressure_avg+0 ; pressure average registers |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
314 clrf amb_pressure_avg+1 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
315 clrf temperature_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
316 clrf temperature_avg+1 |
238 | 317 |
318 sensor_int_state1: | |
319 call get_temperature_value ; State 1: Get temperature | |
320 call get_pressure_start ; and start pressure integration. | |
321 return ; Done. | |
322 | |
323 sensor_int_state2: | |
324 call get_pressure_value ; State2: Get pressure (51us) | |
325 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
|
326 goto calculate_compensation ; calculate temperature compensated pressure (233us) |
238 | 327 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
328 ;============================================================================= |
0 | 329 |
330 RTCisr: | |
331 clrf timer1int_counter1 ; counts to 16 (one second / 62.5ms) | |
332 bsf onesecupdate ; we have a new second! | |
333 | |
334 bcf STATUS,Z ; are we in dive mode? | |
335 btfss divemode | |
238 | 336 bra RTCisr2 ; No, must be surface or sleepmode |
0 | 337 |
338 incf samplesecs,F ; CF20 diving seconds done | |
339 decf samplesecs_value,W ; holds CF20 value (minus 1 into WREG) | |
340 cpfsgt samplesecs | |
238 | 341 bra RTCisr1 ; no |
0 | 342 |
343 clrf samplesecs ; clear counter... | |
344 bsf store_sample ; ...and set bit for profile storage | |
238 | 345 |
0 | 346 RTCisr1: |
347 ; Increase re-setable average depth divetime counter | |
111 | 348 incf average_divesecs+0,F ; increase stopwatch registers |
0 | 349 btfsc STATUS,Z |
357
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
350 incf average_divesecs+1,F ; increase stopwatch registers |
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
351 ; Increase total divetime (Regardless of CF01) |
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
352 incf total_divetime_seconds+0,F ; increase stopwatch registers |
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
353 btfsc STATUS,Z |
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
354 incf total_divetime_seconds+1,F ; increase stopwatch registers |
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
355 |
0 | 356 btfss divemode2 ; displayed divetime is running? |
357 bra RTCisr2 ; No (e.g. too shallow) | |
358 | |
357
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
359 ; increase divetime registers (Displayed dive time) |
562f1bc79f3c
Bugfix: Wake-up into divemode with 1.91alpha
Heinrichsweikamp
parents:
347
diff
changeset
|
360 incf divesecs,F |
0 | 361 movlw d'59' |
362 cpfsgt divesecs | |
363 bra RTCisr1a | |
238 | 364 |
0 | 365 clrf divesecs |
366 bsf realdive ; this bit is always set (again) if the dive is longer then one minute | |
367 | |
368 incf divemins+0,F ; increase divemins | |
369 btfsc STATUS,Z | |
370 incf divemins+1,F ; and now do the realtime clock routine anyway | |
371 | |
372 RTCisr1a: | |
373 btfss FLAG_apnoe_mode ; Are we in Apnoe mode? | |
374 bra RTCisr2 ; No, skip the following | |
375 | |
376 incf apnoe_secs,F ; increase descent registers | |
377 movlw d'59' | |
378 cpfsgt apnoe_secs | |
379 bra RTCisr2 | |
380 clrf apnoe_secs | |
381 | |
382 incf apnoe_mins,F ; increase descent mins | |
383 ; Now, do the RTC routine.... | |
384 RTCisr2: | |
385 incf secs,F ; adjusts seconds, minutes, hours, day, month and year. Checks for a leap year and works until 2099! | |
356 | 386 movlw d'60' |
359 | 387 cpfseq secs ; Secs == 60 ? |
388 return ; NO : done. | |
389 clrf secs ; YES: increment minutes instead... | |
0 | 390 bsf oneminupdate |
497
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
391 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
392 btfss divemode ; In Divemode? |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
393 rcall check_nofly_desat_time ; No, so reduce NoFly and Desat and increase interval |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
394 |
0 | 395 incf mins,F |
396 movlw d'59' | |
397 cpfsgt mins | |
398 return | |
399 clrf mins | |
400 incf hours,F | |
401 movlw d'23' | |
402 cpfsgt hours | |
403 return | |
404 clrf hours | |
13 | 405 incf day,F |
392 | 406 movff time_correction_value,secs ; Correct too slow clock |
13 | 407 |
0 | 408 check_date: |
409 movff month,isr_divB ; new month? | |
410 dcfsnz isr_divB,F | |
411 movlw .31 | |
412 dcfsnz isr_divB,F | |
413 movlw .28 | |
414 dcfsnz isr_divB,F | |
415 movlw .31 | |
416 dcfsnz isr_divB,F | |
417 movlw .30 | |
418 dcfsnz isr_divB,F | |
419 movlw .31 | |
420 dcfsnz isr_divB,F | |
421 movlw .30 | |
422 dcfsnz isr_divB,F | |
423 movlw .31 | |
424 dcfsnz isr_divB,F | |
425 movlw .31 | |
426 dcfsnz isr_divB,F | |
427 movlw .30 | |
428 dcfsnz isr_divB,F | |
429 movlw .31 | |
430 dcfsnz isr_divB,F | |
431 movlw .30 | |
432 dcfsnz isr_divB,F | |
433 movlw .31 | |
434 cpfsgt day,1 | |
435 return | |
436 movlw .1 | |
437 movwf day | |
438 incf month,F | |
439 movlw .12 | |
440 cpfsgt month,1 | |
441 return | |
442 movlw .1 | |
443 movwf month | |
444 incf year,F | |
497
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
445 return |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
446 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
447 check_nofly_desat_time: |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
448 bcf nofly_active ; Clear flag |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
449 movf nofly_time+0,W ; Is nofly null ? |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
450 iorwf nofly_time+1,W |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
451 bz check_nofly_desat_time2 ; yes... |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
452 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
453 bsf nofly_active ; Set flag (again) |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
454 movlw d'1' |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
455 subwf nofly_time+0,F |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
456 movlw d'0' |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
457 subwfb nofly_time+1,F ; reduce by one |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
458 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
459 check_nofly_desat_time2: |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
460 movff desaturation_time_buffer+0,lo |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
461 movff desaturation_time_buffer+1,hi |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
462 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
463 movf lo,W ; Is Desat null ? |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
464 iorwf hi,W |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
465 bz check_nofly_desat_time3 ; yes... |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
466 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
467 movlw d'1' |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
468 subwf lo,F |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
469 movlw d'0' |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
470 subwfb hi,F ; reduce by one... |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
471 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
472 movff lo,desaturation_time_buffer+0 ; ...and copy back |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
473 movff hi,desaturation_time_buffer+1 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
474 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
475 check_nofly_desat_time3: |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
476 ; Now increase interval timer |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
477 movff desaturation_time_buffer+0,lo |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
478 movff desaturation_time_buffer+1,hi |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
479 tstfsz lo ;=0? |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
480 bra calc_surface_interval2 ; No |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
481 tstfsz hi ;=0? |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
482 bra calc_surface_interval2 ; No |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
483 clrf surface_interval+0 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
484 clrf surface_interval+1 ; Clear surface interval timer |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
485 return ; Done. |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
486 |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
487 calc_surface_interval2: ; Increase surface interval timer |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
488 movlw d'1' |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
489 addwf surface_interval+0,F |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
490 movlw d'0' |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
491 addwfc surface_interval+1,F |
06db5dd9149f
show numeric _and_ graphic velocity, move desat, nofly and interval into isr
heinrichsweikamp
parents:
402
diff
changeset
|
492 return ; Done |