Hello
I am testing MPU9250 with STM32F4.
It is no problem that STM32F4 communicates with MPU9250 via SPI to get accelerometer and gyroscope data.
However, with magnetometer, sometimes I can get accel+gyro+mag data, sometimes I just can get accel+gyro data without mag data. And sometimes I even can't get all three types data(accel+gyro+mag).
These are my some configuration to communicate with magnetometer, by the way I use I2C_SLV0 registers to communicate with AK8963.
(MPU9250_USER_CTRL, 0x20) // Enable I2C Master mode
(MPU9250_I2C_MST_CTRL, 0x1D) // I2C configuration STOP after each transaction, master I2C bus at 400 KHz
(MPU9250_I2C_MST_DELAY_CTRL, 0x81) // Use blocking data retreival and enable delay for mag sample rate mismatch
(MPU9250_I2C_SLV4_CTRL, 0x01) // Delay mag data retrieval to once every other accel/gyro data sample
(MPU9250_I2C_SLV0_ADDR, MPU9250_AK8963_I2C_ADDR | 0x80) // Set the I2C slave address of AK8963 and set for read.
(MPU9250_I2C_SLV0_REG, MPU9250_AK8963_XOUT_L) // I2C slave 0 register address from where to begin data transfer
(MPU9250_I2C_SLV0_CTRL, 0x87) // Enable I2C and read 7 bytes
(MPU9250_EXT_SENS_DATA_00, 7, &rawData[0]) // Read the x-, y-, and z-axis magnet raw values
I find the value of register PWR_MGMT_1(0x6B) is inconstant, sometimes 0x01, sometimes 0x18. Is this situation normal? Do you know?
Additionally, I has checked the hardware: the pin 1 RESV is already connected to VDDIO.
So, what is the right way that MCU gets magnetometer data with I2C slaver register using SPI interface.
regards.