MPU-6000 problem: Can't write to the Auxilliary I2C bus

By jomo2012 , 3 July 2012

I’m trying to write/read to/from a Honeywell HMC5883L magnetometer via the MPU-6000’s SPI bus and I’m seeing no activity on the Aux I2C bus. Below is the gist of what I’m up to ...

The initialization table:

WAIT_FOR_MSECS, 100, // 0xFF Pause 100 msec while device powers up
USER_CTRL, DISABLE_I2C_INTERFACE, // 0x10 User control: Disable both I2C interface and FIFO usage then enable SPI interface.
PWR_MGMT_1, DEVICE_RESET, // 0x80 Power management 1: Reset the MPU-6000 accelerometer/gyroscope.
WAIT_FOR_MSECS, 100, // 0xFF Pause 100 msec while device resets itself
USER_CTRL, DISABLE_I2C_INTERFACE, // 0x10 User control: Disable both I2C interface and FIFO usage then enable SPI interface.
USER_CTRL, DISABLE_I2C_INTERFACE+RESET_SIGNAL_PATHS_AND_REGS,
WAIT_FOR_MSECS, 100, // 0xFF Pause 100 msec while device resets itself
AUX_VDDIO, I2C_SUPPLY_VOLTAGE_FOR_MPU6000, // 0x00 Auxiliary I2C supply selection
PWR_MGMT_1, INT_8_MHZ_OSC_CLOCK, // 0x00 Power management 1: Bring device out of sleep mode.
SMPLRT_DIV, SAMPLE_RATE_1KHZ, // 0x07 sample rate = gyroscope output rate/(1 + SMPLRT_DIV) = 8KHz / 1 + 7) = 1KHz)
CONFIG, NO_EXT_SYNC_MINIMUM_DELAY, // 0x00 Configuration
GYRO_CONFIG, GYRO_FULL_SCALE_2000_DEG_PER_SEC, // 0x18 Gyroscope configuration and invocation of self-test
ACCEL_CONFIG, ACCEL_FULL_SCALE_PLUS_MINUS_16G, // 0x18 Accelerometer configuration and invocation of self-test
FIFO_EN, /*USE_FIFO_FOR_ALL_SENSORS*/0, // 0xFF FIFO enable
I2C_MST_CTRL, WAIT_FOR_COMPASS_I2C_AT_400KHZ, // 0x4D I2C master control (wait for magnetometer, run I2C at 400KHz
// The next three command groups are writes via I2C to the compass
I2C_SLV4_ADDR, SPI_WRITE+COMPASS_I2C_SLAVE_WRITE_ADDR, // 0x3C I2C slave 4 address: I2C compass' slave address
I2C_SLV4_REG, CONFIGURATION_REGISTER_A, // 0x00 I2C slave 4 register: Configuration register A
I2C_SLV4_DO, NO_BIAS_8_SAMPLES_75HZ, // 0x78 I2C slave 4 data out: No bias, average 8 samples, 75Hz sample rate
I2C_SLV4_CTRL, SLAVE_ENABLE+1, // 0x81 I2C slave 4 control; Send I2C message to compass with one data byte
WAIT_FOR_I2C_READY, WAIT_FOR_I2C_READY, // 0x00 Await the finish of slave 4 transaction

I2C_SLV4_ADDR, SPI_WRITE+COMPASS_I2C_SLAVE_WRITE_ADDR, // 0x3C I2C slave 4 address: I2C compass' slave address
I2C_SLV4_REG, CONFIGURATION_REGISTER_B, // 0x01 I2C slave 4 register: Configuration register B
I2C_SLV4_DO, GAIN_PLUS_MINUS_1_3_GA, // 0x20 I2C slave 4 data out: Compass gain = +/1 2.3Ga
I2C_SLV4_CTRL, SLAVE_ENABLE+1, // 0x81 I2C slave 4 control; Send I2C message to compass with one data byte
WAIT_FOR_I2C_READY, WAIT_FOR_I2C_READY, // 0x00 Await the finish of slave 4 transaction

I2C_SLV4_ADDR, SPI_WRITE+COMPASS_I2C_SLAVE_WRITE_ADDR, // 0x3C I2C slave 4 address: I2C compass' slave address
I2C_SLV4_REG, MODE_REGISTER, // 0x02 I2C slave 4 register: Compass' mode register
I2C_SLV4_DO, CONTINUOUS_MEASUREMENT_MODE, // 0x00 I2C slave 4 data out: Continuous measurement mode
I2C_SLV4_CTRL, SLAVE_ENABLE+1, // 0x81 I2C slave 4 control; Send I2C message to compass with one data byte
WAIT_FOR_I2C_READY, WAIT_FOR_I2C_READY, // 0x00 Await the finish of slave 4 transaction

// The next command group is a read via I2C from the compass
I2C_SLV0_ADDR, SPI_READ+COMPASS_I2C_SLAVE_READ_ADDR, // 0xBD I2C slave 0 address: I2C compass' slave address + read bit set
I2C_SLV0_REG, DATA_OUTPUT_X_MSB_REGISTER, // 0x03 I2C slave 0 register: 1st of compass' data registers
I2C_SLV0_CTRL, SLAVE_ENABLE+NUM_COMPASS_BYTES, // 0x86 I2C slave 0 control; Send I2C message to compass to read six data bytes
INT_ENABLE, IRQ_UPON_DATA_READY, // 0x01 Interrupt upon data ready
INT_PIN_CFG, ACTIVE_LOW_OPEN_DRAIN_IRQ }; // 0xD0 Interrupt pins: Active low open drain IRQ, clear on register read

Upon interrupt, reading the registers then starting another transfer of mag data:

read_accel_gyro_register(FIRST_DATUM_ADDRESS,motion.raw,SENSOR_DATA_SIZE); // read accel, gyro, and mag values
write_accel_gyro_register(I2C_SLV0_CTRL,SLAVE_ENABLE+NUM_COMPASS_BYTES); // cause the mag to send another set of values

Only the accel, gyro, and temperature are read. Mag data is all zeroes.

So, what do you think? A simple example of how to get the Aux I2C reads/writes going will move me along past this initial hurdle quite well.

phpbb Topic ID
14490