From c95209bf7aeab1fa8ea867d85645a2171a5db590 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 28 Aug 2019 13:45:01 -0400 Subject: [PATCH] atsam: ADC pins need to be in input mode with pullups disabled The ADC pins (on at least the sam3x8e) need to be configured in input mode with the internal pullups disabled in order to get accurate ADC readings. Reported by @bryanboettcher. Signed-off-by: Kevin O'Connor --- src/atsam/adc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/atsam/adc.c b/src/atsam/adc.c index 816b388e..150ac011 100644 --- a/src/atsam/adc.c +++ b/src/atsam/adc.c @@ -49,6 +49,9 @@ gpio_adc_setup(uint8_t pin) | ADC_MR_STARTUP_SUT768 | ADC_MR_TRANSFER(1)); } + + // Place pin in input floating mode + gpio_in_setup(pin, 0); return (struct gpio_adc){ .chan = 1 << chan }; }