Hi All
This is in relational to a Previous Post i did in regards the battery voltage dropping below 2.8V and then causing the charger to preform in trickle charge mode, but as my circuit was consuming much of the power therefore the battery was not recovering.
What i intend to do is measure the VCC, and if its is below 3.2V, not enable any my modules or circuit. If i am able to read 3.2V this would indicate to the battery has progressed from the trickle charge phase to the stage where adequate current is being outputted from the charger to enable circuit.
When VCC is 3.3V i get 672 and when VCC is 2.5V i am getting 515.
But i was expecting 3.3/10=0.33
0.33*4095=1351. when 3.3V
and
i was expecting 2.5/10=0.25
0.25*4095=1023. when 2.5V
The ADC is 12-bit
Is my code or my calculation incorrect?
void adc_init(void) { ADCB_CTRLB|=ADC_CURRLIMIT1_bm|ADC_CONMODE_bm; ADCB_REFCTRL|=ADC_BANDGAP_bm; ADCB_EVCTRL=0x00; ADCB_PRESCALER|=ADC_PRESCALER2_bm; ADCB_INTFLAGS=ADC_CH0IF_bm; ADCB_CH0_MUXCTRL|=ADC_CH_MUXPOS1_bm; ADCB_CTRLA=ADC_ENABLE_bm; //enable ADC } int adc_result(void) { ADCB_CTRLA|=ADC_CH0START_bm; //start ADC conversion while(!(ADCB_INTFLAGS & ADC_CH0IF_bm)); ADCB_INTFLAGS=ADC_CH0IF_bm; int result=ADCB_CH0_RES; return result; }