I am using the MPU6500 with embedded motion driver 5.1.2. Everything appears to work correctly as long as at least one of the gyros is enabled. However when only the accelerometer is enabled (with DMP off) the FIFO fills up quickly, as if a very high sample rate was in use.
The problem is caused by the following code in inv_mpu.c mpu_init:
#ifdef MPU6500
/* MPU6500 shares 4kB of memory between the DMP and the FIFO. Since the
* first 3kB are needed by the DMP, we'll use the last 1kB for the FIFO.
*/
data[0] = BIT_FIFO_SIZE_1024 | 0x8;
if (i2c_write(st.hw->addr, st.reg->accel_cfg2, 1, data))
return -1;
#endif
The ACCEL_FCHOICE_B bit of the accel_cfg2 register is being set here, setting a 4kHz sampling rate for the accelerometer and disabling the DLPF and causing SMPLRT_DIV to be ignored. Removing the 0x8 clearing ACCEL_FCHOICE_B results in samples being stored in the FIFO at the correct sampling rate, based on a 1kHz accelerometer rate and SMPLRT_DIV.
The accel_cfg2 register is never set anywhere else in the motion driver, so the accelerometer DLPF is never being configured. mpu_set_lpf only sets the gyro DLPF. Is the DLPF setting in accel_cfg2 always used for the accelerometer, or is it overridden by the gyro DLPF setting when a gyro is enabled in addition to the accelerometer? Should I configure the accel DLPF at the same time as the gyro DLPF is configured in mpu_set_lpf if only the accelerometer is in use?