Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/isr.asm @ 346:193d1adc97b7 ScreenDump
Added screen dumps.
author | JeanDo |
---|---|
date | Sat, 21 May 2011 15:13:06 +0200 |
parents | 8bb7c901743d |
children | ba0f30f3d560 |
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 ; |
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 | |
113 mullw d'100' ; result will be mbar | |
114 movff PRODL,sim_pressure+0 ; stored for pressure overwrite | |
115 movff PRODH,sim_pressure+1 | |
116 bra uartint1 ; exit uart int | |
117 | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
118 ;============================================================================= |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
119 |
238 | 120 switch_left_int: |
0 | 121 bcf INTCON,INT0IF ; Clear flag |
122 | |
123 btfsc T0CON,TMR0ON ; Timer0 running? | |
124 bra timer0_restart ; Yes, restart | |
125 | |
266 | 126 ; OSTC 2N has flipped screen and exchanged switches... |
127 movff win_flags,WREG ; Get into Bank0 | |
128 btfss WREG,0 | |
0 | 129 bsf switch_left ; Set flag, button press is OK |
266 | 130 btfsc WREG,0 |
131 bsf switch_right ; Set flag, button press is OK | |
0 | 132 |
133 bsf T0CON,TMR0ON ; Start Timer 0 | |
134 return | |
135 | |
136 | |
238 | 137 switch_right_int: |
0 | 138 bcf INTCON3,INT1IF ; Clear flag |
139 | |
140 btfsc T0CON,TMR0ON ; Timer0 running? | |
141 bra timer0_restart ; Yes, restart | |
142 | |
266 | 143 ; OSTC 2N has flipped screen and exchanged switches... |
144 movff win_flags,WREG ; Get into Bank0 | |
145 btfsc WREG,0 | |
146 bsf switch_left ; Set flag, button press is OK | |
147 btfss WREG,0 | |
0 | 148 bsf switch_right ; Set flag, button press is OK |
149 | |
150 bsf T0CON,TMR0ON ; Start Timer 0 | |
151 return | |
152 | |
153 timer0_restart: | |
154 bcf INTCON,TMR0IF ; Clear flag | |
155 clrf T0CON ; Timer0 | |
156 clrf TMR0H | |
157 clrf TMR0L | |
158 bsf T0CON,TMR0ON ; Start Timer 0 | |
159 return | |
160 | |
161 timer0int: | |
162 bcf INTCON,TMR0IF ; Clear flag | |
163 bcf T0CON,TMR0ON ; Stop Timer 0 | |
164 clrf TMR0H | |
165 clrf TMR0L | |
166 return | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
167 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
168 ;============================================================================= |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
169 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
170 |
0 | 171 timer1int: |
172 bcf PIR1,TMR1IF ; Clear flag | |
173 | |
174 timer1int_debug: | |
21 | 175 bcf LED_red ; LEDr off (For charge indicator) |
0 | 176 |
177 movlw 0x08 ; Timer1 int after 62.5ms (=16/second) | |
178 cpfslt TMR1H ; Did we miss a 1/16 second? | |
179 incf timer1int_counter1,F ; Yes, add extra 1/16 second | |
180 | |
181 movlw 0x08 ; Timer1 int after 62.5ms (=16/second) | |
182 subwf TMR1H,F | |
183 | |
238 | 184 incf timer1int_counter1,F ; Increase timer1 counter |
185 | |
0 | 186 movlw d'15' ; One second 16 |
187 cpfsgt timer1int_counter1 | |
188 bra sensor_int_pre ; only pressure sensor | |
238 | 189 rcall RTCisr ; adjust time, then query pressure sensor |
0 | 190 |
191 sensor_int_pre: | |
238 | 192 btfsc sleepmode ; In sleepmode? |
193 return ; Yes | |
0 | 194 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
195 ; Sensor interput do poll the presure/temperature sensor, download results, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
196 ; compute compensations, and store results in various shared variables. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
197 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
198 ; Input: interupt (every 62.5msec == 16Hz), sensor, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
199 ; last_surfpressure:2. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
200 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
201 ; Output: amb_pressure:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
202 ; temperature:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
203 ; rel_pressure:2, |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
204 ; and the pressure_refresh flag. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
205 ; |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
206 ; 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
|
207 ; 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
|
208 ; from the main code. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
209 ; |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
210 ; 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
|
211 ; the read data is correct. Ie. SAFE_2BYTE_COPY is mandatory to get |
344 | 212 ; amb_pressure, temperature or rel_pressure |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
213 ; |
0 | 214 sensor_int: |
215 btfsc no_sensor_int ; No sensor interrupt (because it's addressed during sleep) | |
216 return | |
217 | |
238 | 218 incf timer1int_counter2,F ; counts to eight for state maschine |
0 | 219 |
238 | 220 ; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us) |
221 ; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
222 ; State 3: Get temperature (51us) and start pressure integration (73,5us) | |
223 ; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
224 ; State 5: Get temperature (51us) and start pressure integration (73,5us) | |
225 ; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
226 ; State 7: Get temperature (51us) and start pressure integration (73,5us) | |
227 ; 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 | |
228 | |
229 movff timer1int_counter2,isr_divB ; isr_divB used as temp here... | |
230 dcfsnz isr_divB,F | |
231 bra sensor_int_state1_plus_restart ; Do State 1 | |
232 dcfsnz isr_divB,F | |
233 bra sensor_int_state2 ; Do State 2 | |
234 dcfsnz isr_divB,F | |
235 bra sensor_int_state1 ; Do State 3 | |
236 dcfsnz isr_divB,F | |
237 bra sensor_int_state2 ; Do State 4 | |
238 dcfsnz isr_divB,F | |
239 bra sensor_int_state1 ; Do State 5 | |
240 dcfsnz isr_divB,F | |
241 bra sensor_int_state2 ; Do State 6 | |
242 dcfsnz isr_divB,F | |
243 bra sensor_int_state1 ; Do State 7 | |
244 ; bra sensor_int2_plus_average ; Do State 8 | |
245 | |
246 ;sensor_int2_plus_average: | |
247 rcall sensor_int_state2 | |
248 sensor_int2_plus_average2: | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
249 bcf STATUS,C ; clear carry bit. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
250 rrcf amb_pressure_avg+1 ; amb_pressure sum / 2 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
251 rrcf amb_pressure_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
252 bcf STATUS,C ; clear carry bit, twice. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
253 rrcf amb_pressure_avg+1 ; amb_pressure sum / 4 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
254 rrcf amb_pressure_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
255 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
256 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
|
257 movff amb_pressure_avg+0,amb_pressure+0 |
238 | 258 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
259 bcf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
260 btfsc temperature_avg+1,7 ; Copy sign bit to carry |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
261 bsf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
262 rrcf temperature_avg+1 ; Signed temperature /2 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
263 rrcf temperature_avg+0 |
0 | 264 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
265 bcf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
266 btfsc temperature_avg+1,7 ; Copy sign bit to carry |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
267 bsf STATUS,C |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
268 rrcf temperature_avg+1 ; Signed temperature /4 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
269 rrcf temperature_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
270 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
271 movff temperature_avg+1,temperature+1 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
272 movff temperature_avg+0,temperature+0 |
0 | 273 |
274 bsf pressure_refresh ; Set flag! Temp and pressure were updated! | |
238 | 275 clrf timer1int_counter2 ; Then reset State counter |
0 | 276 |
277 btfss simulatormode_active ; are we in simulator mode? | |
278 bra comp_air_pressure ; no | |
279 | |
280 comp_air_pressure0: | |
281 movlw LOW d'1000' ; yes, so simulate 1Bar surface pressure | |
282 movwf last_surfpressure+0 | |
283 movlw HIGH d'1000' | |
284 movwf last_surfpressure+1 | |
285 | |
286 comp_air_pressure: | |
287 movf last_surfpressure+0,W ; compensate airpressure | |
288 subwf amb_pressure+0,W | |
238 | 289 movwf rel_pressure+0 ; rel_pressure stores depth! |
0 | 290 |
291 movf last_surfpressure+1,W | |
292 subwfb amb_pressure+1,W | |
293 movwf rel_pressure+1 | |
238 | 294 btfss STATUS,N ; result is below zero? |
295 return | |
296 clrf rel_pressure+0 ; Yes, do not display negative depths | |
297 clrf rel_pressure+1 ; e.g. when surface air pressure dropped during the dive | |
0 | 298 return |
238 | 299 |
300 sensor_int_state1_plus_restart: | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
301 ;;; bcf pressure_refresh ; clear flags |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
302 clrf amb_pressure_avg+0 ; pressure average registers |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
303 clrf amb_pressure_avg+1 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
304 clrf temperature_avg+0 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
305 clrf temperature_avg+1 |
238 | 306 |
307 sensor_int_state1: | |
308 call get_temperature_value ; State 1: Get temperature | |
309 call get_pressure_start ; and start pressure integration. | |
310 return ; Done. | |
311 | |
312 sensor_int_state2: | |
313 call get_pressure_value ; State2: Get pressure (51us) | |
314 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
|
315 goto calculate_compensation ; calculate temperature compensated pressure (233us) |
238 | 316 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
297
diff
changeset
|
317 ;============================================================================= |
0 | 318 |
319 RTCisr: | |
320 clrf timer1int_counter1 ; counts to 16 (one second / 62.5ms) | |
321 bsf onesecupdate ; we have a new second! | |
322 | |
323 bcf STATUS,Z ; are we in dive mode? | |
324 btfss divemode | |
238 | 325 bra RTCisr2 ; No, must be surface or sleepmode |
0 | 326 |
327 incf samplesecs,F ; CF20 diving seconds done | |
328 decf samplesecs_value,W ; holds CF20 value (minus 1 into WREG) | |
329 cpfsgt samplesecs | |
238 | 330 bra RTCisr1 ; no |
0 | 331 |
332 clrf samplesecs ; clear counter... | |
333 bsf store_sample ; ...and set bit for profile storage | |
238 | 334 |
0 | 335 RTCisr1: |
336 ; Increase re-setable average depth divetime counter | |
111 | 337 incf average_divesecs+0,F ; increase stopwatch registers |
0 | 338 btfsc STATUS,Z |
111 | 339 incf average_divesecs+1,F ; increase stopwatch registers |
0 | 340 |
341 btfss divemode2 ; displayed divetime is running? | |
342 bra RTCisr2 ; No (e.g. too shallow) | |
343 | |
344 incf divesecs,F ; increase divetime registers | |
345 movlw d'59' | |
346 cpfsgt divesecs | |
347 bra RTCisr1a | |
238 | 348 |
0 | 349 clrf divesecs |
350 bsf realdive ; this bit is always set (again) if the dive is longer then one minute | |
351 | |
352 incf divemins+0,F ; increase divemins | |
353 btfsc STATUS,Z | |
354 incf divemins+1,F ; and now do the realtime clock routine anyway | |
355 | |
356 RTCisr1a: | |
357 btfss FLAG_apnoe_mode ; Are we in Apnoe mode? | |
358 bra RTCisr2 ; No, skip the following | |
359 | |
360 incf apnoe_secs,F ; increase descent registers | |
361 movlw d'59' | |
362 cpfsgt apnoe_secs | |
363 bra RTCisr2 | |
364 clrf apnoe_secs | |
365 | |
366 incf apnoe_mins,F ; increase descent mins | |
367 ; Now, do the RTC routine.... | |
368 RTCisr2: | |
369 incf secs,F ; adjusts seconds, minutes, hours, day, month and year. Checks for a leap year and works until 2099! | |
370 movlw d'59' | |
371 cpfsgt secs | |
372 return | |
373 clrf secs | |
374 bsf oneminupdate | |
375 incf mins,F | |
376 movlw d'59' | |
377 cpfsgt mins | |
378 return | |
379 clrf mins | |
380 incf hours,F | |
381 movlw d'23' | |
382 cpfsgt hours | |
383 return | |
384 clrf hours | |
13 | 385 incf day,F |
43 | 386 movff time_correction_value,secs ; Correct too slow clock |
13 | 387 |
0 | 388 check_date: |
389 movff month,isr_divB ; new month? | |
390 dcfsnz isr_divB,F | |
391 movlw .31 | |
392 dcfsnz isr_divB,F | |
393 movlw .28 | |
394 dcfsnz isr_divB,F | |
395 movlw .31 | |
396 dcfsnz isr_divB,F | |
397 movlw .30 | |
398 dcfsnz isr_divB,F | |
399 movlw .31 | |
400 dcfsnz isr_divB,F | |
401 movlw .30 | |
402 dcfsnz isr_divB,F | |
403 movlw .31 | |
404 dcfsnz isr_divB,F | |
405 movlw .31 | |
406 dcfsnz isr_divB,F | |
407 movlw .30 | |
408 dcfsnz isr_divB,F | |
409 movlw .31 | |
410 dcfsnz isr_divB,F | |
411 movlw .30 | |
412 dcfsnz isr_divB,F | |
413 movlw .31 | |
414 cpfsgt day,1 | |
415 return | |
416 movlw .1 | |
417 movwf day | |
418 incf month,F | |
419 movlw .12 | |
420 cpfsgt month,1 | |
421 return | |
422 movlw .1 | |
423 movwf month | |
424 incf year,F | |
425 return |