Hi all,
I'm measuring two battery voltage with cc2530 ADC. I'm using P0.0 and P0.1. Both with a resistor divide because batteries are 7.2V.
In my code I put this configuration in HalAdcInit() function:
P0SEL |= BV(0); // periferic
P0SEL |= BV(1); // periferic
APCFG |= BV(0); // Enable P0.0 as input ANALOG
APCFG |= BV(1); // Enable P0.1 as input ANALOG
I've a problem when I mesure the voltages. Some times the voltage measured is very low (2.7V or 3.1V).
But measuring with a oscilloscope the voltage batteries are 7.2V.
The problem is random.
In hal_adc.c there is a function "HalAdcRead()" with a comment:
" * The code does NOT disable the pin at the end of this function. I think it is better to leave the pin
* enabled because the results will be more accurate. Because of the inherent capacitance on the
* pin, it takes time for the voltage on the pin to charge up to its steady-state level. If
* HalAdcRead() has to turn on the pin for every conversion, the results may show a lower voltage
* than actuality because the pin did not have time to fully charge."
But I think these inputs are disable by code in line 169 of "hal_adc.c" with this instruction:
/* Disable channel after done conversion */
ADCCFG &= (adcChannel ^ 0xFF);
Note that ADCCFG is mapped to APCFG register. So every time a channel is selected,
his pin is enabled and disabled by the code when a adc read is performed.
So,
1. Would be better delete the "ADCCFG &= (adcChannel ^ 0xFF);" instruccion in code?
2. Could be a problem if I delete this instruction with P0.0 and P0.1 connected?
3. The Sigma-Delta modulator could be afected by this?
Thanks.