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 4x4 I2C problem

Other Parts Discussed in Thread: CC2640

Hi,
I have problem with I2C interface. I'm  working on the CC2640 with SHT20 sensor. I can't read temperature. This is steps which I did:
1) I added this code to the CC2650DK_4XS.c

/* 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 <ti/drivers/i2c/I2CCC26XX.h>
/* I2C objects */
I2CCC26XX_Object i2cCC26xxObjects;
#define Board_I2C                   0
#define Board_I2C0_SDA0             IOID_2
#define Board_I2C0_SCL0             IOID_1
/* I2C configuration structure, describing which pins are to be used */
const I2CCC26XX_HWAttrsV1 i2cCC26xxHWAttrs[] = {
    {
        .baseAddr = I2C0_BASE,
        //.powerMngrId = PowerCC26XX_PERIPH_I2C0,
        .powerMngrId = 7,
        .intNum = INT_I2C_IRQ,
        .intPriority = ~0,
        .swiPriority = 0,
        .sdaPin = Board_I2C0_SDA0,
        .sclPin = Board_I2C0_SCL0,
    }
};

const I2C_Config I2C_config[] = {
    {
        .fxnTablePtr = &I2CCC26XX_fxnTable,
        .object = &i2cCC26xxObjects,
        .hwAttrs = &i2cCC26xxHWAttrs
    },
    {NULL, NULL, NULL}
};

2) I included to the main program defines and variables:
#include <ti/drivers/I2C.h>
#include <ti/drivers/i2c/I2CCC26XX.h>


static I2C_Handle handleI2C;
static I2C_Params params;
static I2C_Transaction i2cTrans;
static uint8_t rxBuf[21];      // Receive buffer
static uint8_t txBuf[8];      // Transmit buffer
static const I2CCC26XX_I2CPinCfg pinCfg1 =
{
    // Pin configuration for I2C interface 1
    .pinSDA = 0x00000002,
    .pinSCL = 0x00000001
};

3) I wrote functions to read temperatur:

static void SHT20_Init(){
	// Configure I2C parameters.
	I2C_init(handleI2C);
	txBuf[0]=128; //soft reset
	txBuf[1]=0xFE;
	SHT20_Send();
}

static void SHT20_ReadTemperature(){
	// Open I2C
	//SHT20_Send(128);
	txBuf[0]=129;
	txBuf[1]=0xE3;
	txBuf[2]=128;
	SHT20_Read();
}

static void SHT20_Send(){
	// Initialize master I2C transaction structure
	I2C_Params_init(&params);
	i2cTrans.writeCount   = 2;
	i2cTrans.writeBuf     = txBuf;
	i2cTrans.readCount    = 0;
	i2cTrans.readBuf      = rxBuf;
	i2cTrans.slaveAddress = SHT20_ADDR;
	params.custom = (uintptr_t)&pinCfg1;
	handleI2C = I2C_open(Board_I2C, &params);
	// Do I2C transfer receive
	I2C_transfer(handleI2C, &i2cTrans);
	I2C_close(handleI2C);
}

static void SHT20_Read(){
	//txBuf[0]=data;
	// Initialize master I2C transaction structure
	I2C_Params_init(&params);
	i2cTrans.writeCount   = 3;
	i2cTrans.writeBuf     = txBuf;
	i2cTrans.readCount    = 21;
	i2cTrans.readBuf      = rxBuf;
	i2cTrans.slaveAddress = SHT20_ADDR;
	params.custom = (uintptr_t)&pinCfg1;
	handleI2C = I2C_open(Board_I2C, &params);
	// Do I2C transfer receive
	I2C_transfer(handleI2C, &i2cTrans);
	I2C_close(handleI2C);
}

128 is a I2C address + write bit
129 is a I2C address + write bit
0xE3 is a command trig. temp meas. hold master
SHT20_ADDR is a address of SHT20

The rfBuf is still 0;

Thanks for help in advance,
Best wishes,
MC