The TI MSP430F20XX series has a 12-bit internal ADC output, which is right-justified.

What is the difference between a left-justified output and a right-justified output? What are their pros and cons?


On this processor, the register that holds the conversion result is 16 bits wide.

A right-justified result means that bits [(N-1):0] (where N is the number of bits of precision) of the register contain the ADC value and the most-significant bits of the register are set to zero.

A left-justified result means that bits [15:(16-N)] of the register hold the result, and bits [(15-N):0] are set to zero.

For example, if your actual conversion result is 0x123, it would be read as 0x0123 if the register was right-justified, and as 0x1230 if it was left-justified.

An advantage of left-justified results (on processors that support it) is that you can take just the most-significant byte of the register, giving you 8-bits of precision instead of the native precision. This can be useful if you don't need the extra precision, or have RAM constraints and want to store a large number of samples.

On the other hand, a right-justified value can be used directly without the scaling that a left-justified value would need.

  • $\begingroup$ I know this might sound a bit stupid but if it is right justified, but can't you just take the lower byte and end up at the same place? $\endgroup$ – Balázs Börcsök May 28 at 18:06
  • $\begingroup$ The OP was asking about a 12-bit ADC; if you take the lower byte of a right-justified value, you're throwing away the 4 most significant bits of the ADC result. You'd need to right shift the ADC result by four bits, then take the lower byte. $\endgroup$ – Niall C. May 28 at 18:31
  • $\begingroup$ Do I understand it right that the 12-bit ADC result is always stored in the 16-bit register and left shitfing than taking the upper byte would mean that we took the bits 12. to 5. bits of the ADC results in your example? I'm kinda in the dark here. Thanks for the answer. $\endgroup$ – Balázs Börcsök May 29 at 10:36
  • $\begingroup$ That's more or less correct, except that bits are usually numbered from 0 (the LSB) to N-1 (the MSB), not 1 to N. In the case of the 12-bit result in the OP's question, it's in bits [11:0] of the 16-bit ADC result register. If you left shift by 4 bits, then drop the lower byte, you're effectively taking bits [11:4] of the original result. $\endgroup$ – Niall C. May 29 at 15:07
  • $\begingroup$ I see thanks for the explanation :) ! $\endgroup$ – Balázs Börcsök May 31 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.