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.

RTOS/CC2650: I2C data rate and unblocking

Part Number: CC2650


Tool/software: TI-RTOS

Hi, this is my first venture into firmware so please be patient. 

1. In the file SensorTagApp, bsp_i2c.c there seem to be two different initializations of i2cParams. First, in bspI2cInit we have i2cParams.bitRate = I2C_400kHz. Second, in bspI2cSelect we have i2cParams.bitRate set to the default I2C_100kHz. Why are there two different bit rates, and what are these two different bit rates used for? As far as I can tell, the only one that matters is the second because all of the calls to read actual data use SENSOR_SELECT. What is the purpose of setting the bitrates differently? 

2. How do I set up a non blocking read from the mpu9250 FIFO? Should the following modification to bspI2cSelect work? I believe that  post to  may have suggested a better callback using a semaphore but i didn't understand that suggestion in enough detail. 

Thanks in advance! 

Allan 

 

 

volatile bool lastI2cResult = false; 
void myI2C_Callback (I2C_Handle foo, I2CTransaction* bar, bool status)
{
    lastI2cResult = status; 
}
bool getI2cResult()
{
    bool ret = lastI2cResult; 
    lastI2cResult = false; 
    return lastI2cResult; 
}
bool bspI2cSelectNonBlocking(uint8_t newInterface, uint8_t address)
{
--------------------------- code not pasted -------------------------- if (newInterface != interface) {
--------------------------- code not pasted --------------------------
    // Sets custom to NULL, selects I2C interface 0
    I2C_Params_init(&i2cParams);
    // Modifications for bitrate and non blocking 
    i2cParams.bitRate = I2C_400kHz;
    i2cParams.transferMode  = I2C_MODE_CALLBACK;
    i2cParams.transferCallbackFxn = myI2C_Callback;
--------------------------- code not pasted --------------------------
  }
  return i2cHandle != NULL;
}

  • Hi,

    I would recommend you to directly use TI-RTOS I2C driver.

    You can find the detail about how to use I2C driver in C:\ti\tirtos_cc13xx_cc26xx_2_20_01_08\products\tidrivers_cc13xx_cc26xx_2_20_01_10\packages\ti\drivers\I2C.h

  • Hi Allan,

    I will try to answer your questions. I2C bus support both vlock speeds (100 KHz or 400 KHz), you need to select wich one you want to use depending your sensor, you need to search in the sensor datasheet for that information. 

    If you debug your program you can check that the bitRate was changed to 400 KHz. If you want to know better what the functions do, please read the examples in the libraries (I2CCC26XX.h, I2C.h, etc)

    I2C_Params_init(&i2cParams);
        // Modifications for bitrate and non blocking 
    i2cParams.bitRate = I2C_400kHz;



    Best Regards,
    Miguel
    
    
  • Hi Miguel, Christin.

    Thanks for your replies. Based on your suggestions, I would like to reformulate my question 1.

    1. My observation is, sensorTag has two i2c busses. Bus #0 is initially set to 400khz but as soon as the MPU9250 is accessed on bus #1, BOTH busses are set to 100khz. My question is, is this done intentionally or is it a bug (oversight). 

    Thanks! 
    Allan 

  • The code you refer to is obsolete. Please download BLE SDK 2.2.1 to get the the latest (ti.com/blestack). After installing you can find the relevant code in SensorI2C.c.