There are two things that confuses me in the below text:

"The ADC uses the successive-approximation method to perform the conversion.The HCS12 uses two 8-bit registers to hold a ananlog to digital conversion result. The result can be stored either right- or left-justified. The A/D conversion is performed in a sequence from one to eight samples."

1- I always thought that registers are storage locations in the CPU. So ADCs would have their own registers too?

2- What are the functionality and meaning of the right- or left-justified registers?

I always thought that registers are storage locations in the CPU. So ADCs would have their own registers too?

Registers can be storage locations in any device. You'll find the in ADCs, accelerometers, EEPROMs, etc.

What are the functionality and meaning of the right- or left-justified registers?

This implies that the result is less than the 16 bits allocated to it. Suppose the ADC produces a 12 bit result. In the left justified case, it would be shifted to the so the MSB is in the MSB of the 16 bit space, like so:

16         |3|2|1|0
MSB|...|LSB|X|X|X|X


Right justified is the reverse, where the LSB is in the LSB of the 16 bit space.

16|15|14|13|12 |   |0
X | X| X| X|MSB|...|LSB

• Thank you. So can I ask another question?..in the three registers of right-justified unsigned, left-justified signed, and left-justified unsigned.What role unsigned and signed part play? – Jack Oct 1 '15 at 13:00
• Unsigned is straight binary. Signed will be 2's complement, sign extended, so the don't care bits become sign extension. – Matt Young Oct 1 '15 at 14:04

1 - The ADC is given a spot in the same memory the CPU uses to park its result. It isn't a separate chunk of memory. Same memory, reserved location. 2 - In an 8 bit CPU, memory comes in groups of 8 bits. I presume your ADC is 10 or 12 bit? Thus, it is greater than 8 bits but less than 16. The micro gives you the choice it should put the ADC results towards the left or right of those 16 bits. For example, for a 12 bit ADC: left justified will use bits 15-4. Right justified will use bits 11-0.

• Thank you. Yes the ADC is 10 bit. So is there a preference between right justified and left justified? SO ADC chip does not have any memory within and the output is stored in CPU? – Jack Oct 1 '15 at 12:41
• I've always preferred right justified since it seems more intuitive to just truncate the extra bits that arent used. Though most of the MCUs I've used default to left justified, so I assume there is some advantage. Perhaps someone else can speak to that. – Justin Trzeciak Oct 1 '15 at 12:44
• @JustinTrzeciak Have you got that round the wrong way (in your comment, not your answer): right justified means the 'overflow' bits are the MSBs, left justified allows truncation of the LSBs. – CharlieHanson Oct 1 '15 at 12:56
• I think I just used the word truncate incorrectly then. For a 12 bit result, I like being able to do this: result = ADCRESULT & 0x0FFF – Justin Trzeciak Oct 1 '15 at 12:58
• Ah, I see what you mean, I misinterpreted what you said. I think left-justified is 'default' because it allows the user to opt for an 8-bit result without having to shift any bits. However, this only applies to low-level/assembly programming where all instructions are one register at a time. – CharlieHanson Oct 1 '15 at 13:13