A robot controller can pass repeated short tests and still mishandle a timeout after long uptime. One candidate is a finite-width tick counter crossing its maximum value and returning to zero. The scheduler may handle that correctly while application code comparing raw timestamps does not.

The useful distinction is between elapsed-time arithmetic, timestamp ordering and clock discontinuities. They are not the same problem, even when all three appear as an unexpected timeout.

### A small counter exposes the mechanism

Consider a deliberately simplified eight-bit tick counter, with values from 0 to 255. A wait starts at tick 250 and should last 10 ticks, so its stored deadline wraps to 4. A naive unsigned comparison of `now >= deadline` is already true at tick 251, even though only one tick has elapsed.

Modular elapsed-time arithmetic gives a different answer: the difference between 251 and 250 is 1 tick, and the wrapped difference between 4 and 250 is 10 ticks. This is an arithmetic illustration, not a recommendation to substitute an eight-bit clock into a running controller.

For an N-bit counter running at f ticks per second, the wrap period is `2^N / f`. The width and actual tick frequency therefore matter more than the variable name or the assumed uptime scale.

### Define the interval over which the comparison is valid

Unsigned subtraction in the intended counter-width domain can support elapsed-time checks across a wrap, but it cannot reveal how many complete counter periods have passed without additional information. If monitoring can stall across an entire period, two raw samples are insufficient.

Ordering arbitrary wrapped timestamps introduces additional range assumptions. Familiar signed-difference tricks should not be copied without checking half-range restrictions, language conversions and the target compiler's behaviour. Signed overflow is not a portable substitute for intentionally modular unsigned arithmetic.

A wider counter extends the interval but does not remove interface problems. A wide timestamp read non-atomically on a narrower processor can also be inconsistent. Tick-to-time conversion, intermediate arithmetic and serialisation fields deserve the same width audit as the original timer.

### Prefer documented timing facilities where they fit

The [FreeRTOS V10 reference manual](https://www.freertos.org/media/2018/FreeRTOS_Reference_Manual_V10.0.0.pdf), for example, documents `xTaskCheckForTimeOut()` together with `vTaskSetTimeOutState()` for adjusting repeated blocked waits while accounting for tick overflows. That is a versioned API example, not a claim that a particular kernel version or custom watchdog configuration is correct without review.

Use the installed platform's documented timing APIs and contracts where appropriate. An application timeout is also not proof of an independent protective function or of the robot's actual stopped state.

### Test the boundary without waiting for real uptime

A software clock abstraction can place unit tests just before wrap while leaving the live scheduler and hardware clock untouched. Include immediately-before, exactly-at and immediately-after expiry cases on both sides of zero. Also test delayed checking, repeated partial waits, counter reset and suspend/resume semantics.

Record raw ticks, clock domain, counter width, conversion scale and the computed elapsed value in the diagnostic capture. A device reboot or timebase reset must not be mistaken for an ordinary wrap; session or reset information may be needed to distinguish them.

**Open engineering question:** which test crosses your application's tick boundary deliberately, and what documented maximum interval makes its elapsed-time and timestamp-ordering rules unambiguous?