annotate code_part1/OSTC_code_asm_part1/ms5535.asm @ 161:8d6aca08f66b

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