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.

adcsinglechannel_CC2650DK_7ID_TI_CC2650F128 peoject adc question

Dear All:

I import adcsinglechannel project to CCS:

about TaskFxn0:

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

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

if (adc == NULL) {
System_abort("Error initializing ADC channel 0\n");
}
else {
System_printf("ADC channel 0 initialized\n");
}

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

if (res == ADC_STATUS_SUCCESS) {
System_printf("ADC channel 0 convert result: 0x%x\n", adcValue0);
}
else {
System_printf("ADC channel 0 convert failed\n");
}

ADC_close(adc);

System_flush();
}

I get result:

if I want to read ADC channel 0 many times , what do I do?

  • Hi,

    Have you tried calling ADC_convert() many times?

    Best wishes
  • No, but I guess I know where I am wrong.

    I revise CC2650DK_7ID.c :

    /*

    *  ========================== ADC begin =========================================

    */

    /* Place into subsections to allow the TI linker to remove items properly */

    #if defined(__TI_COMPILER_VERSION__)

    #pragma DATA_SECTION(ADC_config, ".const:ADC_config")

    #pragma DATA_SECTION(adcCC26xxHWAttrs, ".const:adcCC26xxHWAttrs")

    #endif

    /* Include drivers */

    #include <ti/drivers/ADC.h>

    #include <ti/drivers/adc/ADCCC26XX.h>

    /* ADC objects */

    ADCCC26XX_Object adcCC26xxObjects[CC2650DK_7ID_ADCCOUNT];

    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650DK_7ID_ADCCOUNT] = {

      {

           .adcDIO = Board_DIO25_ANALOG,

           .adcCompBInput = ADC_COMPB_IN_AUXIO5,

           .refSource = ADCCC26XX_FIXED_REFERENCE,

           .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,

           .inputScalingEnabled = true,

           .triggerSource = ADCCC26XX_TRIGGER_MANUAL

       },

       {

           .adcDIO = PIN_UNASSIGNED,

           .adcCompBInput = ADC_COMPB_IN_DCOUPL,

           .refSource = ADCCC26XX_FIXED_REFERENCE,

           .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,

           .inputScalingEnabled = true,

           .triggerSource = ADCCC26XX_TRIGGER_MANUAL

       },

       {

           .adcDIO = PIN_UNASSIGNED,

           .adcCompBInput = ADC_COMPB_IN_VSS,

           .refSource = ADCCC26XX_FIXED_REFERENCE,

           .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,

           .inputScalingEnabled = true,

           .triggerSource = ADCCC26XX_TRIGGER_MANUAL

       },

       {

           .adcDIO = PIN_UNASSIGNED,

           .adcCompBInput = ADC_COMPB_IN_VDDS,

           .refSource = ADCCC26XX_FIXED_REFERENCE,

           .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,

           .inputScalingEnabled = true,

           .triggerSource = ADCCC26XX_TRIGGER_MANUAL

       }

    };

    const ADC_Config ADC_config[] = {

       {&ADCCC26XX_fxnTable, &adcCC26xxObjects[0], &adcCC26xxHWAttrs[0]},

       {&ADCCC26XX_fxnTable, &adcCC26xxObjects[1], &adcCC26xxHWAttrs[1]},

       {&ADCCC26XX_fxnTable, &adcCC26xxObjects[2], &adcCC26xxHWAttrs[2]},

       {&ADCCC26XX_fxnTable, &adcCC26xxObjects[3], &adcCC26xxHWAttrs[3]},

       {NULL, NULL, NULL},

    };

    but I don't revise 

    const PIN_Config BoardGpioInitTable[] = {

    Board_DK_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
    Board_DK_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
    Board_DK_LED3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
    Board_DK_LED4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
    Board_KEY_SELECT | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
    Board_KEY_UP | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
    Board_KEY_DOWN | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
    Board_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
    Board_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
    Board_3V3_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* 3V3 domain off initially */
    Board_LCD_MODE | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* LCD pin high initially */
    Board_LCD_RST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* LCD pin high initially */
    Board_LCD_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* LCD CSn deasserted initially */
    Board_ALS_PWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* ALS power off initially */
    Board_ACC_PWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* ACC power off initially */
    Board_ACC_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* ACC CSn deasserted initially */
    Board_SDCARD_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* SDCARD CSn deasserted initially */
    Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX pin at inactive level */
    PIN_TERMINATE /* Terminate list */
    };

    Should I modify red line ?

  • No, but I guess I know where I am wrong.
    I revise CC2650DK_7ID.c :
    /*
    * ========================== ADC begin =========================================
    */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(ADC_config, ".const:ADC_config")
    #pragma DATA_SECTION(adcCC26xxHWAttrs, ".const:adcCC26xxHWAttrs")
    #endif

    /* Include drivers */
    #include <ti/drivers/ADC.h>
    #include <ti/drivers/adc/ADCCC26XX.h>

    /* ADC objects */
    ADCCC26XX_Object adcCC26xxObjects[CC2650DK_7ID_ADCCOUNT];


    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650DK_7ID_ADCCOUNT] = {
    {
    .adcDIO = Board_DIO25_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO5,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = PIN_UNASSIGNED,
    .adcCompBInput = ADC_COMPB_IN_DCOUPL,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = PIN_UNASSIGNED,
    .adcCompBInput = ADC_COMPB_IN_VSS,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = PIN_UNASSIGNED,
    .adcCompBInput = ADC_COMPB_IN_VDDS,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    }
    };

    const ADC_Config ADC_config[] = {
    {&ADCCC26XX_fxnTable, &adcCC26xxObjects[0], &adcCC26xxHWAttrs[0]},
    {&ADCCC26XX_fxnTable, &adcCC26xxObjects[1], &adcCC26xxHWAttrs[1]},
    {&ADCCC26XX_fxnTable, &adcCC26xxObjects[2], &adcCC26xxHWAttrs[2]},
    {&ADCCC26XX_fxnTable, &adcCC26xxObjects[3], &adcCC26xxHWAttrs[3]},
    {NULL, NULL, NULL},
    };
  • but I don't revise :
    const PIN_Config BoardGpioInitTable[] = {
    ..
    ..
    ..
    Board_ALS_PWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* ALS power off initially */
    ..
    ..
    }
    Should I need to revise Board_ALS_PWR ??
  • Dear All:

    I use project adcsinglechannel_CC2650DK_7ID_TI_CC2650F128 to test Moisture Sensor:

    and CC2650DK connect sensor :

    RF2.11 -->Sensor Data

    and revise CC2650DK_7ID.c

    .adcDIO = Board_DIO25_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO5,

    and adcsinglechannel.c:

    Void taskFxn0(UArg arg0, UArg arg1)
    {
    ADC_Handle adc;
    ADC_Params params;
    int_fast16_t res;

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

    if (adc == NULL) {
    System_abort("Error initializing ADC channel 0\n");
    }
    else {
    System_printf("ADC channel 0 initialized\n");
    }

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

    if (res == ADC_STATUS_SUCCESS) {
    System_printf("ADC channel 0 convert result: %d\n", adcValue0);
    }
    else {
    System_printf("ADC channel 0 convert failed\n");
    }

    ADC_close(adc);

    System_flush();
    }

    I get result always:

    ADC channel 0 convert result: 3113

    I don't know what's happen ? I hope someone can help , Thank you.

  • Hi,

    Perhaps the moisture level is the same? Did you test the code with some generated input voltage to the ADC pin?

    Best wishes
  • Hello:

    I revise  adc = ADC_open(Board_ADC0, &params);

    to

    adc = ADC_open(Board_ADC1, &params);

    then that value seems normal.

    I don't understand Board_ADC1 and Board_ADC0 , what's different ?

    I guess it't the same.

    Because the file : CC2650DK_7ID.h written ADCName is :

    typedef enum CC2650DK_7ID_ADCName {

       CC2650DK_7ID_ADCALS = 0,  //Board_ADC1

       CC2650DK_7ID_ADCDCOUPL,

       CC2650DK_7ID_ADCVSS,

       CC2650DK_7ID_ADCVDDS,   //Board_ADC0

       CC2650DK_7ID_ADCCOUNT

    } CC2650DK_7ID_ADCName;