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
- Enter code, bits, registerBits. Use the units and conventions below.
- Run the tool. Correct any format, range, or cross-field input error before interpreting the output.
- 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 field | Meaning and units | Accepted input |
|---|---|---|
| code | Code | Required. Safe integer; minimum 0. |
| bits | Bits | Required. Safe integer; minimum 1. |
| registerBits | Register Bits | Required. Safe integer; minimum 1; maximum 32. |
| Output field | Interpretation | Returned shape |
|---|---|---|
| registerValue | Register Value | Required. Finite number. |
| mask | Mask | Required. Finite number. |
{
"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
Similar or alternative tools
- Register Field Reset Value Extractor
Validate field offset and length within a 1-128-bit resetWord.
- Microcontroller: ADC Differential Midcode Offset
Subtract 2^(bits - 1) from offsetBinaryCode for signedCode, with code bounded by the selected 1-24-bit width.