Skip to content

Commit 4ee26fd

Browse files
deadprogramaykevl
authored andcommitted
machine/atsamd21: correct issue with invalid first reading coming from ADC
Signed-off-by: Ron Evans <[email protected]>
1 parent a718b10 commit 4ee26fd

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/machine/machine_atsamd21.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ func (a ADC) Get() uint16 {
192192
sam.ADC.SWTRIG.SetBits(sam.ADC_SWTRIG_START)
193193
waitADCSync()
194194

195+
// wait for first conversion to finish to fix same issue as
196+
// https://github.com/arduino/ArduinoCore-samd/issues/446
197+
for !sam.ADC.INTFLAG.HasBits(sam.ADC_INTFLAG_RESRDY) {
198+
}
199+
195200
// Clear the Data Ready flag
196201
sam.ADC.INTFLAG.SetBits(sam.ADC_INTFLAG_RESRDY)
197202
waitADCSync()

0 commit comments

Comments
 (0)