I am working with the SAMD21 Xplained Pro PCB.
I am seeing an issue when reading an external pin and then the internal MCU temperature sensor.
When I read the external pin 1st the ADC value is correct and the internal temperature is incorrect.
In the opposite case, where I read the internal temperature 1st and then the external pin, the temperature is correct and the analog
voltage on the external pin is incorrect.
The values for the two ADC reads are vary close to each other.
In the screen capture above, the external ADC pin reads the internal temperature sensor and then battery voltage.
Notice the values are vary close. The battery voltage should be 0 since it is reading a grounded input.
The adc_init() function returns an error code 0x1C when reading either input.
Yet, adc_init() does not return an error code the very first time it is run.
My project is based upon the examples in the Atmel ADC app note.
The examples run and produce the correct result by themselves however, when combined, there is a conflict.
I have tried numerous different variations of my code using adc_reset() and adc_flush(). These functions lock up the MCU
in the default interrupt handlers infinite while loop if placed near the start of the initialization code.
My suspicion is that I have an issue with the input multiplexer or the sample buffer.
Before I post a boatload of code here, is there some general advice that anyone could offer?