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.

CC3220S-LAUNCHXL: Questions about ADC.h

Part Number: CC3220S-LAUNCHXL

I have a question on how the ADCs work using ADC.h.  Are the 4 ADC inputs multiplexed?  Also, how do I disconnect the ADC from the pin when I'm not wanting to sample it.  Does ADC_close() do that?  The reasons I ask is because I see samples every 62.5kHz on the pins so it seems like it just continues to sample.  I just can't seem to track it down in the code what is actually happening.  I'm currently including ADC.h just like the following example from the SDK (adcsinglechannel.c).  Should I be using ADCCC32XX.h instead?

/*
 *  ======== threadFxn0 ========
 *  Open an ADC instance and get a sampling result from a one-shot conversion.
 */
void *threadFxn0(void *arg0)
{
    ADC_Handle   adc;
    ADC_Params   params;
    int_fast16_t res;

    ADC_Params_init(&params);
    adc = ADC_open(Board_ADC0, &params);

    if (adc == NULL) {
        Display_printf(display, 0, 0, "Error initializing ADC channel 0\n");
        while (1);
    }

    /* Blocking mode conversion */
    res = ADC_convert(adc, &adcValue0);

    if (res == ADC_STATUS_SUCCESS) {

        adcValue0MicroVolt = ADC_convertRawToMicroVolts(adc, adcValue0);

        Display_printf(display, 0, 0, "ADC channel 0 convert result: %d uV\n", adcValue0MicroVolt);
    }
    else {
        Display_printf(display, 0, 0, "ADC channel 0 convert failed\n");
    }

    ADC_close(adc);

    return (NULL);
}

  • Hi Andrew5821,

    Including ADC.h is the best way to do it to keep your code portable throughout the SimpleLink platform. All of the ADC function calls you make will call down into the implementations in ADCCC32XX.C anyway.

    When enabled, the ADC will sample the channels in a round robin format. The way it is implemented in TI Drivers, ADC_Close() will only disable the ADC if all channels are disabled.

    If a channel is left on, the channel will be disabled and the pin will be unmuxed from the ADC function but the ADC itself will not be disabled.

    Best Regards,
    Ben M
  • Thanks for the helpful information.  How do you exactly disable a channel or all channels for that matter?  I currently "open" one adc channel do a convert and then "close" and then move to the next channel perform and "open" and then "close" in a function called by a timer interrupt.  So I would expect at some point all the channels to be "closed" and thus no sampling occurring, although the scope suggests otherwise.

  • Hi Andrew,

    How exactly are you monitoring the ADC activity? The ADC should continue to run in order to continue to sample the 4 internal channels.

    Best Regards,
    Ben M
  • I can see the voltage disturbance from the sampling capacitor at 62.5kHz on the ADC input channels with a scope.