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.

CC2640R2L: inquiry for implementation of 2-channel ADC

Part Number: CC2640R2L

Tool/software:

Hi experts.

please let me know how to implement the function to read ADC 2-channel using CC2640R2L 5*5 IC.

when the program is written as follows, ADC_CO is normally open, but ADC_SMOKE is not open and returned as null.

could you give me some advise?

///////////////////////////////////////////////////////////////////////////////

ADC_Handle adc_co;

ADC_Params params_co;

 

ADC_Handle adc_smoke;

ADC_Params params_smoke;

 

bool ADC12_Init()

{

    Board_initADC();

 

    ADC_Params_init(&params_co);

    params_co.isProtected = true;

    adc_co = ADC_open(Board_ADC0, &params_co);

    if (adc_co != NULL) return false;

 

    ADC_Params_init(&params_smoke);

    params_smoke.isProtected = true;

    adc_smoke = ADC_open(Board_ADC1, &params_smoke);

    if (adc_smoke != NULL) return false;

    return true;

}

 

bool ADC12_CO_Data_Acquisition(uint16_t *punAdcValue)

{

    uint16_t adcValue = 0;

    if (ADC_convert(adc_co, &adcValue) != ADC_STATUS_SUCCESS) return false;

    uint32_t resultUv = ADC_convertToMicroVolts(adc_co, adcValue);

    *(punAdcValue) = adcValue;

    return true;

}

 

bool ADC12_Smoke_Data_Acquisition(uint16_t *punAdcValue)

{

    uint16_t adcValue = 0;

    if (ADC_convert(adc_smoke, &adcValue) != ADC_STATUS_SUCCESS) return false;

    uint32_t resultUv = ADC_convertToMicroVolts(adc_smoke, adcValue);

    *(punAdcValue) = adcValue;

    return true;

}

////////////////////////////////////////////////////////////////////////////////////////////////

thanks

regards,

  • Hi Robin, 

    Thanks for reaching out. I would recommend taking the adcsinglechannel example and modifying it to your requirements. ADC CC2652R ExampleThis would verify that the code is working well. 

    Regards 

    Ivan

  • Hi Robin,

    The ADC TI Driver will only open one instance since simultaneous ADC channel sampling is not supported by the device.  Thus in the code's current setup you can close Board_ADC0 before opening Board_ADC1.  Or you may benefit from using the ADCBuf TI Driver where you can set one-shot recurrence mode in blocking return mode, then change the adcChannel parameter in between ADCBuf_convert function calls.

    Regards,
    Ryan