04-20-2023 11:50 AM
I can't figure out why the bmx160/bmi160 is not generating any fifo watermark interrupt while it does generated any motion interrupts.
Here is a dump of all the 85 registers of the bmx160 :
0s024:###### BMX160 regs offset = 0x00 -> d8 21 0 10 0 0 0 0 0 0 0 0 0 0 0 0
0s125:###### BMX160 regs offset = 0x10 -> 0 0 8f f2 fc fb 4d c5 f3 9c 9c 10 0 0 0 0
0s227:###### BMX160 regs offset = 0x20 -> 93 f2 2d 1 84 8b f2 4 fc 94 c5 84 86 f2 29 fc
0s329:###### BMX160 regs offset = 0x30 -> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0s430:###### BMX160 regs offset = 0x40 -> 29 3 8 0 b 88 64 52 0 0 0 20 80 42 4c 0
0s532:###### BMX160 regs offset = 0x50 -> 7 40 0 a9 8 0 40 4 0 0 7 30 81 b c0 0
0s633:###### BMX160 regs offset = 0x60 -> e 14 24 4 a 18 48 8 11 0 0 0 0 0 0 0
0s735:###### BMX160 regs offset = 0x70 -> 0 0 0 0 3f a7 6 0 0 0 15 3 0 0 0 0
0s836:###### BMX160 regs offset = 0x80 -> d8 21 0 10 0 0 0 0 0 0 0 0 0 0 0 0
any help is greatly appriciated!!!!
here is the code used :
uint8_t Open_BMI160_ANY_MOTION(struct bmi160_dev *dev, uint8_t latch_dur, enum bmi160_int_channel int_channel) {
/* Select the Interrupt channel/pin */
struct bmi160_int_settg int_config;
uint8_t rslt;
/* Select the Interrupt channel/pin */
int_config.int_channel = int_channel; //BMI160_INT_CHANNEL_2;// Interrupt channel/pin 1
/* Select the Interrupt type */
int_config.int_type = BMI160_ACC_ANY_MOTION_INT;// Choosing Any motion interrupt
/* Select the interrupt channel/pin settings */
int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
int_config.int_pin_settg.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
int_config.int_pin_settg.output_type = BMI160_ENABLE;// Choosing active high output
int_config.int_pin_settg.edge_ctrl = BMI160_DISABLE;// Choosing edge triggered output
int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
int_config.int_pin_settg.latch_dur = latch_dur; //// non-latched output
/* Select the Any-motion interrupt parameters */
int_config.int_type_cfg.acc_any_motion_int.anymotion_en = BMI160_ENABLE;// 1- Enable the any-motion, 0- disable any-motion
int_config.int_type_cfg.acc_any_motion_int.anymotion_x = BMI160_ENABLE;// Enabling x-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_y = BMI160_ENABLE;// Enabling y-axis for any motion interrupt
int_config.int_type_cfg.acc_any_motion_int.anymotion_z = BMI160_ENABLE;// Enabling z-axis for any motion interrupt
// any duration is anymotion_dur * 1 / ODR so 8 * 1 / 400 == 1/100 == 20 mS
int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = ANYMOTION_DURATION;// any-motion duration
int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = ANYMOTION_THRESHOLD;
rslt = bmi160_set_int_config(&int_config, dev);
return rslt;
}
int8_t Open_BMI160_DRDY(struct bmi160_dev *dev, int enable, enum bmi160_int_channel int_channel)
{
int8_t rslt = BMI160_OK;
struct bmi160_int_settg int_config;
/* Select the Interrupt channel/pin */
int_config.int_channel = int_channel; // BMI160_INT_CHANNEL_1;// Interrupt channel/pin 2
/* Select the Interrupt type */
if (enable != 0 ) {
int_config.int_type = BMI160_ACC_GYRO_DATA_RDY_INT;// Choosing interrupt
} else {
int_config.int_type = 0;// Choosing interrupt
}
/* Select the interrupt channel/pin settings */
int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
int_config.int_pin_settg.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
int_config.int_pin_settg.output_type = BMI160_DISABLE;// Choosing active high output
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_312_5_MICRO_SEC;// non-latched output
//int_config.fifo_wtm_int_en = BMI160_ENABLE;//Enable FIFO watermark interrupt
//int_config.fifo_wtm_int_en = BMI160_ENABLE;//Enable FIFO watermark interrupt
/* Set the FIFO watermark interrupt */
bmi160_set_int_config(&int_config, dev);
return rslt;
}
int8_t Open_BMI160_FIFO(struct bmi160_dev *dev, uint8_t fwm, enum bmi160_int_channel int_channel)
{
int8_t rslt = BMI160_OK;
struct bmi160_int_settg int_config;
fifo_frame.data = fifo_buff;
fifo_frame.length = FIFO_SIZE;
dev->fifo = &fifo_frame;
/* Clear FIFO configuration register */
rslt = bmi160_set_fifo_config(BMI160_FIFO_CONFIG_1_MASK, BMI160_DISABLE, dev);
if (rslt != BMI160_OK)
{
APP_LOG(TS_ON, VLEVEL_M, "Clear FIFO configuration register error, error code: %d\r\n", rslt);
return rslt;
}
// 400Hz : 1024 bytes fifo buffer holds 1024/7 = 146 samples of 7 bytes, set watermark at 80%
// means watermark is 117, make it 100 drames
// Avk set watermark level to 20 entries
rslt = bmi160_set_fifo_wm( fwm /*100 */, dev);//7*50=350 bytes, water mark value was word unit, cann't be greater than 255, 87*4=348
if(rslt != BMI160_OK)
{
APP_LOG(TS_ON, VLEVEL_M,"bmi160_set_fifo_wm error, error code: %d\r\n", rslt);
}
// BMI160_FIFO_A_ENABLE enable fifo for accelerometer only
rslt = bmi160_set_fifo_config(/*BMI160_FIFO_A_ENABLE |BMI160_FIFO_TAG_INT1 */
BMI160_FIFO_ACCEL|BMI160_FIFO_HEADER|BMI160_FIFO_TIME, BMI160_ENABLE, dev);
if(rslt != BMI160_OK)
{
APP_LOG(TS_ON, VLEVEL_M,"bmi160_set_fifo_config error, error code: %d\r\n", rslt);
}
/* Flush FIFO */
rslt = bmi160_set_fifo_flush(dev);
if (rslt != BMI160_OK)
{
APP_LOG(TS_ON, VLEVEL_M, "Flush FIFO error, error code: %d\r\n", rslt);
return rslt;
}
/* Select the Interrupt channel/pin */
int_config.int_channel = int_channel; // BMI160_INT_CHANNEL_1;// Interrupt channel/pin 2
/* Select the Interrupt type */
int_config.int_type = BMI160_ACC_GYRO_FIFO_WATERMARK_INT;// Choosing interrupt
/* Select the interrupt channel/pin settings */
int_config.int_pin_settg.output_en = BMI160_ENABLE;// Enabling interrupt pins to act as output pin
int_config.int_pin_settg.output_mode = BMI160_DISABLE;// Choosing push-pull mode for interrupt pin
int_config.int_pin_settg.output_type = BMI160_DISABLE;// Choosing active high output
int_config.int_pin_settg.edge_ctrl = BMI160_ENABLE;// Choosing edge triggered output
int_config.int_pin_settg.input_en = BMI160_DISABLE;// Disabling interrupt pin to act as input
int_config.int_pin_settg.latch_dur = BMI160_LATCH_DUR_NONE;// non-latched output
int_config.fifo_wtm_int_en = BMI160_ENABLE;//Enable FIFO watermark interrupt
/* Set the FIFO watermark interrupt */
bmi160_set_int_config(&int_config, dev);
return rslt;
}
int8_t Close_BMI160_FIFO(struct bmi160_dev *dev)
{
int8_t rslt = BMI160_OK;
return rslt;
}
int8_t Open_BMI160_ACC(struct bmi160_dev *dev)
{
int8_t rslt = BMI160_OK;
/* Select the Output data rate, range of accelerometer sensor */
dev->accel_cfg.odr = 0x09; // 200Hz
dev->accel_cfg.range = BMI160_ACCEL_RANGE_2G;
// TODO: dev->accel_cfg.power = BMI160_ACCEL_LOWPOWER_MODE;
dev->accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
dev->gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE;
/* Set the sensor configuration */
rslt = bmi160_set_sens_conf(dev);
//PDEBUG("bmi160_set_sens_conf rslt=%d\r\n", rslt);
return rslt;
}
04-20-2023 05:02 PM
Hi André,
Do you mean your host don't receive any interrupt from INT1?
What is FWM_LEVEL value in your code?
How is the implement of interrupt service handler?
04-21-2023 05:19 PM
> Do you mean your host don't receive any interrupt from INT1?
Yes!
> What is FWM_LEVEL value in your code?
100
> How is the implement of interrupt service handler?
I check it with a scope for now
> How is the implement of interrupt service handler?
Not yet implemented, check it with a scope on INT1 pin directly and I dont see any activity
I hope that the register dump can help finding the problem.
Cheers
05-30-2023 08:35 AM
Hi André,
water mark value was word unit, 100 means 100*4=400 bytes FIFO data. Water mark interrupt will be triggled every 400/7=57 frame data.
I upload example code for your reference, enable macro definition in the file user_define.h.
#if defined(USE_BMI160)
#define ACC_ONLY
//#define GYRO_ONLY
//#define ACC_GYRO
//#define USE_EXT_BMM150
//#define DATA_POLL
//#define TAP
//#define NO_MOTION
//#define STEP_COUNTER
//#define FIFO_POLL
#define FIFO_WM_INT
#endif