If Arduino-compatible vendors are being truly compatible (and it looks like they are in this case) then I think the answer to your question is this one:
But be aware of the distinction between what the h/w is capable of, and what the h/w pretends to be. In reality, I think you’d struggle to find an ARM based Adrudino that only has 10-bit ADCs, although given the diversity of processors out there I wouldn’t guarantee that. But even if it’s true, i.e. even if all ARM based Arduinos have 12-bit ADCs, they’re required to pretend that they have 10-bit ADCs until you call
analogReadResolution(12);
so that old AVR Arduino application code should run fine unmodified. That’s assuming everyone implements the Arduino runtime spec correctly, and looking at that Adafruit analog code I posted a pointer to above, it looks like they have (although I don’t have one, so haven’t tested that).
Things to note about analogReadResolution():
Sets the size (in bits) of the value returned by analogRead()
. It defaults to 10 bits (returns values between 0-1023) for backward compatibility with AVR based boards.
The Due, Zero and MKR Family boards have 12-bit ADC capabilities that can be accessed by changing the resolution to 12. This will return values from analogRead()
between 0 and 4095.
If you set the analogReadResolution()
value to a value higher than your board’s capabilities, the Arduino will only report back at its highest resolution, padding the extra bits with zeros.
For example: using the Due with analogReadResolution(16)
will give you an approximated 16-bit number with the first 12 bits containing the real ADC reading and the last 4 bits padded with zeros.
If you set the analogReadResolution()
value to a value lower than your board’s capabilities, the extra least significant bits read from the ADC will be discarded.
Using a 16 bit resolution (or any resolution higher than actual hardware capabilities) allows you to write sketches that automatically handle devices with a higher resolution ADC when these become available on future boards without changing a line of code.
[EDIT] - what would have been really helpful is if they’d back-ported analogReadResolution() to the AVR runtime. Then your application code could always set it to 12, and when you were running on an AVR with 10-bit ADCs you’d still get back 0-4095 (well 4092 actually), but the two LSBs would always be 0. A quick check of the AVR Arduino analog source makes me think they’ve not done that.