The first few gyroscope samples immediately after initialisation are always zero. The corresponding accelerometer samples are of expected values. Both the gyroscope and accelerometer are configured for the same ODR. Data is read each time the data-ready interrupt is asserted.
This behaviour suggests that the gyroscope and accelerometer are not synchronised. Please can someone clarify what is going on.
The number of consecutive gyroscope samples equal to zero immediately after initialisation is constant for each ODR as summarised in the table below. These values are not affected by gyr.filter_perf or gyr.noise_perf.
Here is the initialisation code for reference:
// Initialise device
if (bmi270_init(&bmi270) != BMI2_OK) {
initialisationFailed = true;
return;
}
// Perform soft reset
bmi2_soft_reset(&bmi270);
bmi2_set_adv_power_save(BMI2_DISABLE, &bmi270);
// Enable accelerometer and gyroscope
const uint8_t sensorList[] = {BMI2_ACCEL, BMI2_GYRO};
bmi2_sensor_enable(sensorList, 2, &bmi270);
// Configure accelerometer
struct bmi2_sens_config accelerometerConfig = {
.type = BMI2_ACCEL,
.cfg.acc.odr = BMI2_ACC_ODR_400HZ,
.cfg.acc.bwp = BMI2_ACC_NORMAL_AVG4,
.cfg.acc.filter_perf = 1,
.cfg.acc.range = BMI2_ACC_RANGE_16G,
};
bmi2_set_sensor_config(&accelerometerConfig, 1, &bmi270);
// Configure gyroscope
struct bmi2_sens_config gyroscopeConfig = {
.type = BMI2_GYRO,
.cfg.gyr.odr = BMI2_GYR_ODR_400HZ,
.cfg.gyr.bwp = BMI2_GYR_NORMAL_MODE,
.cfg.gyr.filter_perf = 1,
.cfg.gyr.ois_range = BMI2_GYR_OIS_2000,
.cfg.gyr.range = BMI2_GYR_RANGE_2000,
.cfg.gyr.noise_perf = 1,
};
bmi2_set_sensor_config(&gyroscopeConfig, 1, &bmi270);
// Configure data ready interrupt on INT1 pin
struct bmi2_int_pin_config intPinConfig = {
.pin_type = BMI2_INT1,
.int_latch = BMI2_INT_NON_LATCH,
.pin_cfg[0].lvl = BMI2_INT_ACTIVE_HIGH,
.pin_cfg[0].od = BMI2_INT_PUSH_PULL,
.pin_cfg[0].output_en = BMI2_INT_OUTPUT_ENABLE,
.pin_cfg[0].input_en = BMI2_INT_INPUT_DISABLE,
};
bmi2_set_int_pin_config(&intPinConfig, &bmi270);
bmi2_map_data_int(BMI2_DRDY_INT, BMI2_INT1, &bmi270);