Skip to content

Commit

Permalink
[sam] Fix SAMx7x ADC readChannel() if previous data has not been read
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chris-durand committed Apr 19, 2023
1 parent c572d16 commit c7c4c57
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/modm/platform/adc/samg/adc.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public:
{
if (!setChannel(channel)) return 0;

// clear data ready by reading last value register
getValue();
startConversion();
while (!isConversionFinished()) {}

Expand Down

0 comments on commit c7c4c57

Please sign in to comment.