Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    BMI160 watermark interrupt FIFO data being repeated

    BMI160 watermark interrupt FIFO data being repeated

    michiels
    Member

    Hi,


    We are using the watermark interrupt to read 64 gyroscope and accelerometer samples at a time. This works fine when the device is laying still on a desk but when we repeat the test with the device being moved around we seem to get the same values being read from the FIFO at some instances.
    We have checked with the bmi160_get_int_status function to see if maybe any other inter-rupts are being triggered but that does not seem to be the case.


    Any thoughts?

    Thanks and best regards,

    Michiel

    8 REPLIES 8

    BSTRobin
    Community Moderator
    Community Moderator

    Hello michiels,

    When host received BMI160 watermark interrupt, did host read 64 bytes of data directly or according to the actual FIFO length?

    Hi Robin,

    Thanks for the reply.

    Not sure what you mean by your question, but we do something like this:

    void inertial_sensor_interrupt_handler_blocking(void)
    {
        NRF_LOG_INFO("Read blocking start");
        nrf_gpio_pin_set(TOGGLE_PIN);
        waiting_flag = true;
        uint8_t data = 0x00;
        fifo_counter++;
        fifo_interrupt_time_stamp = time_stamp_get_time_since_boot();
        NRF_LOG_INFO("IMU interrupt Elapsed time since boot %i", fifo_interrupt_time_stamp);
        if(inertial_sensor_get_fifo_new_data_flag()){
            NRF_LOG_INFO("FIFO DATA OVERWRITTEN WITHOUT READING!");
        }
        inertial_sensor_set_fifo_new_data_flag();
        /* Disable the WM interrupt */
        bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1, &inertial_sensor); 
        /* Check what the available amount of data is prior to FIFO read out */ 
        uint16_t available_data_pre;
        available_data_pre = inertial_sensor_fifo_available_amount_of_data(&inertial_sensor);
        NRF_LOG_INFO("%i bytes of available data prior to FIFO read out", available_data_pre);
        /* Read data from the sensor's FIFO and store it the FIFO buffer,"fifo_buff" */
        inertial_sensor_fifo_read(&inertial_sensor);
        /* Enable the WM interrupt */
        data = BMI160_FIFO_WATERMARK_INT_EN_MASK; 
        bmi160_set_regs(BMI160_INT_ENABLE_1_ADDR, &data, 1,  &inertial_sensor);  
        nrf_gpio_pin_clear(TOGGLE_PIN);
        NRF_LOG_INFO("Read blocking stop");
    }
    
    int8_t inertial_sensor_fifo_read(struct bmi160_dev *dev)
    {
        int8_t rslt = 0;
        /* Modify the FIFO buffer instance and link to the device instance */
        dev->fifo->length = FIFO_SIZE;
        
        /* Initialization of variables */
        uint16_t index = 0;   
        uint8_t gyro_index = 0;
        uint8_t accel_index = 0;
        uint8_t gyro_frames_req = GYR_FRAMES;   
        uint8_t accel_frames_req = ACC_FRAMES;  
    
    
        NRF_LOG_INFO("\n USER REQUESTED FIFO LENGTH : %d\n",dev->fifo->length);
    
        /* Read the data from the FIFO buffer */
        rslt = bmi160_get_fifo_data(dev);
    
        if (rslt == BMI160_OK) {
              NRF_LOG_INFO("\n AVAILABLE FIFO LENGTH : %d\n",dev->fifo->length);
              /* Print the raw FIFO data */
              //for (index = 0; index < dev->fifo->length; index++) {
              //	NRF_LOG_INFO("\n FIFO DATA INDEX[%d] = %d", index,
              //		dev->fifo->data[index]);
              //}
              NRF_LOG_INFO("\n REQUESTED GYRO DATA FRAMES : %d\n ",gyro_frames_req);
    
              /* Parse the FIFO data to extract gyroscope data from the FIFO buffer */
              rslt = bmi160_extract_gyro(&gyro_data, &gyro_frames_req, dev);
    
              if (rslt == BMI160_OK) {
                      NRF_LOG_INFO("\n AVAILABLE GYRO DATA FRAMES : %d\n ",gyro_frames_req);                    
                      /* Print the parsed gyro data from the FIFO buffer */
                      //for (gyro_index = 0 ; gyro_index <gyro_frames_req ; gyro_index++) {
                      //	NRF_LOG_INFO("\nFIFO GYRO FRAME[%d]",gyro_index);
                          //NRF_LOG_INFO("\nGYRO X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
                          //	,gyro_data[gyro_index].x ,gyro_data[gyro_index].y
                      //		,gyro_data[gyro_index].z);
                      //}
                      /*Print a sample as speed is too high*/
                      NRF_LOG_INFO("\nGYRO X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
                                        ,gyro_data[18].x ,gyro_data[18].y
                                        ,gyro_data[18].z);
                      /* Print the special FIFO frame data like sensortime */
                      //NRF_LOG_INFO("\n SENSOR TIME DATA : %d \n",dev->fifo->sensor_time);
                      //NRF_LOG_INFO("SKIPPED FRAME COUNT : %d",dev->fifo->skipped_frame_count);                                
              } else {
                      NRF_LOG_INFO("\n Gyro data extraction failed");
              }           
      
              NRF_LOG_INFO("\n REQUESTED ACCEL DATA FRAMES : %d\n ",accel_frames_req);
    
              /* Parse the FIFO data to extract accelerometer data from the FIFO buffer */
              rslt = bmi160_extract_accel(&accel_data, &accel_frames_req, dev);
    
              if (rslt == BMI160_OK) {
                  
                      NRF_LOG_INFO("\n AVAILABLE ACCEL DATA FRAMES : %d\n ",accel_frames_req);
                      
                      /* Print the parsed accel data from the FIFO buffer */
                      //for (accel_index = 0; accel_index < accel_frames_req; accel_index++) {
                      //	printf("\nFIFO ACCEL FRAME[%d]",accel_index);
                      //	printf("\nACCEL X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
                      //		,accel_data[accel_index].x ,accel_data[accel_index].y
                      //		,accel_data[accel_index].z);                
                      //}
                      /*Print a sample as speed is too high*/
                      NRF_LOG_INFO("\nACCEL X-DATA : %d \t Y-DATA : %d \t Z-DATA : %d"
                                  ,accel_data[60].x ,accel_data[60].y
                                  ,accel_data[60].z);
                      /* Print the special FIFO frame data like sensortime */
                      //NRF_LOG_INFO("\n SENSOR TIME DATA : %d \n",dev->fifo->sensor_time);
                      //NRF_LOG_INFO("SKIPPED FRAME COUNT : %d",dev->fifo->skipped_frame_count);                                
              } else {
                      NRF_LOG_INFO("\n Accel data extraction failed");
              }
        } else {
                NRF_LOG_INFO("\n Reading FIFO data failed");
    
        }
        return rslt;
    }

     I don't fully understand how that would be influenced by the sensor moving or not.

    Best regards,

    Michiel

    Hi,

    I wanted to add, I added a bmi160_set_fifo_flush(dev) command and it did not resolve the issue.

    Best regards,

    Michiel

    BSTRobin
    Community Moderator
    Community Moderator

    Hello michiels,

    I uploaed BMI160 example code on my side for your reference.

    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