Have you seen this :
https://github.com/jevermeister/MPU6050 ... S/issues/2 ?
"To get the library to function and detect the MPU6050, I had to modify the I2CdevreadBytes function to add in specific support for the STM32F103 chip as in Chibios/Hardware, you are unable to read a single byte from the I2C bus."
A similar thread was opened in this forum too. I thought that the problem would have been solved by now.
I am now using a very simple approach by manually using i2cMasterTransmitTimeout instead of using MPU6050-ChibiOS.
The good thing:By reading in burst mode, I can make several transactions without getting the earlier erros.
The bad thing: The data received is not correct. Reading in burst mode and then chprinting the required register returns incorrect value. For example:
Code: Select all
//READ DATA IN BURST
chprintf((BaseSequentialStream*)&SD2, "==Read Data:==: \n\r");
status = MSG_OK;
i2cAcquireBus(&I2CD2);
tx_data[0] = 0x3B; //Accel_data
status = i2cMasterTransmitTimeout(&I2CD2, 0x68,tx_data, 1, rx_data, 14, tmo);
i2cReleaseBus(&I2CD2);
if(status == MSG_TIMEOUT || status == MSG_RESET) {
chprintf((BaseChannel *)&SD2,"I2C STATUS: %d\n\r", status);
chprintf((BaseChannel *)&SD2,"I2C ERROR: %d\n\r", i2cGetErrors(&I2CD2));
}
chThdSleepMilliseconds(2000);
chprintf((BaseSequentialStream*)&SD2, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d\n\r", rx_data[0], rx_data[1],rx_data[2],rx_data[3],rx_data[4],rx_data[5],rx_data[6],rx_data[7],rx_data[8],rx_data[9],rx_data[10],rx_data[11],rx_data[12],rx_data[13]);
This code returns the current value for 3D accel, 3D gyro, and temperature. But all I am getting is this:
Code: Select all
==Read Data:==: //No 'I2C ERROR' output, meaning the transaction returned MSG_OK
0 0 255 0 0 0 0 0 0 0 0 0 0 0 //The register values. These are very likely incorrect
Won't give up now
