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