Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    [BMI160] can't receive LOW-G interrupt

    [BMI160] can't receive LOW-G interrupt

    potter1234
    New Poster

    Hi all,

    I'm using BMI160 with an MCU. The MCU is able to receive interrupts such as step counter and any-motion.

    However, I am not able to get LOW-G interrupt even though I adjusted parameters like low_dur & low_thres .

    In another platform (a different MCu) with the same settings I can easily generate LOW-G interrupt.

    My code is as follows. 

    Any feedback is appreciated.

    struct bmi160_int_settg int_config;

    /* Select the Interrupt channel/pin */
    int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1

    /* Select the Interrupt type */
    int_config.int_type = BMI160_ACC_LOW_G_INT;// Choosing LOW G/fall detection 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 low 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.int_type_cfg.acc_low_g_int.low_data_src=BMI160_ENABLE;//
    int_config.int_type_cfg.acc_low_g_int.low_en = BMI160_ENABLE;//
    int_config.int_type_cfg.acc_low_g_int.low_mode = BMI160_ENABLE;//
    int_config.int_type_cfg.acc_low_g_int.low_hyst = BMI160_ENABLE;//
    int_config.int_type_cfg.acc_low_g_int.low_dur = acc_int.fd_fall_duration; // [ms] ((n+1) * 2.5) PREV=50
    int_config.int_type_cfg.acc_low_g_int.low_thres = acc_int.fd_fall_threshold; // [mg] (n * 7.81) PREV=96

    bmi160_set_int_config(&int_config, &vImec_gsensor); /* sensor is an instance of the structure bmi160_dev */

    8 REPLIES 8

    Is it possible that  it clears itself so quickly so the interrupt status bit will always be 0 ?

    If that's the case, how do I distinguish different interrupts?

    BSTRobin
    Community Moderator
    Community Moderator

    Hello potter1234,

    "After some more experiment I am able to receive low-g interrupt now", do you meant apollo2 could response interrupt?

    Normally, for your low-g test when you receive interrupt and read out interrupt status, int_status.bit.low_g should be 1.  Other interrupt bits should be 0 if you didn't enable corresponding features.

    Hi,
    I mean I can receive interrupt from NRF52 now. However, int_status.bit.low_g is always 0 as well as int_status.bit.
    I am pretty sure low-g is the only interrupt I enabled.

    BSTRobin
    Community Moderator
    Community Moderator

    Hello potter1234,

    I tested low-g on MCU, it worked well. MCU could received interrupt, and low-g bit value of 0x1D register is 1.

    Please refer my code and test result.

    int8_t Open_BMI160_LOW_G(struct bmi160_dev *dev)
    {
    int8_t rslt = BMI160_OK;
    struct bmi160_int_settg int_config;

    /* Select the Interrupt channel/pin */
    int_config.int_channel = BMI160_INT_CHANNEL_1;// Interrupt channel/pin 1

    /* Select the Interrupt type */
    int_config.int_type = BMI160_ACC_LOW_G_INT;
    /* 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_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;// latched output

    /* Select the Flat interrupt parameters */
    int_config.int_type_cfg.acc_low_g_int.low_dur = 24;/*! low-g interrupt trigger delay */
    int_config.int_type_cfg.acc_low_g_int.low_thres = 12;/*! low-g interrupt trigger threshold */
    int_config.int_type_cfg.acc_low_g_int.low_hyst = BMI160_ENABLE;/*! hysteresis of low-g interrupt */
    int_config.int_type_cfg.acc_low_g_int.low_mode = BMI160_ENABLE;/*! 0 - single-axis mode ,1 - axis-summing mode */
    int_config.int_type_cfg.acc_low_g_int.low_data_src=BMI160_ENABLE; /*! data source 0- filter & 1 pre-filter */
    int_config.int_type_cfg.acc_low_g_int.low_en = BMI160_ENABLE; /*! 1 - enable low-g, 0 - disable low-g */

    /* Set the Flat interrupt */
    rslt = bmi160_set_int_config(&int_config, dev); /* sensor is an instance of the structure bmi160_dev */
    if(rslt == BMI160_OK)
    {
    PDEBUG("bmi160_set_int_config for low-g success\r\n");
    }
    else
    {
    PDEBUG("bmi160_set_int_config for low-g failed\r\n");
    }
    return rslt;
    }

    void StartBMI160InterruptTask(void const * argument)
    {
    int8_t rslt = BMI160_OK;
    struct bmi160_dev *dev;
    volatile union bmi160_int_status int_status;

    dev = &bmi160dev;

    for(;;)
    {
    if((int1_flag == 1) || (int2_flag == 1))
    {
    memset(int_status.data, 0x00, sizeof(int_status.data));
    bmi160_get_int_status(BMI160_INT_STATUS_ALL, &int_status, dev);
    PDEBUG("data: 0x%02X, 0x%02X, 0x%02X, 0x%02X\r\n", int_status.data[0], int_status.data[1], int_status.data[2], int_status.data[3]);

    if(int_status.bit.step)
    {
    PDEBUG("Step detector interrupt occured\r\n");
    }

    if(int_status.bit.anym)
    {
    PDEBUG("Any motion interrupt occured\r\n");
    }

    if(int_status.bit.nomo)
    {
    PDEBUG("No motion interrupt occured\r\n");
    }

    if(int_status.bit.flat_int)
    {
    PDEBUG("Flat detection interrupt occured\r\n");
    }

    if(int_status.bit.s_tap)
    {
    PDEBUG("Single TAP interrupt occured\r\n");
    }

    if(int_status.bit.d_tap)
    {
    PDEBUG("Double TAP interrupt occured\r\n");
    }

    if(int_status.bit.tap_sign)
    {
    PDEBUG("TAP sign 1\r\n");
    }
    else
    {
    PDEBUG("TAP sign 0\r\n");
    }

    if(int_status.bit.orient)
    {
    PDEBUG("Orientation interrupt occured\r\n");
    }

    if(int_status.bit.high_g)
    {
    PDEBUG("High-g interrupt occured\r\n");
    }

    if(int_status.bit.low_g)
    {
    PDEBUG("Low-g interrupt occured\r\n");
    }

    memset(int_status.data, 0x00, sizeof(int_status.data));
    int1_flag = 0;
    }
    }
    }

    void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
    {
    if(GPIO_Pin == GPIO_PIN_10)//INT1
    {
    PDEBUG("INT1 Triggered\r\n");
    int1_flag = 1;

    }

    }

    struct bmi160_acc_low_g_int_cfg
    {
    #if LITTLE_ENDIAN == 1

    /*! low-g interrupt trigger delay */
    uint8_t low_dur;

    /*! low-g interrupt trigger threshold */
    uint8_t low_thres;

    /*! hysteresis of low-g interrupt */
    uint8_t low_hyst : 2;

    /*! 0 - single-axis mode ,1 - axis-summing mode */
    uint8_t low_mode : 1;

    /*! data source 0- filter & 1 pre-filter */
    uint8_t low_data_src : 1;

    /*! 1 - enable low-g, 0 - disable low-g */
    uint8_t low_en : 1;
    #elif BIG_ENDIAN == 1

    /*! 1 - enable low-g, 0 - disable low-g */
    uint8_t low_en : 1;

    /*! data source 0- filter & 1 pre-filter */
    uint8_t low_data_src : 1;

    /*! 0 - single-axis mode ,1 - axis-summing mode */
    uint8_t low_mode : 1;

    /*! hysteresis of low-g interrupt */
    uint8_t low_hyst : 2;

    /*! low-g interrupt trigger threshold */
    uint8_t low_thres;

    /*! low-g interrupt trigger delay */
    uint8_t low_dur;
    #endif

    }

    BMI160 Low-g test log.png

    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