comparison code_part1/OSTC_code_asm_part1/ms5535.asm @ 704:422b9eeace4f

minor
author heinrichsweikamp
date Fri, 29 Mar 2013 20:53:41 +0100
parents f53aa96ff2f4
children b7f7184d800d
comparison
equal deleted inserted replaced
703:39e02673db4c 704:422b9eeace4f
32 global C1, C2, C3, C4, C5, C6 32 global C1, C2, C3, C4, C5, C6
33 global xdT, xdT2, OFF, SENS, amb_pressure_avg, temperature_avg 33 global xdT, xdT2, OFF, SENS, amb_pressure_avg, temperature_avg
34 34
35 ;============================================================================= 35 ;=============================================================================
36 calculate_compensation: 36 calculate_compensation:
37 ; calculate UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) 37 ; xdT = D2 - C5 (s16 range -11.400 .. +12.350)
38 clrf isr_xA+1 38 movf C5+0,W ; Get Value to be subtracted
39 movlw d'8'
40 movwf isr_xA+0
41 movff C5+0,isr_xB+0
42 movff C5+1,isr_xB+1
43 call isr_unsigned_mult16x16 ;isr_xA*isr_xB=isr_xC
44 movlw LOW d'10000'
45 addwf isr_xC+0, f
46 movlw HIGH d'10000'
47 addwfc isr_xC+1, f ;isr_xC= 8*C5 + 10000
48
49 ; xdT = D2 - UT1 (s16 range -11.400 .. +12.350)
50 movf isr_xC+0,W ; Get Value to be subtracted
51 subwf D2+0,W ; Do the Low Byte 39 subwf D2+0,W ; Do the Low Byte
52 movwf xdT+0 40 movwf xdT+0
53 movf isr_xC+1,W ; Then the high byte. 41 movf C5+1,W ; Then the high byte.
54 subwfb D2+1,W 42 subwfb D2+1,W
55 movwf xdT+1 43 movwf xdT+1
56 44
57 ; Second order temperature calculation 45 ; Second order temperature calculation
58 ; xdT/128 is in range -89..+96, hence signed 8bit. dT/128 = (2*dT)/256 46 ; xdT/128 is in range -89..+96, hence signed 8bit. dT/128 = (2*dT)/256
85 subwfb xdT+1,W 73 subwfb xdT+1,W
86 movwf xdT2+1 74 movwf xdT2+1
87 75
88 ; Calculate OFF = C2 + ((C4-250)*dT2)/2^12 + 10000 76 ; Calculate OFF = C2 + ((C4-250)*dT2)/2^12 + 10000
89 ; (range +9.246 .. +18.887) 77 ; (range +9.246 .. +18.887)
90 movlw LOW(-.250) ; C4 - 250 --> A 78 movff C4+0,isr_xA+0
91 addwf C4+0,W 79 movff C4+1,isr_xA+1
92 movwf isr_xA+0
93 movlw -1 ; HIGH(- .250) is not hunderstood...
94 addwfc C4+1,W
95 movwf isr_xA+1
96 80
97 movff xdT2+0,isr_xB+0 ; dT2 --> B 81 movff xdT2+0,isr_xB+0 ; dT2 --> B
98 movff xdT2+1,isr_xB+1 82 movff xdT2+1,isr_xB+1
99 call isr_signed_mult16x16 83 call isr_signed_mult16x16
100 movlw .12-.8 ; A 12bit shift = 1 byte + 4 bits. 84 movlw .12-.8 ; A 12bit shift = 1 byte + 4 bits.
392 bcf STATUS,C 376 bcf STATUS,C
393 rlcf C4+0 377 rlcf C4+0
394 clrf C4+1 378 clrf C4+1
395 btfsc W4+1,7 379 btfsc W4+1,7
396 bsf C4+1,0 380 bsf C4+1,0
381
382 ; C4=C4-250
383 movlw LOW(-.250) ; C4 - 250 --> C4
384 addwf C4+0,W
385 movwf C4+0
386 movlw -1 ; HIGH(- .250) is not understood...
387 addwfc C4+1,W
388 movwf C4+1
397 389
398 ; calculate C5 (16Bit) 390 ; calculate C5 (16Bit)
399 movff W3+0,C5+0 391 movff W3+0,C5+0
400 bcf C5+0,6 392 bcf C5+0,6
401 btfsc W2+0,0 393 btfsc W2+0,0
411 btfsc W2+0,4 403 btfsc W2+0,4
412 bsf C5+1,2 404 bsf C5+1,2
413 btfsc W2+0,5 405 btfsc W2+0,5
414 bsf C5+1,3 406 bsf C5+1,3
415 407
408 ; calculate C5 = UT1
409 ; C5 = 8*C5 + 10000 (u16 range 10.000 .. +42.760)
410 clrf isr_xA+1
411 movlw d'8'
412 movwf isr_xA+0
413 movff C5+0,isr_xB+0
414 movff C5+1,isr_xB+1
415 call isr_unsigned_mult16x16 ;isr_xA*isr_xB=isr_xC
416 movff isr_xC+0,C5+0
417 movff isr_xC+1,C5+1
418 movlw LOW d'10000'
419 addwf C5+0,F
420 movlw HIGH d'10000'
421 addwfc C5+1,F ; = 8*C5 + 10000
422
416 ; calculate C6 (16Bit) 423 ; calculate C6 (16Bit)
417 clrf C6+1 424 clrf C6+1
418 movff W4+0,C6+0 425 movff W4+0,C6+0
419 bcf C6+0,7 426 bcf C6+0,7
420 427