Bosch Sensortec Community

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

    Accel-Gyro configuration error after initalization of BMI270

    Accel-Gyro configuration error after initalization of BMI270

    YahyaTawil
    Established Member

    Hello

    In my code, the initalization is done successfully through bmi270_init api (returns BMI2_OK). Afterwords, I do the ACC and Gyro initalization using the steps found in examples (BMI270-Sensor-API/bmi270_examples/accel_gyro) I call the following function  after  interface_init and bmi270_init.

     

    nt8_t BMI270Driver::set_accel_gyro_config()
    {
    
        /* Status of api are returned to this variable. */
        int8_t rslt;
            
        /* Assign accel sensor to variable. */
        uint8_t sensor_list[2] = { BMI2_ACCEL, BMI2_GYRO };
    
    
        /* Structure to define accelerometer and gyro configuration. */
        struct bmi2_sens_config config[2];
    
        /* Configure the type of feature. */
        config[ACCEL].type = BMI2_ACCEL;
        config[GYRO].type = BMI2_GYRO;
    
    tr_debug("111");
        /* Get default configurations for the type of feature selected. */
        rslt = bmi270_get_sensor_config(config, 2, &dev);
        error_codes_print_result(rslt);
    
    tr_debug("222");
        /* Map data ready interrupt to interrupt pin. */
        rslt = bmi2_map_data_int(BMI2_DRDY_INT, BMI2_INT1, &dev);
        error_codes_print_result(rslt);
    
        if (rslt == BMI2_OK)
        {
            /* NOTE: The user can change the following configuration parameters according to their requirement. */
            /* Set Output Data Rate */
            config[ACCEL].cfg.acc.odr = BMI2_ACC_ODR_200HZ;
    
            /* Gravity range of the sensor (+/- 2G, 4G, 8G, 16G). */
            config[ACCEL].cfg.acc.range = BMI2_ACC_RANGE_2G;
    
            /* The bandwidth parameter is used to configure the number of sensor samples that are averaged
             * if it is set to 2, then 2^(bandwidth parameter) samples
             * are averaged, resulting in 4 averaged samples.
             * Note1 : For more information, refer the datasheet.
             * Note2 : A higher number of averaged samples will result in a lower noise level of the signal, but
             * this has an adverse effect on the power consumed.
             */
            config[ACCEL].cfg.acc.bwp = BMI2_ACC_NORMAL_AVG4;
    
            /* Enable the filter performance mode where averaging of samples
             * will be done based on above set bandwidth and ODR.
             * There are two modes
             *  0 -> Ultra low power mode
             *  1 -> High performance mode(Default)
             * For more info refer datasheet.
             */
            config[ACCEL].cfg.acc.filter_perf = BMI2_PERF_OPT_MODE;
    
            /* The user can change the following configuration parameters according to their requirement. */
            /* Set Output Data Rate */
            config[GYRO].cfg.gyr.odr = BMI2_GYR_ODR_200HZ;
    
            /* Gyroscope Angular Rate Measurement Range.By default the range is 2000dps. */
            config[GYRO].cfg.gyr.range = BMI2_GYR_RANGE_2000;
    
            /* Gyroscope bandwidth parameters. By default the gyro bandwidth is in normal mode. */
            config[GYRO].cfg.gyr.bwp = BMI2_GYR_NORMAL_MODE;
    
            /* Enable/Disable the noise performance mode for precision yaw rate sensing
             * There are two modes
             *  0 -> Ultra low power mode(Default)
             *  1 -> High performance mode
             */
            config[GYRO].cfg.gyr.noise_perf = BMI2_POWER_OPT_MODE;
    
            /* Enable/Disable the filter performance mode where averaging of samples
             * will be done based on above set bandwidth and ODR.
             * There are two modes
             *  0 -> Ultra low power mode
             *  1 -> High performance mode(Default)
             */
            config[GYRO].cfg.gyr.filter_perf = BMI2_PERF_OPT_MODE;
            
            am_util_delay_ms(10); 
            tr_debug("333");
            /* Set the accel and gyro configurations. */
            rslt = bmi270_set_sensor_config(config, 2, &dev);
            error_codes_print_result(rslt);
        }
        tr_debug("444");
        rslt = bmi270_sensor_enable(sensor_list, 2, &dev);
        error_codes_print_result(rslt);
                
        return rslt;
    }

     

    I get an error " Invalid Accel-Gyro configuration error. It occurs when there is a error in accel and gyro" " configuration registers which could be one among range, BW or filter performance in reg address 0x40 "

    What whould make the EVENT register raise the acc_and_gyr_err flag although I use the same API functions and example code?

    6 REPLIES 6

    YahyaTawil
    Established Member

    Thanks for the reply. Actually the issue was solved using DMA mode in the MCU 's I2C preipheral. It seems that the ordinary I2C with the RTOS schedular get corrupted some how.

    BSTRobin
    Community Moderator
    Community Moderator

    Good news, YahyaTawil.

    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