I'm using an STM32F4 discovery board to read values of an MPU6050 (inertial movement unit) using a library from
a guy named Tilen Majerle. I've already got it up and running and it works almost fine except of one major issue. The first readAll() function
takes a reasonable 0.4ms but every subsequent read takes about 200ms!! Does anyone have an idea why this might be?
For those who have used the library (tm_stm32f4_mpu6050) , I'm using the function TM_MPU6050_ReadAll(&MPU6050_Data0);
The implementation of the function is as follows:
a guy named Tilen Majerle. I've already got it up and running and it works almost fine except of one major issue. The first readAll() function
takes a reasonable 0.4ms but every subsequent read takes about 200ms!! Does anyone have an idea why this might be?
For those who have used the library (tm_stm32f4_mpu6050) , I'm using the function TM_MPU6050_ReadAll(&MPU6050_Data0);
The implementation of the function is as follows:
C:
TM_MPU6050_Result_t TM_MPU6050_ReadAll(TM_MPU6050_t* DataStruct) {
uint8_t data[14];
int16_t temp;
/* Read full raw data, 14bytes */
TM_I2C_ReadMulti(MPU6050_I2C, DataStruct->Address, MPU6050_ACCEL_XOUT_H, data, 14);
/* Format accelerometer data */
DataStruct->Accelerometer_X = (int16_t)(data[0] << 8 | data[1]);
DataStruct->Accelerometer_Y = (int16_t)(data[2] << 8 | data[3]);
DataStruct->Accelerometer_Z = (int16_t)(data[4] << 8 | data[5]);
/* Format temperature */
temp = (data[6] << 8 | data[7]);
DataStruct->Temperature = (float)((float)((int16_t)temp) / (float)340.0 + (float)36.53);
/* Format gyroscope data */
DataStruct->Gyroscope_X = (int16_t)(data[8] << 8 | data[9]);
DataStruct->Gyroscope_Y = (int16_t)(data[10] << 8 | data[11]);
DataStruct->Gyroscope_Z = (int16_t)(data[12] << 8 | data[13]);
/* Return OK */
return TM_MPU6050_Result_Ok;
}