annotate code_part1/OSTC_code_asm_part1/ms5535.asm @ 16:01510acaeb11

1.54 rc2
author heinrichsweikamp
date Sun, 28 Mar 2010 20:43:54 +0200
parents 2b5c52ae3923
children 31fa973a70fd
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
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
19 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
20 ; written: 9/26/05
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
21 ; last updated: 08/08/31
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
22 ; known bugs:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
23 ; ToDo:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
24
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
25 ; with second order temperature compensation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
26
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
27 calculate_compensation:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
28 ; calculate xdT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
29 clrf isr_xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
30 movlw d'8'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
31 movwf isr_xA+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
32 movff C5+0,isr_xB+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
33 movff C5+1,isr_xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
34 call isr_mult16x16 ;isr_xA*isr_xB=isr_xC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
35 movlw LOW d'10000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
36 addwf isr_xC+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
37 movlw HIGH d'10000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
38 addwfc isr_xC+1, f ;isr_xC= 8*C5 + 10000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
39 movff D2+0,isr_sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
40 movff D2+1,isr_sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
41 movff isr_xC+0,isr_sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
42 movff isr_xC+1,isr_sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
43 call isr_sub16 ; isr_sub_c = isr_sub_a - isr_sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
44 movff isr_sub_c+0,xdT+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
45 movff isr_sub_c+1,xdT+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
46
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
47 ; Second order temperature calculation
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
48 btfsc neg_flag_isr
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
49 bra dTzero_yes
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
50 ; dT>0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
51 bcf neg_flag_xdT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
52 movff xdT+0,isr_xA+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
53 movff xdT+1,isr_xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
54 movff xdT+0,isr_xB+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
55 movff xdT+1,isr_xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
56 call isr_mult16x16 ;isr_xA*isr_xB=isr_xC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
57 movlw d'17' ; 2^17=(128*128)*8
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
58 movwf isr_divB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
59 call isr_div32 ; isr_xC=isr_xC(32Bit)/2^isr_divB (isr_divB: 8Bit only!)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
60 movff xdT+0,isr_sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
61 movff xdT+1,isr_sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
62 movff isr_xC+0,isr_sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
63 movff isr_xC+1,isr_sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
64 call isr_sub16 ; isr_sub_c = isr_sub_a - isr_sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
65 movff isr_sub_c+0,xdT2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
66 movff isr_sub_c+1,xdT2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
67 bra OFF_calc ; Done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
68
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
69 dTzero_yes:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
70 ; dT<0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
71 bsf neg_flag_xdT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
72 movff xdT+0,isr_xA+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
73 movff xdT+1,isr_xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
74 movff xdT+0,isr_xB+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
75 movff xdT+1,isr_xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
76 call isr_mult16x16 ;isr_xA*isr_xB=isr_xC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
77 movlw d'15' ; 2^15=(128*128)*2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
78 movwf isr_divB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
79 call isr_div32 ; isr_xC=isr_xC(32Bit)/2^isr_divB (isr_divB: 8Bit only!)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
80
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
81 movf xdT+0,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
82 addwf isr_xC+0,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
83 movf xdT+1,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
84 addwfc isr_xC+1,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
85 movff isr_xC+0,xdT2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
86 movff isr_xC+1,xdT2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
87
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
88 OFF_calc:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
89 ; calculate OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
90 movff C4+0,isr_sub_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
91 movff C4+1,isr_sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
92 movlw d'250'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
93 movwf isr_sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
94 clrf isr_sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
95 call isr_sub16 ; (C4-250) - Sets neg_flag_isr!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
96 movff isr_sub_c,isr_xA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
97 movff isr_sub_c+1,isr_xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
98 movff xdT+0,isr_xB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
99 movff xdT+0+1,isr_xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
100 call isr_mult16x16 ; (C4-250)*dT
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
101 movff isr_xC+0,isr_divA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
102 movff isr_xC+1,isr_divA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
103 movlw d'12'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
104 movwf isr_divB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
105 call isr_div16 ; [(C4-250)*dT]/2^12
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
106 movff isr_divA+0,isr_xC+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
107 movff isr_divA+1,isr_xC+1 ; isr_xC= {[(C4-250)*dT]/2^12}
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
108 btfss neg_flag_isr ; neg_flag_isr=1?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
109 bra OFF_calc2 ; Yes, do C2 - isr_xC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
110 ; no, so do C2 + isr_xC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
111 movf C2+0,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
112 addwf isr_xC+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
113 movf C2+1,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
114 addwfc isr_xC+1, f ; isr_xC= C2 + {[(C4-250)*dT/2^12]}
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
115 OFF_calc3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
116 movlw LOW d'10000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
117 addwf isr_xC+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
118 movlw HIGH d'10000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
119 addwfc isr_xC+1, f ; isr_xC=[(C4-250)*dT/2^12] + 10000
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
120 movff isr_xC+0,OFF+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
121 movff isr_xC+1,OFF+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
122 bra calculate_SENS ; Done with OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
123
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
124 OFF_calc2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
125 movff C2+0,isr_sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
126 movff C2+1,isr_sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
127 movff isr_xC+0,isr_sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
128 movff isr_xC+1,isr_sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
129 call isr_sub16 ; isr_sub_c = isr_sub_a - isr_sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
130 ; isr_xC= C2 - {[(C4-250)*dT/2^12]}
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
131 movff isr_sub_c+0,isr_xC+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
132 movff isr_sub_c+1,isr_xC+1 ; Done with OFF
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
133 bra OFF_calc3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
134
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
135 calculate_SENS:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
136 movff C3+0, C3_temp+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
137 movff C3+1, C3_temp+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
138 movlw d'200'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
139 addwf C3_temp+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
140 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
141 addwfc C3_temp+1, f ; C3 no longer valid!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
142 movff C3_temp+0, isr_xA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
143 movff C3_temp+1, isr_xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
144 movff xdT+0, isr_xB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
145 movff xdT+1, isr_xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
146 call isr_mult16x16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
147 movff isr_xC+0,isr_divA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
148 movff isr_xC+1,isr_divA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
149 movlw d'13'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
150 movwf isr_divB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
151 call isr_div16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
152 movff isr_divA,SENS+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
153 movff isr_divA+1,SENS+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
154 movff C1+0,isr_divA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
155 movff C1+1,isr_divA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
156 movlw d'1'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
157 movwf isr_divB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
158 call isr_div16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
159 movf isr_divA,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
160 addwf SENS+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
161 movf isr_divA+1,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
162 addwfc SENS+1, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
163 movlw d'184'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
164 addwf SENS+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
165 movlw d'11'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
166 addwfc SENS+1, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
167
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
168 ; calculate amb_pressure
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
169 movff D1+0,isr_sub_a
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
170 movff D1+1,isr_sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
171 movff OFF+0,isr_sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
172 movff OFF+1,isr_sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
173 call isr_sub16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
174 movff isr_sub_c,isr_xA
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
175 movff isr_sub_c+1,isr_xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
176 movff SENS+0,isr_xB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
177 movff SENS+1,isr_xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
178 call isr_mult16x16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
179 movlw d'12'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
180 movwf isr_divB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
181 call isr_div32
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
182 btfsc neg_flag_isr ; invert isr_xC+0 and isr_xC+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
183 call isr_invert_xC
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
184 movlw LOW d'1000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
185 addwf isr_xC+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
186 movlw HIGH d'1000'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
187 addwfc isr_xC+1, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
188 movff isr_xC+0,amb_pressure+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
189 movff isr_xC+1,amb_pressure+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
190
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
191 btfss simulatormode_active ; are we in simulator mode?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
192 bra calc_pressure_done ; no
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
193
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
194 movff sim_pressure+0,amb_pressure+0 ; override readings with simulator values
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
195 movff sim_pressure+1,amb_pressure+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
196
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
197 calc_pressure_done:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
198
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
199 ; calculate temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
200 movff C6+0, C3_temp+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
201 movff C6+1, C3_temp+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
202 movlw d'100'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
203 addwf C3_temp+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
204 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
205 addwfc C3_temp+1, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
206 movff C3_temp+0,isr_xA+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
207 movff C3_temp+1,isr_xA+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
208 movff xdT2+0,isr_xB+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
209 movff xdT2+1,isr_xB+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
210 call isr_mult16x16
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
211 movlw d'11'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
212 movwf isr_divB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
213 call isr_div32
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
214 bcf neg_temp ; Temperatur positive
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
215
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
216 btfsc neg_flag_xdT ; was xdT negative?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
217 bra neg_sub_temp ; yes, 200 - dT*(....
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
218 ; No, 200 + dT*(....
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
219 ; movf temperature_correction,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
220 ; addlw d'200'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
221 ; btfsc STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
222 ; incf isr_xC+1,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
223
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
224 movlw d'200'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
225 addwf isr_xC+0, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
226 movlw d'0'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
227 addwfc isr_xC+1, f
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
228 movff isr_xC+0,temperature+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
229 movff isr_xC+1,temperature+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
230 return ; done
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
231
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
232 neg_sub_temp: ; 200 - dT*(....
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
233 ; movf temperature_correction,W
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
234 ; addlw d'200'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
235 ; btfsc STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
236 ; decf isr_xC+1,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
237
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
238 movlw d'200'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
239 neg_sub_temp3:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
240 movwf isr_sub_a+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
241 clrf isr_sub_a+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
242 movff isr_xC+0, isr_sub_b+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
243 movff isr_xC+1, isr_sub_b+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
244 call isr_sub16 ; isr_sub_c = isr_sub_a - isr_sub_b
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
245 btfsc neg_flag_isr ; below zero?
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
246 bsf neg_temp ; temperature negative!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
247
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
248 movff isr_sub_c+0,temperature+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
249 movff isr_sub_c+1,temperature+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
250 return ; Fertig mit allem
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
251
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
252
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
253 get_pressure_start:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
254 rcall reset_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
255 movlw b'10100000' ;+3*high as start and 1+low as stop!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
256 get_pressure_start2:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
257 movwf isr1_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
258 movlw d'12'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
259 movwf clock_count
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
260 rcall send_data_MS55535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
261 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
262
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
263 get_pressure_value:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
264 rcall get_2bytes_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
265 movff dMSB,D1+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
266 movff dLSB,D1+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
267 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
268
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
269 get_temperature_start:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
270 rcall reset_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
271 movlw b'10010000' ;+3*high as start and 1+low as stop!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
272 bra get_pressure_start2 ; continue in "get_pressure"
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
273
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
274 get_temperature_value:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
275 rcall get_2bytes_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
276 movff dMSB,D2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
277 movff dLSB,D2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
278 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
279
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
280 get_calibration_data:
4
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
281 ; ; read addional temperature correction from internal EEPROM 0x100
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
282 ; bsf no_sensor_int ; No sensor interupt!
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
283 ; clrf temperature_correction ; clear compensation value
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
284 ; movlw LOW 0x100
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
285 ; movwf EEADR
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
286 ; movlw HIGH 0x100
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
287 ; movwf EEADRH
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
288 ; call read_eeprom
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
289 ; clrf EEADRH ; Only 256Bytes used in normal program
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
290 ; movlw d'200' ; limit value
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
291 ; cpfsgt EEDATA ; EEDATA>200?
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
292 ; movff EEDATA, temperature_correction ; No, Store for compensation
2b5c52ae3923 1.52 beta rc
heinrichsweikamp
parents: 0
diff changeset
293 ;
0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
294 rcall reset_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
295 movlw d'13'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
296 movwf clock_count
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
297 movlw b'01010100' ;+3*high as start and 1+low as stop!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
298 movwf isr1_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
299 rcall send_data_MS55535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
300 rcall get_2bytes_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
301 movff dMSB,W1+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
302 movff dLSB,W1+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
303
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
304 movlw d'13'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
305 movwf clock_count
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
306 movlw b'01011000' ;+3*high as start and 1+low as stop!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
307 movwf isr1_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
308 rcall send_data_MS55535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
309 rcall get_2bytes_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
310 movff dMSB,W2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
311 movff dLSB,W2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
312
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
313 movlw d'13'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
314 movwf clock_count
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
315 movlw b'01100100' ;+3*high as start and 1+low as stop!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
316 movwf isr1_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
317 rcall send_data_MS55535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
318 rcall get_2bytes_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
319 movff dMSB,W3+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
320 movff dLSB,W3+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
321
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
322 movlw d'13'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
323 movwf clock_count
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
324 movlw b'01101000' ;+3*high as start and 1+low as stop!
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
325 movwf isr1_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
326 rcall send_data_MS55535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
327 rcall get_2bytes_MS5535A
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
328 movff dMSB,W4+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
329 movff dLSB,W4+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
330
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
331 ; calculate C1 (16Bit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
332 movff W1+1, C1+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
333 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
334 rrcf C1+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
335 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
336 rrcf C1+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
337 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
338 rrcf C1+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
339 movff W1+0, C1+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
340 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
341 btfss W1+1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
342 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
343 rrcf C1+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
344 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
345 btfss W1+1,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
346 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
347 rrcf C1+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
348 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
349 btfss W1+1,2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
350 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
351 rrcf C1+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
352
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
353 ; calculate C2 (16Bit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
354 movff W2+0, C2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
355 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
356 btfss W2+1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
357 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
358 rrcf C2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
359 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
360 btfss W2+1,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
361 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
362 rrcf C2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
363 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
364 btfss W2+1,2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
365 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
366 rrcf C2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
367 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
368 btfss W2+1,3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
369 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
370 rrcf C2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
371 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
372 btfss W2+1,4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
373 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
374 rrcf C2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
375 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
376 btfss W2+1,5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
377 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
378 rrcf C2+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
379
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
380 movff W2+1, C2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
381 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
382 btfss W1+0,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
383 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
384 rrcf C2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
385 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
386 btfss W1+0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
387 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
388 rrcf C2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
389 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
390 btfss W1+0,2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
391 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
392 rrcf C2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
393 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
394 rrcf C2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
395 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
396 rrcf C2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
397 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
398 rrcf C2+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
399
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
400 ; calculate C3 (16Bit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
401 movff W3+1,C3+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
402 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
403 btfss W3+0,7
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
404 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
405 rlcf C3+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
406 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
407 btfss W3+0,6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
408 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
409 rlcf C3+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
410 clrf C3+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
411 btfsc W3+1,7
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
412 bsf C3+1,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
413 btfsc W3+1,6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
414 bsf C3+1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
415
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
416 ; calculate C4 (16Bit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
417 movff W4+1,C4+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
418 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
419 btfss W4+0,7
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
420 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
421 rlcf C4+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
422 clrf C4+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
423 btfsc W4+1,7
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
424 bsf C4+1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
425
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
426 ; calculate C5 (16Bit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
427 movff W3+0,C5+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
428 bcf C5+0,6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
429 btfsc W2+0,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
430 bsf C5+0,6
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
431 bcf C5+0,7
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
432 btfsc W2+0,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
433 bsf C5+0,7
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
434 clrf C5+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
435 btfsc W2+0,2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
436 bsf C5+1,0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
437 btfsc W2+0,3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
438 bsf C5+1,1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
439 btfsc W2+0,4
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
440 bsf C5+1,2
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
441 btfsc W2+0,5
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
442 bsf C5+1,3
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
443
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
444 ; calculate C6 (16Bit)
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
445 clrf C6+1
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
446 movff W4+0,C6+0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
447 bcf C6+0,7
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
448
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
449 bcf no_sensor_int ; enable sensor interrupts
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
450 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
451
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
452 reset_MS5535A_one:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
453 bsf sensor_SDO
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
454 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
455 bsf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
456 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
457 nop
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 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
463 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
464
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
465 reset_MS5535A_zero:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
466 bcf sensor_SDO
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
467 nop
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 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
477
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
478 reset_MS5535A:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
479 rcall reset_MS5535A_one ;0
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
480 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
481 rcall reset_MS5535A_one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
482 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
483 rcall reset_MS5535A_one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
484 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
485 rcall reset_MS5535A_one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
486 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
487 rcall reset_MS5535A_one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
488 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
489 rcall reset_MS5535A_one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
490 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
491 rcall reset_MS5535A_one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
492 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
493 rcall reset_MS5535A_one
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
494 rcall reset_MS5535A_zero ;15
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
495 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
496 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
497 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
498 rcall reset_MS5535A_zero
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
499 rcall reset_MS5535A_zero ;20
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
500 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
501
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
502 get_2bytes_MS5535A:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
503 movlw d'8'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
504 movwf clock_count
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
505 rcall recieve_loop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
506 movff isr1_temp,dMSB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
507
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
508 movlw d'8'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
509 movwf clock_count
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
510 rcall recieve_loop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
511 movff isr1_temp,dLSB
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
512 bsf 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 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
520 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
521
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
522 recieve_loop:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
523 bsf sensor_CLK
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 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 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
531 btfss sensor_SDI ;MSB first
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
532 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
533 btfsc sensor_SDI ;MSB first
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
534 bsf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
535 rlcf isr1_temp,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
536 decfsz clock_count,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
537 bra recieve_loop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
538 return
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
539
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
540
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
541 send_data_MS55535A:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
542 ; send three startbits first
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
543 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
544 bsf sensor_SDO
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
545 movlw d'3'
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
546 subwf clock_count,F ; total bit counter
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
547 bsf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
548 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
549 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
550 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
551 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
552 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
553 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
554 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
555 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
556 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
557 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
558 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
559 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
560 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
561 bsf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
562 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
563 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
564 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
565 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
566 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
567 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
568 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
569 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
570 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
571 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
572 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
573 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
574 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
575 bsf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
576 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
577 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
578 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
579 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
580 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
581 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
582 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
583 ; now send 8 bytes from isr_temp1 and fill-up with zeros
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
584 datenbits:
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
585 btfss isr1_temp,7 ;MSB first
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
586 bcf sensor_SDO
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
587 btfsc isr1_temp,7 ;MSB first
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
588 bsf sensor_SDO
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
589 bcf STATUS,C
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
590 rlcf isr1_temp
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
591
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
592 bsf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
593 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
594 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
595 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
596 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
597 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
598 nop
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
599 bcf sensor_CLK
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
600
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
601 decfsz clock_count,F
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
602 bra datenbits
96a35aeda5f2 Initial setup
heinrichsweikamp
parents:
diff changeset
603 return