You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is a bug in the Code in case you want to read Accel and/or Gyro in fifo mode and also read the Compass Data.
The problem is caused because of the internal variable st.chip_cfg.bypass_mode (in inv_mpu.c) is per default True. In Regular Setup (without using FIFO) the Aux I2C is used in Master Mode (bypass disabled). The bypass flag is not used and the register is written directly to.
When switching to FIFO mode with configuring FIFO the st.chip_cfg.bypass_mode flag is used to determine the I2C_MST_EN bit in USER CONTROL register.
That means the AUX I2C port switches to bypass when configuring fifo.
Here the setup that causes the bug:
imu.setSensors(INV_XYZ_GYRO | INV_XYZ_ACCEL | INV_XYZ_COMPASS);
imu.setGyroFSR(2000); // Set gyro to 2000 dps
imu.setAccelFSR(2); // Set accel to +/-2g
imu.setLPF(5); // Set LPF corner frequency to 5Hz
imu.setSampleRate(AG_SAMPLE_RATE); // Set sample rate to 10Hz
//MPU9250_USER_CTRL: **00100000**
**imu.configureFifo(INV_XYZ_GYRO | INV_XYZ_ACCEL);**
//MPU9250_USER_CTRL: **01000000**
Solution: Set the st.chip_cfg.bypass_mode flag to false while initializing:
(note: AK89xx_SECONDARY is defined. AK89xx_BYPASS is not defined
int mpu_set_sensors(unsigned char sensors)
{
[...]
if (sensors && (sensors != INV_XYZ_ACCEL))
/* Latched interrupts only used in LP accel mode. */
mpu_set_int_latched(0);
#ifdef AK89xx_SECONDARY
#ifdef AK89xx_BYPASS
if (sensors & INV_XYZ_COMPASS)
mpu_set_bypass(1);
else
mpu_set_bypass(0);
#else
**st.chip_cfg.bypass_mode = 0;**
if (i2c_read(st.hw->addr, st.reg->user_ctrl, 1, &user_ctrl))
return -1;
/* Handle AKM power management. */
if (sensors & INV_XYZ_COMPASS) {
data = AKM_SINGLE_MEASUREMENT;
user_ctrl |= BIT_AUX_IF_EN;
} else {
data = AKM_POWER_DOWN;
user_ctrl &= ~BIT_AUX_IF_EN;
}
[...]
}
This might not the best fix but it solves my problem. I'm sure there is a better solution.
The text was updated successfully, but these errors were encountered:
There is a bug in the Code in case you want to read Accel and/or Gyro in fifo mode and also read the Compass Data.
The problem is caused because of the internal variable st.chip_cfg.bypass_mode (in inv_mpu.c) is per default True. In Regular Setup (without using FIFO) the Aux I2C is used in Master Mode (bypass disabled). The bypass flag is not used and the register is written directly to.
When switching to FIFO mode with configuring FIFO the st.chip_cfg.bypass_mode flag is used to determine the I2C_MST_EN bit in USER CONTROL register.
That means the AUX I2C port switches to bypass when configuring fifo.
Here the setup that causes the bug:
Solution: Set the st.chip_cfg.bypass_mode flag to false while initializing:
(note: AK89xx_SECONDARY is defined. AK89xx_BYPASS is not defined
This might not the best fix but it solves my problem. I'm sure there is a better solution.
The text was updated successfully, but these errors were encountered: