Problem reading MPU6000

By jlellmann , 16 December 2013

Hi! I´m new here, and I wanted to ask people with experience about some troubles with my MPU6000.

I chose it instead of the MPU6050 because I wanted to get data at a higher rate, so I needed to use the SPI interface. The microcontroller driving it is an LPC1769 from ARM (Cortex M3).

But when I tried to read it, I coludn´t! I have tested it with the oscilloscope, the clock polarity and phase are ok, and the MOSI line is working perfectly. But the MISO line (SDO in MPU6000) only goes from high to low simultaneously with the first clock, and back to high with the last clock, so I'm only reading zeros and can´t figure out why. SPI works fine in a loopback, so it isn´t a microcontroller problem.

Here is a piece of my code, with the initialize for the SPI and some writings and readings. I have tried both resetting and then disabling I2C, and disabling I2C and then resetting. I only attempted to read the WHO_AM_I register to check if it was working. I tried setting the SPI speed to 1MHz, 100KHz and 10KHz.

If it is any help, the code in the chip says:

MPU6000
D2S727-J1
EI 1318 E

//=====================================
//Configure SSP interface - CPOL=CPHA=1, 1MHz
SSP_Initialize();
for (i=0;i<100000;i++); //wait for startup

//reset
SSP_SendData(LPC_SSP1, 0x6B);
SSP_SendData(LPC_SSP1, 0x80);
for (i=0;i<1000;i++); //wait for MPU reset

//disable I2C
SSP_SendData(LPC_SSP1, 0x6A);
SSP_SendData(LPC_SSP1, 0x10); //set bit I2C_IF_DIS to 1

//sleep mode off
SSP_SendData(LPC_SSP1, 0x6B);
SSP_SendData(LPC_SSP1, 0x00); //clear SLEEP bit

//read who am I register
SSP_SendData(LPC_SSP1, (0x75|0x80));
SSP_SendData(LPC_SSP1, 0x00);
data=SSP_ReceiveData(LPC_SSP1); //read internal shift register

The last instruction doesn´t send anything through the SPI interface, it only reads the internal register of the SPI that has been written by the slave in the last SPI transfer. Only SSP_SendData uses the SPI lines making a SPI transfer.

Thanks a lot!

Claudio

phpbb Topic ID
15816