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.

CC2650 interfacing with I2C accelerometer(LSM6DS3 from ST)

Other Parts Discussed in Thread: CC2650

Hi All,

I have a custom CC2650 board with LSM6DS3 as peripheral. I want to establish I2C communication with this peripheral to implement various functions like pedometer, reading gyro and accelerometer values and fall detection. I am bit confused . Can somebody guide me regarding how to proceed regarding I2C implementation

Regards

Mark

  • Hi,

    You can take a look at our Software developer's guide section 6.3.4 how to add a I2C driver.
    You can also checkout our sensortag project. It uses I2C to access motion sensor too.
  • Hi Christin,

    I have added this in keyfobdemo_init(). I have specified the slave address as D4 of LSM6DS3.I tried to transfer some data through I2C , but after debugging i cant see anything in rxBuf.

    I2C_Params_init(&SbpI2cParams);
    SbpI2cHandle=I2C_open(CC2650_I2C0,&SbpI2cParams);
    I2C_Transaction i2cTransaction;
    uint8 txBuf[]={0,1,2,3,4};
    uint8 rxBuf[5];
    i2cTransaction.writeBuf=txBuf;
    i2cTransaction.writeCount=5;
    i2cTransaction.readBuf=rxBuf;
    i2cTransaction.readCount=5;
    i2cTransaction.slaveAddress=0xD4;
    I2C_transfer(SbpI2cHandle,&i2cTransaction);

    Regards

    Mark

  • Hi,

    The SW might be too optimized to see content in rxBuf. You can try :
    1. declare rxBuf as static
    2. use logic analyzer to check your TX and RX line.
    3. check if I2C_transfer returns Success or Fail.
  • HI Christin,

    I am working on LSM6DS3 and tried to make the I2C driver work by first transferring data and then reading back the same.

    In the txBuf[]={1,2,3,4,5}; , but in the rxBuf i am receiving all zeros. Can you tell why this is happening.

    Regards

    Mark

  • Can you try what I suggested first?

    Also do you see any return value of I2C handle?
  • Hi Christin,

    I tried the below code and the I2C transfer is happening for 5 iterations and each time i am able to turn On LED, But each time i am receiving zeros in the rxBuf instead of 1,2,3,4,5

    /I2C_init();
    I2C_Params_init(&SbpI2cParams);
    SbpI2cHandle=I2C_open(CC2650_I2C0,&SbpI2cParams);
    I2C_Transaction i2cTransaction;
    uint8 txBuf[]={1,2,3,4,5};
    uint8 rxBuf[5];
    i2cTransaction.writeBuf=txBuf;
    i2cTransaction.writeCount=5;
    i2cTransaction.readBuf=rxBuf;
    i2cTransaction.readCount=5;
    i2cTransaction.slaveAddress=0x6A;
    while(1)
    {
    if(I2C_transfer(SbpI2cHandle,&i2cTransaction))
    {

    PIN_setOutputValue(hGpioPin, Board_LED1,Board_LED_ON);
    }}


    Best Wishes
    Mark
  • Hi Christin,

    I did some experiment with the code and tried changing from txBuf[]={1,2,3,4,5} to some different set of value txBuf[]={8,8,8,8,8};

    Then when i debug its showing the previous txbuf values in rxbuf ie is 1,2,3,4.5.

    The problem is i think its not reading the exact memory where it was written. Can you tell what is going wrong here?

    Regards
    Mark