MPU9250 dead magnetometer ?

By ka210 , 3 May 2014

Hello, my MPU9250 used through SPI raises I2C_SLV0_NACK to 1 on the first (and following) I2C master mode transfers. Could the magnetometer be dead ? Accelerometers and gyroscopes are fine. Thank you.

The simplified code is :

command(0x6B, 0x80);	// Power management, reset
delay(100);
command(0x6B, 0x03); // Power management, PLL from Z Gyro
delay(100);
command(0x6A, 0x20); // I2C Master mode
delay(100);
command(0x24, 0x0D); // I2C configured at 400khz
delay(100);

uint8_t a0 = command(0x36 | 0x80); // Check I2C_SLV0_NACK, results in I2C_SLV0_NACK=0
delay(100);

command(0x25, 0X0C); // Magnetometer I2C address in write mode
delay(100);
command(0x26, 0x0A); // Magnetometer register 0x0A
delay(100);
command(0x63, 0x01); // Magnetometer single measurement mode
delay(100);
command(0x27, 0x81); // Write this 1 byte through I2C
delay(100);

uint8_t a1 = command(0x36 | 0x80); // Check I2C_SLV0_NACK, results in I2C_SLV0_NACK=1 !
delay(100);

command(0x25, 0X0C | 0x80); // Magnetometer I2C address in read mode
delay(100);
command(0x26, 0x00); // Read from magnetometer 0x00 register
delay(100);
command(0x27, 0x86); // Read 0x00-0x06 (6 bytes) through I2C
delay(100);

uint8_t a2 = command(0x36 | 0x80); // Check I2C_SLV0_NACK, also results in I2C_SLV0_NACK=1 !
phpbb Topic ID
16128