Bosch Sensortec Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    Problem BHI160b Shuttle Board 3.0 with STM32

    Problem BHI160b Shuttle Board 3.0 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, and I have determined that the I2C address of my BHI160B shuttle board 3.0 is 0x29. 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:

     

    ___J1___|___NUCLEO___
       1/2  |    3.3V
        3   |    GND
       2   |    PB7 -> I2C1_SCL
       4   |    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_0-1699342211735.png

     

    1 REPLY 1

    BSTRobin
    Community Moderator
    Community Moderator

    Hi malekattia,

    According your description, can you check if pin 9(SA_GPIO7) of BHI160B is connected to a high level(you used BHI160B address 0x29) after being powered on? Is pin 23(SCK) and pin 24(SDA) connected to a pull-up resistor?
    And make sure you strictly refer to example code(BHI160B_ReferenceCode).

    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