Mercurial > public > hwos_code
annotate src/ms5541.asm @ 100:9c7d9e7198c0
1.30 release
author | heinrichsweikamp |
---|---|
date | Fri, 02 May 2014 19:38:14 +0200 |
parents | 7ca1105751c7 |
children | 39f6c07ce2f6 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File ms5541.asm | |
4 ; | |
5 ; Sensor subroutines | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-03 : [mH] moving from OSTC code | |
11 | |
12 #include "ostc3.inc" ; Mandatory header | |
13 #include "math.inc" ; Math routines | |
14 | |
15 sensors CODE | |
16 | |
17 ;============================================================================= | |
18 ; Expose internal variables, to ease debug: | |
19 global D1, D2 | |
20 global C1, C2, C3, C4, C5, C6 | |
21 global xdT, xdT2, OFF, SENS, amb_pressure_avg, temperature_avg | |
22 | |
23 ;============================================================================= | |
24 global calculate_compensation | |
25 calculate_compensation: | |
26 ; xdT = D2 - C5 (s16 range -11.400 .. +12.350) | |
27 movf C5+0,W ; Get Value to be subtracted | |
28 subwf D2+0,W ; Do the Low Byte | |
29 movwf xdT+0 | |
30 movf C5+1,W ; Then the high byte. | |
31 subwfb D2+1,W | |
32 movwf xdT+1 | |
33 | |
34 ; Second order temperature calculation | |
35 ; xdT/128 is in range -89..+96, hence signed 8bit. dT/128 = (2*dT)/256 | |
36 rlcf xdT+0,W ; put hit bit in carry. | |
37 rlcf xdT+1,W ; inject in high byte. | |
38 movwf isr_xA+0 ; and put result in low byte. | |
39 clrf isr_xA+1 | |
40 btfsc xdT+1,7 ; If dT < 0 | |
41 setf isr_xA+1 ; then signextend to -1 | |
42 movff isr_xA+0,isr_xB+0 ; copy A to B | |
43 movff isr_xA+1,isr_xB+1 | |
44 call isr_signed_mult16x16 ; dT*dT --> xC (32 bits) | |
45 | |
46 ; dT >= 0: divide by 8, ie. 3 shifts rights. | |
47 ; dT < 0: divide by 2, ie. 1 shifts rights. | |
48 movlw .3 | |
49 btfss xdT+1,7 ; Was dT negative ? | |
50 movlw .1 | |
51 calc_loop_1: | |
52 bcf STATUS,C ;dT^2 is positive, so injected zeros. | |
53 rrcf isr_xC+1,F | |
54 rrcf isr_xC+0,F | |
55 decfsz WREG | |
56 bra calc_loop_1 | |
57 | |
58 movf isr_xC+0,W ; dT2 = dT - (dT/128)*(dT/128)/(2 ...or... 8) | |
59 subwf xdT+0,W | |
60 movwf xdT2+0 | |
61 movf isr_xC+1,W | |
62 subwfb xdT+1,W | |
63 movwf xdT2+1 | |
64 | |
65 ; Calculate OFF = C2 + ((C4-250)*dT2)/2^12 + 10000 | |
66 ; (range +9.246 .. +18.887) | |
67 movff C4+0,isr_xA+0 | |
68 movff C4+1,isr_xA+1 | |
69 ; movlw LOW(-.250) ; C4 - 250 --> A | |
70 ; addwf C4+0,W | |
71 ; movwf isr_xA+0 | |
72 ; movlw -1 ; HIGH(- .250) is not understood... | |
73 ; addwfc C4+1,W | |
74 ; movwf isr_xA+1 | |
75 | |
76 movff xdT2+0,isr_xB+0 ; dT2 --> B | |
77 movff xdT2+1,isr_xB+1 | |
78 call isr_signed_mult16x16 | |
79 movlw .12-.8 ; A 12bit shift = 1 byte + 4 bits. | |
80 call isr_shift_C31 | |
81 | |
82 movlw LOW(.10000) ; Add 10000 | |
83 addwf isr_xC+1,F | |
84 movlw HIGH(.10000) | |
85 addwfc isr_xC+2,F | |
86 | |
87 movf C2+0,W ; Add C2, and save into OFF | |
88 addwf isr_xC+1,W | |
89 movwf OFF+0 | |
90 movf C2+1,W | |
91 addwfc isr_xC+2,W | |
92 movwf OFF+1 | |
93 | |
94 ; Calculate SENS = C1/2 + ((C3+200)*dT)/2^13 + 3000 | |
95 movlw LOW(.200) ; C3+200 --> A | |
96 addwf C3+0,W | |
97 movwf isr_xA+0 | |
98 movlw HIGH(.200) | |
99 addwfc C3+1,W | |
100 movwf isr_xA+1 | |
101 ; B still contains dT2 | |
102 call isr_signed_mult16x16 ; A*B --> C | |
103 movlw .13-.8 ; A 13bit shift = 1 byte + 5 bits. | |
104 call isr_shift_C31 | |
105 | |
106 bcf STATUS,C ; SENS = C1 / 2 | |
107 rrcf C1+1,W | |
108 movwf SENS+1 | |
109 rrcf C1+0,W | |
110 movwf SENS+0 | |
111 | |
112 movlw LOW(.3000) ; Add 3000 | |
113 addwf isr_xC+1,F | |
114 movlw HIGH(.3000) | |
115 addwfc isr_xC+2,F | |
116 | |
117 movf isr_xC+1,W ; And sum into SENS | |
118 addwf SENS+0,F | |
119 movf isr_xC+2,W | |
120 addwfc SENS+1,F | |
121 | |
122 ; calculate amb_pressure = (sens * (d1-off))/2^12 + 1000 | |
123 movf OFF+0,W ; d1-off --> a | |
124 subwf D1+0,W | |
125 movwf isr_xA+0 | |
126 movf OFF+1,W | |
127 subwfb D1+1,W | |
128 movwf isr_xA+1 | |
129 | |
130 movff SENS+0,isr_xB+0 ; sens --> b | |
131 movff SENS+1,isr_xB+1 | |
132 call isr_signed_mult16x16 | |
133 movlw .12-.8 ; a 12bit shift = 1 byte + 4 bits. | |
134 call isr_shift_C31 | |
135 | |
136 movlw LOW(.1000) ; add 1000 | |
137 addwf isr_xC+1,F | |
138 movlw HIGH(.1000) | |
139 addwfc isr_xC+2,F | |
140 | |
92
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
141 ; Add opt_pressure_adjust to result (SIGNED!) |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
142 movff opt_pressure_adjust,isr_xC+0 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
143 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
144 btfss isr_xC+0,7 ; <0? |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
145 bra pressure_extra_add ; No |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
146 ; Yes |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
147 comf isr_xC+0,F |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
148 incf isr_xC+0,F |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
149 ; Check for max. of 20mbar |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
150 movlw .21 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
151 cpfslt isr_xC+0 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
152 clrf isr_xC+0 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
153 ; Subtract |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
154 movf isr_xC+0,W |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
155 subwf isr_xC+1,F |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
156 movlw .0 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
157 subwfb isr_xC+2,F |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
158 bra pressure_extra_common |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
159 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
160 pressure_extra_add: |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
161 ; Check for max. of 20mbar |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
162 movlw .21 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
163 cpfslt isr_xC+0 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
164 clrf isr_xC+0 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
165 ; Add |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
166 movf isr_xC+0,W |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
167 addwf isr_xC+1,F |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
168 movlw .0 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
169 addwfc isr_xC+2,F |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
170 |
7ca1105751c7
add sensor calibration option (PC only), some cleanup
heinrichsweikamp
parents:
29
diff
changeset
|
171 pressure_extra_common: |
0 | 172 banksel common |
173 btfss simulatormode_active ; are we in simulator mode? | |
174 bra calc_compensation_2 ; no | |
175 banksel isr_backup | |
176 | |
177 movff sim_pressure+0,isr_xC+1 ; override readings with simulator values | |
178 movff sim_pressure+1,isr_xC+2 | |
179 | |
180 calc_compensation_2: | |
181 banksel isr_backup | |
182 movf isr_xC+1,W ; Then sum_up to pressure averaging buffer. | |
183 addwf amb_pressure_avg+0,F | |
184 movf isr_xC+2,W | |
185 addwfc amb_pressure_avg+1,F | |
186 | |
187 ; calculate temp = 200 + dT*(C6+100)/2^11 | |
188 movlw LOW(.100) ; C6 + 100 --> A | |
189 addwf C6+0,W | |
190 movwf isr_xA+0 | |
191 movlw HIGH(.100) | |
192 addwfc C6+1,W | |
193 movwf isr_xA+1 | |
194 | |
195 movff xdT2+0,isr_xB+0 ; dT2 --> B | |
196 movff xdT2+1,isr_xB+1 | |
197 call isr_signed_mult16x16 ; A*B | |
198 movlw .11-.8 ; A 12bit shift = 1 byte + 3 bits. | |
199 call isr_shift_C31 | |
200 | |
201 movlw LOW(.200) ; Add 200 | |
202 addwf isr_xC+1,F | |
203 movlw HIGH(.200) | |
204 addwfc isr_xC+2,F | |
205 | |
206 movf isr_xC+1,W | |
207 addwf temperature_avg+0,F | |
208 movf isr_xC+2,W | |
209 addwfc temperature_avg+1,F | |
210 | |
211 return ; Done. | |
212 | |
213 ;============================================================================= | |
214 global get_pressure_start | |
215 get_pressure_start: | |
216 rcall reset_MS5541 | |
217 movlw b'10100000' ;+3*high as start and 1+low as stop! | |
218 get_pressure_start2: | |
219 movwf isr1_temp | |
220 movlw d'12' | |
221 rcall send_data_MS5541 | |
222 return | |
223 | |
224 global get_pressure_value | |
225 get_pressure_value: | |
226 btfsc MS5541_miso ; Conversion done? | |
227 return ; No, Return | |
228 rcall get_2bytes_MS5541 | |
229 movff dMSB,D1+1 | |
230 movff dLSB,D1+0 | |
231 return | |
232 | |
233 ;============================================================================= | |
234 global get_temperature_start | |
235 get_temperature_start: | |
236 rcall reset_MS5541 | |
237 movlw b'10010000' ;+3*high as start and 1+low as stop! | |
238 bra get_pressure_start2 ; continue in "get_pressure" | |
239 | |
240 global get_temperature_value | |
241 get_temperature_value: | |
242 btfsc MS5541_miso ; Conversion done? | |
243 return ; No, Return | |
244 rcall get_2bytes_MS5541 | |
245 movff dMSB,D2+1 | |
246 movff dLSB,D2+0 | |
247 return | |
248 | |
249 ;============================================================================= | |
250 global get_calibration_data | |
251 get_calibration_data: | |
252 banksel common | |
253 bsf no_sensor_int ; disable sensor interrupts | |
254 banksel isr_backup ; Back to Bank0 ISR data | |
255 | |
256 rcall reset_MS5541 | |
257 movlw b'01010100' ;+3*high as start and 1+low as stop! | |
258 movwf isr1_temp | |
259 movlw d'13' | |
260 rcall send_data_MS5541 | |
261 rcall get_2bytes_MS5541 | |
262 movff dMSB,W1+1 | |
263 movff dLSB,W1+0 | |
264 | |
265 movlw b'01011000' ;+3*high as start and 1+low as stop! | |
266 movwf isr1_temp | |
267 movlw d'13' | |
268 rcall send_data_MS5541 | |
269 rcall get_2bytes_MS5541 | |
270 movff dMSB,W2+1 | |
271 movff dLSB,W2+0 | |
272 | |
273 movlw b'01100100' ;+3*high as start and 1+low as stop! | |
274 movwf isr1_temp | |
275 movlw d'13' | |
276 rcall send_data_MS5541 | |
277 rcall get_2bytes_MS5541 | |
278 movff dMSB,W3+1 | |
279 movff dLSB,W3+0 | |
280 | |
281 movlw b'01101000' ;+3*high as start and 1+low as stop! | |
282 movwf isr1_temp | |
283 movlw d'13' | |
284 rcall send_data_MS5541 | |
285 rcall get_2bytes_MS5541 | |
286 movff dMSB,W4+1 | |
287 movff dLSB,W4+0 | |
288 | |
289 ; calculate C1 (16Bit) | |
290 movff W1+1, C1+1 | |
291 bcf STATUS,C | |
292 rrcf C1+1 | |
293 bcf STATUS,C | |
294 rrcf C1+1 | |
295 bcf STATUS,C | |
296 rrcf C1+1 | |
297 movff W1+0, C1+0 | |
298 bsf STATUS,C | |
299 btfss W1+1,0 | |
300 bcf STATUS,C | |
301 rrcf C1+0 | |
302 bsf STATUS,C | |
303 btfss W1+1,1 | |
304 bcf STATUS,C | |
305 rrcf C1+0 | |
306 bsf STATUS,C | |
307 btfss W1+1,2 | |
308 bcf STATUS,C | |
309 rrcf C1+0 | |
310 | |
311 ; calculate C2 (16Bit) | |
312 movff W2+0, C2+0 | |
313 bsf STATUS,C | |
314 btfss W2+1,0 | |
315 bcf STATUS,C | |
316 rrcf C2+0 | |
317 bsf STATUS,C | |
318 btfss W2+1,1 | |
319 bcf STATUS,C | |
320 rrcf C2+0 | |
321 bsf STATUS,C | |
322 btfss W2+1,2 | |
323 bcf STATUS,C | |
324 rrcf C2+0 | |
325 bsf STATUS,C | |
326 btfss W2+1,3 | |
327 bcf STATUS,C | |
328 rrcf C2+0 | |
329 bsf STATUS,C | |
330 btfss W2+1,4 | |
331 bcf STATUS,C | |
332 rrcf C2+0 | |
333 bsf STATUS,C | |
334 btfss W2+1,5 | |
335 bcf STATUS,C | |
336 rrcf C2+0 | |
337 | |
338 movff W2+1, C2+1 | |
339 bsf STATUS,C | |
340 btfss W1+0,0 | |
341 bcf STATUS,C | |
342 rrcf C2+1 | |
343 bsf STATUS,C | |
344 btfss W1+0,1 | |
345 bcf STATUS,C | |
346 rrcf C2+1 | |
347 bsf STATUS,C | |
348 btfss W1+0,2 | |
349 bcf STATUS,C | |
350 rrcf C2+1 | |
351 bcf STATUS,C | |
352 rrcf C2+1 | |
353 bcf STATUS,C | |
354 rrcf C2+1 | |
355 bcf STATUS,C | |
356 rrcf C2+1 | |
357 | |
358 ; calculate C3 (16Bit) | |
359 movff W3+1,C3+0 | |
360 bsf STATUS,C | |
361 btfss W3+0,7 | |
362 bcf STATUS,C | |
363 rlcf C3+0 | |
364 bsf STATUS,C | |
365 btfss W3+0,6 | |
366 bcf STATUS,C | |
367 rlcf C3+0 | |
368 clrf C3+1 | |
369 btfsc W3+1,7 | |
370 bsf C3+1,1 | |
371 btfsc W3+1,6 | |
372 bsf C3+1,0 | |
373 | |
374 ; calculate C4 (16Bit) | |
375 movff W4+1,C4+0 | |
376 bsf STATUS,C | |
377 btfss W4+0,7 | |
378 bcf STATUS,C | |
379 rlcf C4+0 | |
380 clrf C4+1 | |
381 btfsc W4+1,7 | |
382 bsf C4+1,0 | |
383 | |
384 ; C4=C4-250 | |
385 movlw LOW(-.250) ; C4 - 250 --> C4 | |
386 addwf C4+0,W | |
387 movwf C4+0 | |
388 movlw -1 ; HIGH(- .250) is not understood... | |
389 addwfc C4+1,W | |
390 movwf C4+1 | |
391 | |
392 ; calculate C5 (16Bit) | |
393 movff W3+0,C5+0 | |
394 bcf C5+0,6 | |
395 btfsc W2+0,0 | |
396 bsf C5+0,6 | |
397 bcf C5+0,7 | |
398 btfsc W2+0,1 | |
399 bsf C5+0,7 | |
400 clrf C5+1 | |
401 btfsc W2+0,2 | |
402 bsf C5+1,0 | |
403 btfsc W2+0,3 | |
404 bsf C5+1,1 | |
405 btfsc W2+0,4 | |
406 bsf C5+1,2 | |
407 btfsc W2+0,5 | |
408 bsf C5+1,3 | |
409 | |
410 ; calculate C5 = UT1 | |
411 ; C5 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) | |
412 clrf isr_xA+1 | |
413 movlw d'8' | |
414 movwf isr_xA+0 | |
415 movff C5+0,isr_xB+0 | |
416 movff C5+1,isr_xB+1 | |
417 call isr_unsigned_mult16x16 ;isr_xA*isr_xB=isr_xC | |
418 movff isr_xC+0,C5+0 | |
419 movff isr_xC+1,C5+1 | |
420 movlw LOW d'10000' | |
421 addwf C5+0,F | |
422 movlw HIGH d'10000' | |
423 addwfc C5+1,F ; = 8*C5 + 10000 | |
424 | |
425 ; calculate C6 (16Bit) | |
426 clrf C6+1 | |
427 movff W4+0,C6+0 | |
428 bcf C6+0,7 | |
429 | |
430 banksel common | |
431 bcf no_sensor_int ; enable sensor interrupts | |
432 bcf pressure_refresh ; Clear flag | |
433 banksel isr_backup ; Back to Bank0 ISR data | |
434 | |
435 clrf sensor_state_counter ; Then reset State counter | |
436 | |
437 return | |
438 | |
439 ;============================================================================= | |
440 reset_MS5541_one: | |
441 bsf MS5541_mosi | |
442 bra send_clk_pulse ; Send one high-low sequence on MS5541_clk -> and return | |
443 | |
444 reset_MS5541_zero: | |
445 bcf MS5541_mosi | |
446 bra send_clk_pulse ; Send one high-low sequence on MS5541_clk -> and return | |
447 | |
448 reset_MS5541: | |
449 rcall reset_MS5541_one ;0 | |
450 rcall reset_MS5541_zero | |
451 rcall reset_MS5541_one | |
452 rcall reset_MS5541_zero | |
453 rcall reset_MS5541_one | |
454 rcall reset_MS5541_zero | |
455 rcall reset_MS5541_one | |
456 rcall reset_MS5541_zero | |
457 rcall reset_MS5541_one | |
458 rcall reset_MS5541_zero | |
459 rcall reset_MS5541_one | |
460 rcall reset_MS5541_zero | |
461 rcall reset_MS5541_one | |
462 rcall reset_MS5541_zero | |
463 rcall reset_MS5541_one | |
464 rcall reset_MS5541_zero ;15 | |
465 rcall reset_MS5541_zero | |
466 rcall reset_MS5541_zero | |
467 rcall reset_MS5541_zero | |
468 rcall reset_MS5541_zero | |
469 rcall reset_MS5541_zero ;20 | |
470 return | |
471 | |
472 get_2bytes_MS5541: | |
473 movlw d'8' | |
474 movwf clock_count | |
475 rcall recieve_loop | |
476 movff isr1_temp,dMSB | |
477 | |
478 movlw d'8' | |
479 movwf clock_count | |
480 rcall recieve_loop | |
481 movff isr1_temp,dLSB | |
482 bra send_clk_pulse ; Send one high-low sequence on MS5541_clk -> and return | |
483 ;return | |
484 | |
485 recieve_loop: | |
486 rcall send_clk_pulse ; Send one high-low sequence on MS5541_clk | |
487 btfss MS5541_miso ;MSB first | |
488 bcf STATUS,C | |
489 btfsc MS5541_miso ;MSB first | |
490 bsf STATUS,C | |
491 rlcf isr1_temp,F | |
492 decfsz clock_count,F | |
493 bra recieve_loop | |
494 return | |
495 | |
496 send_clk_pulse: | |
497 bsf MS5541_clk | |
498 nop | |
499 nop | |
500 nop | |
501 nop | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
502 nop |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
503 nop |
0 | 504 bcf MS5541_clk |
505 nop | |
506 nop | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
507 nop |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
508 nop |
0 | 509 return |
510 | |
511 send_data_MS5541: | |
512 movwf clock_count ; From WREG | |
513 ; send three startbits first | |
514 bcf MS5541_clk | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
515 nop |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
516 nop |
0 | 517 bsf MS5541_mosi |
518 movlw d'3' | |
519 subwf clock_count,F ; total bit counter | |
520 rcall send_clk_pulse ; Send one high-low sequence on MS5541_clk | |
521 rcall send_clk_pulse ; Send one high-low sequence on MS5541_clk | |
522 rcall send_clk_pulse ; Send one high-low sequence on MS5541_clk | |
523 ; now send 8 bytes from isr_temp1 and fill-up with zeros | |
524 send_data_MS5541_2: | |
525 bcf MS5541_clk | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
526 nop |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
527 nop |
0 | 528 |
529 btfss isr1_temp,7 ;MSB first | |
530 bcf MS5541_mosi | |
531 btfsc isr1_temp,7 ;MSB first | |
532 bsf MS5541_mosi | |
533 | |
534 bsf MS5541_clk | |
535 | |
536 bcf STATUS,C | |
537 rlcf isr1_temp,F | |
29
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
538 nop |
50c3e2c7ba7a
adding cardinal (and ordinal) directions for the compass
heinrichsweikamp
parents:
0
diff
changeset
|
539 nop |
0 | 540 ; nop |
541 ; nop | |
542 ; nop | |
543 ; nop | |
544 ; bcf MS5541_clk | |
545 | |
546 decfsz clock_count,F | |
547 bra send_data_MS5541_2 | |
548 bcf MS5541_clk | |
549 return | |
550 | |
551 END |