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()
void loop()

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:

enter image description here

For reference, here's the pinout for the 1284 DIP:

enter image description here

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:

enter image description here

  • 2
    \$\begingroup\$ Have you tried connecting AVcc through a low pass circuit as described in the datasheet? \$\endgroup\$ – FRob May 1 '15 at 0:12
  • \$\begingroup\$ @FRob No, I haven't. Where in the datasheet does it describe what values to use for the low pass? \$\endgroup\$ – Fiver May 1 '15 at 0:40
  • \$\begingroup\$ grab a scope trace of Vcc too, ideally AC-coupled with, say, 50mV or 100mV per division setting, at the same timebase - if you've got the same noise on Vcc, then that's your problem. What type & capacity are your decoupling caps? a picture of the setup could help too. & as FRob said above, low-pass filtering AVcc from Vcc is fairly important if analog performance is significant to your app. \$\endgroup\$ – Techydude May 1 '15 at 1:35
  • \$\begingroup\$ @Techydude Currently, I have 22uF electrolytics near both Vcc and AVcc. Will update the question with a shot of the Vcc trace. \$\endgroup\$ – Fiver May 1 '15 at 13:13
  • \$\begingroup\$ You want to add more decoupling caps on power pins. I bet the spec sheet tells you to use 0.1uF. You could also try 0.01uF in parallel. The Vcc and AVcc are usually separated by a ferrite bead or an inductor. \$\endgroup\$ – Nazar May 1 '15 at 13:24

Pin 40 is an input i.e. it is relatively high impedance (compared to an output or a power supply line). That's the first important thing to note.

Next you connect your o-scope probe to it and now you have basically a high impedance pin connected to what could be described as a medium length antenna.

Is it any surprise that something might be seen? You might also find that if you hold the scope probe close by in several areas, fast transients on the SCK line also couple to the probe.

General layout of breadboard could easily cause the spikes to appear (to a lesser extent) on any other pins. If it's on a PCB with a decent earthplane and the scope earth wire is connected to the closet 0V pin you may still see a little spike - this would be due to the scope probe acting as a loop antenna.

  • \$\begingroup\$ I think you are correct that the probe is acting as an antenna. I can connect to a completely unpopulated breadboard column and still pick up a faint signal. So, does this mean the other pins, like the ADC inputs, aren't really detecting this signal? Or if they are, there's nothing I can do about it? \$\endgroup\$ – Fiver May 1 '15 at 22:34
  • \$\begingroup\$ if you had a proper low impedance analog voltage source connected to an adc input you'll find that the spike is zero or, maybe a few millivolts with a decent PCB layout. \$\endgroup\$ – Andy aka May 1 '15 at 22:41
  • \$\begingroup\$ Your scope probes came with little pointy spring-steel coils, which slip over the probe tip (when you remove the normal plastic tip). Using the springy thing to touch a very nearby ground, and probe Vcc (and other signals) you will dramatically reduce the size of the loop formed by the scope's ground-wire-alligator-clip). Yes, inductive pick-up could be what you're seeing. This might be suggestin your SPI bus is radiating a lot, which could be a problem in itself... \$\endgroup\$ – Techydude May 1 '15 at 22:42
  • \$\begingroup\$ It can also be very tricky isolating stray pickup caused by a scope probe from a real signal on a pin. Good luck. \$\endgroup\$ – Andy aka May 1 '15 at 22:44
  • \$\begingroup\$ Oh, this is breadboard? I wish the OP had mentioned that.... :) \$\endgroup\$ – Techydude May 1 '15 at 22:46

Following on from my comment, so the noise is on Vcc, which means it's probably everywhere. A 22uF electrolytic is not a decoupling cap, far too much inductance & ESR. Ceramic disc if thru-hole, or MLCC (multi layer ceramic chip) if SMD, at 100nF (0.1uF) will usually do the job. Sometimes in thru-hole a combo of 100n & 10n works better, depends on the cap type, PCB layout, etc. Put the decoupling cap as close to the Vcc/AVcc & Gnd pins as humanly possible, shortest (thru-hole) leads as possible. Further explanation: http://www.baldengineer.com/a-1uf-decoupling-capacitor-is-too-much.html And as also commented by Ignacio, that app-note is important, especially putting a low-pass LC filter between Vcc & AVcc. Then take another shot & show us the difference :)

  • 1
    \$\begingroup\$ Note that the 1µF cap in the article is an aluminum electrolytic. A 1µF ceramic cap has a much better chance of working due to its lower ESR. \$\endgroup\$ – Ignacio Vazquez-Abrams May 1 '15 at 21:37
  • \$\begingroup\$ Added the 0.1uF ceramic caps on Vcc and AVcc and still see the spikes. I suspect Andy is correct that the probe is acting as an antenna. \$\endgroup\$ – Fiver May 1 '15 at 22:30
  • \$\begingroup\$ But are they still the same amplitude? \$\endgroup\$ – Techydude May 1 '15 at 22:42
  • \$\begingroup\$ Pretty much, but the background noise was reduced, so that's something. \$\endgroup\$ – Fiver May 1 '15 at 23:22
  • \$\begingroup\$ ok, so it sounds like that low-level 'grass' (noise) has been cleaned up a bit by the caps, but the SPI-timing-aligned spikes were inductively coupled via the 'scope probe's ground loop, provable if you try those little spring-steel ground-probe things i mentioned under the other answer. have fun! \$\endgroup\$ – Techydude May 2 '15 at 1:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.