Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Problem BHI160b Shuttle Board with STM32

    Problem BHI160b Shuttle Board with STM32

    malekattia
    New Poster

    I am working on the BHI160B shuttle board connected to an STM32F411.I am working on this example(BHI160B_ReferenceCode) I have integrated the library into my STM project. The next step was to modify the read/write operations in the bhy_support.c driver file as follows:

    int8_t sensor_i2c_write(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size){
    	HAL_I2C_Mem_Write(&hi2c1, (uint16_t) addr, (uint16_t) reg, I2C_MEMADD_SIZE_8BIT, p_buf, size,HAL_MAX_DELAY);
    }
    int8_t sensor_i2c_read(uint8_t addr, uint8_t reg, uint8_t *p_buf, uint16_t size){
    	HAL_I2C_Mem_Read(&hi2c1, (uint16_t) addr, (uint16_t) reg,I2C_MEMADD_SIZE_8BIT,p_buf, size, HAL_MAX_DELAY);
    
    }

     

    I connected the Shuttle Board to my NUCLEO board like this:

    malekattia_1-1697703817855.png

    ___J1___|___NUCLEO___
       1/2  |    3.3V
        3   |    GND
       17   |    PB7 -> I2C1_SCL
       18   |    PB6 -> I2C1_SDA ​

     

    The problem occurs during initialization, specifically within the "bhy_init" function, when attempting to read (BHY_BUS_READ_FUNC) the BHY_I2C_REG_PRODUCT_ID_ADDR register (0x90). It gets stuck in the HAL function (HAL_StatusTypeDef I2C_WaitOnMasterAddressFlagUntilTimeout).

     

    BHY_RETURN_FUNCTION_TYPE bhy_init(struct bhy_t *bhy)
    {
        /* variable used for return the status of communication result*/
        BHY_RETURN_FUNCTION_TYPE com_rslt = BHY_COMM_RES;
        u8 v_data_u8 = BHY_INIT_VALUE;
        /* assign bhy ptr */
        p_bhy = bhy;
        com_rslt =
        p_bhy->BHY_BUS_READ_FUNC(p_bhy->device_addr,
        BHY_I2C_REG_PRODUCT_ID_ADDR,
        &v_data_u8, BHY_GEN_READ_WRITE_LENGTH);
        /* read product Id */
        p_bhy->product_id = v_data_u8;
        return com_rslt;
    }

     

    malekattia_2-1697707113344.png

     


    3 REPLIES 3

    BSTRobin
    Community Moderator
    Community Moderator

    Hi malekattia,

    Pin 15(SA_GPIO7) of BHI160B shuttle board 2.0 should be connected to GND or VDDIO to determine whether the I2C device address of BHI160B is 0x28 or 0x29.

    I upload BHI160B example code on STM32F401 for your reference. You can migrate it to your STM32 and run it.

    Thank you, BSTRobin, for your response.
    I've read the I2C address of my BHI160B shuttle board 3.0 is 0x29 ( my sensor is version 3, I connected it using GPIO 4 https://www.bosch-sensortec.com/media/boschsensortec/downloads/shuttle_board_flyer/application_board...

    adresse_i2c_bhi160b_Eval.png

     but the same issue still persists.
    The problem occurs during initialization, specifically within the "bhy_init" function, when attempting to read (BHY_BUS_READ_FUNC) the BHY_I2C_REG_PRODUCT_ID_ADDR register (0x90). It gets stuck in the HAL function (HAL_StatusTypeDef I2C_WaitOnMasterAddressFlagUntilTimeout).

    BSTRobin
    Community Moderator
    Community Moderator

    Hi malekattia,

    You can strictly refer to previous attached example code as it also run on STM32F4.

    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