Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMI270 - FIFO data receiving and converting

    BMI270 - FIFO data receiving and converting

    Yegor
    Occasional Visitor

    I am using a BMI270 chip and trying to read the data from the FIFO. I also use an exemple  to read data from FIFO. But I have a problem. The data I get from the FIFO is not valid at rest. When I read data directly from registers DATA_0 - DATA_19 (accelerometer and gyroscope data) using the example, the data converted to m/s^2 and dps are valid at rest - that is, one axis of the accelerometer ~9.8g others ~0g in horizontal position and for the gyroscope - all axes ~0dps. The same functions are used to convert FIFO data as for data from DATA_0 to DATA_19 registers:
    static float lsb_to_mps2(int16_t val, float g_range, uint8_t bit_width)
    static float lsb_to_dps(int16_t val, float dps, uint8_t bit_width)
    I also noticed that my revision of the chip (5P 04C) uses 2 dummy bytes between the register address and the data received from the requested register. And the library above uses 1 dummy byte.
    Can I use the above examples to work with my revision's chip? Maybe for my revision of the chip I need another way to convert data received from FIFO?

    1 REPLY 1

    BSTRobin
    Community Moderator
    Community Moderator

    Hello Yegor,

    If you use the sensor API, the code has implemented the conversion.
    https://github.com/BoschSensortec/BMI270-Sensor-API/blob/master/bmi2.c

    static void unpack_accel_data(struct bmi2_sens_axes_data *acc,
    uint16_t data_start_index,
    const struct bmi2_fifo_frame *fifo,
    const struct bmi2_dev *dev)
    {
    /* Variables to store LSB value */
    uint16_t data_lsb;

    /* Variables to store MSB value */
    uint16_t data_msb;

    /* Accelerometer raw x data */
    data_lsb = fifo->data[data_start_index++];
    data_msb = fifo->data[data_start_index++];
    acc->x = (int16_t)((data_msb << 😎 | data_lsb);

    /* Accelerometer raw y data */
    data_lsb = fifo->data[data_start_index++];
    data_msb = fifo->data[data_start_index++];
    acc->y = (int16_t)((data_msb << 😎 | data_lsb);

    /* Accelerometer raw z data */
    data_lsb = fifo->data[data_start_index++];
    data_msb = fifo->data[data_start_index++];
    acc->z = (int16_t)((data_msb << 😎 | data_lsb);

    /* Get the re-mapped accelerometer data */
    get_remapped_data(acc, dev);
    }

    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