comparison code_part1/OSTC_code_asm_part1/adc_rtc.asm @ 702:e6ff73e88e45

bugfix battery history
author heinrichsweikamp
date Sat, 16 Mar 2013 13:56:26 +0100
parents 82f71a73f450
children 39e02673db4c
comparison
equal deleted inserted replaced
701:4498d34462d4 702:e6ff73e88e45
61 movff batt_voltage+1,sub_b+1 61 movff batt_voltage+1,sub_b+1
62 movlw LOW d'2600' ; must be greater then 2600mV... 62 movlw LOW d'2600' ; must be greater then 2600mV...
63 movwf sub_a+0 63 movwf sub_a+0
64 movlw HIGH d'2600' 64 movlw HIGH d'2600'
65 movwf sub_a+1 65 movwf sub_a+1
66 call sub16 ; sub_c = sub_a - sub_b 66 call subU16 ; sub_c = sub_a - sub_b
67 bcf enter_error_sleep ; Clear flag 67 bcf enter_error_sleep ; Clear flag
68 btfsc neg_flag ; neg_flag=1 if eeprom40:41 < 2000 68 btfsc neg_flag ; neg_flag=1 if eeprom40:41 < 2000
69 bra get_battery_voltage3 ; Battery in OK range 69 bra get_battery_voltage3 ; Battery in OK range
70 70
71 movlw d'2' 71 movlw d'2'
77 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 subU16 ; sub_c = sub_a - sub_b
83 bcf enter_error_sleep ; Clear flag 83 bcf enter_error_sleep ; Clear flag
84 btfss neg_flag ; 84 btfss neg_flag ;
85 bra get_battery_voltage4 ; Pressure in OK range 85 bra get_battery_voltage4 ; Pressure in OK range
86 86
87 movlw d'3' 87 movlw d'3'
100 100
101 movlw LOW d'2000' ; must be greater then 2000mV... 101 movlw LOW d'2000' ; must be greater then 2000mV...
102 movwf sub_a+0 102 movwf sub_a+0
103 movlw HIGH d'2000' 103 movlw HIGH d'2000'
104 movwf sub_a+1 104 movwf sub_a+1
105 call sub16 ; sub_c = sub_a - sub_b 105 call subU16 ; sub_c = sub_a - sub_b
106 btfss neg_flag ; neg_flag=1 if eeprom40:41 < 2000 106 btfss neg_flag ; neg_flag=1 if eeprom40:41 < 2000
107 bsf initialize_battery1 ; battery need to be initialised 107 bsf initialize_battery1 ; battery need to be initialised
108 108
109 movlw LOW d'4500' ; must be lower then 4500mV... 109 movlw LOW d'4500' ; must be lower then 4500mV...
110 movwf sub_a+0 110 movwf sub_a+0
111 movlw HIGH d'4500' 111 movlw HIGH d'4500'
112 movwf sub_a+1 112 movwf sub_a+1
113 call sub16 ; sub_c = sub_a - sub_b 113 call subU16 ; sub_c = sub_a - sub_b
114 btfss neg_flag ; neg_flag=1 if eeprom40:41 < 4500 114 btfsc neg_flag ; neg_flag=1 if eeprom40:41 < 4500
115 bsf initialize_battery1 ; battery need to be initialised 115 bsf initialize_battery1 ; battery need to be initialised
116 116
117 btfss initialize_battery1 ; battery need to be initialised? 117 btfss initialize_battery1 ; battery need to be initialised?
118 bra get_battery_no_init ; No, we have already valid values, just check for new extremas 118 bra get_battery_no_init ; No, we have already valid values, just check for new extremas
119 119
120 get_battery_voltage_reset: 120 get_battery_voltage_reset:
121 ; Init EEPROM for battery control 121 ; Init EEPROM for battery control
122 ; Reset lowest battery seen 122 ; Reset lowest battery seen
123 movlw LOW d'4200' ; reset to 4.2V 123 movlw LOW d'4200' ; reset to 4.2V
124 movwf EEDATA 124 movwf EEDATA
125 write_int_eeprom d'40' 125 write_int_eeprom d'40'
166 write_int_eeprom d'61' 166 write_int_eeprom d'61'
167 movff day,EEDATA 167 movff day,EEDATA
168 write_int_eeprom d'62' 168 write_int_eeprom d'62'
169 movff year,EEDATA 169 movff year,EEDATA
170 write_int_eeprom d'63' 170 write_int_eeprom d'63'
171
172 get_battery_no_init: 171 get_battery_no_init:
173 read_int_eeprom d'40' ; get lowest battery voltage seen in mV 172 read_int_eeprom d'40' ; get lowest battery voltage seen in mV
174 movff EEDATA,sub_b+0 173 movff EEDATA,sub_b+0
175 read_int_eeprom d'41' 174 read_int_eeprom d'41'
176 movff EEDATA,sub_b+1 175 movff EEDATA,sub_b+1
177 movff batt_voltage+0,sub_a+0 176 movff batt_voltage+0,sub_a+0
178 movff batt_voltage+1,sub_a+1 177 movff batt_voltage+1,sub_a+1
179 call sub16 ; sub_c = sub_a - sub_b 178 call subU16 ; sub_c = sub_a - sub_b
180 btfss neg_flag ; new lowest battery voltage? 179 btfss neg_flag ; new lowest battery voltage?
181 return ; no, quit routine 180 return ; no, quit routine
182 ; Yes, store new value together with the date and temperature values 181 ; Yes, store new value together with the date and temperature values
183 movff batt_voltage+0,EEDATA 182 movff batt_voltage+0,EEDATA
184 write_int_eeprom d'40' 183 write_int_eeprom d'40'