MPU-9250 Troubles

According to the InvenSense website:

The MPU-9250 is a System in Package (SiP) that combines two chips: the MPU-6500, which contains a 3-axis gyroscope, a 3-axis accelerometer, and an onboard Digital Motion Processor™ (DMP™) capable of processing complex MotionFusion algorithms; and the AK8963, the market leading 3-axis digital compass.

Sure sure sure. Despite the marketing language from InvenSense, we do get a picture of what the sensor actually is: a package with two chips.

Currently I’m using SPI with the sensor, and I was getting rather reliable data from the gyroscope and accelerometer, yet didn’t seem to be able to get a high data rate from the magnetometer (I could only get around 5Hz).

After scanning through the datasheet of the AK8963, I discovered something interesting:

When continuous measurement mode 1 (MODE[3:0]=“0010”) or 2 (MODE[3:0]=“0110”) is set, sensor is measured periodically at 8Hz or 100Hz respectively.

Was the sensor set in mode 1?

It was.

figure

Admittedly, I had ported the SPI code from mbed and had to make some minor adjustments to get transfer working. However, I didn’t check through thoroughly what the initialisation configuration was. So it turned out that the Teensy was writing the 0x12 to the CNTL1 register.

In binary, 0x12 is 0001 0010, meaning that the magnetometer was in 16-bit mode and reading at 100Hz.

What I wanted was 0001 0110, so all I had to do was change 0x12 to 0x16.