Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 
    SOLVED

    No data avaiable in fifo while fifo's watermark flag int_fwm_en is set

    No data avaiable in fifo while fifo's watermark flag int_fwm_en is set

    André
    Established Member

     

     

    Hi there,

     

    I run into a problem where the int_fwm_en bit is constantly set even after emptying the contents of the fifo. 

     

    No ISR routine is used yet so the code polls for any motion or fifo watermark flags (via I2C)  to reguarly (once per second) empty the fifo contents. 

    What I can see on the scope is that the watermark interrupt is continously triggerd (high). I expect that the bug is in the setup of the bmx160 code as shown here below. I use a stm32 nucleo board for testing.

    The code that I use is here below,

    Any help is greatly appriciated

    Thanks!

    André

    struct bmi160_int_settg int_config;
    uint8_t rslt;

    dev->intf = BMI160_I2C_INTF;
    dev->id = BMI160_I2C_ADDR;
    dev->read = SensorAPI_I2Cx_Read;
    dev->write = SensorAPI_I2Cx_Write;
    dev->delay_ms = HAL_Delay;
    dev->read_write_len = 32;


    rslt = bmi160_soft_reset(dev);
    dev->delay_ms(200);

    bmi160_init(dev);

    dev->accel_cfg.odr = BMI160_ACCEL_ODR_200HZ;
    dev->accel_cfg.range = BMI160_ACCEL_RANGE_2G;
    dev->accel_cfg.power = BMI160_ACCEL_NORMAL_MODE;
    dev->gyro_cfg.power = BMI160_GYRO_SUSPEND_MODE;

    bmi160_set_sens_conf(dev);

    fifo_frame.data = fifo_buff;
    fifo_frame.length = 1024;
    dev->fifo = &fifo_frame;

    /* Clear FIFO configuration register */
    bmi160_set_fifo_config(BMI160_FIFO_CONFIG_1_MASK, BMI160_DISABLE, dev);
    bmi160_set_fifo_wm(20, dev);
    bmi160_set_fifo_config(BMI160_FIFO_A_ENABLE /*|BMI160_FIFO_TIME_ENABLE*/ |BMI160_FIFO_TAG_INT2, BMI160_ENABLE, dev);
    bmi160_set_fifo_flush(dev);

    int_config.int_channel = BMI160_INT_CHANNEL_2;
    int_config.int_type = BMI160_ACC_GYRO_FIFO_WATERMARK_INT;

    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 low 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 = BMI160_LATCH_DUR_10_MILLI_SEC; /* non-latched output */

    int_config.fifo_wtm_int_en = BMI160_ENABLE;
    bmi160_set_int_config(&int_config, dev);

    int_config.int_type = BMI160_ACC_ANY_MOTION_INT;
    int_config.int_channel = BMI160_INT_CHANNEL_1;

    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 low 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 = BMI160_LATCH_DUR_320_MILLI_SEC; /* non-latched output */

    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

    int_config.int_type_cfg.acc_any_motion_int.anymotion_dur = 1; // any-motion duration
    int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 1;

    int_config.int_type_cfg.acc_any_motion_int.anymotion_thr = 0x80;

    bmi160_set_int_config(&int_config, dev);

     

    uint8_t reg_data, samples_count=0;

    for(;;)
    {
    memset(int_status.data, 0x00, sizeof(int_status.data));
    bmi160_get_int_status(BMI160_INT_STATUS_ALL, &int_status, dev);

    if(int_status.bit.fwm )
    {

    acc_frames_req = 50;


    /* disable fifo watermark otherwise the BMX160 can generate interrupts while reading the fifo */
    disable_fifo_watermark_interrupt(dev);

    while(acc_frames_req>0) {

    rslt = bmi160_get_fifo_data(dev);
    print_bmi160_rslt(rslt);


    //PDEBUG("Fifo length:%d\r\n", dev->fifo->length);
    if(rslt == BMI160_OK)
    {

    /* Parse the FIFO data to extract accelerometer data from the FIFO buffer */
    rslt = bmi160_extract_accel(fifo_acc_data, &acc_frames_req, dev);

    if (rslt == BMI160_OK)
    {
    PDEBUG("Parsed accelerometer data frames: %d\r\n", acc_frames_req);

    /* Print the parsed accelerometer data from the FIFO buffer */
    for(bmi160_fifo_idx = 0 ; bmi160_fifo_idx < acc_frames_req ; bmi160_fifo_idx++)
    {
    samples_count++;

    PDEBUG("ACCEL[%d] x=%d y=%d z=%d time=%x\r\n", bmi160_fifo_idx , fifo_acc_data[bmi160_fifo_idx].x, fifo_acc_data[bmi160_fifo_idx].y, fifo_acc_data[bmi160_fifo_idx].z,
    fifo_acc_data[bmi160_fifo_idx].sensortime);
    }
    } else {
    PDEBUG("bmi160_extract_accel ERROR rslt=%d\r\n", rslt);
    }
    }
    }
    enable_fifo_watermark_interrupt(dev);
    }

    HAL_Delay(1000);
    }

     

    2 REPLIES 2

    BSTRobin
    Community Moderator
    Community Moderator

    Hi André,

    You could refer attached exmaple code.
    As you would like to read data with FIFO poll, you could enable the following macro definition.
    #define ACC_GYRO
    #define FIFO_POLL

    André
    Established Member

    i found the error in my own code 😕 ... I kept reading the fifo in small chunks without checking the watermark flag in the bmx160 itself. 

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist