comparison src/sleepmode.asm @ 198:c511dc403d7e

(Slightly) reduce current consumption in Eco and sleep mode
author heinrichsweikamp
date Mon, 10 Nov 2014 13:54:20 +0100
parents 4574aed5cd4c
children dcd513840c6c
comparison
equal deleted inserted replaced
197:3bbfac29ba3e 198:c511dc403d7e
53 clrf ADCON0 ; Power-Down ADC Module 53 clrf ADCON0 ; Power-Down ADC Module
54 sleeploop_loop: 54 sleeploop_loop:
55 btfsc onesecupdate ; one second in sleep? 55 btfsc onesecupdate ; one second in sleep?
56 rcall onesec_sleep ; check switches, check pressure sensor, etc. 56 rcall onesec_sleep ; check switches, check pressure sensor, etc.
57 57
58 btfsc oneminupdate ; one minute in sleep?
59 rcall onemin_sleep ; do oneminute tasks, e.g. calculate desaturation
60
61 btfsc onehourupdate ; one hour in sleep?
62 rcall onehour_sleep ; Yes
63
64 btfss sleepmode ; wake up? (This bit will be set in other routines) 58 btfss sleepmode ; wake up? (This bit will be set in other routines)
65 goto restart ; yes 59 goto restart ; yes
66 60
67 rcall sleepmode_sleep ; Wait at least 35ms (every 62,5ms Timer7 wakeup) 61 rcall sleepmode_sleep ; Wait at least 35ms (every 62,5ms Timer7 wakeup)
68 62
82 call vault_decodata_into_eeprom ; update deco data 76 call vault_decodata_into_eeprom ; update deco data
83 bcf onehourupdate ; all done 77 bcf onehourupdate ; all done
84 return 78 return
85 79
86 onemin_sleep: 80 onemin_sleep:
81 btfsc onehourupdate ; one hour in sleep?
82 rcall onehour_sleep ; Yes
83
87 ;---- adjust airpressure compensation any 15 minutes 84 ;---- adjust airpressure compensation any 15 minutes
88 incf divemins+1,F ; counts to 14... 85 incf divemins+1,F ; counts to 14...
89 movlw d'14' 86 movlw d'14'
90 cpfsgt divemins+1 87 cpfsgt divemins+1
91 bra onemin_sleep2 ; 15 minutes not done! 88 bra onemin_sleep2 ; 15 minutes not done!
123 120
124 bcf oneminupdate ; all done 121 bcf oneminupdate ; all done
125 return 122 return
126 123
127 onesec_sleep: 124 onesec_sleep:
125 btfsc oneminupdate ; one minute in sleep?
126 rcall onemin_sleep ; do oneminute tasks, e.g. calculate desaturation
127
128 btfsc c3_hardware 128 btfsc c3_hardware
129 call get_battery_voltage ; Check for charger 129 call get_battery_voltage ; Check for charger
130 130
131 incf divemins+0,F ; counts to #test_pressure_in_sleep (5) 131 incf divemins+0,F ; counts to #test_pressure_in_sleep (5)
132 movlw d'5' 132 movlw d'5'
202 sleepmode_sleep: 202 sleepmode_sleep:
203 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM. 203 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
204 clrf T7GCON ; Reset Timer7 Gate Control register 204 clrf T7GCON ; Reset Timer7 Gate Control register
205 movlw b'10001101' ; 1:1 Prescaler -> 2seconds@32768Hz, not synced 205 movlw b'10001101' ; 1:1 Prescaler -> 2seconds@32768Hz, not synced
206 movwf T7CON 206 movwf T7CON
207 banksel common ; Bank1
208 sleep 207 sleep
209 nop 208 sleep
210 banksel 0xF16 ; Addresses, F16h through F5Fh, are also used by SFRs, but are not part of the Access RAM.
211 clrf T7GCON ; Reset Timer7 Gate Control register 209 clrf T7GCON ; Reset Timer7 Gate Control register
212 movlw b'10001001' ; 1:1 Prescaler -> 2seconds@32768Hz, synced 210 movlw b'10001001' ; 1:1 Prescaler -> 2seconds@32768Hz, synced
213 movwf T7CON 211 movwf T7CON
214 banksel common ; Bank1 212 banksel common ; Bank1
215 return 213 return