Skip to content

fifoClear is break #36

Description

@Lucasmm016

When configuring the LSM6DS3 accelerometer sample rate to 6660 Hz and the FIFO sample rate to 6600 Hz, then attempting to use the fifoClear() function, the code gets stuck.

This probably happens because the fifoClear() function does not actually reset the FIFO. Instead, it tries to drain it by reading word-by-word through repeated calls to fifoRead(), while new data continues to arrive. Basically, fifoRead() cannot drain the FIFO faster than new samples are being written into it, so it never reaches FIFO_EMPTY.

The correct solution may be to avoid clearing the FIFO by draining it while in continuous mode. One idea would be to switch the FIFO to bypass mode to reset it, then enable continuous mode again afterward.

The board used for testing is the MG24 Sense.

Example to reproduce the issue:

myIMU.settings.accelEnabled = 1;
myIMU.settings.accelRange = 16;
myIMU.settings.accelSampleRate = 6660; // <--- 6660hz
myIMU.settings.accelBandWidth = 400;
myIMU.settings.accelFifoEnabled = 1;
myIMU.settings.accelFifoDecimation = 1;

myIMU.settings.gyroEnabled = 0;
myIMU.settings.gyroFifoEnabled = 0;
myIMU.settings.gyroFifoDecimation = 0;

myIMU.settings.timestampEnabled = 0;
myIMU.settings.timestampFifoEnabled = 0;
myIMU.settings.timestampResolution = 0;

myIMU.settings.fifoThreshold = 240;
myIMU.settings.fifoSampleRate = 6600; // <--- 6600hz
myIMU.settings.fifoModeWord = 6;

myIMU.settings.commMode = 1;

if (myIMU.begin() != 0) {
    Serial.println("Device error");
    while (1);
  }

myIMU.fifoBegin();
myIMU.fifoClear(); // <--- BREAK!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions