Mercurial > public > mk2
annotate code_part1/OSTC_code_asm_part1/ms5535.asm @ 352:544a96faa9f3 64kByte Logbook
New "Quit sim" option in simulated dive mode, CF02 now allows more then 240seconds, Bugfix with runtime=1min in runtime simulator
author | Heinrichsweikamp |
---|---|
date | Mon, 06 Jun 2011 18:50:26 +0200 |
parents | 2144f19fa1eb |
children | f53aa96ff2f4 |
rev | line source |
---|---|
0 | 1 ; OSTC - diving computer code |
2 ; Copyright (C) 2008 HeinrichsWeikamp GbR | |
3 | |
4 ; This program is free software: you can redistribute it and/or modify | |
5 ; it under the terms of the GNU General Public License as published by | |
6 ; the Free Software Foundation, either version 3 of the License, or | |
7 ; (at your option) any later version. | |
8 | |
9 ; This program is distributed in the hope that it will be useful, | |
10 ; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 ; GNU General Public License for more details. | |
13 | |
14 ; You should have received a copy of the GNU General Public License | |
15 ; along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | |
17 | |
18 ; routines for Intersema MS5535A, MS5541B and MS5541C | |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
19 ; history: |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
20 ; 2005-09-26: Written by Matthias Heinrichs, info@heinrichsweikamp.com |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
21 ; 2008-08-21: MH last updated, with second order compensation. |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
22 ; 2011-01-19: jDG Clean up using true signed arithmetics. |
341
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
23 ; 2011-05-19: jDG Avegaring temperature and amb_pressure in private variable, |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
24 ; Use signed 16bit value for temperature (compat with avg !). |
2144f19fa1eb
BUGFIX protect against ISR changing pressure/temperature while reading it.
JeanDo
parents:
340
diff
changeset
|
25 ; |
0 | 26 ; known bugs: |
27 ; ToDo: | |
28 | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
29 ;============================================================================= |
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
30 ; Expose internal variables, to ease debug: |
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
31 global D1, D2 |
289 | 32 global C1, C2, C3, C4, C5, C6 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
33 global xdT, xdT2, OFF, SENS, amb_pressure_avg, temperature_avg |
0 | 34 |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
35 ;============================================================================= |
0 | 36 calculate_compensation: |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
37 ; calculate UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) |
0 | 38 clrf isr_xA+1 |
39 movlw d'8' | |
40 movwf isr_xA+0 | |
41 movff C5+0,isr_xB+0 | |
42 movff C5+1,isr_xB+1 | |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
43 call isr_unsigned_mult16x16 ;isr_xA*isr_xB=isr_xC |
0 | 44 movlw LOW d'10000' |
45 addwf isr_xC+0, f | |
46 movlw HIGH d'10000' | |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
47 addwfc isr_xC+1, f ;isr_xC= 8*C5 + 10000 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
48 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
49 ; xdT = D2 - UT1 (s16 range -11.400 .. +12.350) |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
50 movf isr_xC+0,W ; Get Value to be subtracted |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
51 subwf D2+0,W ; Do the Low Byte |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
52 movwf xdT+0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
53 movf isr_xC+1,W ; Then the high byte. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
54 subwfb D2+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
55 movwf xdT+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
56 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
57 ; Second order temperature calculation |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
58 ; xdT/128 is in range -89..+96, hence signed 8bit. dT/128 = (2*dT)/256 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
59 rlcf xdT+0,W ; put hit bit in carry. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
60 rlcf xdT+1,W ; inject in high byte. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
61 movwf isr_xA+0 ; and put result in low byte. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
62 clrf isr_xA+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
63 btfsc xdT+1,7 ; If dT < 0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
64 setf isr_xA+1 ; then signextend to -1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
65 movff isr_xA+0,isr_xB+0 ; copy A to B |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
66 movff isr_xA+1,isr_xB+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
67 call isr_signed_mult16x16 ; dT*dT --> xC (32 bits) |
0 | 68 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
69 ; dT >= 0: divide by 8, ie. 3 shifts rights. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
70 ; dT < 0: divide by 2, ie. 1 shifts rights. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
71 movlw .3 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
72 btfss xdT+1,7 ; Was dT negatif ? |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
73 movlw .1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
74 calc_loop_1: |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
75 bcf STATUS,C ;dT^2 is positiv, so injected zeros. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
76 rrcf isr_xC+1,F |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
77 rrcf isr_xC+0,F |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
78 decfsz WREG |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
79 bra calc_loop_1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
80 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
81 movf isr_xC+0,W ; dT2 = dT - (dT/128)*(dT/128)/(2 ...or... 8) |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
82 subwf xdT+0,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
83 movwf xdT2+0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
84 movf isr_xC+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
85 subwfb xdT+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
86 movwf xdT2+1 |
0 | 87 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
88 ; Calculate OFF = C2 + ((C4-250)*dT2)/2^12 + 10000 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
89 ; (range +9.246 .. +18.887) |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
90 movlw LOW(-.250) ; C4 - 250 --> A |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
91 addwf C4+0,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
92 movwf isr_xA+0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
93 movlw -1 ; HIGH(- .250) is not hunderstood... |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
94 addwfc C4+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
95 movwf isr_xA+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
96 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
97 movff xdT2+0,isr_xB+0 ; dT2 --> B |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
98 movff xdT2+1,isr_xB+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
99 call isr_signed_mult16x16 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
100 movlw .12-.8 ; A 12bit shift = 1 byte + 4 bits. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
101 call isr_shift_C31 |
0 | 102 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
103 movlw LOW(.10000) ; Add 10000 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
104 addwf isr_xC+1,F |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
105 movlw HIGH(.10000) |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
106 addwfc isr_xC+2,F |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
107 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
108 movf C2+0,W ; Add C2, and save into OFF |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
109 addwf isr_xC+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
110 movwf OFF+0 |
0 | 111 movf C2+1,W |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
112 addwfc isr_xC+2,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
113 movwf OFF+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
114 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
115 ; Calculate SENS = C1/2 + ((C3+200)*dT)/2^13 + 3000 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
116 movlw LOW(.200) ; C3+200 --> A |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
117 addwf C3+0,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
118 movwf isr_xA+0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
119 movlw HIGH(.200) |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
120 addwfc C3+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
121 movwf isr_xA+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
122 ; B still contains dT2 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
123 call isr_signed_mult16x16 ; A*B --> C |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
124 movlw .13-.8 ; A 13bit shift = 1 byte + 5 bits. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
125 call isr_shift_C31 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
126 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
127 bcf STATUS,C ; SENS = C1 / 2 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
128 rrcf C1+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
129 movwf SENS+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
130 rrcf C1+0,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
131 movwf SENS+0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
132 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
133 movlw LOW(.3000) ; Add 3000 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
134 addwf isr_xC+1,F |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
135 movlw HIGH(.3000) |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
136 addwfc isr_xC+2,F |
0 | 137 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
138 movf isr_xC+1,W ; And sum into SENS |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
139 addwf SENS+0,F |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
140 movf isr_xC+2,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
141 addwfc SENS+1,F |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
142 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
143 ; calculate amb_pressure = (sens * (d1-off))/2^12 + 1000 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
144 movf OFF+0,W ; d1-off --> a |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
145 subwf D1+0,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
146 movwf isr_xA+0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
147 movf OFF+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
148 subwfb D1+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
149 movwf isr_xA+1 |
0 | 150 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
151 movff SENS+0,isr_xB+0 ; sens --> b |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
152 movff SENS+1,isr_xB+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
153 call isr_signed_mult16x16 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
154 movlw .12-.8 ; a 12bit shift = 1 byte + 4 bits. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
155 call isr_shift_C31 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
156 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
157 movlw LOW(.1000) ; add 1000 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
158 addwf isr_xC+1,F |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
159 movlw HIGH(.1000) |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
160 addwfc isr_xC+2,F |
0 | 161 |
162 btfss simulatormode_active ; are we in simulator mode? | |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
163 bra calc_compensation_2 ; no |
0 | 164 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
165 movff sim_pressure+0,isr_xC+1 ; override readings with simulator values |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
166 movff sim_pressure+1,isr_xC+2 |
0 | 167 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
168 calc_compensation_2: |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
169 movf isr_xC+1,W ; Then sum_up to pressure averaging buffer. |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
170 addwf amb_pressure_avg+0,F |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
171 movf isr_xC+2,W |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
172 addwfc amb_pressure_avg+1,F |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
173 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
174 ; calculate temp = 200 + dT*(C6+100)/2^11 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
175 movlw LOW(.100) ; C6 + 100 --> A |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
176 addwf C6+0,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
177 movwf isr_xA+0 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
178 movlw HIGH(.100) |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
179 addwfc C6+1,W |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
180 movwf isr_xA+1 |
0 | 181 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
182 movff xdT2+0,isr_xB+0 ; dT2 --> B |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
183 movff xdT2+1,isr_xB+1 |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
184 call isr_signed_mult16x16 ; A*B |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
185 movlw .11-.8 ; A 12bit shift = 1 byte + 3 bits. |
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
186 call isr_shift_C31 |
0 | 187 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
188 movlw LOW(.200) ; Add 200 |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
189 addwf isr_xC+1,F |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
190 movlw HIGH(.200) |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
191 addwfc isr_xC+2,F |
0 | 192 |
340
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
193 movf isr_xC+1,W |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
194 addwf temperature_avg+0,F |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
195 movf isr_xC+2,W |
ecbbbd423e86
BUGFIX save negativ temperatures in logbook (bbbug #6)
JeanDo
parents:
289
diff
changeset
|
196 addwfc temperature_avg+1,F |
0 | 197 |
161
8d6aca08f66b
Use signed arithmetic for pressure/temperature compensation.
JeanDo
parents:
83
diff
changeset
|
198 return ; Fertig mit allem |
0 | 199 |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
200 ;============================================================================= |
0 | 201 get_pressure_start: |
202 rcall reset_MS5535A | |
203 movlw b'10100000' ;+3*high as start and 1+low as stop! | |
204 get_pressure_start2: | |
205 movwf isr1_temp | |
206 movlw d'12' | |
207 movwf clock_count | |
208 rcall send_data_MS55535A | |
209 return | |
210 | |
211 get_pressure_value: | |
81
31fa973a70fd
Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
JeanDo
parents:
4
diff
changeset
|
212 #ifndef TESTING |
31fa973a70fd
Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
JeanDo
parents:
4
diff
changeset
|
213 ; Use register injection instead when in MPLab Sim emulation... |
0 | 214 rcall get_2bytes_MS5535A |
215 movff dMSB,D1+1 | |
216 movff dLSB,D1+0 | |
81
31fa973a70fd
Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
JeanDo
parents:
4
diff
changeset
|
217 #endif |
0 | 218 return |
219 | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
220 ;============================================================================= |
0 | 221 get_temperature_start: |
222 rcall reset_MS5535A | |
223 movlw b'10010000' ;+3*high as start and 1+low as stop! | |
224 bra get_pressure_start2 ; continue in "get_pressure" | |
225 | |
226 get_temperature_value: | |
81
31fa973a70fd
Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
JeanDo
parents:
4
diff
changeset
|
227 #ifndef TESTING |
31fa973a70fd
Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
JeanDo
parents:
4
diff
changeset
|
228 ; Use register injection instead... |
0 | 229 rcall get_2bytes_MS5535A |
230 movff dMSB,D2+1 | |
231 movff dLSB,D2+0 | |
81
31fa973a70fd
Kludges to emulate inexisting devices when debugged with the MPLAB software SIMulator.
JeanDo
parents:
4
diff
changeset
|
232 #endif |
0 | 233 return |
234 | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
235 ;============================================================================= |
0 | 236 get_calibration_data: |
237 rcall reset_MS5535A | |
238 movlw d'13' | |
239 movwf clock_count | |
240 movlw b'01010100' ;+3*high as start and 1+low as stop! | |
241 movwf isr1_temp | |
242 rcall send_data_MS55535A | |
243 rcall get_2bytes_MS5535A | |
289 | 244 |
245 #ifdef TESTING | |
246 movlw LOW(.18556) | |
247 movff WREG,W1+0 | |
248 movlw HIGH(.18556) | |
249 movff WREG,W1+1 | |
250 #else | |
0 | 251 movff dMSB,W1+1 |
252 movff dLSB,W1+0 | |
289 | 253 #endif |
0 | 254 |
255 movlw d'13' | |
256 movwf clock_count | |
257 movlw b'01011000' ;+3*high as start and 1+low as stop! | |
258 movwf isr1_temp | |
259 rcall send_data_MS55535A | |
260 rcall get_2bytes_MS5535A | |
289 | 261 #ifdef TESTING |
262 movlw LOW(.49183) | |
263 movff WREG,W2+0 | |
264 movlw HIGH(.49183) | |
265 movff WREG,W2+1 | |
266 #else | |
0 | 267 movff dMSB,W2+1 |
268 movff dLSB,W2+0 | |
289 | 269 #endif |
0 | 270 |
271 movlw d'13' | |
272 movwf clock_count | |
273 movlw b'01100100' ;+3*high as start and 1+low as stop! | |
274 movwf isr1_temp | |
275 rcall send_data_MS55535A | |
276 rcall get_2bytes_MS5535A | |
289 | 277 #ifdef TESTING |
278 movlw LOW(.22354) | |
279 movff WREG,W3+0 | |
280 movlw HIGH(.22354) | |
281 movff WREG,W3+1 | |
282 #else | |
0 | 283 movff dMSB,W3+1 |
284 movff dLSB,W3+0 | |
289 | 285 #endif |
0 | 286 |
287 movlw d'13' | |
288 movwf clock_count | |
289 movlw b'01101000' ;+3*high as start and 1+low as stop! | |
290 movwf isr1_temp | |
291 rcall send_data_MS55535A | |
292 rcall get_2bytes_MS5535A | |
289 | 293 #ifdef TESTING |
294 movlw LOW(.28083) | |
295 movff WREG,W4+0 | |
296 movlw HIGH(.28083) | |
297 movff WREG,W4+1 | |
298 #else | |
0 | 299 movff dMSB,W4+1 |
300 movff dLSB,W4+0 | |
289 | 301 #endif |
0 | 302 |
303 ; calculate C1 (16Bit) | |
304 movff W1+1, C1+1 | |
305 bcf STATUS,C | |
306 rrcf C1+1 | |
307 bcf STATUS,C | |
308 rrcf C1+1 | |
309 bcf STATUS,C | |
310 rrcf C1+1 | |
311 movff W1+0, C1+0 | |
312 bsf STATUS,C | |
313 btfss W1+1,0 | |
314 bcf STATUS,C | |
315 rrcf C1+0 | |
316 bsf STATUS,C | |
317 btfss W1+1,1 | |
318 bcf STATUS,C | |
319 rrcf C1+0 | |
320 bsf STATUS,C | |
321 btfss W1+1,2 | |
322 bcf STATUS,C | |
323 rrcf C1+0 | |
324 | |
325 ; calculate C2 (16Bit) | |
326 movff W2+0, C2+0 | |
327 bsf STATUS,C | |
328 btfss W2+1,0 | |
329 bcf STATUS,C | |
330 rrcf C2+0 | |
331 bsf STATUS,C | |
332 btfss W2+1,1 | |
333 bcf STATUS,C | |
334 rrcf C2+0 | |
335 bsf STATUS,C | |
336 btfss W2+1,2 | |
337 bcf STATUS,C | |
338 rrcf C2+0 | |
339 bsf STATUS,C | |
340 btfss W2+1,3 | |
341 bcf STATUS,C | |
342 rrcf C2+0 | |
343 bsf STATUS,C | |
344 btfss W2+1,4 | |
345 bcf STATUS,C | |
346 rrcf C2+0 | |
347 bsf STATUS,C | |
348 btfss W2+1,5 | |
349 bcf STATUS,C | |
350 rrcf C2+0 | |
351 | |
352 movff W2+1, C2+1 | |
353 bsf STATUS,C | |
354 btfss W1+0,0 | |
355 bcf STATUS,C | |
356 rrcf C2+1 | |
357 bsf STATUS,C | |
358 btfss W1+0,1 | |
359 bcf STATUS,C | |
360 rrcf C2+1 | |
361 bsf STATUS,C | |
362 btfss W1+0,2 | |
363 bcf STATUS,C | |
364 rrcf C2+1 | |
365 bcf STATUS,C | |
366 rrcf C2+1 | |
367 bcf STATUS,C | |
368 rrcf C2+1 | |
369 bcf STATUS,C | |
370 rrcf C2+1 | |
371 | |
372 ; calculate C3 (16Bit) | |
373 movff W3+1,C3+0 | |
374 bsf STATUS,C | |
375 btfss W3+0,7 | |
376 bcf STATUS,C | |
377 rlcf C3+0 | |
378 bsf STATUS,C | |
379 btfss W3+0,6 | |
380 bcf STATUS,C | |
381 rlcf C3+0 | |
382 clrf C3+1 | |
383 btfsc W3+1,7 | |
384 bsf C3+1,1 | |
385 btfsc W3+1,6 | |
386 bsf C3+1,0 | |
387 | |
388 ; calculate C4 (16Bit) | |
389 movff W4+1,C4+0 | |
390 bsf STATUS,C | |
391 btfss W4+0,7 | |
392 bcf STATUS,C | |
393 rlcf C4+0 | |
394 clrf C4+1 | |
395 btfsc W4+1,7 | |
396 bsf C4+1,0 | |
397 | |
398 ; calculate C5 (16Bit) | |
399 movff W3+0,C5+0 | |
400 bcf C5+0,6 | |
401 btfsc W2+0,0 | |
402 bsf C5+0,6 | |
403 bcf C5+0,7 | |
404 btfsc W2+0,1 | |
405 bsf C5+0,7 | |
406 clrf C5+1 | |
407 btfsc W2+0,2 | |
408 bsf C5+1,0 | |
409 btfsc W2+0,3 | |
410 bsf C5+1,1 | |
411 btfsc W2+0,4 | |
412 bsf C5+1,2 | |
413 btfsc W2+0,5 | |
414 bsf C5+1,3 | |
415 | |
416 ; calculate C6 (16Bit) | |
417 clrf C6+1 | |
418 movff W4+0,C6+0 | |
419 bcf C6+0,7 | |
420 | |
421 bcf no_sensor_int ; enable sensor interrupts | |
422 return | |
423 | |
169
e26f49674956
Merge decoplan display for both GF and Buhlmann models.
JeanDo
parents:
161
diff
changeset
|
424 ;============================================================================= |
0 | 425 reset_MS5535A_one: |
426 bsf sensor_SDO | |
427 nop | |
428 bsf sensor_CLK | |
429 nop | |
430 nop | |
431 nop | |
432 nop | |
433 nop | |
434 nop | |
435 bcf sensor_CLK | |
436 return | |
437 | |
438 reset_MS5535A_zero: | |
439 bcf sensor_SDO | |
440 nop | |
441 bsf sensor_CLK | |
442 nop | |
443 nop | |
444 nop | |
445 nop | |
446 nop | |
447 nop | |
448 bcf sensor_CLK | |
449 return | |
450 | |
451 reset_MS5535A: | |
452 rcall reset_MS5535A_one ;0 | |
453 rcall reset_MS5535A_zero | |
454 rcall reset_MS5535A_one | |
455 rcall reset_MS5535A_zero | |
456 rcall reset_MS5535A_one | |
457 rcall reset_MS5535A_zero | |
458 rcall reset_MS5535A_one | |
459 rcall reset_MS5535A_zero | |
460 rcall reset_MS5535A_one | |
461 rcall reset_MS5535A_zero | |
462 rcall reset_MS5535A_one | |
463 rcall reset_MS5535A_zero | |
464 rcall reset_MS5535A_one | |
465 rcall reset_MS5535A_zero | |
466 rcall reset_MS5535A_one | |
467 rcall reset_MS5535A_zero ;15 | |
468 rcall reset_MS5535A_zero | |
469 rcall reset_MS5535A_zero | |
470 rcall reset_MS5535A_zero | |
471 rcall reset_MS5535A_zero | |
472 rcall reset_MS5535A_zero ;20 | |
473 return | |
474 | |
475 get_2bytes_MS5535A: | |
476 movlw d'8' | |
477 movwf clock_count | |
478 rcall recieve_loop | |
479 movff isr1_temp,dMSB | |
480 | |
481 movlw d'8' | |
482 movwf clock_count | |
483 rcall recieve_loop | |
484 movff isr1_temp,dLSB | |
485 bsf sensor_CLK | |
486 nop | |
487 nop | |
488 nop | |
489 nop | |
490 nop | |
491 nop | |
492 bcf sensor_CLK | |
493 return | |
494 | |
495 recieve_loop: | |
496 bsf sensor_CLK | |
497 nop | |
498 nop | |
499 nop | |
500 nop | |
501 nop | |
502 nop | |
503 bcf sensor_CLK | |
504 btfss sensor_SDI ;MSB first | |
505 bcf STATUS,C | |
506 btfsc sensor_SDI ;MSB first | |
507 bsf STATUS,C | |
508 rlcf isr1_temp,F | |
509 decfsz clock_count,F | |
510 bra recieve_loop | |
511 return | |
512 | |
513 send_data_MS55535A: | |
514 ; send three startbits first | |
515 bcf sensor_CLK | |
516 bsf sensor_SDO | |
517 movlw d'3' | |
518 subwf clock_count,F ; total bit counter | |
519 bsf sensor_CLK | |
520 nop | |
521 nop | |
522 nop | |
523 nop | |
524 nop | |
525 nop | |
526 bcf sensor_CLK | |
527 nop | |
528 nop | |
529 nop | |
530 nop | |
531 nop | |
532 nop | |
533 bsf sensor_CLK | |
534 nop | |
535 nop | |
536 nop | |
537 nop | |
538 nop | |
539 nop | |
540 bcf sensor_CLK | |
541 nop | |
542 nop | |
543 nop | |
544 nop | |
545 nop | |
546 nop | |
547 bsf sensor_CLK | |
548 nop | |
549 nop | |
550 nop | |
551 nop | |
552 nop | |
553 nop | |
554 bcf sensor_CLK | |
555 ; now send 8 bytes from isr_temp1 and fill-up with zeros | |
556 datenbits: | |
557 btfss isr1_temp,7 ;MSB first | |
558 bcf sensor_SDO | |
559 btfsc isr1_temp,7 ;MSB first | |
560 bsf sensor_SDO | |
561 bcf STATUS,C | |
562 rlcf isr1_temp | |
563 | |
564 bsf sensor_CLK | |
565 nop | |
566 nop | |
567 nop | |
568 nop | |
569 nop | |
570 nop | |
571 bcf sensor_CLK | |
572 | |
573 decfsz clock_count,F | |
574 bra datenbits | |
575 return |