Hi all.
I got at big problem regarding I2C communication with the MPU6050.
I seem to have tried everything but it just wont work. The protocol can be found at:
http://invensense.com/mems/gyro/documents/PS-MPU-6000A.pdf (page 37)
The problem is that I2C_1_MasterSendStart(devAddr, I2C_1_WRITE_XFER_MODE) returns I2C_MSTR_ERR_LB_NAK ??? Which I dont understand.
Here's my souce code:
void main(){
uint8 wrData;
uint8 rdData;
uint8 status;
uint8 readFlag;
uint8 breakp;
uint8 masterStatus;
I2C_1_Start();
wrData = 117; //Reg number
uint8 devAddr = 0b110100;
for(;;){
status = I2C_1_MasterSendStart(devAddr, I2C_1_WRITE_XFER_MODE);
if(status == I2C_1_MSTR_NO_ERROR){ /* Check if transfer completed without errors */
status = I2C_1_MasterWriteByte(wrData);
}
I2C_1_MasterSendStop(); /* Send Stop */
status = I2C_1_MasterSendStart(devAddr, I2C_1_READ_XFER_MODE);
if(status == I2C_1_MSTR_NO_ERROR) { /* Check if transfer completed without errors */
rdData = I2C_1_MasterReadByte(I2C_1_NAK_DATA);
}
I2C_1_MasterSendStop(); /* Send Stop */
}
}
Now problem is the if's are always going false because of the status :( ..
Any help pls?
|