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.

LAUNCHXL-CC3235SF: Enabling GPIO pins as ADC in CC3235SF

Part Number: LAUNCHXL-CC3235SF
Other Parts Discussed in Thread: CC3235SF, SYSCONFIG

Tool/software:

Hi, I'm trying make a simple ADC reading with the CC3235SF. Previously I tried and everything I saw were random values. Now I'm reading the datasheet and I found that I need to configure the ADC switches.

The (4) statement: 

"Requires user configuration to enable the analog switch of the ADC channel (the switch is off by default.) The digital I/O is always connected and must be made Hi-Z before enabling the ADC switch."

I checked my configuration in the Sysconfig file but it has no options to set that. I think I have to change that manually in code but I don't know where to start. Can you help me?

PD: I also would like to know if I this ADC works with binary offset or Two's complement. Thanks btw.

  • Carlos,

    The driver should take care of this for you.

    Set the pins in the ADC module using sysconfig, and the code generated and aDC driver will handle this for you.

    Can you confirm this?

  • Hi AB! 
    Yeah, that's what I did. The image shows what I've got in sysconfig. 

    Anyways, when I run my code, the ADC values printed are completely random. I'm trying to read an analog Microphone I already checked it works.

  • Your Sysconfig file looks correct to me.
    Make sure that everything is plugged in correctly and that the value seen by the ADC is in the supported mV range.
    Here is a snippet directly form our working example:

    /* Inputs to the ADC on the CC32XX launchpads are downscaled by a factor of 0.42
     * Multiplying the conversion output with 2.365 will provide compensated output.
     */
    #define COMPENSATION_FACTOR 2365
    
    
    /* ADC conversion result variables */
    uint16_t adcValue0;
    uint32_t adcValue0MicroVolt;
    
    ADC_Handle adc;
    ADC_Params params;
    int_fast16_t res;
    
    ADC_Params_init(&params);
    adc = ADC_open(CONFIG_ADC_0, &params);
    
    if (adc == NULL)
    {
        Display_printf(display, 0, 0, "Error initializing CONFIG_ADC_0\n");
        while (1) {}
    }
    
    /* Blocking mode conversion */
    res = ADC_convert(adc, &adcValue0);
    
    if (res == ADC_STATUS_SUCCESS)
    {
    
        adcValue0MicroVolt = (COMPENSATION_FACTOR * ADC_convertToMicroVolts(adc, adcValue0)) / 1000;
    
        Display_printf(display, 0, 0, "CONFIG_ADC_0 raw result: %d\n", adcValue0);
        Display_printf(display, 0, 0, "CONFIG_ADC_0 convert result: %d uV\n", adcValue0MicroVolt);
    }
    else
    {
        Display_printf(display, 0, 0, "CONFIG_ADC_0 convert failed\n");
    }
    
    ADC_close(adc);