Circular Buffer Index

Wrap a signed offset around a zero-based circular buffer without changing the stored head index.

Description

Wrap a signed offset around a zero-based circular buffer without changing the stored head index.

Circular Buffer Index: Wrap a signed offset around a zero-based circular buffer without changing the stored head index.

When to use Circular Buffer Index

Use this embedded-systems calculation to configure or check a timer, serial bus, ADC, PWM, buffer, power mode, flash budget, or watchdog from known clock and device parameters.

Head Index
Required integer input.
Offset
Required integer input.
Capacity
Required integer input.

How Circular Buffer Index works

Wrap a signed offset around a zero-based circular buffer without changing the stored head index. The tool evaluates the supplied inputs together and returns the named outputs below; it does not infer omitted operating conditions or change the units shown.1

Wrapped Index
The resulting wrapped index returned as an integer.

Limitations and assumptions

  • Register widths, clock trees, prescalers, oscillator tolerance, interrupt latency, peripheral modes, voltage references, quantization, sleep states, endurance conditions, and silicon errata are device-specific.
  • Use finite inputs in the displayed units and preserve more precision than the final presentation requires. Independently verify safety-critical, financial, compliance, or production decisions.

Alternative or Complementary approaches

Confirm equations against the exact datasheet and reference manual, derive register values with integer rounding visible, and verify timing or voltage on hardware.

References

  1. Microcontroller — Wikipedia contributors

Similar or alternative tools

  • Timer Overflow Period

    Overflow interval for a free-running N-bit timer with a zero-based counter. Prescaler is the effective clock divisor, not necessarily the raw register value.

  • PWM Duty Count

    Nearest PWM active-tick count for a target duty fraction over an inclusive zero-to-period-register timer cycle.

  • ADC Code To Voltage

    Ideal unipolar endpoint-inclusive ADC code-to-voltage conversion, where the maximum code maps to Vref.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies