Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is right or left alignment of data in ADC? #2

Open
mucahitdemir opened this issue Jun 20, 2022 · 0 comments
Open

What is right or left alignment of data in ADC? #2

mucahitdemir opened this issue Jun 20, 2022 · 0 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@mucahitdemir
Copy link
Owner

mucahitdemir commented Jun 20, 2022

Alignment determines how the binary will end up in the hardware register. Suppose you have a 16 bit resolution register (or 2x8 bits) but only 12 bit ADC resolution. Your option is then either to get:

XXXX DDDD DDDD DDDD

or

DDDD DDDD DDDD XXXX

Where "D" is your data bits and "X" is "don't care" bits (usually filled with zeroes). The form requiring the least amount of bitwise arithmetic to get to your desired format is usual the preferred one. One will contain the need to shift, the other won't.

This in turn depends on endianess - the byte order. If the ADC is using the same endianess as your CPU then you'd pick the one matching best. In case of STM32 little endian that probably means the 2nd of the two forms. Built-in ADCs in microcontrollers typically have the same endianess as the CPU. In case of external ones, it could have either big or little endian.
Source: electronics.stackexchange

@mucahitdemir mucahitdemir self-assigned this Jun 20, 2022
@mucahitdemir mucahitdemir added the documentation Improvements or additions to documentation label Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant