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.

RTOS/LAUNCHXL-CC2640R2: ADC Config troubles

Part Number: LAUNCHXL-CC2640R2

Tool/software: TI-RTOS

Hello everyone, 

I am getting some troubles using ADC on my LAUNCH XL-CC2640R2F. 

I am want to measure a signal which would be around 1.65V. What is the best configuration to measure it ? 

When I say "configuration", I mean : 

.adcDIO = CC2640R2_LAUNCHXL_DIO25_ANALOG,
.adcCompBInput = ADC_COMPB_IN_AUXIO5,
.refSource = ADCCC26XX_FIXED_REFERENCE or ADCCC26XX_VDDS_REFERENCE, ???
.samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
.inputScalingEnabled = true or false, ???
.triggerSource = ADCCC26XX_TRIGGER_MANUAL,
.returnAdjustedVal = 0

Thank you a lot. 

Julie. 

  • Hi Julie,

    I'd recommend using the Fixed Reference and with input scaling enabled.

    The fixed reference will look like a 4.2V when input scaling is enabled, while with it disabled it'll look like 1.44V. So you'll be forced to enable scaling if you're using the reference. Without knowing more about your application, it's hard to recommend anything else - this also happens to be the safest option

    For more information - check out the technical reference manual. Particularly the Chapter on AUX - Sensor Controller with Digital and Analog Peripherals. There you'll find a section on the ADC which will describe it's characteristics in detail.

    Regards,
    Rebel
  • Hi Rebel,

    Thanks a lot for helping me, your answer was pretty clear. In fact, I still get a wrong ADC value but at least, I know that it does not come from the ADC ref and scale.

    I suppose now that my wrong ADC value comes from an inappropriate PIN config.
    The problem is that I need to change the PIN config of one of my pins several times in my program. By config, I mean I need to change the PIN from digital to analog and analog to digital, change the digital value (0 to 1 and 1 to 0). The ADC measure has to be done when the pin is set as analog. However, I could not get the good values. What are the right config to use ? I used the following :

    In the config table :
    Board_DIO26_ANALOG | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
    Board_DIO28_ANALOG | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL,
    I assume that after these settings, the pins DIO 26 & DIO 28 are set in digital, with à 0 value.

    Then :
    PIN_setOutputValue(PIN, Board_DIO28_ANALOG, 1);
    PIN_setOutputValue(PIN, Board_DIO26_ANALOG, 1);
    I think that these commands change their value to 1.


    To change the DIO 26 to an analog input and then, do the ADC measure, I wrote :
    PIN_setConfig(PIN, PIN_BM_OUTPUT_MODE, Board_DIO26_ANALOG | PIN_GPIO_OUTPUT_DIS | PIN_PUSHPULL);
    PIN_setConfig(PIN, PIN_BM_INPUT_MODE, Board_DIO26_ANALOG | PIN_INPUT_EN | PIN_PUSHPULL);

    And to change the DIO 26 from analog to digital set to 0, I wrote :
    PIN_setConfig(PIN, PIN_BM_OUTPUT_MODE, Board_DIO26_ANALOG | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL);
    PIN_setConfig(PIN, PIN_BM_INPUT_MODE, Board_DIO26_ANALOG | PIN_INPUT_DIS | PIN_PUSHPULL);

    As far as I know, these commands are not suitable if followed by an ADC measurement. I don't even know if they really do what I think they do. I already looked at the pins signals with an oscilloscope but I did not detect anything which looks wrong.

    Could you please help me ?

    Thanks a lot,

    Julie.
  • Hi Julie,

    I haven't personally tried out your code - perhaps you could take a look at how the ADC driver does it: <SDK>\source\ti\drivers\adc

    Or actually, have you tried using the ADC driver? It should eliminate your headaches!

    Regards,
    Rebel
  • Hi Rebel,

    Yes, I used the ADC driver, that's why I don't understand why it doesn't worK. For using this driver, and perform an ADC measurement, it says that the PIN must be in the conf : INPUT/OUTOUT/PULL DISABLED. I set that but it is still not working. The question is so : did I set it well, did I use the right commands ? (those above)

    Thanks again,
    Regards,

    Julie.