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.

How to setup multiple I2C channels on CC26xx

Other Parts Discussed in Thread: CC2650

Hi,

Hope this hasn't already been answered somewhere else but I'm having some trouble with talking to an I2C device is on a second I2C channel coming off the CC26xx. Here's the trouble.  Sometimes, I can talk to the device and sometimes I can't.  I'm not having any trouble talking to devices on the first I2C channel (on which there are multiple devices). On the second I2C channel, there's only one device, but when I ask for it's signature, sometimes it's there and sometimes it's not. 

At this point, one of my main uncertainties is how I've set up the I2C channels in my Board.c file. Here's how I've set up the Board.c file:

/* I2C */
#define Board_I2C0_SDA1 IOID_19
#define Board_I2C0_SCL1 IOID_18
#define Board_I2C0_SDA0 IOID_1
#define Board_I2C0_SCL0 IOID_0

typedef enum CC2650_I2CName {
CC2650_I2C0 = 0,CC2650_I2C1 = 1,
CC2650_I2CCOUNT
} CC2650_I2CName;

#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[CC2650_I2CCOUNT];

/* I2C configuration structure, describing which pins are to be used */
const I2CCC26XX_HWAttrs i2cCC26xxHWAttrs[CC2650_I2CCOUNT] = {
{
.baseAddr = I2C0_BASE,
.intNum = INT_I2C,
.powerMngrId = PERIPH_I2C0,
.sdaPin = Board_I2C0_SDA0,
.sclPin = Board_I2C0_SCL0,
},
{
.baseAddr = I2C0_BASE,
.intNum = INT_I2C,
.powerMngrId = PERIPH_I2C0,
.sdaPin = Board_I2C0_SDA1,
.sclPin = Board_I2C0_SCL1,
}
};

const I2C_Config I2C_config[] = {
{&I2CCC26XX_fxnTable, &i2cCC26xxObjects[0], &i2cCC26xxHWAttrs[0]},
{&I2CCC26XX_fxnTable, &i2cCC26xxObjects[1], &i2cCC26xxHWAttrs[1]},
{NULL, NULL, NULL}
};

In red, green, and blue, I've highlighted my uncertainties. In blue is the fact that both are sharing the interrupt #. Is this okay and, if not, what should it be? In red is the fact that they're both sharing the same power manager id. Is this okay, and, if not, what can I do about it? Same for the green?

Any help you might be able to give would be greatly appreciated...

Thanks!

Hunter

  • Hi Hunter,

    There is only one I2C peripheral on the CC26xx device. Therefore, the I2C can only be used on only one set of pins at a time.
    I'm surprised that you are able to get data from the device connected to the second set of pins.

    It is possible to form two I2C "channels" that are shared by the same peripheral by time multiplexing them. However, you most open and close the I2C driver to achieve this.

    Take a look at the bsp_i2c files at C:\ti\simplelink\ble_cc26xx_2_01_00_44423\Projects\ble\SensorTag\CC26xx\Source\Application\Board_patch\Interfaces

    The sensortag project uses this interface on top of the I2C driver to achieve two I2C channels. Do you have a reason why the device cannot be attached to the first I2C bus to prevent this conflict?
  • You can see the relevant board files up one directory at \CC26XXST_0120
  • Hi Sean,

    Thanks for this. I have to use two I2C "channels" because one set of peripherals (i.e. those sensors on channel #1) is powered down while the other set (sensors on channel #2) need to remain on all the time.

    I'll check out the code you mentioned and see if I can make it work.

    Thanks again
  • Hi Hunter,

    I believe that a similar scheme may be used in the code I referenced. Best of luck!