Skip to content

Main content

Microcontroller: DMA Circular Buffer End Address Tool

Compute exact half-open DMA buffer end and last used byte from explicit geometry, rejecting address-space overflow; empty buffers use base as unused last-byte witness.

Loading tool…

Description

Multiply elementCount by elementBytes using exact integers and add baseAddress.

Address calculations distinguish an occupied last byte from an exclusive end, and alignment rounds to a defined boundary. Element counts and byte counts are not interchangeable.

Multiply elementCount by elementBytes using exact integers and add baseAddress.

When to use this tool

Use Microcontroller: DMA Circular Buffer End Address when you need an explicit address, alignment, page, or transfer-count mapping.

How to use the tool and how it works

  1. Enter baseAddress, elementCount, elementBytes, addressBits. 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 result. Expand result to inspect the returned fields.

Multiply elementCount by elementBytes using exact integers and add baseAddress. Require endExclusive at most 2^addressBits; return the final byte address or baseAddress with empty true for zero elements.1

Input fieldMeaning and unitsAccepted input
baseAddressBase AddressRequired. Text. Implementation limit: 8192 Unicode code points and 16384 UTF-16 code units.
elementCountElement CountRequired. Safe integer.
elementBytesElement BytesRequired. Safe integer.
addressBitsAddress BitsRequired. Safe integer.
Output fieldInterpretationReturned shape
resultResultRequired. Object.
result.endExclusiveEnd boundary excluded from the represented span.Calculated result member: string.
result.lastByteAddressLast occupied byte address; equals baseAddress as a placeholder when empty is true.Calculated result member: string.
result.emptyWhether the represented collection or span has no occupied elements.Calculated result member: boolean.
json
{
  "input": {
    "baseAddress": "100",
    "elementCount": 4,
    "elementBytes": 2,
    "addressBits": 16
  },
  "output": {
    "result": {
      "endExclusive": "108",
      "lastByteAddress": "107",
      "empty": false
    }
  }
}

Limitations and assumptions

  • An exclusive end may equal the address-space limit. For an empty buffer, lastByteAddress is a placeholder and does not identify an occupied byte.
  • Outputs are nested inside result. 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

Validate the resulting span against actual memory bounds and device-specific access and transfer rules.

References

  1. Calculation and input contract: microcontroller/dma-circular-buffer-end-address — tool.io

Similar or alternative tools