comparison src/ms5541.asm @ 255:ad62dff7739a

add bearing option to compass
author heinrichsweikamp
date Mon, 23 Mar 2015 17:07:57 +0100
parents 39f6c07ce2f6
children 653a3ab08062
comparison
equal deleted inserted replaced
254:5fe7aff622f3 255:ad62dff7739a
256 movlw b'01010100' ;+3*high as start and 1+low as stop! 256 movlw b'01010100' ;+3*high as start and 1+low as stop!
257 movwf isr1_temp 257 movwf isr1_temp
258 movlw d'13' 258 movlw d'13'
259 rcall send_data_MS5541 259 rcall send_data_MS5541
260 rcall get_2bytes_MS5541 260 rcall get_2bytes_MS5541
261 movff dMSB,W1+1 261 movff dMSB,ir_s8_buffer+1
262 movff dLSB,W1+0 262 movff dLSB,ir_s8_buffer+0
263 263
264 movlw b'01011000' ;+3*high as start and 1+low as stop! 264 movlw b'01011000' ;+3*high as start and 1+low as stop!
265 movwf isr1_temp 265 movwf isr1_temp
266 movlw d'13' 266 movlw d'13'
267 rcall send_data_MS5541 267 rcall send_data_MS5541
268 rcall get_2bytes_MS5541 268 rcall get_2bytes_MS5541
269 movff dMSB,W2+1 269 movff dMSB,ir_s8_buffer+3
270 movff dLSB,W2+0 270 movff dLSB,ir_s8_buffer+2
271 271
272 movlw b'01100100' ;+3*high as start and 1+low as stop! 272 movlw b'01100100' ;+3*high as start and 1+low as stop!
273 movwf isr1_temp 273 movwf isr1_temp
274 movlw d'13' 274 movlw d'13'
275 rcall send_data_MS5541 275 rcall send_data_MS5541
276 rcall get_2bytes_MS5541 276 rcall get_2bytes_MS5541
277 movff dMSB,W3+1 277 movff dMSB,ir_s8_buffer+5
278 movff dLSB,W3+0 278 movff dLSB,ir_s8_buffer+4
279 279
280 movlw b'01101000' ;+3*high as start and 1+low as stop! 280 movlw b'01101000' ;+3*high as start and 1+low as stop!
281 movwf isr1_temp 281 movwf isr1_temp
282 movlw d'13' 282 movlw d'13'
283 rcall send_data_MS5541 283 rcall send_data_MS5541
284 rcall get_2bytes_MS5541 284 rcall get_2bytes_MS5541
285 movff dMSB,W4+1 285 movff dMSB,ir_s8_buffer+7
286 movff dLSB,W4+0 286 movff dLSB,ir_s8_buffer+6
287 287
288 ; calculate C1 (16Bit) 288 ; calculate C1 (16Bit)
289 movff W1+1, C1+1 289 movff ir_s8_buffer+1, C1+1
290 bcf STATUS,C 290 bcf STATUS,C
291 rrcf C1+1 291 rrcf C1+1
292 bcf STATUS,C 292 bcf STATUS,C
293 rrcf C1+1 293 rrcf C1+1
294 bcf STATUS,C 294 bcf STATUS,C
295 rrcf C1+1 295 rrcf C1+1
296 movff W1+0, C1+0 296 movff ir_s8_buffer+0, C1+0
297 bsf STATUS,C 297 bsf STATUS,C
298 btfss W1+1,0 298 btfss ir_s8_buffer+1,0
299 bcf STATUS,C 299 bcf STATUS,C
300 rrcf C1+0 300 rrcf C1+0
301 bsf STATUS,C 301 bsf STATUS,C
302 btfss W1+1,1 302 btfss ir_s8_buffer+1,1
303 bcf STATUS,C 303 bcf STATUS,C
304 rrcf C1+0 304 rrcf C1+0
305 bsf STATUS,C 305 bsf STATUS,C
306 btfss W1+1,2 306 btfss ir_s8_buffer+1,2
307 bcf STATUS,C 307 bcf STATUS,C
308 rrcf C1+0 308 rrcf C1+0
309 309
310 ; calculate C2 (16Bit) 310 ; calculate C2 (16Bit)
311 movff W2+0, C2+0 311 movff ir_s8_buffer+2, C2+0
312 bsf STATUS,C 312 bsf STATUS,C
313 btfss W2+1,0 313 btfss ir_s8_buffer+3,0
314 bcf STATUS,C 314 bcf STATUS,C
315 rrcf C2+0 315 rrcf C2+0
316 bsf STATUS,C 316 bsf STATUS,C
317 btfss W2+1,1 317 btfss ir_s8_buffer+3,1
318 bcf STATUS,C 318 bcf STATUS,C
319 rrcf C2+0 319 rrcf C2+0
320 bsf STATUS,C 320 bsf STATUS,C
321 btfss W2+1,2 321 btfss ir_s8_buffer+3,2
322 bcf STATUS,C 322 bcf STATUS,C
323 rrcf C2+0 323 rrcf C2+0
324 bsf STATUS,C 324 bsf STATUS,C
325 btfss W2+1,3 325 btfss ir_s8_buffer+3,3
326 bcf STATUS,C 326 bcf STATUS,C
327 rrcf C2+0 327 rrcf C2+0
328 bsf STATUS,C 328 bsf STATUS,C
329 btfss W2+1,4 329 btfss ir_s8_buffer+3,4
330 bcf STATUS,C 330 bcf STATUS,C
331 rrcf C2+0 331 rrcf C2+0
332 bsf STATUS,C 332 bsf STATUS,C
333 btfss W2+1,5 333 btfss ir_s8_buffer+3,5
334 bcf STATUS,C 334 bcf STATUS,C
335 rrcf C2+0 335 rrcf C2+0
336 336
337 movff W2+1, C2+1 337 movff ir_s8_buffer+3, C2+1
338 bsf STATUS,C 338 bsf STATUS,C
339 btfss W1+0,0 339 btfss ir_s8_buffer+0,0
340 bcf STATUS,C 340 bcf STATUS,C
341 rrcf C2+1 341 rrcf C2+1
342 bsf STATUS,C 342 bsf STATUS,C
343 btfss W1+0,1 343 btfss ir_s8_buffer+0,1
344 bcf STATUS,C 344 bcf STATUS,C
345 rrcf C2+1 345 rrcf C2+1
346 bsf STATUS,C 346 bsf STATUS,C
347 btfss W1+0,2 347 btfss ir_s8_buffer+0,2
348 bcf STATUS,C 348 bcf STATUS,C
349 rrcf C2+1 349 rrcf C2+1
350 bcf STATUS,C 350 bcf STATUS,C
351 rrcf C2+1 351 rrcf C2+1
352 bcf STATUS,C 352 bcf STATUS,C
353 rrcf C2+1 353 rrcf C2+1
354 bcf STATUS,C 354 bcf STATUS,C
355 rrcf C2+1 355 rrcf C2+1
356 356
357 ; calculate C3 (16Bit) 357 ; calculate C3 (16Bit)
358 movff W3+1,C3+0 358 movff ir_s8_buffer+5,C3+0
359 bsf STATUS,C 359 bsf STATUS,C
360 btfss W3+0,7 360 btfss ir_s8_buffer+4,7
361 bcf STATUS,C 361 bcf STATUS,C
362 rlcf C3+0 362 rlcf C3+0
363 bsf STATUS,C 363 bsf STATUS,C
364 btfss W3+0,6 364 btfss ir_s8_buffer+4,6
365 bcf STATUS,C 365 bcf STATUS,C
366 rlcf C3+0 366 rlcf C3+0
367 clrf C3+1 367 clrf C3+1
368 btfsc W3+1,7 368 btfsc ir_s8_buffer+5,7
369 bsf C3+1,1 369 bsf C3+1,1
370 btfsc W3+1,6 370 btfsc ir_s8_buffer+5,6
371 bsf C3+1,0 371 bsf C3+1,0
372 372
373 ; calculate C4 (16Bit) 373 ; calculate C4 (16Bit)
374 movff W4+1,C4+0 374 movff ir_s8_buffer+7,C4+0
375 bsf STATUS,C 375 bsf STATUS,C
376 btfss W4+0,7 376 btfss ir_s8_buffer+6,7
377 bcf STATUS,C 377 bcf STATUS,C
378 rlcf C4+0 378 rlcf C4+0
379 clrf C4+1 379 clrf C4+1
380 btfsc W4+1,7 380 btfsc ir_s8_buffer+7,7
381 bsf C4+1,0 381 bsf C4+1,0
382 382
383 ; C4=C4-250 383 ; C4=C4-250
384 movlw LOW(-.250) ; C4 - 250 --> C4 384 movlw LOW(-.250) ; C4 - 250 --> C4
385 addwf C4+0,W 385 addwf C4+0,W
387 movlw -1 ; HIGH(- .250) is not understood... 387 movlw -1 ; HIGH(- .250) is not understood...
388 addwfc C4+1,W 388 addwfc C4+1,W
389 movwf C4+1 389 movwf C4+1
390 390
391 ; calculate C5 (16Bit) 391 ; calculate C5 (16Bit)
392 movff W3+0,C5+0 392 movff ir_s8_buffer+4,C5+0
393 bcf C5+0,6 393 bcf C5+0,6
394 btfsc W2+0,0 394 btfsc ir_s8_buffer+2,0
395 bsf C5+0,6 395 bsf C5+0,6
396 bcf C5+0,7 396 bcf C5+0,7
397 btfsc W2+0,1 397 btfsc ir_s8_buffer+2,1
398 bsf C5+0,7 398 bsf C5+0,7
399 clrf C5+1 399 clrf C5+1
400 btfsc W2+0,2 400 btfsc ir_s8_buffer+2,2
401 bsf C5+1,0 401 bsf C5+1,0
402 btfsc W2+0,3 402 btfsc ir_s8_buffer+2,3
403 bsf C5+1,1 403 bsf C5+1,1
404 btfsc W2+0,4 404 btfsc ir_s8_buffer+2,4
405 bsf C5+1,2 405 bsf C5+1,2
406 btfsc W2+0,5 406 btfsc ir_s8_buffer+2,5
407 bsf C5+1,3 407 bsf C5+1,3
408 408
409 ; calculate C5 = UT1 409 ; calculate C5 = UT1
410 ; C5 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) 410 ; C5 = 8*C5 + 10000 (u16 range 10.000 .. +42.760)
411 clrf isr_xA+1 411 clrf isr_xA+1
421 movlw HIGH d'10000' 421 movlw HIGH d'10000'
422 addwfc C5+1,F ; = 8*C5 + 10000 422 addwfc C5+1,F ; = 8*C5 + 10000
423 423
424 ; calculate C6 (16Bit) 424 ; calculate C6 (16Bit)
425 clrf C6+1 425 clrf C6+1
426 movff W4+0,C6+0 426 movff ir_s8_buffer+6,C6+0
427 bcf C6+0,7 427 bcf C6+0,7
428 428
429 banksel common 429 banksel common
430 bcf no_sensor_int ; enable sensor interrupts 430 bcf no_sensor_int ; enable sensor interrupts
431 bcf pressure_refresh ; Clear flag 431 bcf pressure_refresh ; Clear flag