Bosch Sensortec Community

    Showing results for 
    Search instead for 
    Did you mean: 

    BMI270 - FIFO data receiving and converting

    BMI270 - FIFO data receiving and converting

    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

    Community Moderator
    Community Moderator

    Hello Yegor,

    If you use the sensor API, the code has implemented the conversion.

    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);