# 12 bit vs 10 bit ADC PIC18f [closed]

Convert 12 bits adc to 10 bit adc. We know that the resolution of the step size for a 12 bit is 1.22, different than the step size of 4.88 of the 10 bit. We need to take into account the extra 2 bits.

What would be the best solution. Just an idea of where to start to look into solving the problem.

Adc
bcf     STATUS, C
rrcf    lowbyte, f
rrcf    lowbyte,W
bcf    STATUS, C
rrcf    highbyte, f
rrcf    highbyte, W
bcf    STATUS, C
return

• We can't see your firmware so we can't give much ideas how to modify it. Obviously the part that processes the ADC reading needs to be modifief. Dec 30 '21 at 6:36

Divide the 12-bit ADC value by 4. This will make it 10-bit.

You can use 2 right-shifts to do this.

• jp314, yes so I'll need to right shift the ADRESL and ADRESH right?. And thus dividing by 4 since 4.88/1.22=4
– Citi
Dec 30 '21 at 8:04
• Do not forget to reset C bit at status register. It may affect the next instruction. Dec 30 '21 at 10:38
• @Citi a 2-bit right-shift basically is the integer division by four, no need to divide it again. Note that jp314's solution would just disregard the two lowest bits, so your uC won't get 12-bit values Dec 30 '21 at 16:57
• @sim so I'll use RRCF to shift right and as well to clear bcf STATUS, C. Thank you
– Citi
Dec 30 '21 at 18:11
• @user263983, I edited my question. Is that is the right way to shift, I probably need to clear C for each shift right and not every two shifts. Thank you guys
– Citi
Dec 30 '21 at 20:12