I am using the BMI160 in the following configuration. I have High G and FLAT Interrupt on INT2. I want to send the FLAT interrupt status when HIGH-G is triggered. However, the FLAT INT value is 1 only when the module is kept idle and on a table. If I do any high-g motion on it, the FLAT interrupt becomes 0 despite keeping the device flat. I have code snippets below which I have used. FLAT INT int8_t rslt; struct bmi160_int_settg int1; int1.int_channel = BMI160_INT_CHANNEL_2; int1.int_type = BMI160_ACC_FLAT_INT; int1.int_pin_settg.output_en = BMI160_ENABLE; int1.int_pin_settg.output_mode = BMI160_DISABLE; int1.int_pin_settg.output_type = BMI160_DISABLE; int1.int_pin_settg.edge_ctrl = BMI160_DISABLE; int1.int_pin_settg.input_en = BMI160_DISABLE; int1.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; int1.int_type_cfg.acc_flat_int.flat_en = 1; int1.int_type_cfg.acc_flat_int.flat_theta = 40; int1.int_type_cfg.acc_flat_int.flat_hy = 2; int1.int_type_cfg.acc_flat_int.flat_hold_time = 0; rslt = bmi160_set_int_config(&int1, &bmi160); HIGH G Conf. int2.int_channel = BMI160_INT_CHANNEL_2; int2.int_type = BMI160_ACC_HIGH_G_INT; int2.int_pin_settg.output_en = BMI160_ENABLE; int2.int_pin_settg.output_mode = BMI160_DISABLE; int2.int_pin_settg.output_type = BMI160_DISABLE; int2.int_pin_settg.edge_ctrl = BMI160_DISABLE; int2.int_pin_settg.input_en = BMI160_DISABLE; int2.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; int2.int_type_cfg.acc_high_g_int.high_g_x = 1; int2.int_type_cfg.acc_high_g_int.high_g_y = 0; int2.int_type_cfg.acc_high_g_int.high_g_z = 0; int2.int_type_cfg.acc_high_g_int.high_hy = 2; int2.int_type_cfg.acc_high_g_int.high_data_src=0; int2.int_type_cfg.acc_high_g_int.high_dur = 2; int2.int_type_cfg.acc_high_g_int.high_thres = 10; Orientation Config // Orientation int1.int_channel = BMI160_INT_CHANNEL_2; int1.int_type = BMI160_ACC_ORIENT_INT; int1.int_pin_settg.output_en = BMI160_ENABLE; int1.int_pin_settg.output_mode = BMI160_DISABLE; int1.int_pin_settg.output_type = BMI160_DISABLE; int1.int_pin_settg.edge_ctrl = BMI160_DISABLE; int1.int_pin_settg.input_en = BMI160_DISABLE; int1.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE; int1.int_type_cfg.acc_orient_int.orient_en = 1; int1.int_type_cfg.acc_orient_int.orient_mode = 1; int1.int_type_cfg.acc_orient_int.orient_theta = 10; int1.int_type_cfg.acc_orient_int.orient_ud_en = 1; int1.int_type_cfg.acc_orient_int.orient_hyst = 1; int1.int_type_cfg.acc_orient_int.axes_ex = 0; //int2.int_type_cfg.acc_orient_int. int1.int_type_cfg.acc_orient_int.orient_blocking = 3; rslt = bmi160_set_int_config(&int1, &bmi160); Interrupt Handler if(pin == BMI160_INT2) { //imu_flat = flat; bool orient = true; if (high) { if (!high_g && in_hand) { high_g = true; bool orient = false; uint16_t len = 30; raw_data_buffer[8] = 0x1A; raw_data_buffer[10] = 0x1F; // Start Activity ID raw_data_buffer[12] = tool_id; // Tool ID raw_data_buffer[14] = imu_flat; // Starting Orientation activity_counter = 1; ble_nus_data_send(&m_nus, raw_data_buffer, &len, m_conn_handle); }else { activity_counter++; } } if (flat) { orient = false; //imu_flat = int_status.bit.flat; imu_flat = 1; } if (orient){ imu_flat = 0; } } Any solution?
... View more