Skip to content

Main content

ADC Code Left Alignment Register Mask Tool

Compute adc code left alignment register mask from explicit bounded inputs.

Loading tool…

Description

Multiply code by 2^(registerBits - bits) to left-align it; apply the same shift to an all-ones code mask.

A register mask selects bits within a fixed width. Read-clear and write-one-to-clear semantics describe state transitions that differ from ordinary assignment.

Multiply code by 2^(registerBits - bits) to left-align it; apply the same shift to an all-ones code mask.

When to use this tool

Use ADC Code Left Alignment Register Mask when you need a deterministic fixed-width field or register-state calculation.

How to use the tool and how it works

  1. Enter code, bits, registerBits. 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 registerValue, mask. Use the output convention below.

Multiply code by 2^(registerBits - bits) to left-align it; apply the same shift to an all-ones code mask.1

Input fieldMeaning and unitsAccepted input
codeCodeRequired. Safe integer; minimum 0.
bitsBitsRequired. Safe integer; minimum 1.
registerBitsRegister BitsRequired. Safe integer; minimum 1; maximum 32.
Output fieldInterpretationReturned shape
registerValueRegister ValueRequired. Finite number.
maskMaskRequired. Finite number.
json
{
  "input": {
    "code": 3,
    "bits": 4,
    "registerBits": 8
  },
  "output": {
    "registerValue": 48,
    "mask": 240
  }
}

Limitations and assumptions

  • Only numeric field placement is modeled; other register bits, access widths, and hardware side effects are not included.
  • 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

Use the device's access semantics and account for concurrent hardware changes before applying a register operation.

References

  1. Calculation and input contract: microcontroller/adc-code-left-alignment-register-mask — tool.io

Similar or alternative tools