Electronics > Microcontrollers

[SAMC] ADC 12 bit result accumulation of 4095 or 4096?

(1/5) > >>

Simon:
I'm struggling to wrap my head around this. I expect it applies to any ADC with result accumulation.

Do I take it that given the ADC is 12 bit and that I can accumulate up to 16 of those results into the 16 bit result register before overflowing is the total range 16 * 4095 = 65520 or 16 * 4096 - 1 = 65535 ?

using 4095 sounds right to me in terms or basic math but some in my head says that as this has taken me out of round binary numbers it can't be right.

Kleinstein:
The largest number possible with 12 bits is 4095 = 2^12 - 1. So the sum of 16 such values can not be larger then 16*4095.

pcprogrammer:
Another way to look at it is in hexadecimal.

Max number in 12 bit is 0x0FFF. Shift this 4 bits to the left, which is the same as multiplying by 16, you get 0xFFF0, which is 65520.

Simon:
Yes of course, thank you for proving I am semi sane

Siwastaja:
Range is 2^n, but largest possible number is 2^n - 1, because smallest possible number is 0.

Therefore, if you do stuff like divide by range (to get percentage), you need to divide by 2^n, not 2^n -1.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod