Hi everyone, I am trying to map some interrupts on CHANNEL1. I followed the API instructions to configure the interrupts with success. So far I have configured the Any-Motion Detection, Flat Detection, and the NO-Motion Detection Regarding the NO-Motion Detection, everything works fine but when I use the Any-Motion Detection & Flat Detection the interrupt they are both always set and never resets. I have experimented with the configuration parameters as well as the acceleration range with no success so far. I have read carefully the manual without being able to find what's going wrong. However, I assume that is something simple.. I checked the registers 0x55-0x57 (INT_MAP), 0x5F-0x62 (INT_MOTION), 0x54 (INT_LATCH) and everything are fine (no latching). This is the Any-Motion Detection configuration void anyMotionInterrupt_set() {
int_config.int_channel = BMI160_INT_CHANNEL_1; // na - Select the interrupt channel
int_config.int_type = BMI160_ACC_ANY_MOTION_INT; // na - choosing Any Motion Interrupt
// na - the following configuration is written to registers (0x53) INT_OUT_CTRL & (0x54) INT_LATCH see datasheet pg71 section 2.11.20
int_config.int_pin_settg.output_en = BMI160_ENABLE; // na - Enabling interrupt pin as output -> register (0x53)
int_config.int_pin_settg.output_mode = BMI160_DISABLE; // na - Selecting push-pull mode for interrupt pin -> register (0x53)
int_config.int_pin_settg.output_type = BMI160_DISABLE; // na - Setting interrupt pin to active low -> register (0x53)
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE; // na - Enabling edge trigger -> register (0x53)
int_config.int_pin_settg.input_en = BMI160_DISABLE; // na - Disabling interrupt pin to act as input -> register (0x54)
int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; // na - non-latched output -> register (0x54)
// na - Select the Any Motion Interrupt parameter
int_config.int_type_cfg.acc_any_motion_int.anymotion_en = BMI160_ENABLE; // na - 1- Enable the any-motion, 0- disable any-motion
int_config.int_type_cfg.acc_any_motion_int.anymotion_x = BMI160_ENABLE; // na - Enabling x-axis for any motion interrupt - monitor x axis
int_config.int_type_cfg.acc_any_motion_int.anymotion_y = BMI160_ENABLE; // na - Enabling y-axis for any motion interrupt - monitor y axis
int_config.int_type_cfg.acc_any_motion_int.anymotion_z = BMI160_ENABLE; // na - Enabling z-axis for any motion interrupt - monitor z axis
int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = 2; // na - any-motion duration. This is the consecutive datapoints -> see datasheet pg32 section 2.6.1 <int_anym_dur> and pg78
int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 20; // na - An interrupt will be generated if the absolute value of two consecutive accelarion signal exceeds the threshold value -> see datasheet pg32 section 2.6.1 <int_anym_th> and pg78 INT_MOTION[1]
// na - (2-g range) -> (anymotion_thr) * 3.91 mg, (4-g range) -> (anymotion_thr) * 7.81 mg, (8-g range) ->(anymotion_thr) * 15.63 mg, (16-g range) -> (anymotion_thr) * 31.25 mg
rslt = bmi160_set_int_config(&int_config, &sensor); // na - Set Any-motion interrupt
NRF_LOG_INFO("rslt: %d", rslt);
if (rslt != BMI160_OK) {
NRF_LOG_INFO("BMI160 Any-motion interrupt configuration failure!\n");
} else {
NRF_LOG_INFO("BMI160 Any-motion interrupt configuration done!\n");
}
} This is the Flat Detection configuration void flatInterrupt_set() {
/* Select the Interrupt channel/pin */
int_config.int_channel = BMI160_INT_CHANNEL_1; // Interrupt channel/pin 1
/* Select the Interrupt type */
int_config.int_type = BMI160_ACC_FLAT_INT; // Choosing flat 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 Flat interrupt parameters */
int_config.int_type_cfg.acc_flat_int.flat_en = BMI160_DISABLE; // 1-enable, 0-disable the flat interrupt
int_config.int_type_cfg.acc_flat_int.flat_theta = 8; // threshold for detection of flat position in range from 0° to 44.8°.
int_config.int_type_cfg.acc_flat_int.flat_hy = 1; // Flat hysteresis
int_config.int_type_cfg.acc_flat_int.flat_hold_time = 1; // Flat hold time (0 -> 0 ms, 1 -> 640 ms, 2 -> 1280 ms, 3 -> 2560 ms) - delay time for which the flat value must remain stable for the flat interrupt to be generated (datasheet pg82)
/* Set the Flat interrupt */
rslt = bmi160_set_int_config(&int_config, &sensor); /* sensor is an instance of the structure bmi160_dev */
if (rslt != BMI160_OK) {
NRF_LOG_INFO("BMI160 flat interrupt configuration failure!\n");
} else {
NRF_LOG_INFO("BMI160 flat interrupt configuration done!\n");
}
} This is accel/gyro/mag configuration // na - configure Accel sensor
sensor.accel_cfg.odr = BMI160_ACCEL_ODR_100HZ; // na - output data rate - Configure accel to measure at 100Hz
sensor.accel_cfg.range = BMI160_ACCEL_RANGE_2G; // na - range
sensor.accel_cfg.bw = BMI160_ACCEL_BW_NORMAL_AVG4; // na - bandwidth
sensor.accel_cfg.power = BMI160_ACCEL_NORMAL_MODE; // na - powermode
// na - configure Gyro sensor
sensor.gyro_cfg.odr = BMI160_GYRO_ODR_100HZ; // na - output data rate - Configure gyro to measure at 100Hz
sensor.gyro_cfg.range = BMI160_GYRO_RANGE_500_DPS; // na - range
sensor.gyro_cfg.bw = BMI160_GYRO_BW_NORMAL_MODE; // na - bandwidth
sensor.gyro_cfg.power = BMI160_GYRO_NORMAL_MODE; // na - powermode
rslt = bmi160_set_sens_conf(&sensor); // na - configures the power mode, range and bandwidth of sensors
APP_ERROR_CHECK(rslt);
bmm150.settings.preset_mode = BMM150_PRESETMODE_REGULAR; //BMM150_PRESETMODE_LOWPOWER; // // na - Presetmode of sensor - Datasheet page 19
rslt = bmm150_set_presetmode(&bmm150); // na - set the preset mode of the sensor
APP_ERROR_CHECK(rslt);
bmm150.settings.pwr_mode = BMM150_NORMAL_MODE; //BMM150_FORCED_MODE;
rslt = bmm150_set_op_mode(&bmm150); //
APP_ERROR_CHECK(rslt);
// Set the polling rate (Hz). Is the output data rate
sensor.aux_cfg.aux_odr = BMI160_AUX_ODR_100HZ; // na - Configure accel to measure at 100Hz. See the table on page 67 of the datasheet. 8 = 100Hz , 6 = 25Hz see the formula on pg67 of the datasheet
bmi160_config_aux_mode(&sensor);
bmi160_set_aux_auto_mode(&aux_addr, &sensor); // na - Set the auxiliary sensor to auto mode Any advice from the experts? Thanks in advance Nick
... View more