LSM6DSOX FIFO Overruns: Set the Watermark From Your Drain Time

Adafruit LSM6DSOX six-degree-of-freedom inertial sensor breakout

An LSM6DSOX FIFO watermark is not just a convenient batch size. It must leave enough unused capacity for the host’s worst interrupt latency and the time needed to transfer queued words. If either interval is underestimated, continuous mode starts discarding the oldest data.

The sensor has up to 9 KB of FIFO storage. Each reported FIFO word contains one tag byte and six data bytes, while the unread count is reported through DIFF_FIFO[9:0]. Count tagged words, not raw accelerometer axes.

Start with the aggregate batch rate

Accelerometer and gyroscope samples can be batched at independent rates. If both are stored at 104 Hz, the FIFO receives about 208 tagged words per second. At seven bytes per word, that is about 1,456 bytes per second before timestamps, temperature, step-counter or sensor-hub data are added.

Adafruit LSM6DSOX breakout board with its inertial sensor and interface pins
Image: Adafruit.

A watermark of 104 words would therefore represent about 0.5 seconds of accelerometer-plus-gyroscope history in that configuration. The same numeric watermark covers only about 0.125 seconds when both streams are batched at 416 Hz. The threshold has no fixed time meaning until every enabled batch source is included.

Reserve words for latency and drain time

Let R be the aggregate incoming rate in FIFO words per second, L the worst delay before the service routine starts, and D the time to transfer and process the selected batch. A minimum headroom estimate is R × (L + D), plus margin for scheduling jitter and any additional batched source.

At 208 words/s, 40 ms of worst-case scheduling latency and 20 ms of drain time consume about 12.5 words. A 104-word watermark therefore needs at least 13 free words after the threshold, and more if logging or radio activity can block the bus longer. Measure the real service interval rather than substituting the task’s nominal period.

Rear view of the Adafruit LSM6DSOX breakout and its address and interface pads
Image: Adafruit.

The transfer term should include bus overhead. Reading 104 seven-byte words moves 728 payload bytes, not counting register addressing and transaction overhead. At 400 kbit/s I2C, the payload alone has a theoretical wire time of roughly 14.6 ms before acknowledgements, starts, stops and software delays. A short polling interval does not make that transfer instantaneous.

Read status in a consistent order

The programmable threshold occupies WTM[8:0] in FIFO_CTRL1 and FIFO_CTRL2. FIFO_STATUS1 and FIFO_STATUS2 report the unread count, watermark, full and overrun conditions. When block-data update is enabled, ST says firmware must read FIFO_STATUS1 before FIFO_STATUS2 so the paired status is coherent.

Route the watermark event to INT1 or INT2 if the host supports interrupts, but keep overrun monitoring enabled in software. A missed edge or delayed task can still leave the FIFO above threshold. The status flag is the evidence that at least one oldest sample was overwritten.

Choose the overwrite policy deliberately

In continuous mode, new data replaces the oldest data after capacity is exhausted. That behavior preserves the most recent motion window but breaks a gap-free log. FIFO mode stops accepting new words when full, preserving the earlier window at the cost of losing later motion. Continuous-to-FIFO and bypass-to-continuous modes support trigger-oriented captures with different pre-event behavior.

For streaming, select a watermark that fits a bounded transfer, reserve measured headroom, drain complete tagged words and record every overrun. For event capture, choose the mode according to whether pre-trigger or post-trigger history matters. The watermark then expresses a time budget that can be verified on the target MCU and bus.

Sources

About TVG Editorial Team

TVG Report editorial coverage for robotics, AI, maker hardware, automation, and STEM technology.

View all posts by TVG Editorial Team →

Leave a Reply

Your email address will not be published. Required fields are marked *