Skip to content

Main content

Timer Compare Wrap Latency Budget Tool

Modular compare horizon and strict latency slack under an explicit equality policy.

Loading tool…

Description

Compute the forward modular distance from counter to compare.

Timer formulas depend on whether endpoints are inclusive, the count direction, prescaling, and wrap behavior. A counter reading alone cannot reveal an arbitrary number of elapsed wraps.

Compute the forward modular distance from counter to compare.

When to use this tool

Use Timer Compare Wrap Latency Budget when you need a timer period, wrap delta, or explicit count-budget term.

How to use the tool and how it works

  1. Enter counter, compare, modulus, latencyTicks, equalMeansNextCycle. Use the units and conventions below.
  2. Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
  3. Read ticksUntil, margin, reachableBeforeCompare. Inspect reachableBeforeCompare before interpreting the associated values.

Compute the forward modular distance from counter to compare. At equality, optionally use one whole modulus instead of zero. Subtract latencyTicks for margin and require strict positive margin for reachableBeforeCompare.1

Input fieldMeaning and unitsAccepted input
counterCounterRequired. Safe integer; minimum 0.
compareCompareRequired. Safe integer; minimum 0.
modulusModulusRequired. Safe integer; minimum 1.
latencyTicksLatency TicksRequired. Safe integer; minimum 0.
equalMeansNextCycleEqual Means Next CycleRequired. Boolean.
Output fieldInterpretationReturned shape
ticksUntilTicks UntilRequired. Safe integer.
marginMarginRequired. Safe integer.
reachableBeforeCompareReachable Before CompareRequired. Boolean.
json
{
  "input": {
    "counter": 250,
    "compare": 5,
    "modulus": 256,
    "latencyTicks": 3,
    "equalMeansNextCycle": false
  },
  "output": {
    "ticksUntil": 11,
    "margin": 8,
    "reachableBeforeCompare": true
  }
}

Limitations and assumptions

  • Equality with the latency budget fails the strict margin test; actual interrupt and synchronization timing are not modeled.
  • Inputs must satisfy both the field types and the cross-field conditions above. Invalid input causes an error; a successful false flag or documented placeholder is a different result.
  • Numeric calculations use binary floating point unless exact decimal-integer arithmetic is explicitly stated. No hidden measurement tolerance or decimal rounding is added; nonfinite or out-of-contract results are rejected. Numeric signed-zero results are exported as zero.

Alternative or Complementary methods

Check the timer mode and register semantics in the device documentation, including synchronization and latency.

References

  1. Calculation and input contract: microcontroller/timer-compare-wrap-latency-budget — tool.io

Similar or alternative tools