04-28-2021 03:56 AM
Hi,
I use the sample code in Github to enable BMI270 anymotion function. After I enable this feature, it takes around 0.6mA @ 3V.
I try to change anymotion parameters to reduce power consumption but I cannot obtain good results.
Below is my source code:
static int8_t set_feature_config(struct bmi2_dev *bmi2_dev)
{
/* Status of api are returned to this variable. */
int8_t rslt;
/* Structure to define the type of sensor and its configurations. */
struct bmi2_sens_config config;
/* Configure the anyMotion feature. */
config.type = BMI2_ANY_MOTION;
config.cfg.acc.filter_perf = BMI2_POWER_OPT_MODE;
/* Get default configurations for the type of feature selected. */
rslt = bmi270_get_sensor_config(&config, 1, bmi2_dev);
print_rslt(rslt);
if (rslt == BMI2_OK)
{
/* NOTE: The user can change the following configuration parameters according to their requirement. */
/* 1LSB equals 20ms. Default is 100ms, */
config.cfg.any_motion.duration = 0x05;
/* 1LSB equals to 0.48mg. Default is 83mg, */
config.cfg.any_motion.threshold = 0xAA;
/* Set new configurations. */
rslt = bmi270_set_sensor_config(&config, 1, bmi2_dev);
/* Interrupt PINs configuration */
struct bmi2_int_pin_config int_cfg;
int_cfg.pin_type = BMI2_INT1;
int_cfg.int_latch = BMI2_INT_NON_LATCH;
int_cfg.pin_cfg[0].output_en = BMI2_INT_OUTPUT_ENABLE;
int_cfg.pin_cfg[0].od = BMI2_INT_PUSH_PULL;
int_cfg.pin_cfg[0].lvl = BMI2_INT_ACTIVE_HIGH;
int_cfg.pin_cfg[0].input_en = BMI2_INT_INPUT_DISABLE;
rslt = bmi2_set_int_pin_config(&int_cfg, bmi2_dev);
print_rslt(rslt);
}
return rslt;
}
void M_DRV_BMI270_AnyMotion_Init(void)
{
M_PRINTF("[%s]\r\n", __func__);
bmi_dev.read = bmi_reg_read;
bmi_dev.write = bmi_reg_write;
bmi_dev.delay_us = bmi_delay_us;
bmi_dev.read_write_len = 64;
bmi_dev.intf = BMI2_SPI_INTF;
bmi_dev.chip_id = 1;
bmi_dev.dummy_byte = 1;
int8_t rslt;
/* Accel sensor and any-motion feature are listed in array. */
uint8_t sens_list[2] = { BMI2_ACCEL, BMI2_ANY_MOTION };
/* Select features and their pins to be mapped to. */
struct bmi2_sens_int_config sens_int = { .type = BMI2_ANY_MOTION, .hw_int_pin = BMI2_INT1 };
/* Interface reference is given as a parameter
* For I2C : BMI2_I2C_INTF
* For SPI : BMI2_SPI_INTF
*/
rslt = bmi270_init(&bmi_dev);
print_rslt(rslt);
if (rslt == BMI2_OK){
/* Enable the selected sensors. */
rslt = bmi270_sensor_enable(sens_list, 2, &bmi_dev);
print_rslt(rslt);
if (rslt == BMI2_OK)
{
/* Set feature configurations for any-motion. */
rslt = set_feature_config(&bmi_dev);
print_rslt(rslt);
if (rslt == BMI2_OK)
{
/* Map the feature interrupt for any-motion. */
rslt = bmi270_map_feat_int(&sens_int, 1, &bmi_dev);
print_rslt(rslt);
}
}
}
}
04-28-2021 07:13 AM
Hello Neo,
Please refer the following BMI270 power modes table to set your power mode.