Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/sleepmode.asm @ 774:fac7710ab84e
auto wake-up from no-battery state
author | heinrichsweikamp |
---|---|
date | Thu, 13 Mar 2014 17:08:52 +0100 |
parents | b7f7184d800d |
children | c50296c3059e |
comparison
equal
deleted
inserted
replaced
773:9e82de8dc12d | 774:fac7710ab84e |
---|---|
192 clrf amb_pressure_avg+1 ; clear for sleep routine | 192 clrf amb_pressure_avg+1 ; clear for sleep routine |
193 call calculate_compensation ; calculate temperature compensated pressure (233us) | 193 call calculate_compensation ; calculate temperature compensated pressure (233us) |
194 return | 194 return |
195 | 195 |
196 fatal_error_sleep: | 196 fatal_error_sleep: |
197 call get_calibration_data ; Get calibration data from pressure sensor | 197 call DISP_DisplayOff ; display off |
198 banksel flag5 | 198 call disable_rs232 ; disable UART module |
199 bcf no_sensor_int ; Enable sensor interrupt | 199 |
200 WAITMS d'250' | 200 bcf TRISB,6 |
201 WAITMS d'250' | 201 bcf TRISB,7 |
202 call get_battery_voltage ; get battery voltage | 202 bcf PORTB,6 |
203 btfss enter_error_sleep ; REALLY enter Fatal Error Routine? | 203 bcf PORTB,7 ; Disable UART |
204 return ; No! | 204 fatal_error_sleep_loop: |
205 SAFE_2BYTE_COPY amb_pressure, sub_b | |
206 movlw LOW d'15001' ; must be lower then 15001mbar | |
207 movwf sub_a+0 | |
208 movlw HIGH d'15001' | |
209 movwf sub_a+1 | |
210 call subU16 ; sub_c = sub_a - sub_b | |
211 bcf enter_error_sleep ; Clear flag | |
212 btfss neg_flag ; | |
213 return ; No! | |
214 bsf enter_error_sleep ; Set flag | |
215 clrf INTCON | |
216 clrf INTCON2 | |
217 clrf INTCON3 | |
218 bcf ADCON0,0 ; AD converter off | |
219 call disable_rs232 ; disable UART module | |
220 movlw b'00010000' | |
221 movwf TRISA | |
222 clrf PORTA ; And pulled to GND | |
223 clrf TRISB ; All output | |
224 clrf PORTB ; And pulled to GND | |
225 movlw b'00011101' ; UART | |
226 movwf TRISC | |
227 clrf PORTC ; And pulled to GND | |
228 clrf TRISD ; All output | |
229 clrf PORTD ; And pulled to GND | |
230 clrf TRISE ; All output | |
231 clrf PORTE ; And pulled to GND | |
232 clrf T0CON ; Timer OFF | |
233 clrf T1CON ; Timer OFF | |
234 clrf T2CON ; Timer OFF | |
235 clrf OSCTUNE | |
236 movlw b'00000010' ; 31kHz | |
237 movwf OSCCON | |
238 bsf WDTCON,0 ; Watchdog timer on... | |
239 fatal_error_sleep_loop: ; Device will never quit this loop! | |
240 movff fatal_error_code,temp4 | 205 movff fatal_error_code,temp4 |
241 movlw d'15' | 206 movlw d'15' |
242 movwf temp1 | 207 movwf temp1 |
243 fatal_error_sleep_loop1: | 208 fatal_error_sleep_loop1: |
244 sleep | 209 sleep |
245 nop | 210 nop |
246 decfsz temp1,F | 211 decfsz temp1,F |
247 bra fatal_error_sleep_loop1 | 212 bra fatal_error_sleep_loop1 |
248 fatal_error_sleep_loop2: | 213 fatal_error_sleep_loop2: |
214 call get_battery_voltage ; get battery voltage | |
215 btfss enter_error_sleep ; REALLY enter Fatal Error Routine? | |
216 goto restart ; No | |
249 bsf LED_red | 217 bsf LED_red |
250 clrwdt | 218 clrwdt |
251 WAIT10US d'5' | 219 WAIT10US d'5' |
252 bcf LED_red | 220 bcf LED_red |
253 sleep | 221 sleep |