comparison src/isr.asm @ 187:669b5d00706d

CHANGE: Longer timeout (4 min) for calibration menu Ignore 1,2mV noise for not-connected inputs
author heinrichsweikamp
date Sat, 25 Oct 2014 15:28:18 +0200
parents 39f6c07ce2f6
children dcd513840c6c
comparison
equal deleted inserted replaced
186:a004b482604a 187:669b5d00706d
42 btfsc INTCON,INT0IF ; Buttons 42 btfsc INTCON,INT0IF ; Buttons
43 rcall isr_switch_right 43 rcall isr_switch_right
44 btfsc INTCON3,INT1IF ; Buttons 44 btfsc INTCON3,INT1IF ; Buttons
45 rcall isr_switch_left 45 rcall isr_switch_left
46 46
47 ; IR-Link 47 ; IR/S8-Link
48 btfsc PIR3,RC2IF ; UART2 48 btfsc PIR3,RC2IF ; UART2
49 rcall isr_uart2 ; IR-Link 49 rcall isr_uart2 ; IR/S8-Link
50 btfsc PIR2,TMR3IF ; Timer 3 50 btfsc PIR2,TMR3IF ; Timer 3
51 rcall isr_timer3 ; IR-Link Timeout 51 rcall isr_timer3 ; IR-Link Timeout
52 52
53 ; Pressure sensor and others 53 ; Pressure sensor and others
54 btfsc PIR5,TMR7IF ; Timer 7 54 btfsc PIR5,TMR7IF ; Timer 7
62 movff isr_prod+0,PRODL 62 movff isr_prod+0,PRODL
63 retfie FAST ; Restores BSR, STATUS and WREG 63 retfie FAST ; Restores BSR, STATUS and WREG
64 64
65 ;============================================================================= 65 ;=============================================================================
66 66
67 isr_uart2: ; IR-Link 67 isr_uart2: ; IR/S8-Link
68 banksel RCREG2 68 banksel RCREG2
69 movf RCREG2,W 69 movf RCREG2,W
70 bcf RCSTA2,CREN ; Clear receiver status 70 bcf RCSTA2,CREN ; Clear receiver status
71 bsf RCSTA2,CREN 71 bsf RCSTA2,CREN
72 banksel isr_backup 72 banksel isr_backup
73 incf ir_counter,F ; Increase counter 73 incf ir_s8_counter,F ; Increase counter
74 movff ir_counter,isr1_temp ; Copy 74 movff ir_s8_counter,isr1_temp ; Copy
75 dcfsnz isr1_temp,F 75 dcfsnz isr1_temp,F
76 movwf ir_buffer+.0 76 movwf ir_s8_buffer+.0
77 dcfsnz isr1_temp,F 77 dcfsnz isr1_temp,F
78 movwf ir_buffer+.1 78 movwf ir_s8_buffer+.1
79 dcfsnz isr1_temp,F 79 dcfsnz isr1_temp,F
80 movwf ir_buffer+.2 80 movwf ir_s8_buffer+.2
81 dcfsnz isr1_temp,F 81 dcfsnz isr1_temp,F
82 movwf ir_buffer+.3 82 movwf ir_s8_buffer+.3
83 dcfsnz isr1_temp,F 83 dcfsnz isr1_temp,F
84 movwf ir_buffer+.4 84 movwf ir_s8_buffer+.4
85 dcfsnz isr1_temp,F 85 dcfsnz isr1_temp,F
86 movwf ir_buffer+.5 86 movwf ir_s8_buffer+.5
87 dcfsnz isr1_temp,F 87 dcfsnz isr1_temp,F
88 movwf ir_buffer+.6 88 movwf ir_s8_buffer+.6
89 dcfsnz isr1_temp,F 89 dcfsnz isr1_temp,F
90 movwf ir_buffer+.7 90 movwf ir_s8_buffer+.7
91 dcfsnz isr1_temp,F 91 dcfsnz isr1_temp,F
92 movwf ir_buffer+.8 92 movwf ir_s8_buffer+.8
93 dcfsnz isr1_temp,F 93 dcfsnz isr1_temp,F
94 movwf ir_buffer+.9 94 movwf ir_s8_buffer+.9
95 dcfsnz isr1_temp,F 95 dcfsnz isr1_temp,F
96 movwf ir_buffer+.10 96 movwf ir_s8_buffer+.10
97 dcfsnz isr1_temp,F 97 dcfsnz isr1_temp,F
98 movwf ir_buffer+.11 98 movwf ir_s8_buffer+.11
99 dcfsnz isr1_temp,F 99 dcfsnz isr1_temp,F
100 movwf ir_buffer+.12 100 movwf ir_s8_buffer+.12
101 dcfsnz isr1_temp,F 101 dcfsnz isr1_temp,F
102 movwf ir_buffer+.13 102 movwf ir_s8_buffer+.13
103 dcfsnz isr1_temp,F 103 dcfsnz isr1_temp,F
104 movwf ir_buffer+.14 104 movwf ir_s8_buffer+.14
105 dcfsnz isr1_temp,F 105 dcfsnz isr1_temp,F
106 movwf ir_buffer+.15 106 movwf ir_s8_buffer+.15
107 dcfsnz isr1_temp,F 107 dcfsnz isr1_temp,F
108 movwf ir_buffer+.16 108 movwf ir_s8_buffer+.16
109 dcfsnz isr1_temp,F 109 dcfsnz isr1_temp,F
110 movwf ir_buffer+.17 110 movwf ir_s8_buffer+.17
111 111
112 clrf TMR3L ; Preload timer 112 clrf TMR3L ; Preload timer
113 movlw .253 113 movlw .253
114 movwf TMR3H 114 movwf TMR3H
115 bsf T3CON,TMR3ON ; (Re)Start Timeout counter 115 bsf T3CON,TMR3ON ; (Re)Start Timeout counter
116 return 116 return
117 117
118 isr_timer3: ; IR-Link Timeout 118 isr_timer3: ; IR/S8-Link Timeout
119 bcf T3CON,TMR3ON ; Stop Timer3 119 bcf T3CON,TMR3ON ; Stop Timer3
120 banksel isr_backup ; Select Bank0 for ISR data. 120 banksel isr_backup ; Select Bank0 for ISR data.
121 movlw .15 121 movlw .15
122 cpfseq ir_counter ; Got exact 15bytes? 122 cpfseq ir_s8_counter ; Got exact 15bytes?
123 bra isr_timer3_1 ; No, test for 16bytes 123 bra isr_timer3_1 ; No, test for 16bytes
124 bra isr_timer3_ir ; Got 15 bytes, compute local checksum 124 bra isr_timer3_ir ; Got 15 bytes, compute local checksum
125 isr_timer3_1: 125 isr_timer3_1:
126 movlw .16 126 movlw .16
127 cpfseq ir_counter ; Got exact 16bytes? 127 cpfseq ir_s8_counter ; Got exact 16bytes?
128 bra isr_timer3_2 ; No, test for 17bytes 128 bra isr_timer3_2 ; No, test for 17bytes
129 tstfsz ir_buffer+.15 ; Last byte=0x00 129 tstfsz ir_s8_buffer+.15 ; Last byte=0x00
130 bra isr_timer3_exit ; No, exit 130 bra isr_timer3_exit ; No, exit
131 bra isr_timer3_ir ; Got 16 bytes, compute local checksum 131 bra isr_timer3_ir ; Got 16 bytes, compute local checksum
132 isr_timer3_2: 132 isr_timer3_2:
133 movlw .17 133 movlw .17
134 cpfseq ir_counter ; Got exact 17bytes? 134 cpfseq ir_s8_counter ; Got exact 17bytes?
135 bra isr_timer3_exit ; No, exit 135 bra isr_timer3_exit ; No, exit
136 bra isr_timer3_s8 ; S8 data 136 bra isr_timer3_s8 ; S8 data
137 137
138 isr_timer3_ir: ; IR input 138 isr_timer3_ir: ; IR input
139 movff ir_buffer+.0,PRODL 139 movff ir_s8_buffer+.0,PRODL
140 clrf PRODH 140 clrf PRODH
141 movf ir_buffer+.1,W 141 movf ir_s8_buffer+.1,W
142 rcall isr_timer3_checksum 142 rcall isr_timer3_checksum
143 movf ir_buffer+.2,W 143 movf ir_s8_buffer+.2,W
144 rcall isr_timer3_checksum 144 rcall isr_timer3_checksum
145 movf ir_buffer+.3,W 145 movf ir_s8_buffer+.3,W
146 rcall isr_timer3_checksum 146 rcall isr_timer3_checksum
147 movf ir_buffer+.4,W 147 movf ir_s8_buffer+.4,W
148 rcall isr_timer3_checksum 148 rcall isr_timer3_checksum
149 movf ir_buffer+.5,W 149 movf ir_s8_buffer+.5,W
150 rcall isr_timer3_checksum 150 rcall isr_timer3_checksum
151 movf ir_buffer+.6,W 151 movf ir_s8_buffer+.6,W
152 rcall isr_timer3_checksum 152 rcall isr_timer3_checksum
153 movf ir_buffer+.7,W 153 movf ir_s8_buffer+.7,W
154 rcall isr_timer3_checksum 154 rcall isr_timer3_checksum
155 movf ir_buffer+.8,W 155 movf ir_s8_buffer+.8,W
156 rcall isr_timer3_checksum 156 rcall isr_timer3_checksum
157 movf ir_buffer+.9,W 157 movf ir_s8_buffer+.9,W
158 rcall isr_timer3_checksum 158 rcall isr_timer3_checksum
159 movf ir_buffer+.10,W 159 movf ir_s8_buffer+.10,W
160 rcall isr_timer3_checksum 160 rcall isr_timer3_checksum
161 movf ir_buffer+.11,W 161 movf ir_s8_buffer+.11,W
162 rcall isr_timer3_checksum 162 rcall isr_timer3_checksum
163 movf ir_buffer+.12,W 163 movf ir_s8_buffer+.12,W
164 rcall isr_timer3_checksum 164 rcall isr_timer3_checksum
165 165
166 ; Compare checksum 166 ; Compare checksum
167 movf ir_buffer+.13,W 167 movf ir_s8_buffer+.13,W
168 cpfseq PRODL ; Checksum ok? 168 cpfseq PRODL ; Checksum ok?
169 bra isr_timer3_exit ; No, exit 169 bra isr_timer3_exit ; No, exit
170 movf ir_buffer+.14,W 170 movf ir_s8_buffer+.14,W
171 cpfseq PRODH ; Checksum ok? 171 cpfseq PRODH ; Checksum ok?
172 bra isr_timer3_exit ; No, exit 172 bra isr_timer3_exit ; No, exit
173 173
174 ; Checksum OK, copy results 174 ; Checksum OK, copy results
175 movff ir_buffer+.1,hud_status_byte 175 movff ir_s8_buffer+.1,hud_status_byte
176 movff ir_buffer+.2,o2_mv_sensor1+0 176 movff ir_s8_buffer+.2,o2_mv_sensor1+0
177 movff ir_buffer+.3,o2_mv_sensor1+1 177 movff ir_s8_buffer+.3,o2_mv_sensor1+1
178 movff ir_buffer+.4,o2_mv_sensor2+0 178 movff ir_s8_buffer+.4,o2_mv_sensor2+0
179 movff ir_buffer+.5,o2_mv_sensor2+1 179 movff ir_s8_buffer+.5,o2_mv_sensor2+1
180 movff ir_buffer+.6,o2_mv_sensor3+0 180 movff ir_s8_buffer+.6,o2_mv_sensor3+0
181 movff ir_buffer+.7,o2_mv_sensor3+1 181 movff ir_s8_buffer+.7,o2_mv_sensor3+1
182 movff ir_buffer+.8,o2_ppo2_sensor1 182 movff ir_s8_buffer+.8,o2_ppo2_sensor1
183 movff ir_buffer+.9,o2_ppo2_sensor2 183 movff ir_s8_buffer+.9,o2_ppo2_sensor2
184 movff ir_buffer+.10,o2_ppo2_sensor3 184 movff ir_s8_buffer+.10,o2_ppo2_sensor3
185 movff ir_buffer+.11,hud_battery_mv+0 185 movff ir_s8_buffer+.11,hud_battery_mv+0
186 movff ir_buffer+.12,hud_battery_mv+1 186 movff ir_s8_buffer+.12,hud_battery_mv+1
187 187
188 movlw ir_timeout_value ; multiples of 62,5ms 188 movlw ir_timeout_value ; multiples of 62,5ms
189 movwf ir_timeout ; Reload timeout 189 movwf ir_S8_timeout ; Reload timeout
190 190
191 isr_timer3_exit: 191 isr_timer3_exit:
192 clrf ir_counter ; Clear pointer 192 clrf ir_s8_counter ; Clear pointer
193 bcf PIR2,TMR3IF ; Clear flag 193 bcf PIR2,TMR3IF ; Clear flag
194 return 194 return
195 195
196 isr_timer3_checksum: 196 isr_timer3_checksum:
197 addwf PRODL,F 197 addwf PRODL,F
198 movlw .0 198 movlw .0
199 addwfc PRODH,F 199 addwfc PRODH,F
200 return 200 return
201 201
202 isr_timer3_s8: ; IR input 202 isr_timer3_s8: ; S8 input
203 movff ir_buffer+.0,PRODL 203 movff ir_s8_buffer+.0,PRODL
204 clrf PRODH 204 clrf PRODH
205 movf ir_buffer+.1,W 205 movf ir_s8_buffer+.1,W
206 rcall isr_timer3_checksum 206 rcall isr_timer3_checksum
207 movf ir_buffer+.2,W 207 movf ir_s8_buffer+.2,W
208 rcall isr_timer3_checksum 208 rcall isr_timer3_checksum
209 movf ir_buffer+.3,W 209 movf ir_s8_buffer+.3,W
210 rcall isr_timer3_checksum 210 rcall isr_timer3_checksum
211 movf ir_buffer+.4,W 211 movf ir_s8_buffer+.4,W
212 rcall isr_timer3_checksum 212 rcall isr_timer3_checksum
213 movf ir_buffer+.5,W 213 movf ir_s8_buffer+.5,W
214 rcall isr_timer3_checksum 214 rcall isr_timer3_checksum
215 movf ir_buffer+.6,W 215 movf ir_s8_buffer+.6,W
216 rcall isr_timer3_checksum 216 rcall isr_timer3_checksum
217 movf ir_buffer+.7,W 217 movf ir_s8_buffer+.7,W
218 rcall isr_timer3_checksum 218 rcall isr_timer3_checksum
219 movf ir_buffer+.8,W 219 movf ir_s8_buffer+.8,W
220 rcall isr_timer3_checksum 220 rcall isr_timer3_checksum
221 movf ir_buffer+.9,W 221 movf ir_s8_buffer+.9,W
222 rcall isr_timer3_checksum 222 rcall isr_timer3_checksum
223 movf ir_buffer+.10,W 223 movf ir_s8_buffer+.10,W
224 rcall isr_timer3_checksum 224 rcall isr_timer3_checksum
225 movf ir_buffer+.11,W 225 movf ir_s8_buffer+.11,W
226 rcall isr_timer3_checksum 226 rcall isr_timer3_checksum
227 movf ir_buffer+.12,W 227 movf ir_s8_buffer+.12,W
228 rcall isr_timer3_checksum 228 rcall isr_timer3_checksum
229 movf ir_buffer+.13,W 229 movf ir_s8_buffer+.13,W
230 rcall isr_timer3_checksum 230 rcall isr_timer3_checksum
231 movf ir_buffer+.14,W 231 movf ir_s8_buffer+.14,W
232 rcall isr_timer3_checksum 232 rcall isr_timer3_checksum
233 233
234 ; Compare checksum 234 ; Compare checksum
235 movf ir_buffer+.15,W 235 movf ir_s8_buffer+.15,W
236 cpfseq PRODL ; Checksum ok? 236 cpfseq PRODL ; Checksum ok?
237 bra isr_timer3_exit ; No, exit 237 bra isr_timer3_exit ; No, exit
238 movf ir_buffer+.16,W 238 movf ir_s8_buffer+.16,W
239 cpfseq PRODH ; Checksum ok? 239 cpfseq PRODH ; Checksum ok?
240 bra isr_timer3_exit ; No, exit 240 bra isr_timer3_exit ; No, exit
241 241
242 ; Checksum OK, copy results 242 ; Checksum OK, copy results
243 movff ir_buffer+.3,hud_status_byte 243 movff ir_s8_buffer+.3,hud_status_byte
244 movff ir_buffer+.13,hud_battery_mv+0 244 movff ir_s8_buffer+.13,hud_battery_mv+0
245 movff ir_buffer+.14,hud_battery_mv+1 245 movff ir_s8_buffer+.14,hud_battery_mv+1
246 246
247 banksel common 247 banksel common
248 bsf new_s8_data_available ; set flag 248 bsf new_s8_data_available ; set flag
249 banksel ir_timeout 249 banksel ir_S8_timeout
250 250
251 movlw ir_timeout_value ; multiples of 62,5ms 251 movlw ir_timeout_value ; multiples of 62,5ms
252 movwf ir_timeout ; Reload timeout 252 movwf ir_S8_timeout ; Reload timeout
253 bra isr_timer3_exit ; Exit 253 bra isr_timer3_exit ; Exit
254 254
255 255
256 ;============================================================================= 256 ;=============================================================================
257 257
265 movf max_CCPR1L,W ; Dimm value 265 movf max_CCPR1L,W ; Dimm value
266 cpfseq CCPR1L ; = current PWM value? 266 cpfseq CCPR1L ; = current PWM value?
267 rcall isr_dimm_tft ; No, adjust until max_CCPR1L=CCPR1L ! 267 rcall isr_dimm_tft ; No, adjust until max_CCPR1L=CCPR1L !
268 268
269 banksel isr_backup 269 banksel isr_backup
270 decfsz ir_timeout,F ; IR Data still valid? 270 decfsz ir_S8_timeout,F ; IR Data still valid?
271 bra isr_tmr7_2 ; Yes, continue 271 bra isr_tmr7_2 ; Yes, continue
272 ; timeout, clear IR-Data 272 ; timeout, clear IR-Data
273 273
274 movlw ir_timeout_value ; multiples of 62,5ms 274 movlw ir_timeout_value ; multiples of 62,5ms
275 movwf ir_timeout ; Reload timeout 275 movwf ir_S8_timeout ; Reload timeout
276 276
277 banksel common 277 banksel common
278 btfss c3_hardware 278 btfss c3_hardware
279 bra isr_tmr7_1a ; Always with normal ostc3 hardware 279 bra isr_tmr7_1a ; Always with normal ostc3 hardware
280 btfss s8_digital 280 btfss s8_digital