06-24-2021 04:28 PM - edited 06-24-2021 04:30 PM
Hi There:
I'm working with the driver from Github, trying to capture just Accelerometer data from the FIFO in headerless mode, and I've noticed that in the current driver code it's not possible to place the BMI160 into headerless mode. Thee problem is in bmi160_set_fifo_config() on line 2248: data |= fifo_config;
rslt = bmi160_get_regs(reg_addr, &data, BMI160_ONE, dev);
if (rslt == BMI160_OK)
{
if (fifo_config > 0)
{
if (enable == BMI160_ENABLE)
{
data = data | fifo_config; //Problem is on this line
}
else
{
data = data & (~fifo_config);
}
}
/* write fifo frame content configuration*/
rslt = bmi160_set_regs(reg_addr, &data, BMI160_ONE, dev);
As shown in the code above, the configuration that gets sent to the BMI FIFO register is an OR of the current configuration and the incoming fifo_config requested. Since Headerless mode is achieved by clearing a bit that is set by default, we can never actually clear this bit. My proposed woraround is to always use the unaltered incoming config without the logical OR of the previously set state:
data = fifo_config;
This will require to user to set the expected configuration on every FIFO config change, but I don't think that's too much to ask.
thanks
Dan
06-24-2021 05:14 PM
Hello dtang,
Before FIFO configuring FIFO, you could clear FIFO coonfiguration register with following code.
/* Clear FIFO configuration register */
rslt = bmi160_set_fifo_config(BMI160_FIFO_CONFIG_1_MASK, BMI160_DISABLE, dev);
06-24-2021 05:18 PM - edited 06-24-2021 05:19 PM
Thanks for this approach
Is this documented somewhere that I missed?
06-25-2021 08:59 AM
Hello dtang,
This part of the code is to clear the register value, refer to the register bit of the data sheet.
06-25-2021 03:00 PM
I understand how to clear the register bit, I'm just not certain if the solution you provided is a workaround to a bug, or is the proper, documented approach. I need to be able to comment my code accordingly. thanks!
Dan