This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Battservice and ADC

Other Parts Discussed in Thread: CC2650, CC1350

We are hoping to find an example of how to use Battservice with ADC.

Our system is driven by a LiPo, which has a max voltage of 4.2V. We are using an external DC/DC to regulate the 4.3V down to 3V which powers a CC2650. 

We have setup a voltage divider to cut the 4.2V down to 2.1 and apply it to a ADC capable pin of the CC2650. We would like to use Battservice.h with this external voltage to determine the charge status of our system battery. 

Battservice.h defines:

/*********************************************************************
 * @fn      Batt_Setup
 *
 * @brief   Set up which ADC source is to be used. Defaults to VDD/3.
 *
 * @param   adc_ch - ADC Channel, e.g. HAL_ADC_CHN_AIN6
 * @param   minVal - max battery level
 * @param   maxVal - min battery level
 * @param   sCB - HW setup callback
 * @param   tCB - HW tear down callback
 * @param   cCB - percentage calculation callback
 *
 * @return  none.
 */
extern void Batt_Setup(uint16 maxVal, battServiceSetupCB_t sCB,
                       battServiceTeardownCB_t tCB);

That sounds great, but if you look at the function signature, it does not match the comments. So we would like to know if there is a more full featured version of Battservice that allows for ADC from a pin. 

As a more general question, is there a ADC example somewhere in the BLE Stack 2.1 source code? A search for ADC doesn't turn up much.

Thanks.

  • Hi pixbroker,

    If you search this forum for "CC26xx ADC", you will see a lot of useful posts. For example,  will give you some ideas.

    - Cetri

  • I am trying to apply the ADC example pointed out above to our project. I have a voltage in the range of 3.6V-4.2V applied to AUXIO7 (DIO23, pin 32 on CC1350 7x7). I have setup ADC like this:

    AUXWUCClockEnable(AUX_WUC_MODCLKEN0_ANAIF_M|AUX_WUC_MODCLKEN0_AUX_ADI4_M);
    
    AUXADCSelectInput(ADC_COMPB_IN_AUXIO7);
    
    AUXADCEnableSync(AUXADC_REF_FIXED, AUXADC_SAMPLE_TIME_10P9_MS, AUXADC_TRIGGER_MANUAL);
    
    AUXADCGenManualTrigger();
    
    ...
    
    singleSample = AUXADCReadFifo();
    
    HWREGBITW(AUX_EVCTL_BASE + AUX_EVCTL_O_EVTOMCUFLAGSCLR, AUX_EVCTL_EVTOMCUFLAGSCLR_ADC_IRQ_BITN) = 1;
    
    int32_t adcOffset = AUXADCGetAdjustmentOffset(AUXADC_REF_FIXED);
    
    int32_t adcGainError = AUXADCGetAdjustmentGain(AUXADC_REF_FIXED);
    
    int32_t adcCorrectedValue = AUXADCAdjustValueForGainAndOffset(singleSample, adcGainError, adcOffset);
    
    int32_t adcMicroVoltValue = AUXADCValueToMicrovolts(AUXADC_FIXED_REF_VOLTAGE_NORMAL, adcCorrectedValue );

    but the values i am getting don't make much sense. they seem to be lower than expected. For example:

    Vin = 3.6V

    correctedValue=3252

    microvolts=3.414784

    getting 3.4V instead of 3.6V

    What am i missing?

    Sidenote: when enabling the ADC pin with PIN_INPUT_DIS | PIN_GPIO_OUTPUT_DIS the current draw goes up significantly by ~50mA. Is that expected?

  • Hi Pixbroker,

    The ADC input can never be higher than the CC26XX supply voltage, that would trigger the ESD diodes in the pins (see absolute maximum ratings in data sheet), causing excessive current draw and potentially a drop in input voltage.

    Regards,
    Svend