Mercurial > public > hwos_code
annotate src/isr.asm @ 268:29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
author | heinrichsweikamp |
---|---|
date | Sun, 19 Apr 2015 20:41:48 +0200 |
parents | e2ea74646127 |
children | d316d44530a3 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File isr.asm | |
4 ; | |
5 ; INTERUPT subroutines | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-05-24 : [jDG] Cleanups from initial Matthias code. | |
11 | |
12 #include "ostc3.inc" | |
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
14 #include "ms5541.inc" | |
15 #include "adc_lightsensor.inc" | |
16 | |
17 ;============================================================================= | |
18 | |
19 extern start | |
20 | |
21 isr_high CODE 0x0008 ;High Priority Interrups | |
22 bra HighInt | |
23 nop | |
24 nop | |
25 nop | |
26 nop | |
27 nop | |
28 nop | |
29 bra HighInt | |
30 | |
31 isr_low CODE 0x00018 ;Low Priority Interrups | |
32 ; *** low priority interrupts not used | |
33 retfie FAST ; Restores BSR, STATUS and WREG | |
34 | |
35 HighInt: | |
36 movff PRODL,isr_prod+0 | |
37 movff PRODH,isr_prod+1 | |
38 | |
39 ; Buttons | |
40 btfsc PIR1,TMR1IF ; Timer1 INT (Button hold-down Timer) | |
41 rcall timer1int | |
42 btfsc INTCON,INT0IF ; Buttons | |
43 rcall isr_switch_right | |
44 btfsc INTCON3,INT1IF ; Buttons | |
45 rcall isr_switch_left | |
46 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
47 ; IR/S8-Link |
113 | 48 btfsc PIR3,RC2IF ; UART2 |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
49 rcall isr_uart2 ; IR/S8-Link |
0 | 50 btfsc PIR2,TMR3IF ; Timer 3 |
51 rcall isr_timer3 ; IR-Link Timeout | |
113 | 52 |
53 ; Pressure sensor and others | |
54 btfsc PIR5,TMR7IF ; Timer 7 | |
55 rcall isr_tmr7 ; Every 62,5ms | |
56 | |
0 | 57 ; RTCC |
58 btfsc PIR3,RTCCIF ; Real-time-clock interrupt | |
59 rcall isr_rtcc ; May return in bank common! | |
60 | |
61 movff isr_prod+1,PRODH | |
62 movff isr_prod+0,PRODL | |
63 retfie FAST ; Restores BSR, STATUS and WREG | |
64 | |
65 ;============================================================================= | |
66 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
67 isr_uart2: ; IR/S8-Link |
0 | 68 banksel RCREG2 |
69 movf RCREG2,W | |
70 bcf RCSTA2,CREN ; Clear receiver status | |
71 bsf RCSTA2,CREN | |
72 banksel isr_backup | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
73 incf ir_s8_counter,F ; Increase counter |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
74 movff ir_s8_counter,isr1_temp ; Copy |
0 | 75 dcfsnz isr1_temp,F |
204 | 76 movwf ir_s8_buffer+.0 |
0 | 77 dcfsnz isr1_temp,F |
204 | 78 movwf ir_s8_buffer+.1 |
0 | 79 dcfsnz isr1_temp,F |
204 | 80 movwf ir_s8_buffer+.2 |
0 | 81 dcfsnz isr1_temp,F |
204 | 82 movwf ir_s8_buffer+.3 |
0 | 83 dcfsnz isr1_temp,F |
204 | 84 movwf ir_s8_buffer+.4 |
0 | 85 dcfsnz isr1_temp,F |
204 | 86 movwf ir_s8_buffer+.5 |
0 | 87 dcfsnz isr1_temp,F |
204 | 88 movwf ir_s8_buffer+.6 |
0 | 89 dcfsnz isr1_temp,F |
204 | 90 movwf ir_s8_buffer+.7 |
0 | 91 dcfsnz isr1_temp,F |
204 | 92 movwf ir_s8_buffer+.8 |
0 | 93 dcfsnz isr1_temp,F |
204 | 94 movwf ir_s8_buffer+.9 |
0 | 95 dcfsnz isr1_temp,F |
204 | 96 movwf ir_s8_buffer+.10 |
0 | 97 dcfsnz isr1_temp,F |
204 | 98 movwf ir_s8_buffer+.11 |
0 | 99 dcfsnz isr1_temp,F |
204 | 100 movwf ir_s8_buffer+.12 |
0 | 101 dcfsnz isr1_temp,F |
204 | 102 movwf ir_s8_buffer+.13 |
0 | 103 dcfsnz isr1_temp,F |
204 | 104 movwf ir_s8_buffer+.14 |
0 | 105 dcfsnz isr1_temp,F |
204 | 106 movwf ir_s8_buffer+.15 |
113 | 107 dcfsnz isr1_temp,F |
204 | 108 movwf ir_s8_buffer+.16 |
113 | 109 dcfsnz isr1_temp,F |
204 | 110 movwf ir_s8_buffer+.17 |
113 | 111 |
0 | 112 clrf TMR3L ; Preload timer |
113 movlw .253 | |
114 movwf TMR3H | |
115 bsf T3CON,TMR3ON ; (Re)Start Timeout counter | |
116 return | |
117 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
118 isr_timer3: ; IR/S8-Link Timeout |
0 | 119 bcf T3CON,TMR3ON ; Stop Timer3 |
120 banksel isr_backup ; Select Bank0 for ISR data. | |
121 movlw .15 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
122 cpfseq ir_s8_counter ; Got exact 15bytes? |
0 | 123 bra isr_timer3_1 ; No, test for 16bytes |
113 | 124 bra isr_timer3_ir ; Got 15 bytes, compute local checksum |
0 | 125 isr_timer3_1: |
126 movlw .16 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
127 cpfseq ir_s8_counter ; Got exact 16bytes? |
113 | 128 bra isr_timer3_2 ; No, test for 17bytes |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
129 tstfsz ir_s8_buffer+.15 ; Last byte=0x00 |
0 | 130 bra isr_timer3_exit ; No, exit |
113 | 131 bra isr_timer3_ir ; Got 16 bytes, compute local checksum |
132 isr_timer3_2: | |
133 movlw .17 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
134 cpfseq ir_s8_counter ; Got exact 17bytes? |
113 | 135 bra isr_timer3_exit ; No, exit |
136 bra isr_timer3_s8 ; S8 data | |
0 | 137 |
113 | 138 isr_timer3_ir: ; IR input |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
139 movff ir_s8_buffer+.0,PRODL |
0 | 140 clrf PRODH |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
141 movf ir_s8_buffer+.1,W |
0 | 142 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
143 movf ir_s8_buffer+.2,W |
0 | 144 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
145 movf ir_s8_buffer+.3,W |
0 | 146 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
147 movf ir_s8_buffer+.4,W |
0 | 148 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
149 movf ir_s8_buffer+.5,W |
0 | 150 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
151 movf ir_s8_buffer+.6,W |
0 | 152 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
153 movf ir_s8_buffer+.7,W |
0 | 154 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
155 movf ir_s8_buffer+.8,W |
0 | 156 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
157 movf ir_s8_buffer+.9,W |
0 | 158 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
159 movf ir_s8_buffer+.10,W |
0 | 160 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
161 movf ir_s8_buffer+.11,W |
0 | 162 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
163 movf ir_s8_buffer+.12,W |
0 | 164 rcall isr_timer3_checksum |
165 | |
166 ; Compare checksum | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
167 movf ir_s8_buffer+.13,W |
0 | 168 cpfseq PRODL ; Checksum ok? |
169 bra isr_timer3_exit ; No, exit | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
170 movf ir_s8_buffer+.14,W |
0 | 171 cpfseq PRODH ; Checksum ok? |
172 bra isr_timer3_exit ; No, exit | |
173 | |
174 ; Checksum OK, copy results | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
175 movff ir_s8_buffer+.1,hud_status_byte |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
176 movff ir_s8_buffer+.2,o2_mv_sensor1+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
177 movff ir_s8_buffer+.3,o2_mv_sensor1+1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
178 movff ir_s8_buffer+.4,o2_mv_sensor2+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
179 movff ir_s8_buffer+.5,o2_mv_sensor2+1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
180 movff ir_s8_buffer+.6,o2_mv_sensor3+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
181 movff ir_s8_buffer+.7,o2_mv_sensor3+1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
182 movff ir_s8_buffer+.8,o2_ppo2_sensor1 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
183 movff ir_s8_buffer+.9,o2_ppo2_sensor2 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
184 movff ir_s8_buffer+.10,o2_ppo2_sensor3 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
185 movff ir_s8_buffer+.11,hud_battery_mv+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
186 movff ir_s8_buffer+.12,hud_battery_mv+1 |
0 | 187 |
188 movlw ir_timeout_value ; multiples of 62,5ms | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
189 movwf ir_S8_timeout ; Reload timeout |
227
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
190 |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
191 banksel hud_status_byte |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
192 bsf hud_connection_ok ; Set manually for hwHUD w/o the HUD module... |
03946aa48fa5
NEW: Support for hwHUD without the LED module
heinrichsweikamp
parents:
204
diff
changeset
|
193 banksel isr_backup ; Select Bank0 for ISR data. |
0 | 194 |
195 isr_timer3_exit: | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
196 clrf ir_s8_counter ; Clear pointer |
0 | 197 bcf PIR2,TMR3IF ; Clear flag |
198 return | |
199 | |
200 isr_timer3_checksum: | |
201 addwf PRODL,F | |
202 movlw .0 | |
203 addwfc PRODH,F | |
204 return | |
205 | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
206 isr_timer3_s8: ; S8 input |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
207 movff ir_s8_buffer+.0,PRODL |
113 | 208 clrf PRODH |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
209 movf ir_s8_buffer+.1,W |
113 | 210 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
211 movf ir_s8_buffer+.2,W |
113 | 212 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
213 movf ir_s8_buffer+.3,W |
113 | 214 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
215 movf ir_s8_buffer+.4,W |
113 | 216 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
217 movf ir_s8_buffer+.5,W |
113 | 218 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
219 movf ir_s8_buffer+.6,W |
113 | 220 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
221 movf ir_s8_buffer+.7,W |
113 | 222 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
223 movf ir_s8_buffer+.8,W |
113 | 224 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
225 movf ir_s8_buffer+.9,W |
113 | 226 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
227 movf ir_s8_buffer+.10,W |
113 | 228 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
229 movf ir_s8_buffer+.11,W |
113 | 230 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
231 movf ir_s8_buffer+.12,W |
113 | 232 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
233 movf ir_s8_buffer+.13,W |
113 | 234 rcall isr_timer3_checksum |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
235 movf ir_s8_buffer+.14,W |
113 | 236 rcall isr_timer3_checksum |
237 | |
238 ; Compare checksum | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
239 movf ir_s8_buffer+.15,W |
113 | 240 cpfseq PRODL ; Checksum ok? |
241 bra isr_timer3_exit ; No, exit | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
242 movf ir_s8_buffer+.16,W |
113 | 243 cpfseq PRODH ; Checksum ok? |
244 bra isr_timer3_exit ; No, exit | |
245 | |
246 ; Checksum OK, copy results | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
247 movff ir_s8_buffer+.3,hud_status_byte |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
248 movff ir_s8_buffer+.13,hud_battery_mv+0 |
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
249 movff ir_s8_buffer+.14,hud_battery_mv+1 |
113 | 250 |
251 banksel common | |
268
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
252 btfss new_s8_data_available ; =1: Old data already processed? |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
253 bra isr_timer3_skip ; No, skip copying new results |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
254 banksel ir_S8_timeout |
113 | 255 |
268
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
256 movff ir_s8_buffer+.6,s8_rawdata_sensor1+2 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
257 movff ir_s8_buffer+.5,s8_rawdata_sensor1+1 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
258 movff ir_s8_buffer+.4,s8_rawdata_sensor1+0 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
259 movff ir_s8_buffer+.9,s8_rawdata_sensor2+2 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
260 movff ir_s8_buffer+.8,s8_rawdata_sensor2+1 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
261 movff ir_s8_buffer+.7,s8_rawdata_sensor2+0 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
262 movff ir_s8_buffer+.12,s8_rawdata_sensor3+2 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
263 movff ir_s8_buffer+.11,s8_rawdata_sensor3+1 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
264 movff ir_s8_buffer+.10,s8_rawdata_sensor3+0 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
265 banksel common |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
266 bsf new_s8_data_available ; set flag |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
267 |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
268 isr_timer3_skip: |
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
269 banksel ir_S8_timeout |
113 | 270 movlw ir_timeout_value ; multiples of 62,5ms |
268
29acdb601548
BUGFIX: Increase timing tolerance for S8 HUD (cR only)
heinrichsweikamp
parents:
236
diff
changeset
|
271 movwf ir_S8_timeout ; Reload timeout |
113 | 272 bra isr_timer3_exit ; Exit |
273 | |
274 | |
0 | 275 ;============================================================================= |
276 | |
277 isr_tmr7: ; each 62,5ms | |
278 bcf PIR5,TMR7IF ; clear flag | |
279 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM. | |
280 movlw .248 | |
281 movwf TMR7H ; -> Rollover after 2048 cycles -> 62,5ms | |
282 | |
283 banksel isr_backup | |
284 movf max_CCPR1L,W ; Dimm value | |
285 cpfseq CCPR1L ; = current PWM value? | |
286 rcall isr_dimm_tft ; No, adjust until max_CCPR1L=CCPR1L ! | |
287 | |
288 banksel isr_backup | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
289 decfsz ir_S8_timeout,F ; IR Data still valid? |
0 | 290 bra isr_tmr7_2 ; Yes, continue |
291 ; timeout, clear IR-Data | |
292 | |
293 movlw ir_timeout_value ; multiples of 62,5ms | |
187
669b5d00706d
CHANGE: Longer timeout (4 min) for calibration menu
heinrichsweikamp
parents:
178
diff
changeset
|
294 movwf ir_S8_timeout ; Reload timeout |
0 | 295 |
296 banksel common | |
236 | 297 btfss analog_o2_input |
113 | 298 bra isr_tmr7_1a ; Always with normal ostc3 hardware |
299 btfss s8_digital | |
300 bra isr_tmr7_2 ; only when digital | |
301 isr_tmr7_1a: | |
0 | 302 clrf o2_mv_sensor1+0 |
303 clrf o2_mv_sensor1+1 | |
304 clrf o2_mv_sensor2+0 | |
305 clrf o2_mv_sensor2+1 | |
306 clrf o2_mv_sensor3+0 | |
307 clrf o2_mv_sensor3+1 | |
308 clrf hud_battery_mv+0 | |
309 clrf hud_battery_mv+1 | |
310 clrf hud_status_byte | |
311 clrf o2_ppo2_sensor1 | |
312 clrf o2_ppo2_sensor2 | |
313 clrf o2_ppo2_sensor3 | |
314 | |
315 isr_tmr7_2: | |
316 banksel common | |
317 btfss no_sensor_int ; No sensor interrupt (because it's addressed during sleep) | |
318 bra isr_sensor_state2 ; No, continue | |
319 banksel isr_backup ; Back to Bank0 ISR data | |
320 return | |
321 | |
322 isr_set_speed_to_normal: | |
323 ; Set Speed to normal | |
324 movlw b'01110010' | |
325 movwf OSCCON ; 16MHz INTOSC | |
326 movlw b'00000000' | |
327 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
328 movlw b'00001101' ; 1:2 Postscaler, 1:4 Prescaler, Timer 2 start -> 1960Hz (no-flicker) | |
329 movwf T2CON | |
330 btfss OSCCON,HFIOFS | |
331 bra $-2 ; Wait until clock is stable | |
332 return | |
333 | |
334 isr_sensor_state2: | |
335 banksel common | |
336 movff sensor_state_counter,WREG | |
337 btfss WREG,0 ; every 1/4 second | |
338 bsf quarter_second_update ; Set flag | |
339 movlw d'2' | |
340 cpfseq speed_setting ; Set to normal in case it's not already in normal speed mode | |
341 rcall isr_set_speed_to_normal | |
342 banksel isr_backup ; Back to Bank0 ISR data | |
343 | |
344 incf sensor_state_counter,F ; counts to eight for state maschine | |
345 | |
346 ; State 1: Clear flags and average registers, get temperature (51us) and start pressure integration (73,5us) | |
347 ; State 2: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
348 ; State 3: Get temperature (51us) and start pressure integration (73,5us) | |
349 ; State 4: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
350 ; State 5: Get temperature (51us) and start pressure integration (73,5us) | |
351 ; State 6: Get pressure (51us), start temperature integration (73,5us) and calculate temperature compensated pressure (233us) | |
352 ; State 7: Get temperature (51us) and start pressure integration (73,5us) | |
353 ; 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 | |
354 | |
355 movff sensor_state_counter,WREG ; WREG used as temp here... | |
356 dcfsnz WREG,F | |
357 bra sensor_int_state1_plus_restart ; Do State 1 | |
358 dcfsnz WREG,F | |
359 bra sensor_int_state2 ; Do State 2 | |
360 dcfsnz WREG,F | |
361 bra sensor_int_state1 ; Do State 3 | |
362 dcfsnz WREG,F | |
363 bra sensor_int_state2 ; Do State 4 | |
364 dcfsnz WREG,F | |
365 bra sensor_int_state1 ; Do State 5 | |
366 dcfsnz WREG,F | |
367 bra sensor_int_state2 ; Do State 6 | |
368 dcfsnz WREG,F | |
369 bra sensor_int_state1 ; Do State 7 | |
370 ; bra sensor_int2_plus_average ; Do State 8 | |
371 ;sensor_int2_plus_average: | |
372 ; First, do state2: | |
373 call get_pressure_value ; State2: Get pressure (51us) | |
374 call get_temperature_start ; and start temperature integration (73,5us) | |
375 call calculate_compensation ; calculate temperature compensated pressure (27us) | |
376 ; Build average | |
377 bcf STATUS,C ; clear carry bit. | |
378 rrcf amb_pressure_avg+1 ; amb_pressure sum / 2 | |
379 rrcf amb_pressure_avg+0 | |
380 bcf STATUS,C ; clear carry bit, twice. | |
381 rrcf amb_pressure_avg+1 ; amb_pressure sum / 4 | |
382 rrcf amb_pressure_avg+0 | |
383 | |
384 movff amb_pressure_avg+1,amb_pressure+1 ; copy into actual register | |
385 movff amb_pressure_avg+0,amb_pressure+0 | |
386 | |
387 bcf STATUS,C | |
388 btfsc temperature_avg+1,7 ; Copy sign bit to carry | |
389 bsf STATUS,C | |
390 rrcf temperature_avg+1 ; Signed temperature /2 | |
391 rrcf temperature_avg+0 | |
392 bcf STATUS,C | |
393 btfsc temperature_avg+1,7 ; Copy sign bit to carry | |
394 bsf STATUS,C | |
395 rrcf temperature_avg+1 ; Signed temperature /4 | |
396 rrcf temperature_avg+0 | |
397 | |
398 movff temperature_avg+1,temperature+1 ; copy into actual register | |
399 movff temperature_avg+0,temperature+0 | |
400 | |
401 banksel common ; flag1 is in Bank1 | |
402 bcf temp_changed ; Clear flag for temperature update | |
403 bcf pressure_refresh ; Clear flag for pressure update | |
404 banksel isr_backup ; Back to Bank0 ISR data | |
405 | |
406 ; Temp changed? | |
407 movf temperature+0,W | |
408 cpfseq last_temperature+0 | |
409 bra isr_sensor_state2_2 ; Yes | |
410 movf temperature+1,W | |
411 cpfseq last_temperature+1 | |
412 bra isr_sensor_state2_2 ; Yes | |
413 | |
414 bra isr_sensor_state2_3 ; no change | |
415 | |
416 isr_sensor_state2_2: | |
417 banksel common ; flag1 is in Bank1 | |
418 bsf temp_changed ; Yes | |
419 banksel isr_backup ; Back to Bank0 ISR data | |
420 isr_sensor_state2_3: | |
421 movff temperature+0,last_temperature+0 ; Copy for compare | |
422 movff temperature+1,last_temperature+1 | |
423 | |
424 movf amb_pressure+0,W | |
425 cpfseq last_pressure+0 | |
426 bra isr_sensor_state2_4 ; Yes | |
427 movf amb_pressure+1,W | |
428 cpfseq last_pressure+1 | |
429 bra isr_sensor_state2_4 ; Yes | |
430 | |
431 bra isr_sensor_state2_5 ; No change | |
432 isr_sensor_state2_4: | |
433 banksel common ; flag1 is in Bank1 | |
434 bsf pressure_refresh ; Yes | |
435 banksel isr_backup ; Back to Bank0 ISR data | |
436 isr_sensor_state2_5: | |
437 movff amb_pressure+0,last_pressure+0 ; Copy for compare | |
438 movff amb_pressure+1,last_pressure+1 | |
439 | |
440 clrf sensor_state_counter ; Then reset State counter | |
176 | 441 banksel common ; flag2 is in Bank1 |
0 | 442 btfss simulatormode_active ; are we in simulator mode? |
443 bra comp_air_pressure ; no | |
176 | 444 ; Always set pressure_refresh flag in simulator mode |
445 bsf pressure_refresh ; Yes | |
446 banksel isr_backup ; Back to Bank0 ISR data | |
0 | 447 movlw LOW d'1000' ; yes, so simulate 1000mbar surface pressure |
448 movwf last_surfpressure+0 | |
449 movlw HIGH d'1000' | |
450 movwf last_surfpressure+1 | |
451 | |
452 comp_air_pressure: | |
176 | 453 banksel isr_backup ; Back to Bank0 ISR data |
0 | 454 movf last_surfpressure+0,W ; compensate airpressure |
455 subwf amb_pressure+0,W | |
456 movwf rel_pressure+0 ; rel_pressure stores depth! | |
457 | |
458 movf last_surfpressure+1,W | |
459 subwfb amb_pressure+1,W | |
460 movwf rel_pressure+1 | |
461 btfss STATUS,N ; result is below zero? | |
462 bra sensor_int_state_exit | |
463 clrf rel_pressure+0 ; Yes, do not display negative depths | |
464 clrf rel_pressure+1 ; e.g. when surface air pressure dropped during the dive | |
465 bra sensor_int_state_exit | |
466 | |
467 sensor_int_state1_plus_restart: | |
468 clrf amb_pressure_avg+0 ; pressure average registers | |
469 clrf amb_pressure_avg+1 | |
470 clrf temperature_avg+0 | |
471 clrf temperature_avg+1 | |
472 | |
473 sensor_int_state1: | |
474 call get_temperature_value ; State 1: Get temperature | |
475 call get_pressure_start ; and start pressure integration. | |
476 bra sensor_int_state_exit | |
477 | |
478 sensor_int_state2: | |
479 call get_pressure_value ; State2: Get pressure (51us) | |
480 call get_temperature_start ; and start temperature integration (73,5us) | |
481 call calculate_compensation ; calculate temperature compensated pressure (233us) | |
482 ; bra sensor_int_state_exit | |
483 sensor_int_state_exit: | |
484 rcall isr_restore_clock ; Restore clock | |
485 return | |
486 ;============================================================================= | |
487 | |
488 isr_dimm_tft: ; Adjust until max_CCPR1L=CCPR1L ! | |
489 banksel common | |
490 btfsc tft_is_dimming ; Ignore while dimming | |
491 return | |
492 banksel isr_backup | |
493 movf max_CCPR1L,W | |
494 cpfsgt CCPR1L ; CCPR1L>max_CCPR1L? | |
495 bra isr_dimm_tft2 ; No, dimm up | |
496 ; dimm down | |
497 decf CCPR1L,F ; -1 | |
498 return | |
499 isr_dimm_tft2: | |
500 movf max_CCPR1L,W | |
31
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
30
diff
changeset
|
501 sublw ambient_light_min_eco |
53a09c1b7410
BUGFIX: alternating brightness at very low ambient light
heinrichsweikamp
parents:
30
diff
changeset
|
502 cpfsgt CCPR1L ; CCPR1L>max_CCPR1L-ambient_light_min_eco? |
0 | 503 bra isr_dimm_tft3 ; No, dimm up slow |
504 ; dimm up faster | |
505 movlw .5 | |
506 addwf CCPR1L,F | |
507 isr_dimm_tft3: | |
508 incf CCPR1L,F ; +1 | |
509 return | |
510 | |
511 | |
512 isr_rtcc: ; each second | |
513 bcf PIR3,RTCCIF ; clear flag | |
514 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM. | |
515 bsf RTCCFG,RTCPTR1 | |
516 bsf RTCCFG,RTCPTR0 ; year | |
517 movff RTCVALL,year ; format is BCD! | |
518 movff RTCVALH,day ; dummy read | |
519 movff RTCVALL,day ; format is BCD! | |
520 movff RTCVALH,month ; format is BCD! | |
521 movff RTCVALL,hours ; format is BCD! | |
522 movff RTCVALH,secs ; format is BCD! | |
523 movff RTCVALL,secs ; format is BCD! | |
524 movff RTCVALH,mins ; format is BCD! | |
525 banksel isr_backup ; Back to Bank0 ISR data | |
526 | |
527 ; Convert BCD to DEC and set registers | |
528 movff mins, isr1_temp | |
529 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
530 movff WREG,mins | |
531 movff secs, isr1_temp | |
532 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
533 movff WREG,secs | |
534 movff hours, isr1_temp | |
535 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
536 movff WREG,hours | |
537 movff month, isr1_temp | |
538 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
539 movff WREG,month | |
540 movff day, isr1_temp | |
541 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
542 movff WREG,day | |
543 movff year, isr1_temp | |
544 rcall isr_rtcc_convert ; Converts to dec with result in WREG | |
545 movff WREG,year | |
546 | |
547 ; Place once/second tasks for ISR here (Be sure of the right bank!) | |
548 banksel common ; flag1 is in Bank1 | |
549 btfss sleepmode ; in Sleepmode? | |
550 call get_ambient_level ; No, get ambient light level and set max_CCPR1L | |
551 | |
552 rcall isr_battery_gauge ; Add amount of battery consumption to battery_gauge:6 | |
553 | |
554 banksel common ; flag1 is in Bank1 | |
555 bsf onesecupdate ; A new second has begun | |
556 btfsc divemode ; in divemode? | |
557 rcall isr_divemode_1sec ; Yes, do some divemode stuff in bank common | |
558 | |
559 tstfsz secs ; Secs == 0 ? | |
560 return ; No, Done. | |
561 | |
562 bsf oneminupdate ; A new minute has begun | |
563 | |
564 btfss divemode ; In Divemode? | |
565 rcall check_nofly_desat_time ; No, so reduce NoFly and Desat and increase interval | |
566 | |
567 ; Check if a new hour has just begun | |
568 tstfsz mins ; mins=0? | |
569 bra isr_rtcc2 ; No | |
570 bsf onehourupdate ; Yes, set flag | |
571 | |
572 isr_rtcc2: | |
573 banksel isr_backup ; Back to Bank0 ISR data | |
574 return ; Done. | |
575 | |
576 isr_battery_gauge: | |
577 banksel isr_backup ; Bank0 ISR data | |
578 movlw current_sleepmode ; 100µA/3600 -> nAs (Sleepmode current) | |
579 movwf isr1_temp ; Store value (low byte) | |
580 clrf isr2_temp ; High byte | |
581 | |
582 banksel common ; flag1 is in Bank1 | |
583 btfss sleepmode ; in Sleepmode? | |
584 rcall isr_battery_gauge2 ; No, compute current consumtion value into isr1_temp and isr2_temp | |
585 | |
586 banksel isr_backup ; Bank0 ISR data | |
587 movf isr1_temp,W ; 48Bit add of isr1_temp and isr2_temp into battery_gauge:6 | |
588 addwf battery_gauge+0,F | |
589 movf isr2_temp,W | |
590 addwfc battery_gauge+1,F | |
591 movlw .0 | |
592 addwfc battery_gauge+2,F | |
593 addwfc battery_gauge+3,F | |
594 addwfc battery_gauge+4,F | |
595 addwfc battery_gauge+5,F | |
596 return | |
597 | |
598 isr_battery_gauge2: | |
599 ; set consumtion rate in nAs for an one second interval | |
600 ; Example: | |
601 ; movlw LOW .55556 ; 0,2A/3600*1e9s = nAs | |
602 ; movwf isr1_temp ; Low byte | |
603 ; movlw HIGH .55556 ; 0,2A/3600*1e9s = nAs | |
604 ; movwf isr2_temp ; High byte | |
605 | |
606 ; Current consumption for LED backlight is 47*CCPR1L+272 | |
607 movf CCPR1L,W | |
608 mullw current_backlight_multi | |
609 movlw LOW current_backlight_offset | |
610 addwf PRODL,F | |
611 movlw HIGH current_backlight_offset | |
612 addwfc PRODH,F | |
613 movff PRODL,isr1_temp | |
614 movff PRODH,isr2_temp ; isr1_temp and isr2_temp hold value for backlight | |
615 | |
616 ; Add current for CPU and GPU | |
617 ; speed_setting=1: ECO (3,1mA -> 861nAs), =2: NORMAL (5,50mA -> 1528nAs) or =3: FASTEST (8,04mA -> 2233nAs) | |
618 movlw .1 | |
619 cpfseq speed_setting | |
620 bra isr_battery_gauge3 | |
621 banksel isr_backup ; Bank0 ISR data | |
622 movlw LOW current_speed_eco | |
623 addwf isr1_temp,F | |
624 movlw HIGH current_speed_eco | |
625 addwfc isr2_temp,F | |
626 bra isr_battery_gauge5 | |
627 isr_battery_gauge3: | |
628 movlw .2 | |
629 cpfseq speed_setting | |
630 bra isr_battery_gauge4 | |
631 banksel isr_backup ; Bank0 ISR data | |
632 movlw LOW current_speed_normal | |
633 addwf isr1_temp,F | |
634 movlw HIGH current_speed_normal | |
635 addwfc isr2_temp,F | |
636 bra isr_battery_gauge5 | |
637 isr_battery_gauge4: | |
638 banksel isr_backup ; Bank0 ISR data | |
639 movlw LOW current_speed_fastest | |
640 addwf isr1_temp,F | |
641 movlw HIGH current_speed_fastest | |
642 addwfc isr2_temp,F | |
643 isr_battery_gauge5: | |
644 ; Add current if IR reciever is on | |
645 btfss ir_power ; IR enabled? | |
646 bra isr_battery_gauge6 ; no | |
647 movlw LOW current_ir_reciever | |
648 addwf isr1_temp,F | |
649 movlw HIGH current_ir_reciever | |
650 addwfc isr2_temp,F | |
651 isr_battery_gauge6: | |
652 ; Add current for compass/accelerometer | |
653 btfss compass_enabled ; compass active? | |
654 bra isr_battery_gauge7 ; no | |
655 movlw LOW current_compass | |
656 addwf isr1_temp,F | |
657 movlw HIGH current_compass | |
658 addwfc isr2_temp,F | |
659 isr_battery_gauge7: | |
660 return | |
661 | |
662 isr_divemode_1sec: | |
663 incf samplesecs,F ; "samplingrate" diving seconds done | |
664 decf samplesecs_value,W ; holds "samplingrate" value (minus 1 into WREG) | |
665 cpfsgt samplesecs ; Done? | |
666 bra isr_divemode_1sec2 ; no | |
667 | |
668 clrf samplesecs ; clear counter... | |
669 bsf store_sample ; ...and set bit for profile storage | |
670 isr_divemode_1sec2: | |
671 ; Increase re-setable average depth divetime counter | |
176 | 672 infsnz average_divesecs+0,F ; increase stopwatch registers |
0 | 673 incf average_divesecs+1,F ; increase stopwatch registers |
674 ; Increase total divetime (Regardless of start_dive_threshold) | |
148 | 675 infsnz total_divetime_seconds+0,F |
676 incf total_divetime_seconds+1,F ; Total dive time (Regardless of start_dive_threshold) | |
0 | 677 |
678 btfss divemode2 ; displayed divetime is running? | |
679 return ; No (e.g. too shallow) | |
680 | |
681 ; increase divetime registers (Displayed dive time) | |
682 incf divesecs,F | |
683 movlw d'59' | |
684 cpfsgt divesecs | |
685 bra isr_divemode_1sec2a | |
686 | |
687 clrf divesecs | |
688 bsf realdive ; this bit is always set (again) if the dive is longer then one minute | |
148 | 689 infsnz divemins+0,F |
690 incf divemins+1,F ; increase divemins | |
0 | 691 |
692 isr_divemode_1sec2a: | |
693 btfss FLAG_apnoe_mode ; Are we in Apnoe mode? | |
694 return ; No | |
695 | |
696 incf apnoe_secs,F ; increase descent registers | |
697 movlw d'59' | |
698 cpfsgt apnoe_secs ; full minute? | |
699 return ; No | |
700 clrf apnoe_secs | |
701 incf apnoe_mins,F ; increase descent mins | |
702 return | |
703 | |
704 ;============================================================================= | |
705 ; BCD to Binary convertion. | |
706 ; Input: isr1_temp = Value in BCD | |
707 ; Output WREG = value in binary. | |
708 isr_rtcc_convert: | |
709 swapf isr1_temp, W | |
710 andlw 0x0F ; W= tens | |
711 rlncf WREG, W ; W= 2*tens | |
712 subwf isr1_temp, F ; 16*tens + ones - 2*tens | |
713 subwf isr1_temp, F ; 14*tens + ones - 2*tens | |
714 subwf isr1_temp, W ; 12*tens + ones - 2*tens | |
715 return | |
716 | |
717 ;============================================================================= | |
718 | |
719 isr_switch_right: ; | |
720 bcf INTCON,INT0IE ; Disable INT0 | |
721 banksel common ; flag1 is in Bank1 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
722 btfss flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
723 bsf switch_right ; Set flag |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
724 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
725 bsf switch_left ; Set flag |
0 | 726 bra isr_switch_common ; Continue... |
727 | |
728 isr_switch_left: ; | |
729 bcf INTCON3,INT1IE ; Disable INT1 | |
730 banksel common ; flag1 is in Bank1 | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
731 btfss flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
732 bsf switch_left ; Set flag |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
733 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
734 bsf switch_right ; Set flag |
0 | 735 isr_switch_common: |
736 ; load timer1 for first press | |
737 clrf TMR1L | |
738 movlw TMR1H_VALUE_FIRST ; in steps of 7,8125ms | |
739 movwf TMR1H | |
740 bsf T1CON,TMR1ON ; Start Timer 1 | |
741 banksel isr_backup ; Select Bank0 for ISR data. | |
742 bcf INTCON3,INT1IF ; Clear flag | |
743 bcf INTCON,INT0IF ; Clear flag | |
744 return | |
745 | |
746 timer1int: | |
747 bcf PIR1,TMR1IF ; Clear flag | |
748 banksel common ; flag1 is in Bank1 | |
204 | 749 bcf INTCON,INT0IF ; Clear flag |
750 bcf INTCON3,INT1IF ; Clear flag | |
0 | 751 btfss switch_left1 ; Left button hold-down? |
752 bra timer1int_left ; Yes | |
753 btfss switch_right2 ; Right button hold-down? | |
754 bra timer1int_right ; Yes | |
755 | |
756 ; No button hold-down, stop Timer 1 | |
757 bcf T1CON,TMR1ON ; Stop Timer 1 | |
758 bsf INTCON,INT0IE ; Enable INT0 | |
759 bsf INTCON3,INT1IE ; Enable INT1 | |
760 return | |
761 | |
762 timer1int_left: | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
763 btfss flip_screen ; 180° flipped? |
0 | 764 bsf switch_left ; (Re-)Set flag |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
765 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
766 bsf switch_right ; (Re-)Set flag |
0 | 767 bra timer1int_common ; Continue |
768 timer1int_right: | |
152
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
769 btfss flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
770 bsf switch_right ; Set flag |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
771 btfsc flip_screen ; 180° flipped? |
19ad15f04f60
BUGFIX: Clear Setpoint-Fallback warning when in bailout
heinrichsweikamp
parents:
148
diff
changeset
|
772 bsf switch_left ; Set flag |
0 | 773 timer1int_common: |
774 ; load timer1 for next press | |
775 clrf TMR1L | |
776 movlw TMR1H_VALUE_CONT ; Surface mode | |
777 btfsc divemode | |
778 movlw TMR1H_VALUE_CONT_DIVE ; Dive mode | |
779 movwf TMR1H | |
780 return ; Return from timer1int with timer1 kept running | |
781 | |
782 ;============================================================================= | |
783 | |
784 check_nofly_desat_time: | |
785 movf nofly_time+0,W ; Is nofly null ? | |
786 iorwf nofly_time+1,W | |
787 bz check_nofly_desat_time2 ; yes... | |
788 | |
789 movlw d'1' | |
790 subwf nofly_time+0,F | |
791 movlw d'0' | |
792 subwfb nofly_time+1,F ; reduce by one | |
793 | |
794 check_nofly_desat_time2: | |
795 movf desaturation_time+0,W ; Is Desat null ? | |
796 iorwf desaturation_time+1,W | |
797 bz check_nofly_desat_time3 ; yes... | |
798 | |
799 movlw d'1' | |
800 subwf desaturation_time+0,F | |
801 movlw d'0' | |
802 subwfb desaturation_time+1,F ; reduce by one... | |
803 | |
147 | 804 ; Increase surface interval timer |
805 infsnz surface_interval+0,F | |
806 incf surface_interval+1,F | |
0 | 807 return ; Done |
808 | |
809 check_nofly_desat_time3: | |
810 clrf surface_interval+0 | |
811 clrf surface_interval+1 ; Clear surface interval timer | |
812 return ; Done. | |
813 | |
814 ;============================================================================= | |
815 | |
816 isr_restore_clock: | |
817 banksel isr_backup | |
818 movff speed_setting,isr1_temp ; Copy to Bank0 | |
819 movlw d'1' | |
820 cpfseq isr1_temp | |
821 bra isr_restore_speed2 | |
822 ; Reset to eco | |
823 movlw b'00000000' | |
824 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
825 movlw b'00110010' | |
826 movwf OSCCON ; 1MHz INTOSC | |
827 movlw T2CON_ECO | |
828 movwf T2CON | |
829 bra isr_restore_exit | |
830 isr_restore_speed2: | |
831 movlw d'2' | |
832 cpfseq isr1_temp | |
833 bra isr_restore_speed3 | |
834 ; Reset to normal | |
835 movlw b'01110010' | |
836 movwf OSCCON ; 16MHz INTOSC | |
837 movlw b'00000000' | |
838 movwf OSCTUNE ; 4x PLL Disable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
839 movlw T2CON_NORMAL | |
840 movwf T2CON | |
841 bra isr_restore_exit | |
842 | |
843 isr_restore_speed3: | |
844 ; Reset to fastest | |
845 movlw b'01110010' ; 16MHz INTOSC | |
846 movwf OSCCON | |
847 movlw b'01000000' | |
848 movwf OSCTUNE ; 4x PLL Enable (Bit6) - only works with 8 or 16MHz (=32 or 64MHz) | |
849 movlw T2CON_FASTEST | |
850 movwf T2CON | |
851 ; bra isr_restore_exit | |
852 isr_restore_exit: | |
853 btfss OSCCON,HFIOFS | |
854 bra isr_restore_exit ; loop until PLL is stable | |
855 return | |
856 | |
857 END |