comparison code_part1/OSTC_code_asm_part1/surfmode.asm @ 583:d14f72af4c07

Battery statistics reset when battery is fully charged
author heinrichsweikamp
date Mon, 07 May 2012 20:03:41 +0200
parents fbd5e2b75a63
children 227eaded4e1b
comparison
equal deleted inserted replaced
582:da400547220d 583:d14f72af4c07
314 bra test_charger2 ; No, add incomplete cycle! 314 bra test_charger2 ; No, add incomplete cycle!
315 315
316 ; Yes, store all data for complete cycle 316 ; Yes, store all data for complete cycle
317 bcf charge_started ; Clear flag 317 bcf charge_started ; Clear flag
318 bcf charge_done ; Clear flag 318 bcf charge_done ; Clear flag
319 ; Store incomplete/total cycles 319 ; Store incomplete cycles
320 read_int_eeprom d'50' ; Read byte (stored in EEDATA) 320 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
321 movff EEDATA,temp1 ; Low byte 321 movff EEDATA,temp1 ; Low byte
322 read_int_eeprom d'51' ; Read byte (stored in EEDATA) 322 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
323 movff EEDATA,temp2 ; high byte 323 movff EEDATA,temp2 ; high byte
324 bcf STATUS,C 324 bcf STATUS,C
351 movff day,EEDATA 351 movff day,EEDATA
352 write_int_eeprom d'48' 352 write_int_eeprom d'48'
353 movff year,EEDATA 353 movff year,EEDATA
354 write_int_eeprom d'49' 354 write_int_eeprom d'49'
355 355
356 ; Reset lowest battery seen
357 movlw LOW d'4200' ; reset to 4.2V
358 movwf EEDATA
359 write_int_eeprom d'40'
360 movlw HIGH d'4200' ; reset to 4.2V
361 movwf EEDATA
362 write_int_eeprom d'41'
363 movff month,EEDATA
364 write_int_eeprom d'42'
365 movff day,EEDATA
366 write_int_eeprom d'43'
367 movff year,EEDATA
368 write_int_eeprom d'44'
369 ; Reset temperature
370 SAFE_2BYTE_COPY temperature,lo
371 movff lo,EEDATA
372 write_int_eeprom d'45'
373 movff hi,EEDATA
374 write_int_eeprom d'46'
375 ; Reset temperature extremas
376 SAFE_2BYTE_COPY temperature,lo
377 movff lo,EEDATA ; Reset mimimum extrema
378 write_int_eeprom d'54'
379 movff hi,EEDATA
380 write_int_eeprom d'55'
381 movff month,EEDATA
382 write_int_eeprom d'56'
383 movff day,EEDATA
384 write_int_eeprom d'57'
385 movff year,EEDATA
386 write_int_eeprom d'58'
387 movff lo,EEDATA ; Reset maximum extrema
388 write_int_eeprom d'59'
389 movff hi,EEDATA
390 write_int_eeprom d'60'
391 movff month,EEDATA
392 write_int_eeprom d'61'
393 movff day,EEDATA
394 write_int_eeprom d'62'
395 movff year,EEDATA
396 write_int_eeprom d'63'
356 return 397 return
357 398
358 test_charger2: 399 test_charger2:
359 btfss charge_started ; Did the charger ever start? 400 btfss charge_started ; Did the charger ever start?
360 return ; No, quit! 401 return ; No, quit!
361 402
362 bcf charge_started ; Clear flag 403 bcf charge_started ; Clear flag
363 ; Store incomplete/total cycles 404 ; Store incomplete cycles
364 read_int_eeprom d'50' ; Read byte (stored in EEDATA) 405 read_int_eeprom d'50' ; Read byte (stored in EEDATA)
365 movff EEDATA,temp1 ; Low byte 406 movff EEDATA,temp1 ; Low byte
366 read_int_eeprom d'51' ; Read byte (stored in EEDATA) 407 read_int_eeprom d'51' ; Read byte (stored in EEDATA)
367 movff EEDATA,temp2 ; high byte 408 movff EEDATA,temp2 ; high byte
368 bcf STATUS,C 409 bcf STATUS,C