Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Left Justify:
ADRESH ADRESL
7654321076543210
9876543210 <<result
Right justify:
ADRESH ADRESL
7654321076543210
9876543210 <<result
The reason for left justify is not for ease or difficulty of reading. It is so that you can easily use the high 8 bits of the result in ADRESH as an 8-bit value, dropping (ignoring) the two least significant bits in ADRESL. In many applications they're probably just noise anyway.Suraj143 said:Hi gualala excellent reply.Thats what I want to know.
The left justify makes hard to read from the software because the 2 LSB is in the ADRESL.
But right justify easy to read.
gualala said:well, if you need 8-bit resolution, you can left-justify it and use ADRESH as the results.
futz said:It is so that you can easily use the high 8 bits of the result in ADRESH as an 8-bit value, dropping (ignoring) the two least significant bits in ADRESL.
If you need precision and your measurement won't exceed 8-bits, right justify it and ignore ADRESH, which should never exceed zero anyway if you've set up your circuit and VREF+ correctly.Suraj143 said:Oh thats the pointignoring the LSB is not a good idea.
I need a 8 bit result format with 2 LSB also.It must vary between 0-255.
Let say the AD result value is decimal 9 = B'00001001'
reading just ADRESH will show the value = d'2' that is wrong.
Whats your idea?
futz said:If you need precision and your measurement won't exceed 8-bits, right justify it and ignore ADRESH, which should never exceed zero anyway if you've set up your circuit and VREF+ correctly.
OH!!! Finally I understand what you were saying earlier! Gotcha!Suraj143 said:This is correct but need bank switching as well.ref are Vdd & Vss.
I need to connect a preset to analog input & when I turn the preset from min to max it must vary the result from 0 to 255.
The PIC doesn't have 8 bit conversion its doing from 10 bit.So when I read the result registers its from 10 bit format.
When I turn it its rolls over 4 times thats the problem.256 X 4 = 1024
They're insignificant! It works. Try it. An 8-bit measurement can't be that accurate anyway, or it would be a 10-bit measurement.Suraj143 said:Oh no again you are telling to left justify then it will still missing 2 LSB![]()
H: ADRESH, L: ADRESL, R: 10-bit AD result
Left-justified:
H7H6H5H4H3H2H1H0L7L6L5L4L3L2L1L0
R9R8R7R6R5R4R3R2R1R0 << 0 ~ 1023
discard ADRESL:
H7H6H5H4H3H2H1H0L7L6L5L4L3L2L1L0
R9R8R7R6R5R4R3R2 0 0 << 0 ~ 1020, step 4
result divide 4:
R9R8R7R6R5R4R3R2 << 0 ~ 255, step 1
Yup. Left justify and read ADRESH. Gives a nice 8-bit result. It works fine. Those two least-significant bits are irrelevant - that's why they're called "least significant".Suraj143 said:Now both of you got it?
For an 8-bit result, bits 1 and 0 of ADRESH are your two LSB's. ADRESH will vary between 0-255. It really does work that way. Try it.Suraj143 said:I need a 8 bit result format with 2 LSB also.It must vary between 0-255.