Bosch Sensortec Community

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

    BMI270 single data ready interrupt

    BMI270 single data ready interrupt

    Myzhar
    Established Member

    Hi,

    I have a problem with data ready interrupt on the BMI270. When my sensor starts I get only the first interrupt, then it seems that the sensor stops firing interrupts.
    The BMI270 is connected to a STM32F072 over SPI.

    I read the data using SPI with DMA:

     

     

    void reqBMIDataDMA(uint8_t getTemp) {
    	static int errCount = 0;
    
    	uint8_t reg_addr[BMI_BUFF_SIZE] = { (BMI2_STATUS_ADDR | BMI2_SPI_RD_MASK) };
    
    	uint16_t dataSize = BMI_BUFF_SIZE;
    
    	// Select BMI270
    	HAL_GPIO_WritePin(SPI_CS_N_GPIO_Port, SPI_CS_N_Pin, GPIO_PIN_RESET);
    
    	HAL_StatusTypeDef res = HAL_SPI_TransmitReceive_DMA(hspi_bmi, reg_addr, bmi_buffer, dataSize);
    
    	if (res != HAL_OK)
    		errCount++;
    }

     

     

    The burst read includes the INT_STATUS_1 register, so the interrupt flag should be automatically cleared...

    This is the configuration for the interrupt pin:

     

     

    	// Interrupt PINs configuration
    	struct bmi2_int_pin_config data_int_cfg;
    	data_int_cfg.pin_type = BMI2_INT1;
    	data_int_cfg.int_latch = BMI2_INT_NON_LATCH;
    	data_int_cfg.pin_cfg[0].output_en = BMI2_INT_OUTPUT_ENABLE; // Output enabled
    	data_int_cfg.pin_cfg[0].od = BMI2_INT_PUSH_PULL;			// OpenDrain disabled
    	data_int_cfg.pin_cfg[0].lvl = BMI2_INT_ACTIVE_LOW;			// Signal Low Active
    	data_int_cfg.pin_cfg[0].input_en = BMI2_INT_INPUT_DISABLE;	// Input Disabled
    
    	rslt =  bmi2_set_int_pin_config( &data_int_cfg, &bmi270_dev);
    	if (rslt != BMI2_OK)
    		goto exit;
    
    	// Map data interrupt
    	rslt = bmi2_map_data_int( BMI2_GYRO, BMI2_INT1, &bmi270_dev);
    	if (rslt != BMI2_OK)
    		goto exit;

     

     

    And this isthe  GPIO configuration MCU side:

     

     

      /*Configure GPIO pins : PBPin PBPin */
      GPIO_InitStruct.Pin = IMU_INT1_Pin|IMU_INT2_Pin;
      GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
      GPIO_InitStruct.Pull = GPIO_NOPULL;
      HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
    
      /* EXTI interrupt init*/
      HAL_NVIC_SetPriority(EXTI4_15_IRQn, 3, 0);
      HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);

     

     

     

    Thank you for helping
    Walter

    4 REPLIES 4

    sebmadgwick
    Established Member

    I suggest you connect the BMI270 INT pin to an oscilloscope to determine the actual data ready interrupt behaviour. It is not clear from your description if the issue is that the BMI270 is not asserting the interrupt or if the host not detecting the interrupt.

    Myzhar
    Established Member

    Hi sebmadgwick,

    the MCU should be correctly configured because I can receive interrupts from a BMI160 using the same parameters.
    I'm trying to understand if I'm doing it right with the BMI270 and I don't know if I'm missing something in the sensor configuration or if the parameters are wrong.

    The documentation is lacking and the no one example is about configuring interrupt features.

    Bests,
    Walter

    Myzhar
    Established Member

    I found the problem in my initialization code.
    The `data_int` parameter of the `bmi2_map_data_int` function must be `BMI2_DRDY_INT` to enable the data ready interrupt:

    	// Map data interrupt
    	rslt = bmi2_map_data_int( BMI2_DRDY_INT, BMI2_INT1, &bmi270_dev);
    	if (rslt != BMI2_OK)
    		goto exit;

     Bests,
    Walter

    Thanks for the feedback Myzhar!

     

    In case other members find themselves in a similar issue, always look at the comment block directly in the code of the sensor API. It *should* always include a description when specific values are required.

     

    In this case:

    /*!
     * @brief This API maps/un-maps data interrupts to that of interrupt pins.
     *
     * @param[in] int_pin      : Interrupt pin selected.
     * @param[in] data_int     : Type of data interrupt to be mapped.
     * @param[in] dev          : Structure instance of bmi2_dev.
     *
     * data_int             |  Mask values
     * ---------------------|---------------------
     * BMI2_FFULL_INT       |  0x01
     * BMI2_FWM_INT         |  0x02
     * BMI2_DRDY_INT        |  0x04
     * BMI2_ERR_INT         |  0x08
     *
     * @return Result of API execution status
     *
     * @retval BMI2_OK - Success.
     * @retval BMI2_E_NULL_PTR - Error: Null pointer error
     * @retval BMI2_E_COM_FAIL - Error: Communication fail
     * @retval BMI2_E_INVALID_INT_PIN -  Error: Invalid interrupt pin
     */
    int8_t bmi2_map_data_int(uint8_t data_int, enum bmi2_hw_int_pin int_pin, struct bmi2_dev *dev);

     

    The BMI2_GYRO definition is actually 0x01, which is FIFO full interrupt in this context.

    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