annotate code_part1/OSTC_code_asm_part1/ms5535.asm @ 841:8d73c9dcf851 default tip

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