annotate src/calibrate.asm @ 125:53409476a05f

minor
author heinrichsweikamp
date Sun, 29 Jun 2014 14:21:23 +0200
parents f3062a611eef
children e3ac5b2021bc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
113
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File calibration.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; o2 sensor calibration subroutines
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2014, Heinrichs Weikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9
heinrichsweikamp
parents:
diff changeset
10 #include "ostc3.inc"
heinrichsweikamp
parents:
diff changeset
11 #include "shared_definitions.h" ; Mailbox between c and asm
heinrichsweikamp
parents:
diff changeset
12 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
13 #include "adc_lightsensor.inc"
heinrichsweikamp
parents:
diff changeset
14 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
15
heinrichsweikamp
parents:
diff changeset
16 calibrate CODE
heinrichsweikamp
parents:
diff changeset
17
heinrichsweikamp
parents:
diff changeset
18 global calibrate_mix
heinrichsweikamp
parents:
diff changeset
19 calibrate_mix:
heinrichsweikamp
parents:
diff changeset
20 ; calibrate S8 HUD
heinrichsweikamp
parents:
diff changeset
21 btfss s8_digital ; S8 Digital?
heinrichsweikamp
parents:
diff changeset
22 bra calibrate_mix2 ; No
heinrichsweikamp
parents:
diff changeset
23
heinrichsweikamp
parents:
diff changeset
24 clrf temp1 ; Chksum
heinrichsweikamp
parents:
diff changeset
25 movlw 0xAA ; Start Byte
heinrichsweikamp
parents:
diff changeset
26 addwf temp1,F
heinrichsweikamp
parents:
diff changeset
27 movff WREG,TXREG2
heinrichsweikamp
parents:
diff changeset
28 call rs232_wait_tx2
heinrichsweikamp
parents:
diff changeset
29
heinrichsweikamp
parents:
diff changeset
30 movlw 0x31 ; Calibrate
heinrichsweikamp
parents:
diff changeset
31 addwf temp1,F
heinrichsweikamp
parents:
diff changeset
32 movff WREG,TXREG2
heinrichsweikamp
parents:
diff changeset
33 call rs232_wait_tx2
heinrichsweikamp
parents:
diff changeset
34
heinrichsweikamp
parents:
diff changeset
35 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2
heinrichsweikamp
parents:
diff changeset
36 addwf temp1,F
heinrichsweikamp
parents:
diff changeset
37 movff WREG,TXREG2
heinrichsweikamp
parents:
diff changeset
38 call rs232_wait_tx2
heinrichsweikamp
parents:
diff changeset
39
heinrichsweikamp
parents:
diff changeset
40 movff amb_pressure+0,WREG ; Ambient pressure
heinrichsweikamp
parents:
diff changeset
41 addwf temp1,F
heinrichsweikamp
parents:
diff changeset
42 movff WREG,TXREG2
heinrichsweikamp
parents:
diff changeset
43 call rs232_wait_tx2
heinrichsweikamp
parents:
diff changeset
44 movff amb_pressure+1,WREG
heinrichsweikamp
parents:
diff changeset
45 addwf temp1,F
heinrichsweikamp
parents:
diff changeset
46 movff WREG,TXREG2
heinrichsweikamp
parents:
diff changeset
47 call rs232_wait_tx2
heinrichsweikamp
parents:
diff changeset
48
heinrichsweikamp
parents:
diff changeset
49 movff temp1,TXREG2 ; Chksum
heinrichsweikamp
parents:
diff changeset
50 call rs232_wait_tx2
heinrichsweikamp
parents:
diff changeset
51
heinrichsweikamp
parents:
diff changeset
52 calibrate_mix2:
heinrichsweikamp
parents:
diff changeset
53 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2
heinrichsweikamp
parents:
diff changeset
54 mullw .100
heinrichsweikamp
parents:
diff changeset
55 movff PRODL,xA+0
heinrichsweikamp
parents:
diff changeset
56 movff PRODH,xA+1
heinrichsweikamp
parents:
diff changeset
57 ; (%O2*100)*[ambient,mbar]/100 -> xC
heinrichsweikamp
parents:
diff changeset
58 movff amb_pressure+0,xB+0
heinrichsweikamp
parents:
diff changeset
59 movff amb_pressure+1,xB+1
heinrichsweikamp
parents:
diff changeset
60 call mult16x16 ;xA*xB=xC
heinrichsweikamp
parents:
diff changeset
61 movlw LOW .100
heinrichsweikamp
parents:
diff changeset
62 movwf xB+0
heinrichsweikamp
parents:
diff changeset
63 movlw HIGH .100
heinrichsweikamp
parents:
diff changeset
64 movwf xB+1
heinrichsweikamp
parents:
diff changeset
65 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
66 movff o2_mv_sensor1+0,xB+0
heinrichsweikamp
parents:
diff changeset
67 movff o2_mv_sensor1+1,xB+1
heinrichsweikamp
parents:
diff changeset
68 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
69 ; xC= ppO2/mV
heinrichsweikamp
parents:
diff changeset
70 movff xC+0,opt_x_s1+0
heinrichsweikamp
parents:
diff changeset
71 movff xC+1,opt_x_s1+1 ; Factor for Sensor1
heinrichsweikamp
parents:
diff changeset
72
heinrichsweikamp
parents:
diff changeset
73 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2
heinrichsweikamp
parents:
diff changeset
74 mullw .100
heinrichsweikamp
parents:
diff changeset
75 movff PRODL,xA+0
heinrichsweikamp
parents:
diff changeset
76 movff PRODH,xA+1
heinrichsweikamp
parents:
diff changeset
77 ; (%O2*100)*[ambient,mbar]/100 -> xC
heinrichsweikamp
parents:
diff changeset
78 movff amb_pressure+0,xB+0
heinrichsweikamp
parents:
diff changeset
79 movff amb_pressure+1,xB+1
heinrichsweikamp
parents:
diff changeset
80 call mult16x16 ;xA*xB=xC
heinrichsweikamp
parents:
diff changeset
81 movlw LOW .100
heinrichsweikamp
parents:
diff changeset
82 movwf xB+0
heinrichsweikamp
parents:
diff changeset
83 movlw HIGH .100
heinrichsweikamp
parents:
diff changeset
84 movwf xB+1
heinrichsweikamp
parents:
diff changeset
85 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
86 movff o2_mv_sensor2+0,xB+0
heinrichsweikamp
parents:
diff changeset
87 movff o2_mv_sensor2+1,xB+1
heinrichsweikamp
parents:
diff changeset
88 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
89 ; xC= ppO2/mV
heinrichsweikamp
parents:
diff changeset
90 movff xC+0,opt_x_s2+0
heinrichsweikamp
parents:
diff changeset
91 movff xC+1,opt_x_s2+1 ; Factor for Sensor2
heinrichsweikamp
parents:
diff changeset
92
heinrichsweikamp
parents:
diff changeset
93 movff opt_calibration_O2_ratio,WREG ; Calibration gas %O2
heinrichsweikamp
parents:
diff changeset
94 mullw .100
heinrichsweikamp
parents:
diff changeset
95 movff PRODL,xA+0
heinrichsweikamp
parents:
diff changeset
96 movff PRODH,xA+1
heinrichsweikamp
parents:
diff changeset
97 ; (%O2*100)*[ambient,mbar]/100 -> xC
heinrichsweikamp
parents:
diff changeset
98 movff amb_pressure+0,xB+0
heinrichsweikamp
parents:
diff changeset
99 movff amb_pressure+1,xB+1
heinrichsweikamp
parents:
diff changeset
100 call mult16x16 ;xA*xB=xC
heinrichsweikamp
parents:
diff changeset
101 movlw LOW .100
heinrichsweikamp
parents:
diff changeset
102 movwf xB+0
heinrichsweikamp
parents:
diff changeset
103 movlw HIGH .100
heinrichsweikamp
parents:
diff changeset
104 movwf xB+1
heinrichsweikamp
parents:
diff changeset
105 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
106 movff o2_mv_sensor3+0,xB+0
heinrichsweikamp
parents:
diff changeset
107 movff o2_mv_sensor3+1,xB+1
heinrichsweikamp
parents:
diff changeset
108 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
109 ; xC= ppO2/mV
heinrichsweikamp
parents:
diff changeset
110 movff xC+0,opt_x_s3+0
heinrichsweikamp
parents:
diff changeset
111 movff xC+1,opt_x_s3+1 ; Factor for Sensor3
heinrichsweikamp
parents:
diff changeset
112
heinrichsweikamp
parents:
diff changeset
113 ; Result is in 100µV
heinrichsweikamp
parents:
diff changeset
114 movff o2_mv_sensor1+0, sub_a+0
heinrichsweikamp
parents:
diff changeset
115 movff o2_mv_sensor1+1, sub_a+1
heinrichsweikamp
parents:
diff changeset
116 movlw LOW min_mv
heinrichsweikamp
parents:
diff changeset
117 movwf sub_b+0
heinrichsweikamp
parents:
diff changeset
118 movlw HIGH min_mv
heinrichsweikamp
parents:
diff changeset
119 movwf sub_b+1
heinrichsweikamp
parents:
diff changeset
120 call sub16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
121 bsf sensor1_active ; Sensor active!
heinrichsweikamp
parents:
diff changeset
122 btfsc neg_flag
heinrichsweikamp
parents:
diff changeset
123 bcf sensor1_active
heinrichsweikamp
parents:
diff changeset
124
heinrichsweikamp
parents:
diff changeset
125 ; Result is in 100µV
heinrichsweikamp
parents:
diff changeset
126 movff o2_mv_sensor2+0, sub_a+0
heinrichsweikamp
parents:
diff changeset
127 movff o2_mv_sensor2+1, sub_a+1
heinrichsweikamp
parents:
diff changeset
128 movlw LOW min_mv
heinrichsweikamp
parents:
diff changeset
129 movwf sub_b+0
heinrichsweikamp
parents:
diff changeset
130 movlw HIGH min_mv
heinrichsweikamp
parents:
diff changeset
131 movwf sub_b+1
heinrichsweikamp
parents:
diff changeset
132 call sub16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
133 bsf sensor2_active ; Sensor active!
heinrichsweikamp
parents:
diff changeset
134 btfsc neg_flag
heinrichsweikamp
parents:
diff changeset
135 bcf sensor2_active
heinrichsweikamp
parents:
diff changeset
136
heinrichsweikamp
parents:
diff changeset
137 ; Result is in 100µV
heinrichsweikamp
parents:
diff changeset
138 movff o2_mv_sensor3+0, sub_a+0
heinrichsweikamp
parents:
diff changeset
139 movff o2_mv_sensor3+1, sub_a+1
heinrichsweikamp
parents:
diff changeset
140 movlw LOW min_mv
heinrichsweikamp
parents:
diff changeset
141 movwf sub_b+0
heinrichsweikamp
parents:
diff changeset
142 movlw HIGH min_mv
heinrichsweikamp
parents:
diff changeset
143 movwf sub_b+1
heinrichsweikamp
parents:
diff changeset
144 call sub16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
145 bsf sensor3_active ; Sensor active!
heinrichsweikamp
parents:
diff changeset
146 btfsc neg_flag
heinrichsweikamp
parents:
diff changeset
147 bcf sensor3_active
heinrichsweikamp
parents:
diff changeset
148
heinrichsweikamp
parents:
diff changeset
149 ; When no sensor is found, enable all three to show error state
heinrichsweikamp
parents:
diff changeset
150 btfsc sensor1_active
heinrichsweikamp
parents:
diff changeset
151 return
heinrichsweikamp
parents:
diff changeset
152 btfsc sensor2_active
heinrichsweikamp
parents:
diff changeset
153 return
heinrichsweikamp
parents:
diff changeset
154 btfsc sensor3_active
heinrichsweikamp
parents:
diff changeset
155 return
heinrichsweikamp
parents:
diff changeset
156 bsf sensor1_active
heinrichsweikamp
parents:
diff changeset
157 bsf sensor2_active
heinrichsweikamp
parents:
diff changeset
158 bsf sensor3_active
heinrichsweikamp
parents:
diff changeset
159 ; Clear factors
heinrichsweikamp
parents:
diff changeset
160 banksel opt_x_s1+0
heinrichsweikamp
parents:
diff changeset
161 clrf opt_x_s1+0
heinrichsweikamp
parents:
diff changeset
162 clrf opt_x_s1+1
heinrichsweikamp
parents:
diff changeset
163 clrf opt_x_s2+0
heinrichsweikamp
parents:
diff changeset
164 clrf opt_x_s2+1
heinrichsweikamp
parents:
diff changeset
165 clrf opt_x_s3+0
heinrichsweikamp
parents:
diff changeset
166 clrf opt_x_s3+1
heinrichsweikamp
parents:
diff changeset
167 banksel common
heinrichsweikamp
parents:
diff changeset
168 return
heinrichsweikamp
parents:
diff changeset
169
heinrichsweikamp
parents:
diff changeset
170 compute_ppo2_analog:
heinrichsweikamp
parents:
diff changeset
171 call get_analog_inputs
heinrichsweikamp
parents:
diff changeset
172 bra compute_ppo2_common
heinrichsweikamp
parents:
diff changeset
173
heinrichsweikamp
parents:
diff changeset
174 global compute_ppo2 ; compute mv_sensorX and ppo2_sensorX arrays
heinrichsweikamp
parents:
diff changeset
175 compute_ppo2:
heinrichsweikamp
parents:
diff changeset
176 btfss c3_hardware ; C3 hardware?
heinrichsweikamp
parents:
diff changeset
177 return ; No
heinrichsweikamp
parents:
diff changeset
178
heinrichsweikamp
parents:
diff changeset
179 btfss s8_digital ; =1: Digital I/O
heinrichsweikamp
parents:
diff changeset
180 bra compute_ppo2_analog ; use analog
heinrichsweikamp
parents:
diff changeset
181
heinrichsweikamp
parents:
diff changeset
182 ; use digital
heinrichsweikamp
parents:
diff changeset
183 btfss new_s8_data_available ; =1: New data frame recieved
heinrichsweikamp
parents:
diff changeset
184 return
heinrichsweikamp
parents:
diff changeset
185 call compute_mvolts_for_all_sensors
heinrichsweikamp
parents:
diff changeset
186
heinrichsweikamp
parents:
diff changeset
187 compute_ppo2_common:
heinrichsweikamp
parents:
diff changeset
188 ; o2_mv_sensor1:2 * opt_x_s1:2 = o2_ppo2_sensor1/10000
heinrichsweikamp
parents:
diff changeset
189 movff o2_mv_sensor1+0,xA+0
heinrichsweikamp
parents:
diff changeset
190 movff o2_mv_sensor1+1,xA+1
heinrichsweikamp
parents:
diff changeset
191 movff opt_x_s1+0,xB+0
heinrichsweikamp
parents:
diff changeset
192 movff opt_x_s1+1,xB+1
heinrichsweikamp
parents:
diff changeset
193 call mult16x16 ;xA:2*xB:2=xC:4
heinrichsweikamp
parents:
diff changeset
194 movlw LOW .1000
heinrichsweikamp
parents:
diff changeset
195 movwf xB+0
heinrichsweikamp
parents:
diff changeset
196 movlw HIGH .1000
heinrichsweikamp
parents:
diff changeset
197 movwf xB+1
heinrichsweikamp
parents:
diff changeset
198 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
199 movlw d'1'
heinrichsweikamp
parents:
diff changeset
200 addwf xC+0,F
heinrichsweikamp
parents:
diff changeset
201 movlw d'0'
heinrichsweikamp
parents:
diff changeset
202 addwfc xC+1,F
heinrichsweikamp
parents:
diff changeset
203 movff xC+0,o2_ppo2_sensor1+0
heinrichsweikamp
parents:
diff changeset
204 movff xC+1,o2_ppo2_sensor1+1 ; result in 0.01bar
heinrichsweikamp
parents:
diff changeset
205 ; Set to zero if sensor is not active!
heinrichsweikamp
parents:
diff changeset
206 btfss sensor1_active
heinrichsweikamp
parents:
diff changeset
207 clrf o2_ppo2_sensor1+0
heinrichsweikamp
parents:
diff changeset
208 btfss sensor1_active
heinrichsweikamp
parents:
diff changeset
209 clrf o2_ppo2_sensor1+1
heinrichsweikamp
parents:
diff changeset
210
heinrichsweikamp
parents:
diff changeset
211 ; o2_mv_sensor2:2 * opt_x_s1:2 = o2_ppo2_sensor2/10000
heinrichsweikamp
parents:
diff changeset
212 movff o2_mv_sensor2+0,xA+0
heinrichsweikamp
parents:
diff changeset
213 movff o2_mv_sensor2+1,xA+1
heinrichsweikamp
parents:
diff changeset
214 movff opt_x_s2+0,xB+0
heinrichsweikamp
parents:
diff changeset
215 movff opt_x_s2+1,xB+1
heinrichsweikamp
parents:
diff changeset
216 call mult16x16 ;xA:2*xB:2=xC:4
heinrichsweikamp
parents:
diff changeset
217 movlw LOW .1000
heinrichsweikamp
parents:
diff changeset
218 movwf xB+0
heinrichsweikamp
parents:
diff changeset
219 movlw HIGH .1000
heinrichsweikamp
parents:
diff changeset
220 movwf xB+1
heinrichsweikamp
parents:
diff changeset
221 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
222 movlw d'1'
heinrichsweikamp
parents:
diff changeset
223 addwf xC+0,F
heinrichsweikamp
parents:
diff changeset
224 movlw d'0'
heinrichsweikamp
parents:
diff changeset
225 addwfc xC+1,F
heinrichsweikamp
parents:
diff changeset
226 movff xC+0,o2_ppo2_sensor2+0
heinrichsweikamp
parents:
diff changeset
227 movff xC+1,o2_ppo2_sensor2+1 ; result in 0.01bar
heinrichsweikamp
parents:
diff changeset
228 ; Set to zero if sensor is not active!
heinrichsweikamp
parents:
diff changeset
229 btfss sensor2_active
heinrichsweikamp
parents:
diff changeset
230 clrf o2_ppo2_sensor2+0
heinrichsweikamp
parents:
diff changeset
231 btfss sensor2_active
heinrichsweikamp
parents:
diff changeset
232 clrf o2_ppo2_sensor2+1
heinrichsweikamp
parents:
diff changeset
233
heinrichsweikamp
parents:
diff changeset
234 ; o2_mv_sensor3:2 * opt_x_s1:2 = o2_ppo2_sensor3/10000
heinrichsweikamp
parents:
diff changeset
235 movff o2_mv_sensor3+0,xA+0
heinrichsweikamp
parents:
diff changeset
236 movff o2_mv_sensor3+1,xA+1
heinrichsweikamp
parents:
diff changeset
237 movff opt_x_s3+0,xB+0
heinrichsweikamp
parents:
diff changeset
238 movff opt_x_s3+1,xB+1
heinrichsweikamp
parents:
diff changeset
239 call mult16x16 ;xA:2*xB:2=xC:4
heinrichsweikamp
parents:
diff changeset
240 movlw LOW .1000
heinrichsweikamp
parents:
diff changeset
241 movwf xB+0
heinrichsweikamp
parents:
diff changeset
242 movlw HIGH .1000
heinrichsweikamp
parents:
diff changeset
243 movwf xB+1
heinrichsweikamp
parents:
diff changeset
244 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
245 movlw d'1'
heinrichsweikamp
parents:
diff changeset
246 addwf xC+0,F
heinrichsweikamp
parents:
diff changeset
247 movlw d'0'
heinrichsweikamp
parents:
diff changeset
248 addwfc xC+1,F
heinrichsweikamp
parents:
diff changeset
249 movff xC+0,o2_ppo2_sensor3+0
heinrichsweikamp
parents:
diff changeset
250 movff xC+1,o2_ppo2_sensor3+1 ; result in 0.01bar
heinrichsweikamp
parents:
diff changeset
251 ; Set to zero if sensor is not active!
heinrichsweikamp
parents:
diff changeset
252 btfss sensor3_active
heinrichsweikamp
parents:
diff changeset
253 clrf o2_ppo2_sensor3+0
heinrichsweikamp
parents:
diff changeset
254 btfss sensor3_active
heinrichsweikamp
parents:
diff changeset
255 clrf o2_ppo2_sensor3+1
heinrichsweikamp
parents:
diff changeset
256
heinrichsweikamp
parents:
diff changeset
257 return ; Done.
heinrichsweikamp
parents:
diff changeset
258
heinrichsweikamp
parents:
diff changeset
259
heinrichsweikamp
parents:
diff changeset
260 compute_mvolts_for_all_sensors: ; Compute mV or all sensors (S8 Mode)
heinrichsweikamp
parents:
diff changeset
261 ; compute AD results in 100µV steps (16bit/sensor)
heinrichsweikamp
parents:
diff changeset
262 ; 24bit AD result is in 244,1406541nV
heinrichsweikamp
parents:
diff changeset
263 ; Devide 24bit value through 409,5999512 -> 410 (0,01% error)
heinrichsweikamp
parents:
diff changeset
264 #DEFINE ad2mv_factor .410
heinrichsweikamp
parents:
diff changeset
265 ; Sensor 1
heinrichsweikamp
parents:
diff changeset
266 clrf xC+3
heinrichsweikamp
parents:
diff changeset
267 movff ir_buffer+.6,xC+2
heinrichsweikamp
parents:
diff changeset
268 movff ir_buffer+.5,xC+1
heinrichsweikamp
parents:
diff changeset
269 movff ir_buffer+.4,xC+0
heinrichsweikamp
parents:
diff changeset
270 movlw LOW ad2mv_factor
heinrichsweikamp
parents:
diff changeset
271 movwf xB+0
heinrichsweikamp
parents:
diff changeset
272 movlw HIGH ad2mv_factor
heinrichsweikamp
parents:
diff changeset
273 movwf xB+1
heinrichsweikamp
parents:
diff changeset
274 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
275 movff xC+1,o2_mv_sensor1+1
heinrichsweikamp
parents:
diff changeset
276 movff xC+0,o2_mv_sensor1+0 ; in 100uV steps
heinrichsweikamp
parents:
diff changeset
277 ; Sensor 2
heinrichsweikamp
parents:
diff changeset
278 clrf xC+3
heinrichsweikamp
parents:
diff changeset
279 movff ir_buffer+.9,xC+2
heinrichsweikamp
parents:
diff changeset
280 movff ir_buffer+.8,xC+1
heinrichsweikamp
parents:
diff changeset
281 movff ir_buffer+.7,xC+0
heinrichsweikamp
parents:
diff changeset
282 movlw LOW ad2mv_factor
heinrichsweikamp
parents:
diff changeset
283 movwf xB+0
heinrichsweikamp
parents:
diff changeset
284 movlw HIGH ad2mv_factor
heinrichsweikamp
parents:
diff changeset
285 movwf xB+1
heinrichsweikamp
parents:
diff changeset
286 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
287 movff xC+1,o2_mv_sensor2+1
heinrichsweikamp
parents:
diff changeset
288 movff xC+0,o2_mv_sensor2+0 ; in 100uV steps
heinrichsweikamp
parents:
diff changeset
289 ; Sensor 3
heinrichsweikamp
parents:
diff changeset
290 clrf xC+3
heinrichsweikamp
parents:
diff changeset
291 movff ir_buffer+.12,xC+2
heinrichsweikamp
parents:
diff changeset
292 movff ir_buffer+.11,xC+1
heinrichsweikamp
parents:
diff changeset
293 movff ir_buffer+.10,xC+0
heinrichsweikamp
parents:
diff changeset
294 movlw LOW ad2mv_factor
heinrichsweikamp
parents:
diff changeset
295 movwf xB+0
heinrichsweikamp
parents:
diff changeset
296 movlw HIGH ad2mv_factor
heinrichsweikamp
parents:
diff changeset
297 movwf xB+1
heinrichsweikamp
parents:
diff changeset
298 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
299 movff xC+1,o2_mv_sensor3+1
heinrichsweikamp
parents:
diff changeset
300 movff xC+0,o2_mv_sensor3+0 ; in 100uV steps
heinrichsweikamp
parents:
diff changeset
301
heinrichsweikamp
parents:
diff changeset
302 bcf new_s8_data_available ; Clear flag
heinrichsweikamp
parents:
diff changeset
303 return ; Done.
heinrichsweikamp
parents:
diff changeset
304
heinrichsweikamp
parents:
diff changeset
305
heinrichsweikamp
parents:
diff changeset
306
heinrichsweikamp
parents:
diff changeset
307 END