This behavior is due to the noise captured by the ADC pin. Anything connected to this 12-bit ADC pin is like a small antenna and you would have the same waveform with no voltage applied to A0.There are several workarounds:- Add an RC filter to A0 with an RC constant greater than 100 times the period of the analog input in case this is a periodic analog input,- Read A0 with an input voltage and (e.g.) A1 without any input voltage in the same conditions (add the same resistor between A1 and Gnd), subtract A1 to A0 before any use of your A0 conversion. It's important to read A1 the faster you can after A0.- Read A0 much faster than you need (oversampling), then average (averaging).An extension of the last method is used to extend the precision from 12-bit to 16-bit ADC conversions whenever your noise is a white noise (at first glance your noise should be in this category...), see this Application Note:https://www.silabs.com/documents/public/application-notes/an118.pdfFor better ADC conversions, power the board with a battery pack thru the jack (I gusess you already do that according to the picture posted) because the power line of the USB cable is very unstable.
values = (ADC->ADC_CDR + ADC->ADC_CDR + ADC->ADC_CDR + ADC->ADC_CDR) >> 1;
ADC->ADC_CHER = 0x3CFF;
while ((ADC->ADC_ISR & 0x80) == 0);// wait for conversion of A0 value = (ADC->ADC_CDR;//read it and only it
AFAIK, ADC samplings for n channels should follow this rule : (n * Sampling_rate ) can't be much faster than 1 MHz (See page 1403, Sam3x datasheet) with a PDC DMA.Here are some ADC example sketches with and without DMA:https://forum.arduino.cc/index.php?topic=547194.0reply 3https://forum.arduino.cc/index.php?topic=224672.0reply 10https://forum.arduino.cc/index.php?topic=487989.0reply 1