Tutorials

LSM6DSOX FIFO Timestamps: Extend the Counter Across Rollover

Published · Updated

A burst arrives at the host in milliseconds even if it contains samples from several hundred milliseconds. Use the sensor time axis when a plot or integration depends on spacing.

Extend the counter before converting it to seconds

Red Pitaya acquisition board with analog connectors.
Red Pitaya acquisition board with analog connectors. Bench or board context. Photo by Geek3. Photo source · CC BY-SA 4.0

For consecutive raw 32-bit timestamps in the same sensor session, compute the unsigned modular difference first. A previous value of 0xFFFFFFF0 followed by 0x00000018 advances by 40 ticks. At the nominal 25 µs per tick, that is 1 ms. Accumulate the difference in a wider integer.

A 32-bit counter running at the nominal rate wraps after about 29.83 hours. The modular difference is unambiguous only when the elapsed interval is shorter than a full wrap and the sensor counter was not reset. Track startup and configuration events explicitly. A sensor reboot starts a new time segment. When absolute timing matters, apply the documented frequency correction or estimate drift against a measured reference.

Attach a timestamp to the right motion record

Previous tick 0xFFFFFFF0: Same sensor session. Next tick 0x00000018: 40 ticks modulo 2^32. 40 × 25 microseconds: 1 ms at nominal tick
Previous tick 0xFFFFFFF0: Same sensor session. Next tick 0x00000018: 40 ticks modulo 2^32. 40 × 25 microseconds: 1 ms at nominal tick.

Decode the FIFO timestamp records and use the placement rules in AN5272 to relate them to motion records. Preserve the batching-rate configuration and tag slot for that segment. When reconstructing intermediate time points, label them as interpolated. A newly read sample block can contain older records than the host interrupt time suggests.

Keep host arrival time separately. It helps measure interrupt and bus latency, while extended sensor ticks describe the recorded motion. Test three fixtures: a normal forward interval, the wrap example above and a reboot with the same two numerical readings. The first two should extend the session. The third should open a new segment with an explicit gap.

Record what happens when your interval plausibility limit is exceeded. A parser that silently discards the discontinuity leaves the plot looking continuous even though downstream velocity estimates may be unreliable.

Can the same modular calculation identify a sensor reboot?

It cannot distinguish a restart from a wrap on its own. Use a session boundary or corroborating reset/configuration evidence.

Show the three-step examplePrevious tick 0xFFFFFFF0: Same sensor session. Next tick 0x00000018: 40 ticks modulo 2^32. 40 × 25 microseconds: 1 ms at nominal tick

Previous tick 0xFFFFFFF0: Same sensor session. Next tick 0x00000018: 40 ticks modulo 2^32. 40 × 25 microseconds: 1 ms at nominal tick.

LSM6DSOX device documentation · nRF52840 host documentation · FIFO watermark and service-time budget · Motion logger project and storage worksheet · Check modular timestamps in a second implementation

Bring raw timestamp words, the sensor reset log, the batching configuration and host times from the same capture. Prepare an engineering review.

References

ST AN5272 Rev 5, timestamp and FIFO time correlation.

Back to Tutorials

Related evidence and next tasks

Continue the task with the relevant source scope. These reading paths do not establish interchangeability or current supply.

Source addresses and citation trail

Full source addresses are retained below. Read each citation with its document revision, page, table and applicability conditions above.

  1. https://commons.wikimedia.org/wiki/File:RedPitaya_STEMLab_FPGA_v1.1_topview.jpg
  2. https://creativecommons.org/licenses/by-sa/4.0
  3. https://www.st.com/resource/en/application_note/an5272-lsm6dsox-alwayson-3d-accelerometer-and-3d-gyroscope-stmicroelectronics.pdf