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