comparison src/adc_lightsensor.asm @ 120:e2f04bb2539c

battery check in sleep
author heinrichsweikamp
date Fri, 27 Jun 2014 15:52:43 +0200
parents abd30446e1cd
children 9a637c9bb19a
comparison
equal deleted inserted replaced
119:2acf3d068fae 120:e2f04bb2539c
30 btfss c3_hardware 30 btfss c3_hardware
31 bra get_battery_voltage1 ; Normal ostc3 hardware 31 bra get_battery_voltage1 ; Normal ostc3 hardware
32 32
33 call lt2942_get_accumulated_charge 33 call lt2942_get_accumulated_charge
34 call lt2942_get_voltage 34 call lt2942_get_voltage
35 bcf LEDr
36 bcf TRISJ,2 ; Chrg-Out output
37 bsf CHRG_OUT
38
39 btfss CHRG_IN
40 bra cc_active
41
42 bcf CHRG_OUT
43 bsf TRISJ,2 ; Chrg-Out high impedance
44
45 WAITMS d'1'
46
47 btfsc CHRG_IN
48 return
49 ;cv_active:
50 bsf LEDr ; Indicate charging
51 call lt2942_charge_done ; Reset accumulating registers to 0xFFFF
52 WAITMS d'10'
53 bcf LEDr ; Indicate charging
54 return
55
56 cc_active:
57 bsf LEDr ; Indicate charging
58 bcf CHRG_OUT
59 bsf TRISJ,2 ; Chrg-Out high impedance
35 return 60 return
36 61
37 get_battery_voltage1: 62 get_battery_voltage1:
38 bsf adc_running ; =1: The ADC is in use 63 bsf adc_running ; =1: The ADC is in use
39 movlw b'00100000' ; 2.048V Vref+ -> 1LSB = 500µV 64 movlw b'00100000' ; 2.048V Vref+ -> 1LSB = 500µV