adafruit / ArduinoCore-samd

114 stars 116 forks source link

Reading Analog Inputs with 12-bit resolution not working on SAMD51 #342

Open DevonReynolds opened 1 year ago

DevonReynolds commented 1 year ago

https://github.com/adafruit/ArduinoCore-samd/blob/0fd44a54b75f34b57a4e634257748e0ba46ab6ae/cores/arduino/wiring_analog.c#L352

The board i'm using is a Grand Central.

In analogRead it enables the adc, reads the value then disables the adc. In 10 bit mode this works fine. In 12 bit resolution this approach somehow changes it to 11-bit resolution. The lowest bit is never set. If the adc is left enabled it works correctly.