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.

Problem with i2c communication refresh rate in TM4C129

Other Parts Discussed in Thread: CC3200

Hello All,

I have been trying to use MPU6050 with TM4C129, with i2c communication. I previously used mpu6050 with CC3200 with which i was getting an update rate of approx 1800Hz for just retrieving the data from the sensor. But with the same code (and adding Wire.Module(x)), on TM4C129, i am getting very low refresh rate (approx 70 Hz). Is there anyway that i can sort this issue?

I am not able to understand the reason behind this, 

Codes used are:

// acc and gyro are arrays which store raw data from sensor

void loop()

{

timer = micros();

mpu.i2cRead(MPU9150_ACCEL_XOUT_H,buffer,6);      // Read 6 bytes of accelerometer data from MPU6050
mpu.extractAccData(acc);
mpu.i2cRead(MPU9150_GYRO_XOUT_H,buffer,6);                // read 6 bytes of gyroscope data from MPU9150
mpu.extractGyroData(gyro);

timer = micros()-timer;

}

this code was in the main loop, related functions used are:

for i2c-

uint8_t MPU9150::i2cRead(uint8_t reg,uint8_t * data, uint8_t length,boolean fromCmps)
{
uint8_t i;
// Read data from MPU9150
Wire.beginTransmission(MPU_ADDRESS); // Initialize communication with MPU9150 on i2c bus (issue start condition)
Wire.write(reg); // Write the address of the register to i2c bus the where the data should be read from
Wire.endTransmission(); // End data transfer throught i2c bus
Wire.requestFrom((int)MPU_ADDRESS,(int) length); // Request length bytes of data from MPU9150

for(i =0; i<length; i++) // Till the length bytes of data is read
{
while(!Wire.available()) // Wait till data is available from MPU9150
{
}
*(data+i) = Wire.read(); // Fill the buffer with read data
}

return i;
}

void MPU9150::extractAccData(uint8_t * data)
{
// Extract acceleration information
// Data is given as 16 bits, big-endian, 2's compliment format
// Default accelearion resolution is +/- 2g
for(int i=0; i<3; i++) // For X,Y and Z axes
{
if((data[2*i] >> 7) == 0x01) // Whether data is positive or negetive
{
// If MSB of high byte is 1, data is negetive
data[2*i] = ~data[2*i]; // Find 2's compliment
data[2*i+1] = ~ data[2*i +1];

// Extract acceleration data
raw_acc[i] =(float) (((data[2*i] << 8) | data[2*i+1])+1); // Combine two bytes of data into one float values
raw_acc[i] /= -acc_res; // Devide by resoultion of the acceleration
}
else
{
// If data is positive
raw_acc[i] = (float)((data[2*i]<<8 )| data[2*i+1] ); // Combine two bytes of data into one float values
raw_acc[i] /= acc_res; // Devide by resoultion of the acceleration
}
}
}

  • Which one is the I2C master? Are the I2C clock frequencies the same?

    Thanks and regards,

    Zhaohong
  • Shambhuraj Sawant said:
    ...with the same code (and adding Wire.Module(x)), on TM4C129, i am getting very low refresh rate

    Might your "addition" of that, "Wire.Module(x)" deserve (some) consideration/analysis in your reduced rate?

    "Apples to apples" dictates that such comparisons, "Avoid any changes which "break the commonality" between such "A-B" tests/contrasts - does it not?

    I haven't full understanding of components/systems all "in play" here - above factor "jumped out" - may warrant (some) consideration...