05-17-2020 04:24 PM - edited 05-17-2020 04:26 PM
Hi, I have an issue to read single tap from BMI 160.
// Power configurations.
sensor.accel_cfg.odr = BMI160_ACCEL_ODR_1600HZ;
sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G;
sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4;
sensor.accel_cfg.power = BMI160_ACCEL_LOWPOWER_MODE;
sensor.gyro_cfg.odr = BMI160_GYRO_ODR_3200HZ;
sensor.gyro_cfg.range = BMI160_GYRO_RANGE_2000_DPS;
sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE;
sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE;
rslt = bmi160_set_sens_conf(&sensor);
// Interrupt Configurations
int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1
/* Select the Interrupt type */
int_config.int_type = BMI160_ACC_SINGLE_TAP_INT;// Choosing Single Tap interrupt
/* Select the interrupt channel/pin settings */
int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
int_config.int_pin_settg.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
int_config.int_pin_settg.output_type = BMI160_DISABLE;// Choosing active low output
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE;// non-latched output
/* Select the Single tap interrupt parameters */
int_config.int_type_cfg.acc_tap_int.tap_thr = 1;
int_config.int_type_cfg.acc_tap_int.tap_shock = BMI160_ENABLE;
int_config.int_type_cfg.acc_tap_int.tap_quiet = BMI160_ENABLE;
int_config.int_type_cfg.acc_tap_int.tap_dur = 1;
int_config.int_type_cfg.acc_tap_int.tap_data_src=BMI160_ENABLE;
int_config.int_type_cfg.acc_tap_int.tap_en = BMI160_ENABLE;
/* Set the Single Tap interrupt */
bmi160_set_int_config(&int_config, &sensor); /* sensor is an instance of the structure bmi160_dev */
// And the reading part
int_status_sel = BMI160_INT_STATUS_ALL;
rslt = bmi160_get_int_status(int_status_sel, &interrupt, &sensor);
if (interrupt.bit.s_tap)
{
int a = 0;
}
else
{
int b = 0;
}
}
05-18-2020 05:38 AM
Can you check register 0x02 first then the accel data from data register if there is correct accel data inside?
I think your accel setting has some problem so your accel is not working properly.
This is the root cause why you didn't see tap interrupt.
In datasheet, table 8 (page 15 - 16), you can find that 1600Hz is only valid for normal power mode not low power mode.
05-20-2020 10:41 AM
05-21-2020 07:58 PM
Can you also read out the Accel sensor data?
In your code, i didn't see you to change the power mode of accel by write command register (0x7E) with value 0x11.
Then please try to use LATCH mode for the interrupt to make sure you are not missing the interrupt if your host is not fast enough to react to the interrupt.