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.

CC2640: Porting from RGZ 7x7 to RSM 4x4

Part Number: CC2640
Other Parts Discussed in Thread: CC2650

Hi.


Need to port   from CC2640F128RGZ  7x7 chip  to  CC2640F128RSM 4x4.
On 7x7 chip everything works well.
But, can't open ADC on 4x4 chip. Function ADC_open(..) always returns NULL.


void Thermometer_taskFxn(UArg a0, UArg a1){
  // Initialize the application.
  Thermometer_init();

ADC_Params params;  
ADC_Handle adc =ADC_open(1, &params);



//if (adc != NULL) {
//  ADC_close(adc);
//}
//ADC_convert(adc, &adcValue);


Regards,

  • Hi Kharlaskin,

    Have you modified the Board.h and CC2650DK_4XS.c/h files (or similar) to compensate for the different ADC pins and configuration?  The adcCC26xxHWAttrs, among other ADC values, need to be correctly defined for the ADC to open correctly (make sure there are no conflicting BoardGpioInitTable as well).  Consider reviewing similar E2E threads.

    .

    Regards,
    Ryan

  • Hi thank you for the fast response.

    const PIN_Config BoardGpioInitTable[] = {

        WLED       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, //LOW        /* LED initially off             */
        RLED       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX,
        
        STOP       | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, // | PIN_DRVSTR_MAX,   
        SensLevel  | PIN_INPUT_EN,
        
        Board_I2C0_SCL0 | PIN_INPUT_EN | PIN_PULLUP,
        Board_I2C0_SDA0 | PIN_INPUT_EN | PIN_PULLUP,
            
        PIN_TERMINATE
    };

    //**************************************************************************************************

    //Anolog
    //#define Board_ADC0                  CC2650_LAUNCHXL_ADC0
    #define Board_ADC1                  CC2650_LAUNCHXL_ADC1    //IOID_6
    #define Board_ADC2                  CC2650_LAUNCHXL_ADC2    //IOID_7
    #define Board_ADC3                  CC2650_LAUNCHXL_ADC3    //IOID_8
    #define Board_ADC4                  CC2650_LAUNCHXL_ADC4    //IOID_9

    //for CC2640RSM 4x4
    //#define Board_DIO5_ANALOG          IOID_5
    #define Board_DIO6_ANALOG          IOID_6
    #define Board_DIO7_ANALOG          IOID_7
    #define Board_DIO8_ANALOG          IOID_8
    #define Board_DIO9_ANALOG          IOID_9


    //***************************************************************************************************


    /* ADCBuf objects */
    ADCBufCC26XX_Object adcBufCC26xxObjects[CC2650_LAUNCHXL_ADCBufCOUNT];

    /*
     *  This table converts a virtual adc channel into a dio and internal analogue input signal.
     *  This table is necessary for the functioning of the adcBuf driver.
     *  Comment out unused entries to save flash.
     *  Dio and internal signal pairs are hardwired. Do not remap them in the table. You may reorder entire entries though.
     *  The mapping of dio and internal signals is package dependent.
     */
    const ADCBufCC26XX_AdcChannelLutEntry ADCBufCC26XX_adcChannelLut[] = {
        {PIN_UNASSIGNED, ADC_COMPB_IN_VDDS},
        {PIN_UNASSIGNED, ADC_COMPB_IN_DCOUPL},
        {PIN_UNASSIGNED, ADC_COMPB_IN_VSS},
    //    {Board_DIO23_ANALOG, ADC_COMPB_IN_AUXIO7},
    //    {Board_DIO24_ANALOG, ADC_COMPB_IN_AUXIO6},
    //    {Board_DIO25_ANALOG, ADC_COMPB_IN_AUXIO5},
    //    {Board_DIO26_ANALOG, ADC_COMPB_IN_AUXIO4},
    //    {Board_DIO27_ANALOG, ADC_COMPB_IN_AUXIO3},
    //    {Board_DIO28_ANALOG, ADC_COMPB_IN_AUXIO2},
    //    {Board_DIO29_ANALOG, ADC_COMPB_IN_AUXIO1},
    //    {Board_DIO30_ANALOG, ADC_COMPB_IN_AUXIO0},
        
        {Board_DIO9_ANALOG, ADC_COMPB_IN_AUXIO3},
        {Board_DIO8_ANALOG, ADC_COMPB_IN_AUXIO4},
        {Board_DIO7_ANALOG, ADC_COMPB_IN_AUXIO5},
        {Board_DIO6_ANALOG, ADC_COMPB_IN_AUXIO6},
        {Board_DIO5_ANALOG, ADC_COMPB_IN_AUXIO7},

    //**************************************************************************************************


    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCCOUNT] = {
    //for CC2640RSM 4x4
        {
            .adcDIO = Board_DIO9_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO3,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO8_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO4,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO7_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO5,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO6_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO6,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO5_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO7,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },    
        
        
     
    /*  
        {
            .adcDIO = Board_DIO23_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
        }
    */    
    };

    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]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[4], &adcCC26xxHWAttrs[4]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[5], &adcCC26xxHWAttrs[5]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[6], &adcCC26xxHWAttrs[6]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[7], &adcCC26xxHWAttrs[7]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[8], &adcCC26xxHWAttrs[8]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[9], &adcCC26xxHWAttrs[9]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[10], &adcCC26xxHWAttrs[10]},
        {NULL, NULL, NULL},
    };


    //**************************************************************************************

    void Thermometer_taskFxn(UArg a0, UArg a1){
      // Initialize the application.
      Thermometer_init();

    ADC_Params params;  
    ADC_Handle adc =ADC_open(Board_ADC1, &params);            //always returns NULL !!!



    //if (adc != NULL) {
    //  ADC_close(adc);
    //}
    //ADC_convert(adc, &adcValue);


    Regards,

  • Focus on adcCC26xxHWAttrs and ADC_config tables.  Make sure that CC2650_LAUNCHXL_ADCCOUNT and the number of ADC_config entries is the same as the total number of adcCC26xxHWAttrs entries.  Possibly reverse the order of ADC pins in adcCC26xxHWAttrs and consider initializing only one ADC pin (i.e. Board_DIO5_ANALOG/ADC_COMPB_IN_AUXIO7) as a starting point.

    Regards,
    Ryan

  • Hi, Ryan

    Here are screenshots for 7x7 and 4x4 after calling ADC_open


    After calling the ADC_open function, the value of the AUX_ADI4 register has not changed for 4x4.
    For 7x7 chip, AUX_ADI4 value changed correctly

    Why?


    Regards

  • Hi

    const ADCCC26XX_HWAttrs adcCC26xxHWAttrs[CC2650_LAUNCHXL_ADCCOUNT] = {
        {
            .adcDIO = Board_DIO9_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO3,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO8_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO4,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO7_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO5,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO6_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO6,
            .refSource = ADCCC26XX_FIXED_REFERENCE,
            .samplingDuration = ADCCC26XX_SAMPLING_DURATION_2P7_US,
            .inputScalingEnabled = true,
            .triggerSource = ADCCC26XX_TRIGGER_MANUAL
        },
        {
            .adcDIO = Board_DIO5_ANALOG,
            .adcCompBInput = ADC_COMPB_IN_AUXIO7,
            .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
        }
        
    };

    typedef enum CC2650_LAUNCHXL_ADCName {
        CC2650_LAUNCHXL_ADC0 = 0,
        CC2650_LAUNCHXL_ADC1,
        CC2650_LAUNCHXL_ADC2,
        CC2650_LAUNCHXL_ADC3,
        CC2650_LAUNCHXL_ADC4,
        CC2650_LAUNCHXL_ADCDCOUPL,
        CC2650_LAUNCHXL_ADCVSS,
        CC2650_LAUNCHXL_ADCVDDS,
        CC2650_LAUNCHXL_ADCCOUNT
    } CC2650_LAUNCHXL_ADCName;


    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]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[4], &adcCC26xxHWAttrs[4]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[5], &adcCC26xxHWAttrs[5]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[6], &adcCC26xxHWAttrs[6]},
        {&ADCCC26XX_fxnTable, &adcCC26xxObjects[7], &adcCC26xxHWAttrs[7]},
        {NULL, NULL, NULL},
    };



    I checked like this:

    adc = ADC_open(10, NULL );  
    adc = ADC_open(9, NULL );  
    adc = ADC_open(8, NULL );  
    adc = ADC_open(7, NULL );  
    adc = ADC_open(6, NULL );
    adc = ADC_open(5, NULL );
    adc = ADC_open(4, NULL );
    adc = ADC_open(3, NULL );
    adc = ADC_open(2, NULL );
    adc = ADC_open(1, NULL );
    adc = ADC_open(0, NULL );


    Function ADC_open(..) always returns NULL

    ((((

    Regards

  • Your ADC setup appears correct.  Can you please add ADCCC26XX.c/h from <ti driver installation>\products\tidrivers_cc13xx_cc26xx_*\packages\ti\drivers\adc directly into your project to further debug ADC_open?  Please make sure IAR is not in simulator mode when attempting to download and debug your code.  The screenshots indicate that the register values cannot be read for the 4x4 instance.

    Regards,
    Ryan

  • Hi, Ryan

    #include <ti/drivers/ADC.h>
    #include "ADCCC26XX.h"  

    Compiling OK

    ADC not working!!!

    (((

    Regards

  • I found a bug!!!

    ADC_init() was commented out in the 4x4 project

    Thank you for your help, Ryan !

    Regards,
    Alex