mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
machine/atsamd21: correct issue with invalid first reading coming from ADC
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
@@ -192,6 +192,11 @@ func (a ADC) Get() uint16 {
|
||||
sam.ADC.SWTRIG.SetBits(sam.ADC_SWTRIG_START)
|
||||
waitADCSync()
|
||||
|
||||
// wait for first conversion to finish to fix same issue as
|
||||
// https://github.com/arduino/ArduinoCore-samd/issues/446
|
||||
for !sam.ADC.INTFLAG.HasBits(sam.ADC_INTFLAG_RESRDY) {
|
||||
}
|
||||
|
||||
// Clear the Data Ready flag
|
||||
sam.ADC.INTFLAG.SetBits(sam.ADC_INTFLAG_RESRDY)
|
||||
waitADCSync()
|
||||
|
||||
Reference in New Issue
Block a user