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.

I2C problems with CC1310 TI-RTOS

Other Parts Discussed in Thread: CC1310

I have some problems using the libraries for the I2C 

Are the i2c libraries complete or not?

I saw that in i2c_open() function there is a control on the first parameter (index).

If it is greater than i2c _count= -1 the function return NULL. I don't understand this control because the unsigned int "index" is used as index in a vector (i2c_config vector).

Where i can fill i2c_confing vector? and why i2c_count is equal to -1?

Thank you very much for the help

Simone Trinchero

  • Hi Simone,

    I hope you are are aware of the I2C API documentation. What you describe sounds like, the I2C driver is uninitialized. Is I2C_init()called prior to using the I2C driver? If you are using one of the "official" TI boards, then they define a function Board_initI2C(). You must call this function during application startup.

    Background: The I2C driver (as many TI-RTOS drivers) expects the existance of global configuration objects. These are normally defined in the board files, but you can define them also in your application if you want. Some of these objects are kept in arrays and are addressed by their array index. The TI board files define a single I2C configuration object that is addressed by an enum defined in the board files.

    Edit: I just saw that the CC1310DK board file does not contain a I2C configuration. That's clearly a bug. Have a look into the Launchpad board files and copy it from there. Sorry for that.

    Best regards

    Richard Weickelt

  • Thank you very much.
    Yes I did Board_initI2C() but it does not work.

    Sorry if I bore you, but what do you mean "Have a look into the Launchpad board files and copy it from there", if I understand which peaces of code i have to add in the libraries I can go ahead with my work.

    Thank again
  • In the TI-RTOS examples we have a convention for board support files. Every project contains at least:

    • Board.h
    • XXX_Board_name.h
    • XXX_Board_name.c
    • XXX_Board_name.cmd

    These files define global configuration objects which are used by the TI-RTOS drivers. For some reason, the I2C configuration object has been left out in the CC1310DK_XXX board files, but it is present in the CC1310_LAUNCHXL board files. You can find those files in your TI-RTOS installation:

    ${TIRTOS_INSTALL_DIR}/products/tidrivers_cc13xx_cc26xx_2_16_00_08/packages/ti/boards.

    From CC1310_LAUNCHXL.h/c, you have to extract the following code snippets:

    /* I2C */
    #define Board_I2C0_SCL0             IOID_4
    #define Board_I2C0_SDA0             IOID_5
    
    /*!
     *  @def    CC1310_LAUNCHXL_I2CName
     *  @brief  Enum of I2C names on the CC2650 dev board
     */
    typedef enum CC1310_LAUNCHXL_I2CName {
        CC1310_LAUNCHXL_I2C0 = 0,
    
        CC1310_LAUNCHXL_I2CCOUNT
    } CC1310_LAUNCHXL_I2CName;
    
     *  ============================= I2C Begin=====================================
    */
    /* Place into subsections to allow the TI linker to remove items properly */
    #if defined(__TI_COMPILER_VERSION__)
    #pragma DATA_SECTION(I2C_config, ".const:I2C_config")
    #pragma DATA_SECTION(i2cCC26xxHWAttrs, ".const:i2cCC26xxHWAttrs")
    #endif
    
    /* Include drivers */
    #include <ti/drivers/i2c/I2CCC26XX.h>
    
    /* I2C objects */
    I2CCC26XX_Object i2cCC26xxObjects[CC1310_LAUNCHXL_I2CCOUNT];
    
    /* I2C configuration structure, describing which pins are to be used */
    const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CC1310_LAUNCHXL_I2CCOUNT] = {
        {
            .baseAddr = I2C0_BASE,
            .powerMngrId = PowerCC26XX_PERIPH_I2C0,
            .intNum = INT_I2C_IRQ,
            .intPriority = ~0,
            .swiPriority = 0,
            .sdaPin = Board_I2C0_SDA0,
            .sclPin = Board_I2C0_SCL0,
        }
    };
    
    /* I2C configuration structure */
    const I2C_Config I2C_config[] = {
        {
            .fxnTablePtr = &I2CCC26XX_fxnTable,
            .object = &i2cCC26xxObjects[0],
            .hwAttrs = &i2cCC26xxHWAttrs[0]
        },
        {NULL, NULL, NULL}
    };
    /*
     *  ========================== I2C end =========================================
     */
    
    

    Then you should be able to call I2C_init() in your application. Sorry that the documentation is a little bit scarce.