2
\$\begingroup\$

I am trying to reach InvenSense MPU9150 magnetometer using master mode disabled and bypass mode enabled. These values are written to and then confirmed from the MPU9150 :

0x6B = 0x01, // Clock from gyro X
0x6A = 0x00, // I2C Master mode disabled
0x37 = 0x02. // Bypass mode enabled

I have then tried to reach the magnetometer through 0x0C->0x0F slave addresses but never received a correct answer from the 0x00 WHOAMI register. Have I missed a register ? The AUX pins on the PCB are floating. I can talk to the MPU9150 correctly and read the accelerometer and gyro data. Could the magnetometer in the MPU9150 be dead on arrival ?

\$\endgroup\$
  • \$\begingroup\$ You might look at some of the published open source quadcopter control boards & firmware sources and see if there's an example of someone successfully using that function. \$\endgroup\$ – Chris Stratton Jan 8 '14 at 20:25
  • \$\begingroup\$ I confirm that the Magnet ID is 0x48. However I use master-slave mode. The address of the magnet is 0x0C. I tried to work with Bypass mode but no luck... \$\endgroup\$ – MooMoo Apr 24 '14 at 17:30
  • \$\begingroup\$ You need to wake up the magnetometer before you read, unfortunetly every time you read \$\endgroup\$ – Timtianyang Feb 16 '15 at 5:41
  • \$\begingroup\$ I am able to read the address of magnetometer 0x00 register but I am getting same data of magnetometer and 0x02 register always read zero . Its for whether data is read from register or not \$\endgroup\$ – user81282 Jul 17 '15 at 12:26
  • \$\begingroup\$ Have you verified that the MPU9150 is correctly hooked up to GND and VCC? One possibility is that your AK8975 is not powered, check page 28 of PS-MPU-9150A-00. \$\endgroup\$ – user96454 Jan 8 '16 at 0:28
1
\$\begingroup\$

Do you get any non-zero answers when reading 0x00? I think that the datasheet is incorrect and WIA does not actually return 0x48, but I don't have a chip handy right now to test.

I'm not sure if there's any other registers that need to be set for the MPU to work, but for the record, I have it working and these are the MPU register values I use:

0x6B = 0x01; // Clock source is PLLGYROZ
0x19 = 0x04; // Set SMPLRT_DIV to 0x04; this gives a 200 Hz sample rate when using the DLPF
0x1A = 0x03; // 42 Hz LPF
0x6A = 0x01; // Disable master mode and clear all signal paths
0x1B = 0x18; // Full gyro range
0x1C = 0x08; // 4G accel range
0x37 = 0x32; // Interrupts pin stays high until cleared, cleared on any read, I2C bypass
0x38 = 0x01; // Data ready interrupt enabled

You could try putting it in FUSEROM mode (write 0x0F to register 0xA) and then reading the sensitivity adjustment values from registers 0x10 to 0x12; you should get the same value across multiple reads.

I'm not sure if there's a "proper" initialization sequence for the AK8975, but I've had the most success with: Put in FUSEROM mode -> read ASAX/Y/Z -> single sample mode, and then waiting on the DRDY interrupt (which, despite what the MPU9150 data sheet claims, is available on pin 14). I definitely had a large amount of trouble actually getting it to work correctly though.

One last question: what speed are you running the I2C bus at? The STM32F4xx line, at least, has issues running at 100 kHz--I have to run at 400 kHz to get correct functionality.

\$\endgroup\$
0
\$\begingroup\$

From what I remember, once in bypass mode you're directly talking to the magnetometer. I suggest you try using an oscilloscope or logic analyzer to see whether your signals reach the magnetometer from your microcontroller.

If they do and you're getting a NACK, then get the right slave address for the magnetometer to make sure it's being addressed. Be careful with 7 and 8 bit representations of the address.

\$\endgroup\$

protected by Community Jan 8 '16 at 1:58

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.