07-24-2019 03:14 PM - edited 07-25-2019 01:48 PM
Hi,
I'm trying to configure the NO MOTION Interrupt on BMI270 connected to an STM32F072 over SPI.
The interrupt is never generated and I have verified it both using an oscilloscope and monitoring the INT_STATUS_0 register (bit num. 5).
This is the code I use to initialize the sensor:
int8_t BMI270_DEVICE_Init() {
systemStatus.bmi270_init_count++;
int8_t rslt = BMI2_OK;
struct bmi2_sens_config configs[SENS_COUNT];
// Array to select sensors
uint8_t sens_list[SENS_COUNT] = {
BMI2_ACCEL,
BMI2_GYRO,
// BMI2_TEMP, // Since Gyro is enabled, temperature is automatically enabled [see datasheet]
BMI2_NO_MOTION,
BMI2_AUX
};
// ----> Set SPI interface params
bmi270_dev.read = bm_spi_read;
bmi270_dev.write = bm_spi_write;
bmi270_dev.delay_us = delayUs;
bmi270_dev.read_write_len = SPI_MAX_RW;
bmi270_dev.intf = BMI2_SPI_INTERFACE;
bmi270_dev.dev_id = 0;
bmi270_dev.dummy_byte = 1;
bmi270_dev.config_file_ptr = NULL; // Load the default `bmi270_config_file` hard coded in the driver
// <---- Set SPI interface params
// ----> Chip-ID read to test SPI communication
uint8_t chip_id;
rslt = bmi2_get_regs(BMI2_CHIP_ID_ADDR, &chip_id, 1, &bmi270_dev);
if (rslt != BMI2_OK || chip_id != BMI270_CHIP_ID) {
rslt = BMI2_E_COM_FAIL;
goto exit;
}
HAL_Delay(10);
// <---- Chip-ID read to test SPI communication
// ----> Initialize bmi270
rslt = bmi270_init(&bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
// <---- Initialize bmi270
// ----> Enable Sensors
//rslt = bmi2_sensor_enable(sens_list, SENS_COUNT, &bmi270_dev);
rslt = bmi2_sensor_enable(sens_list, 2, &bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
// Accelerometer
configs[0].type = BMI2_ACCEL;
configs[0].cfg.acc.odr = BMI2_ACC_ODR_800HZ;
configs[0].cfg.acc.range = BMI2_ACC_RANGE_8G;
configs[0].cfg.acc.bwp = BMI2_ACC_OSR4_AVG1;
configs[0].cfg.acc.filter_perf = BMI2_PERF_OPT_MODE; // Filter for anti-aliasing
// Gyroscope
configs[1].type = BMI2_GYRO;
configs[1].cfg.gyr.odr = BMI2_GYR_ODR_800HZ;
configs[1].cfg.gyr.range = BMI2_GYR_RANGE_1000 ;
configs[1].cfg.gyr.bwp = BMI2_GYR_NORMAL_MODE;
configs[1].cfg.gyr.filter_perf = BMI2_PERF_OPT_MODE ; // Filter for anti-aliasing
configs[1].cfg.gyr.noise_perf = BMI2_PERF_OPT_MODE;
// No Motion detection
configs[2].type = BMI2_NO_MOTION;
configs[2].cfg.no_motion.select_x = BMI2_ENABLE;
configs[2].cfg.no_motion.select_y = BMI2_ENABLE;
configs[2].cfg.no_motion.select_z = BMI2_ENABLE;
configs[2].cfg.no_motion.out_conf = 0x06; // INT_STATUS_0 and INT2_MAP_FEAT bit #5
configs[2].cfg.no_motion.duration = 5;
configs[2].cfg.no_motion.threshold = 144;
// Magnetometer
configs[3].type = BMI2_AUX;
configs[3].cfg.aux.aux_en = BMI2_ENABLE;
configs[3].cfg.aux.manual_en = BMI2_TRUE;
configs[3].cfg.aux.i2c_device_addr = 0x10; // I2C address of BMM150
configs[3].cfg.aux.read_addr = 0x40; // Address of the first read address
configs[3].cfg.aux.man_rd_burst = 50; // Total number of registers to be read for manual burst (0x40 to 0x71)
configs[3].cfg.aux.offset = 2; // Offset for auto burst read
configs[3].cfg.aux.aux_rd_burst = 8; // Size of auto burst read
configs[3].cfg.aux.fcu_write_en = BMI2_ENABLE;
configs[3].cfg.aux.odr = 1;
// Set the configurations
rslt = bmi2_set_sensor_config(configs, SENS_COUNT, &bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
// <---- Enable Sensors
//
// // TODO Configure BMM150 after BMI270 using bmi2_write_aux_man_mode
//
// ----> Interrupt PINs configuration
struct bmi2_int_pin_config int_pin_cfg;
int_pin_cfg.pin_type = BMI2_INT1;
int_pin_cfg.int_latch = BMI2_INT_NON_LATCH;
for(uint8_t i=0; i<BMI2_INT_PIN_MAX_NUM; i++ ) {
int_pin_cfg.pin_cfg[i].output_en = BMI2_INT_OUTPUT_ENABLE; // Output enabled
int_pin_cfg.pin_cfg[i].od = BMI2_INT_PUSH_PULL; // OpenDrain disabled
int_pin_cfg.pin_cfg[i].lvl = BMI2_INT_ACTIVE_LOW; // Signal Low Active
int_pin_cfg.pin_cfg[i].input_en = BMI2_INT_INPUT_DISABLE; // Input Disabled
}
rslt = bmi2_set_int_pin_config( &int_pin_cfg, &bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
// <---- Interrupt PINs configuration
// ----> Map data interrupt
rslt = bmi2_map_data_int( BMI2_DRDY_INT, BMI2_INT1, &bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
// <---- Map data interrupt
// ----> Map features interrupts
struct bmi2_sens_int_config feat_int;
feat_int.type = BMI2_NO_MOTION;
feat_int.hw_int_pin = BMI2_INT2;
rslt = bmi2_map_feat_int(&feat_int, 1, &bmi270_dev);
if (rslt != BMI2_OK)
goto exit;
// <---- Map features interrupts
exit:
if( rslt == BMI2_OK ) {
systemStatus.bmi270_initialized = 1;
} else {
systemStatus.bmi270_initialized = 0;
}
return rslt;
}</bmi2_int_pin_max_num;>
Any advice?
Thank you
Walter
07-25-2019 12:01 PM
I tested many configurations, but I continue to not being able to get the NO_MOTION interrupt working.
I also moved the DATA_READY interrupt to INT2 to verify that it is correctly configured and it's ok, so it's a configuration problem that I cannot figure out.
Any advise?
09-20-2020 09:18 AM
Hi, I ran into the same issue. Were you able to find the root cause?
Thanks