I'm using an Atmel ATmega1284P MCU (40-pin DIP) for a project and noticed some low frequency spikes on the ADC0 pin (pin 40). After some troubleshooting I discovered that the spikes were perfectly synchronized with the SPI communication on pins 6 & 8.
I was able to replicate the issue using the following minimal circuit:
simulate this circuit – Schematic created using CircuitLab
And the minimal code:
#include <SPI.h>
void setup()
{
SPI.begin();
}
void loop()
{
SPI.transfer(B00000000);
delay(61);
}
Monitoring pins 8 & 40 using an oscilloscope I can see that the SCK is correctly jumping to 5V every 61ms, but what is weird is that I see a roughly 400mV spike on the ADC0 line. Here's a screen grab from my scope, the ADC0 probe is in yellow and the SCK in blue:
For reference, here's the pinout for the 1284 DIP:
I'm really not sure what is going on here, but it seems like some sort of grounding issue. I've tried adding decoupling caps between pins 10 & 11, as well as pins 30 & 31, but it made no difference. Any ideas on how to eliminate this spike on the other MCU pins?
Shot of the Vcc trace with 22uF electrolytic decoupling caps near both Vcc & AVcc: