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/BOOSTXL-CC2650MA: Using the ADC on the booster pack

Part Number: BOOSTXL-CC2650MA
Other Parts Discussed in Thread: CC2650MODA, CC2650

Tool/software: TI-RTOS

Howdy,

I am trying to use the adc on the CC2650MODA but am having some issues. I have made the proper board file changes in the launch xl .h and .c files and have also changed the .adcDIO = in the launch xl .c file to match the dio that I want to use. I have tried dio 12, 7, and 14 and they are all giving me results as if nothing is plugged into the dio. I know the ADC code I am running, which is a modification of the single channel ADC code, works as I am able to successfully run it on the CC2650 launchpad. 

I am using CCS 6.2.0 and have tried using complier version 15.12.3 and 5.2.6 and am using ti rtos 2_20_01_08.

  • Hi Hunter,

    Do you know if the ADC_open is successful?
    Can you be more specific on "as if nothing is plugged into the dio"?


    Regards,
    Toby
  • Hi Toby,

    Yes ADC_open was successful after I changed the .adcDIO = to match the specific dio I am trying to use in the launch xl.c file.

    It gives the same reading as if nothing is hooked to the pin. I am using the adc to read a voltage from a voltage divider and the readings only vary slightly from when the voltage divider is connected or not connected.

    Thank You,
    Hunter Schwedler
  • As a sanity check, have you tried hooking the ADC to VDD or ground on the CC2650MA? If so, what ADC values are you reading there?

  • When I set the ADC to read VDD I am reading 3.3V and when I plug the DIO into ground I am reading about 1 V.

  • Do you want me to post my changes to the board files to see if I missed something or did something wrong?
  • Yes, please do.
    Also, can you send a picture of your setup? Can you tell me the raw value of the ADC values?

    Just want to verify that both hw and sw are set up correctly when evaluating the ADC.
  • Here is the code I am running
    * ======== adcsinglechannel.c ======== */ /* XDCtools Header files */ #include <xdc/std.h> #include <xdc/runtime/System.h> /* BIOS Header files */ #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Task.h> /* Driver Header files */ #include <ti/drivers/ADC.h> #if defined(CC2650DK_7ID) || defined(CC1310DK_7XD) #include <ti/drivers/PIN.h> #endif /* Example/Board Header files */ #include "Board.h" /* ADC sample count */ #define ADC_SAMPLE_COUNT (10) /*Task Specific defines */ #define TASKSTACKSIZE (768) Task_Struct task1Struct; Char task1Stack[TASKSTACKSIZE]; /* ADC conversion result variables */ uint16_t adcValue0; uint16_t adcValue1[ADC_SAMPLE_COUNT]; /* * ======== taskFxn1 ======== * Open a ADC handle and get a array of sampling results after * calling several conversions. */ Void taskFxn1(UArg arg0, UArg arg1) { uint16_t i, x, voltage_send; ADC_Handle adc; ADC_Params params; int_fast16_t res; uint32_t value[ADC_SAMPLE_COUNT]; float voltage, sum = 0.0; ADC_Params_init(&params); adc = ADC_open(CC2650_LAUNCHXL_ADC0, &params); if (adc == NULL) { System_abort("Error initializing ADC channel 1\n"); } else { System_printf("ADC channel 1 initialized\n"); } for (i = 0; i < ADC_SAMPLE_COUNT; i++) { res = ADC_convert(adc, &adcValue1[i]); if (res == ADC_STATUS_SUCCESS) { value[i] = ADC_convertRawToMicroVolts(adc,adcValue1[i]); System_printf("ADC channel 1 convert result (%d): %d\n", i, value[i]); } else { System_printf("ADC channel 1 convert failed (%d)\n", i); } System_flush(); } for (x = 0; x < ADC_SAMPLE_COUNT; x++){ sum += value[x]; } voltage = sum / ADC_SAMPLE_COUNT; voltage = voltage / 1000000; voltage = voltage * 2; voltage_send = voltage * 100; System_printf("Battery Voltage = %f\n", voltage); System_printf("Sending Battery Voltage = %d\n", voltage_send); System_flush(); ADC_close(adc); } /* * ======== main ======== */ int main(void) { Task_Params taskParams; /* Call board init functions */ Board_initGeneral(); Board_initADC(); /* Create tasks */ Task_Params_init(&taskParams); taskParams.stackSize = TASKSTACKSIZE; taskParams.stack = &task1Stack; Task_construct(&task1Struct, (Task_FuncPtr)taskFxn1, &taskParams, NULL); /* SysMin will only print to the console when you call flush or exit */ System_flush(); BIOS_start(); return (0); }

    Here is my change to the .h file

    #define CC2650EM_5XD


    /* Mapping of pins to board signals using general board aliases
    * <board signal alias> <pin mapping>
    */

    /* Discrete outputs */
    #define Board_RLED IOID_4
    #define Board_GLED IOID_2
    #define Board_LED_ON 1
    #define Board_LED_OFF 0

    /* Discrete inputs */
    #define Board_BTN1 PIN_UNASSIGNED
    #define Board_BTN2 PIN_UNASSIGNED

    /* UART Board */
    #define Board_UART_RX IOID_1 /* RXD */
    #define Board_UART_TX IOID_0 /* TXD */
    #define Board_UART_CTS PIN_UNASSIGNED /* CTS */
    #define Board_UART_RTS PIN_UNASSIGNED /* RTS */

    /* SPI Board */
    #define Board_SPI0_MISO IOID_12 /* RF1.20 */
    #define Board_SPI0_MOSI IOID_11 /* RF1.18 */
    #define Board_SPI0_CLK IOID_10 /* RF1.16 */
    #define Board_SPI0_CSN PIN_UNASSIGNED
    #define Board_SPI1_MISO PIN_UNASSIGNED
    #define Board_SPI1_MOSI PIN_UNASSIGNED
    #define Board_SPI1_CLK PIN_UNASSIGNED
    #define Board_SPI1_CSN PIN_UNASSIGNED

    /* I2C */
    #define Board_I2C0_SCL0 PIN_UNASSIGNED
    #define Board_I2C0_SDA0 PIN_UNASSIGNED

    /* SPI */
    #define Board_SPI_FLASH_CS PIN_UNASSIGNED
    #define Board_FLASH_CS_ON 0
    #define Board_FLASH_CS_OFF 1

    /* Booster pack generic */
    #define Board_DIO0 IOID_0
    #define Board_DIO1_RFSW IOID_1
    #define Board_DIO7_ANALOG IOID_7 //added
    #define Board_DIO12 IOID_12
    #define Board_DIO14_ANALOG IOID_14 //added
    #define Board_DIO15 IOID_15
    #define Board_DIO16_TDO IOID_16
    #define Board_DIO17_TDI IOID_17
    #define Board_DIO21 IOID_21
    #define Board_DIO22 IOID_22

    #define Board_DIO23_ANALOG IOID_23
    #define Board_DIO24_ANALOG IOID_24
    #define Board_DIO25_ANALOG IOID_25
    #define Board_DIO26_ANALOG IOID_26
    #define Board_DIO27_ANALOG IOID_27
    #define Board_DIO28_ANALOG IOID_28
    #define Board_DIO29_ANALOG IOID_29
    #define Board_DIO30_ANALOG IOID_30
    /* Booster pack LCD (430BOOST - Sharp96 Rev 1.1) */
    #define Board_LCD_CS IOID_24 // SPI chip select
    #define Board_LCD_EXTCOMIN IOID_12 // External COM inversion
    #define Board_LCD_ENABLE IOID_22 // LCD enable
    #define Board_LCD_POWER IOID_23 // LCD power control
    #define Board_LCD_CS_ON 1
    #define Board_LCD_CS_OFF 0

    /* PWM outputs */
    #define Board_PWMPIN0 Board_RLED
    #define Board_PWMPIN1 Board_GLED
    #define Board_PWMPIN2 PIN_UNASSIGNED
    #define Board_PWMPIN3 PIN_UNASSIGNED
    #define Board_PWMPIN4 PIN_UNASSIGNED
    #define Board_PWMPIN5 PIN_UNASSIGNED
    #define Board_PWMPIN6 PIN_UNASSIGNED
    #define Board_PWMPIN7 PIN_UNASSIGNED

    And here is my change to the .c file

    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(BoardGpioInitTable, ".const:BoardGpioInitTable")
    #pragma DATA_SECTION(PINCC26XX_hwAttrs, ".const:PINCC26XX_hwAttrs")
    #endif

    const PIN_Config BoardGpioInitTable[] = {

    Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
    Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
    Board_UART_RX | PIN_INPUT_EN | PIN_PULLDOWN, /* UART RX via debugger back channel */
    Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX via debugger back channel */
    Board_SPI0_MOSI | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master out - slave in */
    Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI master in - slave out */
    Board_SPI0_CLK | PIN_INPUT_EN | PIN_PULLDOWN, /* SPI clock */

    PIN_TERMINATE
    };

    ....

    ....

    ....

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

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


    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCCOUNT] = {
    {
    .adcDIO = Board_DIO14_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO7,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = Board_DIO24_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO6,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .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 = Board_DIO26_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO4,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = Board_DIO27_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO3,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = Board_DIO28_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO2,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = Board_DIO29_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO1,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
    .inputScalingEnabled = true,
    .triggerSource = ADCCC26XX_TRIGGER_MANUAL
    },
    {
    .adcDIO = Board_DIO30_ANALOG,
    .adcCompBInput = ADC_COMPB_IN_AUXIO0,
    .refSource = ADCCC26XX_FIXED_REFERENCE,
    .samplingDuration = ADCCC26XX_SAMPLING_DURATION_10P9_MS,
    .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
    }
    };

  • and all of the code and the set up works as intended when I use the launchpad, it is when I try to use the moda that I have issues. THhe reason this is an issue is we are using the MODA on our custom pcb set to the same pin set up and I have the same adc issues on our pcb as I do on the BoosterPack.
  • Thanks for sharing that!

    Regarding code:
    I would suggest developing from the CC2650_5XD board files. You can find those in \tirtos_cc13xx_cc26xx_2_20_01_08\products\tidrivers_cc13xx_cc26xx_2_20_01_10\packages\ti\boards\CC2650DK_5XD. Seems as if the current code is assuming there are more DIOs than exist on the CC2650MODA. This isn't a problem if you don't use those DIO definitions, but it might get confusing further down the road.
    Since you were able to get different ADC values when you probed VDD and ground, I doubt it's a software issue.

    Regarding HW:
    I know the XDS110 cable has ground connections, but could you try adding a jumper from the breadboard ground to the launchpad ground?
  • Ok I will look into those board files and see if there are some other changes. I did try and change all the DIO definitions to PIN UNASSIGNED aside from the DIO I was using and there was no change. I will add the extra common ground and see if anything else changes as well.
  • Looking at CC2650DK_5XD board files, the files do not have any ADC set up code for the DIOs in them so I would have to use the generic CC2650 board code that I have been using.
  • Toby,

    I found something interesting while messing around with the board files today. I assumed it worked in that adc 0 was tied to which ever was the first in the .AdcDIO= list, however i was messing around with launchpad and i switched DIO 24 to the first in the list (adc 0) and DIO 23 to second in the list (adc 1) and adc 0 still worked with DIO 23 and not DIO 24. Is there another table definition hidden in the board files somewhere that would be causing the issue of DIO 14, 12, and 7 not working on the MODA.

  • I solved the issue. Firstly I went ahead and filled out the .AdcDIO = to all of the analog capable pins in the order they are listed in the CC2650MODA data sheet. After that I added the #Define Board_DIOX IOID_X for each of those pins. This made the CC2650_LAUNCHXL_ADCX work for the order for each analog pin. Finally what is the issue that caused me the most issue is that MY COMMON GROUND WAS WRONG. In the picture of the circuit that I was using the common ground went to pin 22 of the booster pack which is labeled ground. I switched to pin 20 (top right) and suddenly everything started reading as intended. I do not know why pin 22 of the booster pack is not acting as ground I went and looked at the schematic for the booster pack and it shows that entire row of pins as not being connected to anything.
  • Hi Hunter,

    Glad you got things working!


    Regards,
    Toby