Ok, I make changes. I read Who Am I register(75) and he return me value 68, witch is good.
But when I try to read the temperature returns 0, why?
REG FOR TEM IS : 0X41-> TEMP_OUT_H
0X42-> TEMP_OUT_L
#define MPU6050_I2CAddress 0x68
void MPU6050_init(void)
{
}
void MPU6050_read(float *data, uint8_t *orgdatabuffer)
{
uint8_t MPU6050_Buf[2]; MPU6050_Buf[0]=-1;
MPU6050_Buf[1]=-1;
WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_IDLE); // Wait for the master state to be idle
LPC_I2C0->MSTDAT = (MPU6050_I2CAddress<<1) | 0; // Address with 0 for RWn bit (WRITE)
LPC_I2C0->MSTCTL = CTL_MSTSTART; // Start the transaction by setting the MSTSTART bit to 1 in the Master control register.
WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX); // Wait for the address to be ACK'd
LPC_I2C0->MSTDAT = 0x41;
LPC_I2C0->MSTCTL = CTL_MSTCONTINUE;
WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_TX); // Wait for the address to be ACK'd
LPC_I2C0->MSTDAT = (MPU6050_I2CAddress<<1) | 1; // Address with 0 for RWn bit (READ)
LPC_I2C0->MSTCTL = CTL_MSTSTART; // Start the transaction by setting the MSTSTART bit to 1 in the Master control register.
while ((LPC_I2C0->STAT & MASTER_STATE_MASK) != STAT_MSTRX)
{
}
MPU6050_Buf[0] = LPC_I2C0->MSTDAT;
LPC_I2C0->MSTCTL = CTL_MSTCONTINUE;
WaitI2CMasterState(LPC_I2C0, I2C_STAT_MSTST_RX); // Wait for the address to be ACK'd
while ((LPC_I2C0->STAT & MASTER_STATE_MASK) != STAT_MSTRX)
{
}
MPU6050_Buf[1] = LPC_I2C0->MSTDAT;
LPC_I2C0->MSTCTL = CTL_MSTSTOP;
while ((LPC_I2C0->STAT & MASTER_STATE_MASK) != STAT_MSTIDLE)
{
}
printf("%d ",MPU6050_Buf[0]);
printf("%d ",MPU6050_Buf[1]);
}
Can you help me ?
Mihai R.