Skip to content

Commit 8b70e4c

Browse files
authored
Merge pull request arduino#309 from zuyan9/master
Bugfix - waiting for first ADC read to complete after ADC enable.
2 parents bafcb36 + 6ddfddf commit 8b70e4c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cores/arduino/wiring_analog.c

+3
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,9 @@ uint32_t analogRead(uint32_t pin)
375375
syncADC();
376376
ADC->SWTRIG.bit.START = 1;
377377

378+
// Waiting for the 1st conversion to complete
379+
while (ADC->INTFLAG.bit.RESRDY == 0);
380+
378381
// Clear the Data Ready flag
379382
ADC->INTFLAG.reg = ADC_INTFLAG_RESRDY;
380383

0 commit comments

Comments
 (0)