Interfacing issue LPC1769 and MPU6050

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Interfacing issue LPC1769 and MPU6050

800 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kannanataraj on Sat Oct 18 01:38:53 MST 2014
Hi Folks.,

I'm trying to interface LPC1769 and MPU6050 And i am using mcb1700.code.bundle.lpc1769.lpcxpresso libraries.

As specified in the MPU6050 datasheet I coded for the read sequence, it's working first time only, if i try to read second time, it returns zero values. ( i.e., it works only once after the reset )

I tried with many possible ways, No results So please give me some solution to fix this Issue.

Thanks
Nataraj B

 
Labels (1)
0 Kudos
2 Replies

553 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by kannanataraj on Sat Oct 18 01:53:56 MST 2014
Thanks for your timely response, the subroutine i've shown below, and i attached i2c.c lib file with it

uint8_t mpu6050Read(uint8_t regAdd) {
// Clear buffers
uint32_t i;
for (i = 0; i < BUFSIZE; i++) {
I2CMasterBuffer[I2C_PORT] = 0x00;
I2CSlaveBuffer[I2C_PORT] = 0x00;
}

I2CWriteLength[I2C_PORT] = 2;
I2CReadLength[I2C_PORT] = 0;
I2CMasterBuffer[I2C_PORT][0] = MPU6050_ADDRESS;
I2CMasterBuffer[I2C_PORT][1] = regAdd;
I2CEngine(I2C_PORT);

for (i = 0; i < BUFSIZE; i++) {
I2CMasterBuffer[I2C_PORT] = 0x00;
I2CSlaveBuffer[I2C_PORT] = 0x00;
}

I2CWriteLength[I2C_PORT] = 1;
I2CReadLength[I2C_PORT] = 1;
I2CMasterBuffer[I2C_PORT][0] = MPU6050_ADDRESS|MPU6050_READ;
I2CEngine(I2C_PORT);

return  I2CSlaveBuffer[I2C_PORT][0];
}

void mpu6050BurstRead(uint8_t startRegAdd, uint8_t length, uint8_t *data) {
// Clear buffers
uint32_t i;
for (i = 0; i < BUFSIZE; i++) {
I2CMasterBuffer[I2C_PORT] = 0x00;
I2CSlaveBuffer[I2C_PORT] = 0x00;
}

I2CWriteLength[I2C_PORT] = 2;
I2CReadLength[I2C_PORT] = 0;
I2CMasterBuffer[I2C_PORT][0] = MPU6050_ADDRESS;
I2CMasterBuffer[I2C_PORT][1] = startRegAdd;
I2CEngine(I2C_PORT);

for (i = 0; i < BUFSIZE; i++) {
I2CMasterBuffer[I2C_PORT] = 0x00;
I2CSlaveBuffer[I2C_PORT] = 0x00;
}

I2CWriteLength[I2C_PORT] = 1;
I2CReadLength[I2C_PORT] = length;
I2CMasterBuffer[I2C_PORT][0] = MPU6050_ADDRESS|MPU6050_READ;
I2CEngine(I2C_PORT);

memcpy(data,I2CSlaveBuffer,length);

}
0 Kudos

553 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by capiman on Sat Oct 18 01:42:09 MST 2014
Can you share the code you are currently using?
0 Kudos