3
\$\begingroup\$

I am not sure this is the right place to ask this question, but did not see any communities dedicated to Atmel chips.

I used a scope to look at my atmega328 clock signal (pin 14) and got the following result.

enter image description here

I expected a square wave, not a notched sine wave, but I have no basis for that expectation. So, is this what the signal should look like, or do I have some problems with my clock setup (noise, wrong caps, etc). I am using a 16MHz crystal with 22pF caps to ground wired to XTAL1/2 (9 and 10). The clock frequency looks dead-on at 16MHz, 62.3ns which you can see on the scope. Supply voltage is coming from a 7805 (fed from a 12V wall wart) Does this indicate a noise problem (need additional capacitors perhaps) or maybe this is actually what the signal looks like?

Second question this made me think of, what generates the clock signal anyway? (If I need to ask that as a separate question I will).

EDIT:

The probe is a 10x probe, 100 MHz. It was not calibrated when I measured the above signal, so I calibrated it per Stratton's instruction. The probe is now compensated as can be seen here (820 microsec period = approx. 1.22kHz which is what it should be)

enter image description here

Now when I hook everything up, I get the following, it looks worse...

enter image description here

Could the notching be strictly from no bypass capacitor at the chip? I find that hard to believe, but I have never done this experiment, so I am out of my league!! I know every thing I have read and learned says to use them, it would just be amazing.

Also, I included a picture of the setup just for clarification. Maybe you can see something you don't like (besides my poor ability to build a test board!!)

enter image description here

\$\endgroup\$
9
  • \$\begingroup\$ Is your probe's ground clip properly connected to a suitable ground point on your board? \$\endgroup\$
    – Majenko
    Aug 14, 2016 at 12:01
  • \$\begingroup\$ Yes, the ground clip was connected to the "ground plane". I put that in quotes because I set all this up on a proto board- not a PCB. I thought I had a picture of the whole setup but I don't, but I could probably set it all up again if that would help. \$\endgroup\$ Aug 14, 2016 at 12:12
  • 2
    \$\begingroup\$ Ah.. built on breadboard? That's most likely your culprit then. You have massive ringing most likely caused by a combination of your probe capacitance and the huge capacitance of the breadboard itself. Nasty things breadboards. So much capacitance you can even run a crystal without load capacitors...! \$\endgroup\$
    – Majenko
    Aug 14, 2016 at 13:30
  • \$\begingroup\$ I used the term protoboard different from breadboard. This was done with soldered joints. Is perfboard a better description? I hear it called multiple things.. Regardless, my clock signal is not as it should be I take it? \$\endgroup\$ Aug 14, 2016 at 14:18
  • \$\begingroup\$ Ah, I misunderstood. Yes, perfboard is a better description. It still looks like either excess capacitance (from your probe maybe) or a bad ground connection. What is the bandwidth of the probe? \$\endgroup\$
    – Majenko
    Aug 14, 2016 at 14:20

1 Answer 1

2
\$\begingroup\$

The first shot looks like ringing caused by stray inductance of the ground clip on the probe and/or compensation issues. 16MHz is getting in to the realm where stray L-C becomes an issue in measurement.


From your shot after you compensated the probe, it now starts to look like a bandwidth limited square wave. You can clearly see the first (16MHz) and third (48MHz) harmonics, however the fifth (80MHz) and higher are gone. Having said that, the third looks distorted (more like a second harmonic, which shouldn't be that strong)

This makes sense. Your scope bandwidth is too low to get anything higher than the third harmonic, so it will always look distorted in that way. As for the lack of the fifth harmonic, well you either have bandwidth limiting enabled on the scope, or the bandwidth of the probe is not high enough. Either way it is getting filtered out.

There will also be ringing still from the ground clip inductance which will cause some distortion and may explain the extra distortion beyond bandwidth limiting.


Ground clips cause ringing, it's inevitable. However, you can eliminate some of the issue by removing the ground clip all together and use the alternate ground on the probe.

Usually scope probes have a removable spring tip. Once that is removed, you have the tip of the probe (metal point) and a ring (ground). In order to reduce the ringing, you should connect the metal ground ring (usually an attachment is provided with the probe) to ground as close a possible to the chip ground, and then measure directly on pin 14 with the tip of the probe. This eliminates two wires (the ground and your signal wire) from the measurement path, thus reducing the inductance from the wires and improving measurement results.

The fifth harmonic is almost 50MHz, which is as I say getting quite high - 80MHz for the seventh harmonic is even higher. So careful measurement is required to get good and accurate readings.


As to where the clock signal is coming from, the clock out pin (P14) of the ATMega is a buffered version of the internal clock which comes from the crystal causing an inverter to oscillate at a given frequency.

\$\endgroup\$
4
  • \$\begingroup\$ Can you shed on some light on how to prevent the ringing? Some source you can link to? \$\endgroup\$
    – ammar.cma
    Aug 14, 2016 at 20:44
  • \$\begingroup\$ @ammar.cma haven't got a reference immediately (there are some questions on EE.SE that are worth reading that could be found with a search). I have however added an extra section to the answer. \$\endgroup\$ Aug 14, 2016 at 20:53
  • \$\begingroup\$ @TomCarpenter - thanks for your thorough answer. The ringing/harmonics make sense, I am just surprised to see it this pronounced. Is it safe to assume the ringing is caused just by the probe and is not actually present in the chip, or is it a combination of the probe and the board not being professional? Just curious. If nothing else, I learned alot from this little experiment. As I stated in my original question, I expected a square pulsed clock, not a sine wave, which wouldn't make sense to begin with since it is an oscillator! Learn by doing I guess. \$\endgroup\$ Aug 15, 2016 at 1:49
  • \$\begingroup\$ @nu77p01nt3r The ringing almost certainly won't be happening inside the chip. But also some of it is bandwidth of the measurement. If you google square wave harmonics, you'll see several clear pictures of how a square wave is actually formed from odd numbered harmonic sine waves. \$\endgroup\$ Aug 15, 2016 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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