10-19-2023 11:22 AM
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:
___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;
}
10-22-2023 02:55 AM
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.
10-24-2023 03:22 PM
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...
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).
11-28-2023 06:17 AM
Hi malekattia,
You can strictly refer to previous attached example code as it also run on STM32F4.