MPU9250 - how exactly do I get the magnetometer to work?

By lcreqwgcyk , 19 November 2014

Hello,
I'm working with an MSP430 linked to a MPU9250 IMU via SPI.
Everything works fine (accel, gyro, config) except reading the magnetometer via the internal I2C-bus.
What exactly do I have to do to get the magnetometer data to the EXT_SENS_DATA_xx registers?

At the moment I'm doing the following procedure in pseudo-code:
- init clock, ADC, etc. and SPI (1MHz)

- init MPU (FSR etc.)

- init MPU I2C-registers:
--INT_PIN_CFG -> 0x30: INT_ANYRD_2CLEAR=1, LATCH_INT_EN=1
--I2C_MST_CTRL -> 0xCD: MULT_MST_EN=1, WAIT_FOR_ES=1, I2C_MST_CLK[3:0]=1101 (400kHz)
--MPUREG_USER_CTRL -> 0x30: I2C_MST_EN=1, I2C_IF_DIS=1
--MPUREG_I2C_MST_DELAY_CTRL -> 0x81: DELAY_ES_SHADOW=1, I2C_SLV0_DLY_EN=1

-init MPU magnetometer:
--I2C_SLV0_ADDR -> AK8963_I2C_ADDR (0x18): AK8963 address + write
--I2C_SLV0_REG -> AK8963_CNTL1 (0x0A)
--I2C_SLV0_DO -> 0x06: Continuous Measurement Mode 2, 100Hz, 14 bit
--I2C_SLV0_CTRL -> 0x81: I2C_SLV0_EN=1, I2C_SLV0_LENG[3:0]=1 -> write 1 byte

--I2C_SLV0_ADDR -> AK8963_I2C_ADDR|READ_FLAG (0x19): AK8963 address + read
--I2C_SLV0_REG -> AK8963_ST1 (0x02)
--I2C_SLV0_CTRL -> 0x88: I2C_SLV0_EN=1, I2C_SLV0_LENG[3:0]=8 -> read 8 byte

As far as I understand the datasheet, the magnetometer data (plus ST1 and ST2) should now be written periodically into the first available EXT_SENS_DATA-registers. But I can read only 00.
What am I doing wrong?

Regards

phpbb Topic ID
16764