05-22-2023 04:19 PM
Hello,
I'm using a BMI270 in my project.
I have to detect any movement using INT1 pin.
I'm using this code to init the BMI270:
imu2.chip_addr = BMI2_I2C_PRIM_ADDR;
imu2.intf = BMI2_I2C_INTF;
imu2.read = i2c_read_bytes;
imu2.write = i2c_write_bytes;
imu2.read_write_len = 128;
// Initialize BMI270
if(bmi270_legacy_init(&imu2) == BMI2_OK) {
// CONFIGURE ACCELEROMETER SENSOR !! Need to do it before Sensor Enable!
uint8_t sensor_list[2] = { BMI2_ACCEL, MOTION_TYPE };
struct bmi2_sens_config config;
config.type = BMI2_ACCEL;
config.cfg.acc.odr = BMI2_ACC_ODR_100HZ;
config.cfg.acc.bwp = BMI2_ACC_NORMAL_AVG4;
config.cfg.acc.filter_perf = BMI2_PERF_OPT_MODE;
config.cfg.acc.range = BMI2_ACC_RANGE_2G;
bmi270_legacy_set_sensor_config(&config, 1, &imu2);
bmi270_legacy_sensor_enable(sensor_list, 2, &imu2);
motdet_setConfiguration(nvmInfo.motConfInfo, false); // No need to runtime apply conf here, will be done in motdet_init
motdet_init(imu2);
motdet_enable();
}
The problem is that BMI270 raise alwais an INT during the startup, and the put the INT pin down(I also analyzed it with an oscilloscope).
Why BMI270 raise and INT during the startup?
Thanks a lot!
05-23-2023 09:19 AM
Hello, any news?? I'm in throuble...Thanks
05-24-2023 11:42 AM
Hi dmrsim,
The default interrupt triggering method is falling edge triggering, see it from the default register value:
You can configure the interrupt triggering method you would like to use with the following reference code.
#if defined(ANY_MOTION)
int8_t Open_BMI270_ANY_MOTION(struct bmi2_dev *dev)
{
int8_t rslt = BMI2_OK;
uint8_t sensor_list = BMI2_ANY_MOTION;
/* Sensor configuration structure */
struct bmi2_sens_config config = { 0 };
struct bmi2_int_pin_config int_cfg;
/* Select features and their pins to be mapped to */
struct bmi2_sens_int_config sens_int;
sens_int.type = BMI2_ANY_MOTION;
sens_int.hw_int_pin = BMI2_INT1;
/* Enable the selected sensors */
rslt = bmi270_sensor_enable(&sensor_list, 1, dev);
bmi2_error_codes_print_result(rslt);
config.type = sensor_list;
#if 1
/* Get the previous or default configuration settings */
rslt = bmi270_get_sensor_config(&config, 1, dev);
if (rslt == BMI2_OK)
{
/* NOTE: The user can change the following configuration parameters according to their requirement. */
/* 1LSB equals 20ms. Default is 100ms, setting to 140ms. */
config.cfg.any_motion.duration = 7;
/* 1LSB equals to 0.48mg. Default is 83mg, setting to 96mg. */
config.cfg.any_motion.threshold = 200;
/* Set the configurations */
rslt = bmi270_set_sensor_config(&config, 1, dev);
if (rslt != BMI2_OK)
{
PDEBUG("Any motion configuration failed\r\n");
}
else
{
PDEBUG("Any motion configuration set successfully\r\n");
/* Get the configuration settings for validation */
rslt = bmi270_get_sensor_config(&config, 1, dev);
if (rslt == BMI2_OK)
{
PDEBUG("Get any motion Configuration successful\r\n");
}
}
}
#endif
bmi2_get_int_pin_config(&int_cfg, dev);
int_cfg.pin_type = BMI2_INT1;
int_cfg.pin_cfg[0].lvl = BMI2_INT_ACTIVE_HIGH;/*Config INT1 rising edge trigging*/
int_cfg.pin_cfg[0].od = BMI2_INT_PUSH_PULL;
int_cfg.pin_cfg[0].output_en= BMI2_INT_OUTPUT_ENABLE;
bmi2_set_int_pin_config(&int_cfg, dev);
bmi2_error_codes_print_result(rslt);
/* Map the feature interrupt */
rslt = bmi270_map_feat_int(&sens_int, 1, dev);
bmi2_error_codes_print_result(rslt);
return rslt;
}