comparison code_part1/OSTC_code_asm_part1/adc_rtc.asm @ 341:2144f19fa1eb

BUGFIX protect against ISR changing pressure/temperature while reading it.
author JeanDo
date Fri, 20 May 2011 00:48:30 +0200
parents ceedf078b2d8
children ab962c4b19d6
comparison
equal deleted inserted replaced
340:ecbbbd423e86 341:2144f19fa1eb
70 70
71 movlw d'2' 71 movlw d'2'
72 movwf fatal_error_code ; Battery very low! 72 movwf fatal_error_code ; Battery very low!
73 bsf enter_error_sleep ; enter error routine 73 bsf enter_error_sleep ; enter error routine
74 74
75 get_battery_voltage3: 75 get_battery_voltage3:
76 movff amb_pressure+0,sub_b+0 76 SAFE_2BYTE_COPY amb_pressure, sub_b
77 movff amb_pressure+1,sub_b+1 77
78 movlw LOW d'15001' ; must be lower then 15001mBar 78 movlw LOW d'15001' ; must be lower then 15001mBar
79 movwf sub_a+0 79 movwf sub_a+0
80 movlw HIGH d'15001' 80 movlw HIGH d'15001'
81 movwf sub_a+1 81 movwf sub_a+1
82 call sub16 ; sub_c = sub_a - sub_b 82 call sub16 ; sub_c = sub_a - sub_b
134 write_int_eeprom d'42' 134 write_int_eeprom d'42'
135 movff day,EEDATA 135 movff day,EEDATA
136 write_int_eeprom d'43' 136 write_int_eeprom d'43'
137 movff year,EEDATA 137 movff year,EEDATA
138 write_int_eeprom d'44' 138 write_int_eeprom d'44'
139 movff temperature+0,EEDATA 139 SAFE_2BYTE_COPY temperature,lo
140 movff lo,EEDATA
140 write_int_eeprom d'45' 141 write_int_eeprom d'45'
141 movff temperature+1,EEDATA 142 movff hi,EEDATA
142 write_int_eeprom d'46' 143 write_int_eeprom d'46'
143 ; Reset charge statistics 144 ; Reset charge statistics
144 clrf EEDATA 145 clrf EEDATA
145 write_int_eeprom d'47' ; last complete charge 146 write_int_eeprom d'47' ; last complete charge
146 write_int_eeprom d'48' ; last complete charge 147 write_int_eeprom d'48' ; last complete charge
148 write_int_eeprom d'50' ; total cycles 149 write_int_eeprom d'50' ; total cycles
149 write_int_eeprom d'51' ; total cycles 150 write_int_eeprom d'51' ; total cycles
150 write_int_eeprom d'52' ; total complete cycles 151 write_int_eeprom d'52' ; total complete cycles
151 write_int_eeprom d'53' ; total complete cycles 152 write_int_eeprom d'53' ; total complete cycles
152 ; Reset temperature extremas 153 ; Reset temperature extremas
153 movff temperature+0,EEDATA ; Reset mimimum extrema 154 SAFE_2BYTE_COPY temperature,lo
155 movff lo,EEDATA ; Reset mimimum extrema
154 write_int_eeprom d'54' 156 write_int_eeprom d'54'
155 movff temperature+1,EEDATA 157 movff hi,EEDATA
156 write_int_eeprom d'55' 158 write_int_eeprom d'55'
157 movff month,EEDATA 159 movff month,EEDATA
158 write_int_eeprom d'56' 160 write_int_eeprom d'56'
159 movff day,EEDATA 161 movff day,EEDATA
160 write_int_eeprom d'57' 162 write_int_eeprom d'57'
161 movff year,EEDATA 163 movff year,EEDATA
162 write_int_eeprom d'58' 164 write_int_eeprom d'58'
163 movff temperature+0,EEDATA ; Reset maximum extrema 165 movff lo,EEDATA ; Reset maximum extrema
164 write_int_eeprom d'59' 166 write_int_eeprom d'59'
165 movff temperature+1,EEDATA 167 movff hi,EEDATA
166 write_int_eeprom d'60' 168 write_int_eeprom d'60'
167 movff month,EEDATA 169 movff month,EEDATA
168 write_int_eeprom d'61' 170 write_int_eeprom d'61'
169 movff day,EEDATA 171 movff day,EEDATA
170 write_int_eeprom d'62' 172 write_int_eeprom d'62'
190 write_int_eeprom d'42' 192 write_int_eeprom d'42'
191 movff day,EEDATA 193 movff day,EEDATA
192 write_int_eeprom d'43' 194 write_int_eeprom d'43'
193 movff year,EEDATA 195 movff year,EEDATA
194 write_int_eeprom d'44' 196 write_int_eeprom d'44'
195 movff temperature+0,EEDATA 197 SAFE_2BYTE_COPY temperature,lo
198 movff lo,EEDATA
196 write_int_eeprom d'45' 199 write_int_eeprom d'45'
197 movff temperature+1,EEDATA 200 movff hi,EEDATA
198 write_int_eeprom d'46' 201 write_int_eeprom d'46'
199 return 202 return
200 203
201 RTCinit: ; resets RTC 204 RTCinit: ; resets RTC
202 movlw 0x80 205 movlw 0x80