Bosch Sensortec Community

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

    BMA456 spurious interrupt on int2 with anymotion

    Christop
    New Poster

    BMA456 spurious interrupt on int2 with anymotion

    Hi,

    I configured the bma456 using the github library and sets the anymotion feature. When mapping the feature using BMA456_ANY_MOT_INT on BMA4_INTR2_MAP I get an interrupt triggered even if the board is still. After clearing the interrupt by reading the interrupt status register further interrupts are correctly triggered only when moving the board.

    By the way when checking the code I found the code of bma4_map_interrupt to be inconsistent because it clears only the bits when disabling a mapping but override the configuration when enabling a mapping. I believe :

    data[int_line] = (uint8_t)(int_map & (0x00FF));

    data[2] = (uint8_t)((int_map & (0xFF00)) >> 8);

    should use |= instead of =.

    2 REPLIES 2
    BSTRobin
    Community Moderator

    Re: BMA456 spurious interrupt on int2 with anymotion

    Hello Christop,

    Thanks for your feedback. Yes, the driver code should be : data[2] |= (uint8_t)((int_map & (0xFF00)) >> 8);

    You could refer the following code to adjust any motion parameters.

    uint16_t Open_BMA456_ANY_NO_MOTION(struct bma4_dev *dev)
    {
    uint16_t rslt = BMA4_OK;

    /* Structure to define any-motion */
    struct bma456_any_no_mot_config any_mot = {0};
    /* Variable to define two interrupt lines */
    uint8_t int_line = BMA4_INTR1_MAP;
    struct bma4_int_pin_config int_pin_config;

    /* Get any-motion configuration to get the default values */
    rslt = bma456_get_any_mot_config(&any_mot, dev);
    if (rslt != BMA4_OK)
    {
    PDEBUG("Get any-motion configuration fail\r\n");
    return rslt;
    }
    else
    {
    PDEBUG("Get any-motion configuration successful\r\n");
    PDEBUG("axis_en = %x\n", any_mot.axes_en);
    PDEBUG("duration = %x\n", any_mot.duration);
    PDEBUG("threshold = %x\r\n", any_mot.threshold);
    }

    /* Enable any-motion for all axes */
    any_mot.axes_en = BMA456_EN_ALL_AXIS;
    any_mot.duration = 50;
    any_mot.threshold = 100;

    /* Set the new configuration */
    rslt = bma456_set_any_mot_config(&any_mot, dev);
    if (rslt != BMA4_OK)
    {
    PDEBUG("Set any-motion configuration fail\r\n");
    return rslt;
    }
    else
    {
    PDEBUG("Set any-motion configuration successful\r\n");
    }

    /* Get any-motion configuration to validate */
    rslt = bma456_get_any_mot_config(&any_mot, dev);
    if (rslt != BMA4_OK)
    {
    PDEBUG("Get any-motion configuration fail\r\n");
    return rslt;
    }
    else
    {
    PDEBUG("Get any-motion configuration successful\r\n");

    PDEBUG("axis_en = %x\n", any_mot.axes_en);
    PDEBUG("duration = %x\n", any_mot.duration);
    PDEBUG("threshold = %x\r\n", any_mot.threshold);
    }

    rslt = bma4_get_int_pin_config(&int_pin_config, int_line, dev);
    int_pin_config.edge_ctrl |= BMA4_LEVEL_TRIGGER;
    int_pin_config.lvl = BMA4_ACTIVE_HIGH;
    int_pin_config.od = BMA4_PUSH_PULL;
    int_pin_config.output_en = BMA4_OUTPUT_ENABLE;
    rslt = bma4_set_int_pin_config(&int_pin_config, int_line, dev);

    /* Map interrupt for any-motion */
    rslt = bma456_map_interrupt(BMA4_INTR1_MAP, BMA456_ANY_MOT_INT, BMA4_ENABLE, dev);
    if (rslt != BMA4_OK)
    {
    PDEBUG("Map interrupt fail\r\n");
    return rslt;
    }
    else
    {
    PDEBUG("Map interrupt successful\r\n");
    }

    /* Loop over to get the interrupt status of any-motion */
    PDEBUG("Shake the sensor in any direction\r\n");

    return rslt;
    }

    Christop
    New Poster

    Re: BMA456 spurious interrupt on int2 with anymotion

    Thanks Robin.

     

    I think I found what caused the undesired interrupt: by disabling the accel before mapping the interrupt and enabling it back after, I don't get it anymore.

    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