07-26-2021 10:58 AM
Hello
We're developing board using BHI160B with STM32 MCU.
My code and firmware is based on the driver and examples.
Driver : https://github.com/BoschSensortec/BHy1_driver_and_MCU_solution
We were able to upload and check firmware, then we can read interrupt signal and data once.
After that, there is no interrupt signal nor data from the sensor.
We've done some test and found out there's no pullup resistor for aux I2C port, but adding them made no difference.
It seems there's no signal from aux I2C port at all.
Here's our test code snippet.
/* Wait for IMU is powered on. */
while(!Dev_IMU_CheckIntSignal());
/* put callbacks. */
bhy_install_meta_event_callback(BHY_META_EVENT_TYPE_INITIALIZED, meta_event_callback);
bhy_install_meta_event_callback(BHY_META_EVENT_TYPE_SELF_TEST_RESULTS, meta_event_callback);
/* initialize the bhy chip */
if(bhy_driver_init(&bhy1_fw))
{
DEBUG("Fail to init bhy\n");
for(;;){}
}
/* Wait for IMU interrupt pin triggers. */
while(Dev_IMU_CheckIntSignal());
while(!Dev_IMU_CheckIntSignal());
/* Enables a streaming sensor. The goal here is to generate data */
/* in the fifo, not to read the sensor values. */
int dbg;
dbg = bhy_enable_virtual_sensor(VS_TYPE_ROTATION_VECTOR, VS_NON_WAKEUP, FIFO_SAMPLE_RATE, 1000, VS_FLUSH_NONE, 0, 0);
/* empty the fifo for a first time. the interrupt does not contain sensor data */
bhy_read_fifo(fifo, FIFO_SIZE, &bytes_read, &bytes_remaining);
/* Sets the watermark level */
bhy_set_fifo_water_mark(BHY_FIFO_WATER_MARK_NON_WAKEUP, 800);
while (1)
{
/* Wait until IMU releases interrupt signal. */
if(Dev_IMU_CheckIntSignal() || bytes_remaining)
{
bhy_read_fifo(fifo + bytes_left_in_fifo, FIFO_SIZE - bytes_left_in_fifo, &bytes_read, &bytes_remaining);
bytes_read += bytes_left_in_fifo;
fifoptr = fifo;
packet_type = BHY_DATA_TYPE_PADDING;
do
{
/* this function will call callbacks that are registered */
result = bhy_parse_next_fifo_packet(&fifoptr, &bytes_read, &fifo_packet, &packet_type);
/* prints all the debug packets */
if (packet_type == BHY_DATA_TYPE_DEBUG)
{
bhy_print_debug_packet(&fifo_packet.data_debug, bhy_printf);
}
/* the logic here is that if doing a partial parsing of the fifo, then we should not parse */
/* the last 18 bytes (max length of a packet) so that we don't try to parse an incomplete */
/* packet */
} while ((result == BHY_SUCCESS) && (bytes_read > (bytes_remaining ? 18 : 0)));
bytes_left_in_fifo = 0;
if (bytes_remaining)
{
/* shifts the remaining bytes to the beginning of the buffer */
while (bytes_left_in_fifo < bytes_read)
{
fifo[bytes_left_in_fifo++] = *(fifoptr++);
}
}
}
HAL_Delay(1);
}
Regards,
Bae
07-26-2021 11:55 AM
Hello MintaeBae,
You could try to use the way of reading interrupt register.
while(!bhi160b_get_int_status());
int bhi160b_get_int_status()
{
uint8_t value;
bhy_read_reg(BHY_I2C_REG_INT_STATUS_ADDR, &value, 1);
return(value&0x01);
}
07-27-2021 02:29 AM
It does not work.Always reads zero.
08-13-2021 10:49 AM