03-11-2023 12:11 PM
Hello everyone, I have a problem that has troubled me for a long time.I hope I can get your help.
I use BMI 2_ INT1 can be mapped to the external interrupt INT1 of MCU, but BMI2 is used_ INT1 cannot be mapped to external interrupt INT2.
My code is as follows
int any_motion_interrupt(void)
{
/* Status of api are returned to this variable. */
int8_t rslt;
/* Accel sensor and any-motion feature are listed in array. */
uint8_t sens_list[2] = { BMI2_ACCEL, BMI2_ANY_MOTION };
struct bmi2_int_pin_config int_cfg;
/* Variable to get any-motion interrupt status. */
uint16_t int_status = 0;
/* Sensor initialization configuration. */
struct bmi2_dev bmi2_dev;
/* Select features and their pins to be mapped to. */
struct bmi2_sens_int_config sens_int = { .type = BMI2_ANY_MOTION, .hw_int_pin = BMI2_INT2 };
/* Interface reference is given as a parameter
* For I2C : BMI2_I2C_INTF
* For SPI : BMI2_SPI_INTF
*/
rslt = bmi2_interface_init(&bmi2_dev, BMI2_SPI_INTF);
bmi2_error_codes_print_result(rslt);
/* Initialize bmi270. */
rslt = bmi270_init(&bmi2_dev);
bmi2_error_codes_print_result(rslt);
if (rslt == BMI2_OK)
{
/* Enable the selected sensors. */
rslt = bmi270_sensor_enable(sens_list, 2, &bmi2_dev);
bmi2_error_codes_print_result(rslt);
bmi2_get_int_pin_config(&int_cfg, &bmi2_dev);
int_cfg.pin_type = BMI2_INT2;
int_cfg.pin_cfg[0].lvl = BMI2_INT_ACTIVE_HIGH;/*Config INT2 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, &bmi2_dev);
bmi2_error_codes_print_result(rslt);
if (rslt == BMI2_OK)
{
/* Set feature configurations for any-motion. */
rslt = set_feature_config(&bmi2_dev);
bmi2_error_codes_print_result(rslt);
if (rslt == BMI2_OK)
{
/* Map the feature interrupt for any-motion. */
rslt = bmi270_map_feat_int(&sens_int, 1, &bmi2_dev);
bmi2_error_codes_print_result(rslt);
printf("Move the board\n");
/* Loop to get any-motion interrupt. */
do
{
/* Clear buffer. */
int_status = 0;
/* To get the interrupt status of any-motion. */
rslt = bmi2_get_int_status(&int_status, &bmi2_dev);
bmi2_error_codes_print_result(rslt);
/* To check the interrupt status of any-motion. */
if (int_status & BMI270_ANY_MOT_STATUS_MASK)
{
printf("Any-motion interrupt is generated\n");
break;
}
} while (rslt == BMI2_OK);
}
}
}
return rslt;
}
Solved! Go to Solution.
03-11-2023 12:18 PM
I'm sorry to say it again.
I use BMI 2_ INT1 can be mapped to the external interrupt INT1 of MCU, but BMI 2_ INT2 is used cannot be mapped to external interrupt INT2.
03-12-2023 03:39 PM
Hi hjj,
Do you use BMI270 base version and refer the example code https://github.com/boschsensortec/BMI270-Sensor-API/tree/master/bmi270_examples?
03-13-2023 02:41 AM
Hello,
Thank you very much for your reply。The basic version of BMI 270 I use。INT2 cannot be used for any motion of BMI 270, but INT1 can be used.This is what bothers me。The interrupt settings of BMI270_INT1 mapping and BMI270_INT2 mapping in MCU are identical.I don't know why the external interrupt can be triggered by using INT1 in motion, but it cannot be triggered by using INT2. I also measured the port of INT2 with an oscilloscope, and the result is no pulse.
03-15-2023 10:25 AM
Hi hjj,
We will check it and give feedback to you.