annotate code_part1/OSTC_code_asm_part1/ms5535.asm @ 188:caf6153b26cb

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