Bosch Sensortec Community

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

    BMA456 any-/no-motion interrupt does not occur

    rearmimator
    Member

    BMA456 any-/no-motion interrupt does not occur

    Hi there,

     

    I have got a custom made board equiped with BMA456 sensor.

    Following guide found on github I could bring the sensor up over I2C interface: https://github.com/BoschSensortec/BMA456-Sensor-API;

    My issue is that having basic communication working, no (any-/no-motions) interrupts are generated by sensor IC.

    Both interrupt status register 0 & 1 stay zero all ther time regardless how threshold and duration are set up.

    I wonder what could be the reason for missing interrupts.

    Here is the code snippet used to initialise and test the interrupt generation.

    I attached also the traces obtained during one of the test runs.

    Is anything that I am doing wrong there?

     

     

    uint16_t BMA456::sensor_bma456_init(void)
    {
        uint16_t rslt = BMA4_OK;
    
        this->m_AccelDev.dev_addr       = BMA4_I2C_ADDR_SECONDARY;
        this->m_AccelDev.interface      = BMA4_I2C_INTERFACE;
        this->m_AccelDev.bus_read       = &BMA456::bma4_read_wrapper;
        this->m_AccelDev.bus_write      = &BMA456::bma4_write_wrapper;
        this->m_AccelDev.delay          = &BMA456::bma4_udelay;
        this->m_AccelDev.read_write_len = 8;
        this->m_AccelDev.resolution     = 12;
        this->m_AccelDev.feature_len    = BMA456_FEATURE_SIZE;
    
        /* a. Reading the chip id. */
        rslt |= bma456_init(&this->m_AccelDev);
    
        /* b. Performing initialisation sequence.
           c. Checking the correct status of the initialisation sequence.
         */
        rslt |= bma456_write_config_file(&this->m_AccelDev);
    
    #if 0
      {
        uint8_t cmd = 0xB6;
        bma4_set_command_register(&cmd, &this->m_AccelDev); // reset device
      }
    #endif
    
        osDelay(1); // wait for POR finish
    
        rslt |= bma4_set_accel_enable(BMA4_ENABLE, &this->m_AccelDev);
    
        rslt |= bma456_write_config_file(&this->m_AccelDev);
    
        {
            uint16_t int_status = 0u;
            uint16_t rc = BMA4_OK;
    
            rc |= bma4_read_int_status(&int_status, &this->m_AccelDev);
    
            /* Declare a no/any-motion interrupt configuration structure */
            bma456_any_no_mot_config any_mot_confg;
            bma456_any_no_mot_config no_mot_confg;
    
            rc |= bma456_get_any_mot_config(&any_mot_confg, &this->m_AccelDev);
            if (!rc) {
                printf("\n=== Get any-motion configuration successful === \n");
                printf("axis_en = %x\n", any_mot_confg.axes_en);
                printf("duration = %x\n", any_mot_confg.duration);
                printf("threshold = %x\n", any_mot_confg.threshold);
            }
    
            rc |= bma456_get_no_mot_config(&no_mot_confg, &this->m_AccelDev);
            if (!rc) {
                printf("\n=== Get no-motion configuration successful === \n");
                printf("axis_en = %x\n", no_mot_confg.axes_en);
                printf("duration = %x\n", no_mot_confg.duration);
                printf("threshold = %x\n", no_mot_confg.threshold);
            }
    
            any_mot_confg.axes_en = BMA456_EN_ALL_AXIS;
            any_mot_confg.duration = 5u; /* 5 * 20 ms = 100 ms */
            any_mot_confg.threshold = (0xCC); /* 5.11 G, 100 mg */
    
            no_mot_confg.axes_en = BMA456_EN_ALL_AXIS;
            no_mot_confg.duration = 5u; /* 5 * 20 ms = 100 ms */
            no_mot_confg.threshold = (0xCC); /* 5.11 G, 100 mg */
    
            rc |= bma456_set_any_mot_config(&any_mot_confg, &this->m_AccelDev);
            if (!rc) {
                printf("\n=== Set any-motion configuration successful === \n");
                printf("axis_en = %x\n", any_mot_confg.axes_en);
                printf("duration = %x\n", any_mot_confg.duration);
                printf("threshold = %x\n", any_mot_confg.threshold);
            }
    
            rc |= bma456_set_no_mot_config(&no_mot_confg, &this->m_AccelDev);
            if (!rc) {
                printf("\n=== Set no-motion configuration successful === \n");
                printf("axis_en = %x\n", no_mot_confg.axes_en);
                printf("duration = %x\n", no_mot_confg.duration);
                printf("threshold = %x\n", no_mot_confg.threshold);
            }
    
            {
                struct bma4_int_pin_config int_config;
    
                /* Configure INT1 pin */
                int_config.edge_ctrl = BMA4_LEVEL_TRIGGER;
                int_config.lvl = BMA4_ACTIVE_LOW;
                int_config.od = BMA4_PUSH_PULL;
                int_config.output_en = BMA4_OUTPUT_ENABLE;
                int_config.input_en = BMA4_INPUT_DISABLE;
                rc |= bma4_set_int_pin_config(&int_config, BMA4_INTR1_MAP, &this->m_AccelDev);
            }
    
            rc |= bma456_map_interrupt(BMA4_INTR1_MAP, BMA456_ANY_MOT_INT, BMA4_ENABLE, &this->m_AccelDev);
            rc |= bma456_map_interrupt(BMA4_INTR2_MAP, BMA456_NO_MOT_INT, BMA4_ENABLE, &this->m_AccelDev);
            {
                volatile bool trap = true;
    
                printf("Shake the sensor in any direction\n");
                while (trap) {
                    /* Read the interrupt status */
                    rc |= bma4_read_int_status(&int_status, &this->m_AccelDev);
                    
                    if (rslt == BMA4_OK) {
                        /* check if any/no motion interrupt is triggered */
                        if (int_status) {
                            printf("Any-/No-Motion interrupt occurred := %lu\n", int_status);
                            break;
                        }
                        else {
                            bma4_accel sens_data;
                            rc |= bma4_read_accel_xyz(&sens_data, &this->m_AccelDev);
                            printf("X := %i, Y := %i, Z := %i\n", sens_data.x, sens_data.y, sens_data.z);
                        }
                    }
    
                    int_status = 0;
    
                    udelay(200u);
                }
            }
        }
    
        return rslt;
    }

     

     

    2 REPLIES 2
    rearmimator
    Member

    Re: BMA456 any-/no-motion interrupt does not occur

    I found what was missing!

    It seems to be that "soft-reset" command is doing a bit more, than simple reset.

    Issuing soft-reset at the place where that code was remmed out by preprocessor directive made my day.

    shellywang
    Occasional Contributor

    Re: BMA456 any-/no-motion interrupt does not occur

    Thanks for your attention on our products and glad to hear you solve the problem.If still have questions,please come to community and contact us.

    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