Skip to content

Main content

Timer Capture Counter Wrap Delta Tool

Compute timer capture counter wrap delta from explicit bounded inputs.

Loading tool…

Description

Compute (current - previous) modulo 2^width and mark wrapped when current is numerically smaller.

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 (current - previous) modulo 2^width and mark wrapped when current is numerically smaller.

When to use this tool

Use Timer Capture Counter Wrap Delta when you need a timer period, wrap delta, or explicit count-budget term.

How to use the tool and how it works

  1. Enter previous, current, width. 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 ticks, wrapped. Inspect wrapped before interpreting the associated values.

Compute (current - previous) modulo 2^width and mark wrapped when current is numerically smaller.1

Input fieldMeaning and unitsAccepted input
previousPreviousRequired. Safe integer; minimum 0.
currentCurrentRequired. Safe integer; minimum 0.
widthWidthRequired. Safe integer; minimum 1; maximum 32.
Output fieldInterpretationReturned shape
ticksTicksRequired. Finite number.
wrappedWrappedRequired. Boolean.
json
{
  "input": {
    "previous": 250,
    "current": 5,
    "width": 8
  },
  "output": {
    "ticks": 11,
    "wrapped": true
  }
}

Limitations and assumptions

  • Only the within-modulus delta is recovered; complete extra wraps cannot be detected from two samples.
  • 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-capture-counter-wrap-delta — tool.io

Similar or alternative tools