Tutorials
LSM6DSOX FIFO Tags: Decode a Seven-Byte Word Before Pairing Axes
Published · Updated
A parser that treats every fourteen bytes as one accelerometer/gyro pair can appear correct until a timestamp enters the FIFO. Start with a seven-byte record and dispatch on the tag.
Read the tag as a bit field

The first byte contains the sensor ID in bits 7:3, the time-slot counter in bits 2:1 and parity in bit 0. Shift the raw byte right by three before comparing it with the sensor IDs. In uncompressed operation, 0x01 identifies gyroscope data, 0x02 identifies accelerometer data, and 0x04 identifies a timestamp. The two-bit slot counter wraps and cannot identify a record across a gap by itself.
Read whole seven-byte records beginning at FIFO_DATA_OUT_TAG. The six following bytes have a meaning that depends on the ID. Keep the raw tag in your capture log. A parity failure flags the tag, while a valid tag does not verify the six payload bytes.
Test the parser with a deliberately mixed stream

Use the synthetic word 11 34 12 FE FF 00 80. Its tag has even parity, ID 2 and slot zero. Interpret each little-endian axis as signed: X = 4660, Y = −2 and Z = −32768. An unsigned decoder gives 65534 for Y. Follow it with a timestamp record and then a gyro record in your test fixture.
sensor_id = tag >> 3
slot = (tag >> 1) & 3
parity_ok = tag.bit_count() % 2 == 0Count unexpected tags and reject a partial trailing word. If a bus transfer stops mid-record, establish the device read boundary using its documented procedure before accepting new data. Compressing FIFO output requires separate decoders for its additional tags. Validate the uncompressed parser first.
The raw tag is 0x11. Is the sensor ID 0x11?
No. Bits 7:3 give ID 2, the uncompressed accelerometer. Keep the low bits for slot and parity checks.
Show the three-step example

Raw tag 0x11: ID 2 / slot 0 / even parity. First two axis bytes 34 12: X = 4660 signed counts. Next four bytes FE FF 00 80: Y = -2 / Z = -32768.
LSM6DSOX device documentation · nRF52840 host documentation · FIFO watermark and service-time budget · Motion logger project and storage worksheet · Verify signed code interpretation
Bring a hex dump containing at least one accel, gyro and timestamp record, plus the FIFO configuration readback. Prepare an engineering review.
References
Back to Tutorials