From c7c4c57309005322709102f3201376a1256f56dd Mon Sep 17 00:00:00 2001 From: Christopher Durand Date: Wed, 19 Apr 2023 15:08:14 +0200 Subject: [PATCH] [sam] Fix SAMx7x ADC readChannel() if previous data has not been read Clear data ready flag and do not return previous result if it has not been read from the LCDR register. When using conversion sequences data is normally read from the CDR register which does not clear the data ready flag. --- src/modm/platform/adc/samg/adc.hpp.in | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modm/platform/adc/samg/adc.hpp.in b/src/modm/platform/adc/samg/adc.hpp.in index c8677d393b..fcdd554c4f 100644 --- a/src/modm/platform/adc/samg/adc.hpp.in +++ b/src/modm/platform/adc/samg/adc.hpp.in @@ -251,6 +251,8 @@ public: { if (!setChannel(channel)) return 0; + // clear data ready by reading last value register + getValue(); startConversion(); while (!isConversionFinished()) {}