Skip to content

Main content

Microcontroller: DMA Element Count Vs Byte Count Tool

Crosswalk a DMA byte budget to complete fixed-size elements while retaining remainder evidence rather than truncating silently.

Loading tool…

Description

Divide byteCount by bytesPerElement for completeElements and remainingBytes.

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.

Divide byteCount by bytesPerElement for completeElements and remainingBytes.

When to use this tool

Use Microcontroller: DMA Element Count Vs Byte Count when you need an explicit address, alignment, page, or transfer-count mapping.

How to use the tool and how it works

  1. Enter byteCount, bytesPerElement. 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.

Divide byteCount by bytesPerElement for completeElements and remainingBytes. Set exactElementCount when the remainder is zero.1

Input fieldMeaning and unitsAccepted input
byteCountByte CountRequired. Safe integer.
bytesPerElementBytes Per ElementRequired. Safe integer.
Output fieldInterpretationReturned shape
resultResultRequired. Object.
result.completeElementsComplete ElementsCalculated result member: number.
result.remainingBytesRemaining BytesCalculated result member: number.
result.exactElementCountExact Element CountCalculated result member: boolean.
json
{
  "input": {
    "byteCount": 10,
    "bytesPerElement": 4
  },
  "output": {
    "result": {
      "completeElements": 2,
      "remainingBytes": 2,
      "exactElementCount": false
    }
  }
}

Limitations and assumptions

  • Units are bytes and elements; this does not check a DMA register's count encoding or memory alignment.
  • 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-element-count-vs-byte-count — tool.io

Similar or alternative tools