I'm trying to get my hands on the MPU9150 9-axis motion sensor using TM4C123G. I imported the compdcm_mpu9150 example project but ends up with some problems. After I2C initialization and before MPU9150 initialization, the serial monitor (consistently) displays an error message:
I searched and found the error3 to be I2CM_STATUS_ARB_LOST - master arbitration lost. I have been reading about possible causes of I2C arbitration lost, some of the reasons being that the slave is pulling the SDA low so that master could not initiate a new transfer. One of the most common solution is to toggle the SCL and eventually the slave will release SDA. In an attempt to solve the problem, I added the following code segment before MPU9150Init (MPU9150Init is where the I2C line hang): (PD0-SCL, PD1-SDA, PB5-used for measuring logic level of SDA)
uint_fast8_t sdaVal = GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5); // initial check the sda if (sdaVal == 0){ while(sdaVal == 0) { GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, 0); // write 0 to scl SysCtlDelay(500); // wait after lower edge sdaVal = GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5); UARTprintf("SDA %d", sdaVal); if (sdaVal != 0) { break; } else { GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_0, GPIO_PIN_0); // write 1 to scl SysCtlDelay(500); // wait after lower edge sdaVal = GPIOPinRead(GPIO_PORTB_BASE, GPIO_PIN_5); UARTprintf("SDA %d", sdaVal); if (sdaVal != 0) { break; } } if (sdaVal != 0) { break; } } }
As you could see, I was trying to toggle SCL, and monitor SDA after every toggle hoping it could be released by the slave. However, the slave does not release SDA after a lot of toggles, and the SDA remains low.
I'm not sure whether I made any mistakes in trying to solve the problem or it's actually due to some other reasons. And I'm a little surprised the the example project won't work on the exact sensor. (I'm using CCS V6 and newest TIVAWARE, I also tried CCSV5, reinstall TIVAWARE and ended up futile, this problem persists).
Any ideas?