comparison code_part1/OSTC_code_asm_part1/ms5535.asm @ 344:797e2ac42d24 ScreenDump

MERGE with 1.91 main trunk.
author JeanDo
date Sat, 21 May 2011 14:48:07 +0200
parents 2144f19fa1eb
children f53aa96ff2f4
comparison
equal deleted inserted replaced
337:6bdf80d7276c 344:797e2ac42d24
18 ; routines for Intersema MS5535A, MS5541B and MS5541C 18 ; routines for Intersema MS5535A, MS5541B and MS5541C
19 ; history: 19 ; history:
20 ; 2005-09-26: Written by Matthias Heinrichs, info@heinrichsweikamp.com 20 ; 2005-09-26: Written by Matthias Heinrichs, info@heinrichsweikamp.com
21 ; 2008-08-21: MH last updated, with second order compensation. 21 ; 2008-08-21: MH last updated, with second order compensation.
22 ; 2011-01-19: jDG Clean up using true signed arithmetics. 22 ; 2011-01-19: jDG Clean up using true signed arithmetics.
23 ; 2011-05-19: jDG Avegaring temperature and amb_pressure in private variable,
24 ; Use signed 16bit value for temperature (compat with avg !).
25 ;
23 ; known bugs: 26 ; known bugs:
24 ; ToDo: 27 ; ToDo:
25 28
26 ;============================================================================= 29 ;=============================================================================
27 ; Expose internal variables, to ease debug: 30 ; Expose internal variables, to ease debug:
28 global D1, D2 31 global D1, D2
29 global C1, C2, C3, C4, C5, C6 32 global C1, C2, C3, C4, C5, C6
30 global xdT, xdT2, OFF, SENS, amb_pressure, temperature 33 global xdT, xdT2, OFF, SENS, amb_pressure_avg, temperature_avg
31 34
32 ;============================================================================= 35 ;=============================================================================
33 calculate_compensation: 36 calculate_compensation:
34 ; calculate UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760) 37 ; calculate UT1 = 8*C5 + 10000 (u16 range 10.000 .. +42.760)
35 clrf isr_xA+1 38 clrf isr_xA+1
149 movff SENS+1,isr_xB+1 152 movff SENS+1,isr_xB+1
150 call isr_signed_mult16x16 153 call isr_signed_mult16x16
151 movlw .12-.8 ; a 12bit shift = 1 byte + 4 bits. 154 movlw .12-.8 ; a 12bit shift = 1 byte + 4 bits.
152 call isr_shift_C31 155 call isr_shift_C31
153 156
154 movlw LOW(.1000) ; add 1000, and save into amb_pressure 157 movlw LOW(.1000) ; add 1000
155 addwf isr_xC+1,W 158 addwf isr_xC+1,F
156 movwf amb_pressure+0
157 movlw HIGH(.1000) 159 movlw HIGH(.1000)
158 addwfc isr_xC+2,W 160 addwfc isr_xC+2,F
159 movwf amb_pressure+1
160 161
161 btfss simulatormode_active ; are we in simulator mode? 162 btfss simulatormode_active ; are we in simulator mode?
162 bra calc_pressure_done ; no 163 bra calc_compensation_2 ; no
163 164
164 movff sim_pressure+0,amb_pressure+0 ; override readings with simulator values 165 movff sim_pressure+0,isr_xC+1 ; override readings with simulator values
165 movff sim_pressure+1,amb_pressure+1 166 movff sim_pressure+1,isr_xC+2
166 167
167 calc_pressure_done: 168 calc_compensation_2:
169 movf isr_xC+1,W ; Then sum_up to pressure averaging buffer.
170 addwf amb_pressure_avg+0,F
171 movf isr_xC+2,W
172 addwfc amb_pressure_avg+1,F
173
168 ; calculate temp = 200 + dT*(C6+100)/2^11 174 ; calculate temp = 200 + dT*(C6+100)/2^11
169 movlw LOW(.100) ; C6 + 100 --> A 175 movlw LOW(.100) ; C6 + 100 --> A
170 addwf C6+0,W 176 addwf C6+0,W
171 movwf isr_xA+0 177 movwf isr_xA+0
172 movlw HIGH(.100) 178 movlw HIGH(.100)
177 movff xdT2+1,isr_xB+1 183 movff xdT2+1,isr_xB+1
178 call isr_signed_mult16x16 ; A*B 184 call isr_signed_mult16x16 ; A*B
179 movlw .11-.8 ; A 12bit shift = 1 byte + 3 bits. 185 movlw .11-.8 ; A 12bit shift = 1 byte + 3 bits.
180 call isr_shift_C31 186 call isr_shift_C31
181 187
182 movlw LOW(.200) ; Add 200, and save into temperature 188 movlw LOW(.200) ; Add 200
183 addwf isr_xC+1,W 189 addwf isr_xC+1,F
184 movwf temperature+0
185 movlw HIGH(.200) 190 movlw HIGH(.200)
186 addwfc isr_xC+2,W 191 addwfc isr_xC+2,F
187 movwf temperature+1 192
188 193 movf isr_xC+1,W
189 bcf neg_temp 194 addwf temperature_avg+0,F
190 bnn calc_pos_temp ; Is Temp° negativ ? 195 movf isr_xC+2,W
191 196 addwfc temperature_avg+1,F
192 bsf neg_temp ; Yes: set flag and store -temp 197
193 comf temperature+1
194 negf temperature+0
195 btfsc STATUS,C
196 incf temperature+1
197
198 calc_pos_temp:
199 return ; Fertig mit allem 198 return ; Fertig mit allem
200 199
201 ;============================================================================= 200 ;=============================================================================
202 get_pressure_start: 201 get_pressure_start:
203 rcall reset_MS5535A 202 rcall reset_MS5535A