2023-07-24 12:17 PM - edited 2023-07-24 12:19 PM
Hi,
I'm working with a LSM6DS3TR-C.
Currently I've a working app where I configure a FIFO threshold for accel, gyro and timestamp data, and a THS interrupt in INT1.
Once the interrupt occurs, I can read all the patterns, one at a time like this:
#define PATTERN_LEN_WORDS 9
lsm6ds3tr_c_fifo_data_level_get(&stmdev_ctx, &fifo_data_level);
uint16_t num_pattern = fifo_data_level / PATTERN_LEN_WORDS;
while (num_pattern--)
{
lsm6ds3tr_c_fifo_raw_data_get(&stmdev_ctx, buff, 18);
}
This code is working OK, I can do num_pattern i2c reads of 18 bytes each (9 words).
However, I wanted to somehow optimize the i2c reading, and read all patterns at one go:
#define PATTERN_LEN_WORDS 9
lsm6ds3tr_c_fifo_data_level_get(&stmdev_ctx, &fifo_data_level);
uint16_t num_pattern = fifo_data_level / PATTERN_LEN_WORDS;
lsm6ds3tr_c_fifo_raw_data_get(&stmdev_ctx, buff, num_pattern*18);
But the above code is not working correctly.
Do I have to read at most one pattern at a time from the FIFO output registers?
Thanks,
Martxel
2023-07-28 05:16 AM
Hi @Martxel ,
Welcome to ST Community!
Have a look at our PID examples where you can find how to implement multi read from FIFO.
If this helps you, please mark my answer as "Best Answer" by clicking on the "Accept as Solution" button, this can be helpful for Community users to find this solution faster.