Bosch Sensortec Community

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

    Can not read from bmi160's fifo

    Can not read from bmi160's fifo

    TTN
    New Poster

    Hi,

    We have design a custom board that can read single frame from bmi160 without problems,

    Now we want to read more imu data, so we modify the bmi160 and mcu setting.

    Using WM trigger to triiger bmi160_get_fifo_data() function, but i got an error return 11(Hex).

    which is #define BMI160_FOC_FAILURE INT8_C(-11), but the error can't be fix by calling rslt = start_foc(&s_spi_bmi160_sensor);

    i read the datasheet and the repo from github:

    https://github.com/piMagpie/IoT/blob/2fd729ea7dd2e3afe2a169f9798d4ef98656b70b/last Project/ble_app_uart/main.c

    https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/BMI160-FIFO-readings-are-not-updating-da...

    https://github.com/haleighdefoor/GroupDelta_Project2/blob/e4c4336ee705ffa792350caaaf5b5f18c2e14862/L... 

    https://community.bosch-sensortec.com/t5/Knowledge-base/BMI160-FIFO-Advanced-Usage/ta-p/8957 

    and compare the setting with these github repo with my code, still can't figure out why and how to fix it.

    here is snip from my code:

    https://gist.github.com/ttn115/82ab37c0e0acf89587ca60dbee63d51a 

    Please help me to fix the problem, thanks.

     

     

     

    8 REPLIES 8

    BSTRobin
    Community Moderator
    Community Moderator

    Hello TTN,

    1.I setup SW demo on MCU,  you could refer attachment example code to run FIFO poll read, FIFO watermark interrupt read.

    2. For how to extract sensor time in FIFO, you could refer the following driver code in BMI160 sensor API.

    static void extract_accel_header_mode(struct bmi160_sensor_data *accel_data, uint8_t *accel_length, const struct bmi160_dev *dev)

    {

    ...

    /* Sensor time frame */
    case BMI160_FIFO_HEAD_SENSOR_TIME:
    unpack_sensortime_frame(&data_index, dev);
    break;

    ...

    }

    /*!
    * @brief This API is used to parse and store the sensor time from the
    * FIFO data in the structure instance dev.
    */
    static void unpack_sensortime_frame(uint16_t *data_index, const struct bmi160_dev *dev)
    {
    uint32_t sensor_time_byte3 = 0;
    uint16_t sensor_time_byte2 = 0;
    uint8_t sensor_time_byte1 = 0;

    /*Partial read, then move the data index to last data*/
    if ((*data_index + BMI160_SENSOR_TIME_LENGTH) > dev->fifo->length)
    {
    /*Update the data index as complete*/
    *data_index = dev->fifo->length;
    }
    else
    {
    sensor_time_byte3 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_MSB_BYTE] << 16;
    sensor_time_byte2 = dev->fifo->data[(*data_index) + BMI160_SENSOR_TIME_XLSB_BYTE] << 8;
    sensor_time_byte1 = dev->fifo->data[(*data_index)];

    /* Sensor time */
    dev->fifo->sensor_time = (uint32_t)(sensor_time_byte3 | sensor_time_byte2 | sensor_time_byte1);
    *data_index = (*data_index) + BMI160_SENSOR_TIME_LENGTH;
    }
    }

    3.Sensor time is for last frame.

    BMI160 sensortime frame.png

    You could refer this do calculate frame time:

    Previous frame time = dev->fifo->sensor_time*39.0625us-10000us

    Hi Robin,

    Thanks for your reply.

    I try to read the s_spi_bmi160_sensor.fifo->sensor_time, the return is 0, 

    and i check all the data in the fifo, make sure there isn't 0x44 header in the fifo.

    I not sure wheather the configration or something have problem.

    the fifo configration is the below

    /* Link the FIFO memory location */
    fifo_frame.data = FIFO_BUFF;
    fifo_frame.length = FIFO_LEN;
    fifo_frame.fifo_time_enable =BMI160_ENABLE;
    s_spi_bmi160_sensor.fifo = &fifo_frame;

    /*Enable fifo*/
    uint8_t fifo_config = BMI160_FIFO_HEADER | BMI160_FIFO_ACCEL | BMI160_FIFO_GYRO | BMI160_FIFO_TIME ;
    rslt = bmi160_set_fifo_config(fifo_config, BMI160_ENABLE, &s_spi_bmi160_sensor);

    According to the example i aslo change the config as below.

    /* Link the FIFO memory location */
    fifo_frame.data = FIFO_BUFF;
    fifo_frame.length = FIFO_LEN;
    s_spi_bmi160_sensor.fifo = &fifo_frame;

    /*Enable fifo*/
    uint8_t fifo_config = BMI160_FIFO_HEADER | BMI160_FIFO_ACCEL | BMI160_FIFO_GYRO ;
    rslt = bmi160_set_fifo_config(fifo_config, BMI160_ENABLE, &s_spi_bmi160_sensor);

    The combation i can try of setting can't enable the sensortime in the fifo.

    Could you give some suggestion?

    TTN
    New Poster

    Hi,

    Summarize the situation,

    I porting the fifo get function to the new project.

    in the new project the bmi160_get_fifo_data() can get the sensortime ,

    which the configration had no different to the old project.(Question 1)

    so i use add the the function in to a timer, when the timer is trigger,

    the timer event will call the bmi160_get_fifo_data() , and do the ble notify job.

    It works in the frist timer event handler, the funtion get acc and gyro data ,

    s_spi_bmi160_sensor.fifo->sensor_time have a sensortime value which is not 0.

    but all the data became to 0, when the second timer event .(Question 2)

    I change the bmi160_get_fifo_data() to bmi160_get_sensor_data() in the timer event.

    after the sceond timer event the readout value are also  0.  

    Even if I set the event trigger timer to once every 10 seconds.

    please give me some suggestion to findout what's wrong. 

    Thank you.

     

     

     

     

     

    TTN
    New Poster

    Hi Robin,

    All the problem seems to related to the spi doesn't work in the timer and event on our nrf52 board.

    I'll try connect to the bmi160 by other system function to get the data.

    Thanks.

    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