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.

CC2642R: CC2642R - I2C - Can 4 DIOs be configured as I2C interface in an interleaved way in real time?

Part Number: CC2642R
Other Parts Discussed in Thread: SYSCONFIG

The system of this product has 2 sensor chips with same I2C address and these chips are not allowed to select address.

Q1: As found in CC26x2 technical reference manual, all DIO can be configured as I2C data/clock. Can it be possible to have multiple interface at the same time?

Q2: If Q1 is not possible, whether 4 DIOs can be configured as I2C data and clock in real time or not. The expected usage is illustrated in the following example flow.

=> two sensor chips with same I2C address (no address selection) are connected to DIO0 & 1 and DIO2 & 3 respectively
=> DIO0 and DIO1 are configured as I2C data and clock respectively to initialize 1st sensor chip
=> DIO0 and DIO1 are configured as GPIO
=> DIO2 and DIO3 are configured as I2C data and clock respectively to initialize 2nd sensor chip
=> DIO2 and DIO3 are configured as GPIO
=> DIO0 and DIO1 are configured as I2C data and clock again to read data from 1st sensor chip
=> DIO0 and DIO1 are configured as GPIO
=> DIO2 and DIO3 are configured as I2C data and clock again to read data from 2nd sensor chip
=> DIO2 and DIO3 are configured as GPIO
=> DIO0 and DIO1 are configured as I2C data and clock again to read data from 1st sensor chip
=> DIO0 and DIO1 are configured as GPIO
=> DIO2 and DIO3 are configured as I2C data and clock again to read data from 2nd sensor chip
=> DIO2 and DIO3 are configured as GPIO

  • Hi Ray,

    You could do what you have outlined in "Q2" but there is no way to have "multiple interfaces" at the same time as there is only one I2C peripheral on the device. 

    You could realize "Q2" in a few different ways:

    1) Manually perform the PIN muxing in SW to do what you have outlined in the code above. The risk here is that the I2C peripheral could be confused by this muxing if there would appear any "glitches" on the line during the muxing (for example, releasing the SDA pin from the peripheral while it is enabled). This is the easiest approach but you would need to manually disable the I2C module before doing the muxing to minimize the risk for this error. I suggest you look at the "I2CCC26XX_close()" function in the "I2CCC26XX.c" driver file to get an idea on how to disable this. 

    2) Create two set of I2C setups and open/close the driver whenever you change device. This would be the preferred way but unfortunately there is no easy way doing this while using SysConfig. 

    For 2), the idea is that  you would expand the following section (the generated HW attributes) from one (1) entry to two (2) entries for the same peripheral:

    /*
     *  ======== i2cCC26xxObjects ========
     */
    I2CCC26XX_Object i2cCC26xxObjects[CONFIG_I2C_COUNT];
    
    /*
     *  ======== i2cCC26xxHWAttrs ========
     */
    const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[CONFIG_I2C_COUNT] = {
        /* CONFIG_I2C_0 */
        {
            .baseAddr    = I2C0_BASE,
            .powerMngrId = PowerCC26XX_PERIPH_I2C0,
            .intNum      = INT_I2C_IRQ,
            .intPriority = (~0),
            .swiPriority = 0,
            .sclPin      = IOID_21,
            .sdaPin      = IOID_30
        },
        /* CONFIG_I2C_1 */
        {
            .baseAddr    = I2C0_BASE,
            .powerMngrId = PowerCC26XX_PERIPH_I2C0,
            .intNum      = INT_I2C_IRQ,
            .intPriority = (~0),
            .swiPriority = 0,
            .sclPin      = IOID_X,
            .sdaPin      = IOID_Y
        },
    };
    
    /*
     *  ======== I2C_config ========
     */
    const I2C_Config I2C_config[CONFIG_I2C_COUNT] = {
        /* CONFIG_I2C_0 */
        {
            .fxnTablePtr = &I2CCC26XX_fxnTable,
            .object      = &i2cCC26xxObjects[CONFIG_I2C_0],
            .hwAttrs     = &i2cCC26xxHWAttrs[CONFIG_I2C_0]
        },
        {
            .fxnTablePtr = &I2CCC26XX_fxnTable,
            .object      = &i2cCC26xxObjects[CONFIG_I2C_1],
            .hwAttrs     = &i2cCC26xxHWAttrs[CONFIG_I2C_1]
        },
    };

    Setting this up with the two different set of pins would allow you to open the set you want by passing in the correct index into the driver open call (the I2C_open() takes the index to this structure as the first input argument to select which structure to use).

    You would also want to edit the "BoardGpioInitTable" structure to define the "default" state of each of these pins to make sure they are in left at the correct configuration while not being used by any driver.

    All of these structures would be found in the ti_drivers_config.c file generated by SysConfig.