Standalone ATmega328 + oscillator

Hello,

What could be the source of a noisy (literally!) oscillator?

A bit of context: I've built a small PCB including an ATmega328, a 16MHz oscillator and 2x 22pF capacitors as described in numerous examples. I've attached a LED+resistor to one of the ATmega outputs. There is also a power regulator 7805 and its capacitors, but in this example I didn't solder them to simplify the circuit... So I end up with something really basic (controller + LED). I'm powering this circuit with an external 5V regulated source.

If I'm using the components on a breadboard, then everything is fine. If I solder them on my PCB, the circuit works fine (the script is simple: make the LED blink). But after few seconds, the oscillator starts to make noise and the LED doesn't blink anymore or stay "on"... So I remove/unsolder all components (ATmega + oscillator + capa + LED + resistor) and put them back on a breadboard. Here, the ATmega works well and the oscillator doesn't make any noise...

Any clue?

Thanks a lot,
Patrick

Common missing things that cause issues:

10K pullup resistor on the reset pin.

5V on both VCC and AVCC.
0.1uF decoupling cap on both pins.

Crystals should not make audible noise. That seems to be what you are saying. If it really is... audible... your crystal is stressed and not working.

pwillard:
Crystals should not make audible noise. That seems to be what you are saying. If it really is... audible... your crystal is stressed and not working.

Should I consider the crystal to be "bad", or is there other possible source of error? I ordered a set of 10 crystals and the two I tested have the same behavior...

Are you certain it is the crystal? Larger value ceramics are piezoelectric, and it works both ways. If you are getting some kind of oscillation in the circuit, it could be a ceramic capacitor producing the noise. What kind of noise? A squealing? Whistle? White noise? What happens if you touch various components while it is making the noise? Is anything getting hot?

I'm not seeing any mention of bypass capacitors. As Grumpy_Mike says, there should be at least a couple in the circuit.

CrossRoads:
Common missing things that cause issues:

10K pullup resistor on the reset pin.

5V on both VCC and AVCC.
0.1uF decoupling cap on both pins.

I'm not sure to understand... Web examples of standalone Arduino on a breadboard don't include that extra components. Even my early tests on a breadboard didn't required those components to work. The led was blinking perfectly and the oscillator didn't make any noise...

polymorph:
Are you certain it is the crystal?

Not really... I didn't expect a ceramic to produce that noise, so I imagine it comes from the oscillator...

Larger value ceramics are piezoelectric, and it works both ways. If you are getting some kind of oscillation in the circuit, it could be a ceramic capacitor producing the noise. What kind of noise? A squealing? Whistle? White noise?

A "random" noise like soldering a component with soldering flux.

What happens if you touch various components while it is making the noise? Is anything getting hot?

I didn't see any smoke, any burnt solder points, no component is hot...

I'm not seeing any mention of bypass capacitors. As Grumpy_Mike says, there should be at least a couple in the circuit.

Yes, I didn't put those capacitors. Again, I didn't see those on examples... Where should I put them exactly?

'Web examples of standalone Arduino on a breadboard don't include that extra components"
Doesn't make them correct. The extras are clearly called for in Atmel design notes.

Any chance you have +5/Gnd going to the crystal and not the 2 arduino pins?

CrossRoads:
'Web examples of standalone Arduino on a breadboard don't include that extra components"
Doesn't make them correct. The extras are clearly called for in Atmel design notes.

Sure... As I'm fairly new to this, I'm trying to grab info on the net. And you are right saying that these are not always true information...

Any chance you have +5/Gnd going to the crystal and not the 2 arduino pins?

No, each pin of crystal is connected to 22pF and capa to ground.

CrossRoads:
Common missing things that cause issues:

10K pullup resistor on the reset pin.

5V on both VCC and AVCC.
0.1uF decoupling cap on both pins.

Hi,

As you mentionned, I put two 0.1uF, one between 7 and 8 (VCC & GND) and one between 20 and 22 (AVCC & GND). Also, the 10k pull-up was already there (I forgot to mention it earlier).

It seems I get more stability which means my little script is performed correctly each time I power up the ATmega.

But now the ATmega becomes a bit hot and I still here the noise... Any other clue?
Thanks,
Patrick

Can only guess you have damaged something. If the arduino is hot, that's usually a sign that a pin is overstressed and or damaged, and total chip failure typically follows.

CrossRoads:
Can only guess you have damaged something. If the arduino is hot, that's usually a sign that a pin is overstressed and or damaged, and total chip failure typically follows.

Actually, I have noticed that the overheating problem appeared since I put decoupling 0.1uF capacitors. Both capacitors are also getting hot. Is it a clue or only a side effect? As a test, I put the ATmega back on the Arduino Uno board and it doesn't become hot...

Any chance you have power & Gnd backwards?
Or, a very noisy power supply - like an AC supply instead of a DC supply?

Following my previous posts, I forgot to thank you helping me with that... It is really appreciated!

CrossRoads:
Any chance you have power & Gnd backwards?

I double-checked it and it is not inverted.

Or, a very noisy power supply - like an AC supply instead of a DC supply?

I have been using the following configurations to power my circuit:

  1. +5V and gnd ports coming from the original Arduino Uno board (without the ATmega chip)
  2. a separate USB/power converter that plugs into a breadboard (from DFRobot)
  3. I soldered the power regulation parts of my circuit (1N4001 + 10uF + 7805 + 10uF). I purposely didn't soldered those at the beginning of my project to remove possible source of errors. But I finally soldered them...
    But in all three cases, the ATmega becomes hot...

In case 3) I have also soldered the LED+resistor that is part of the power regulation of my circuit (some kind of "on" LED) and I can see that the LED is not always steady... In that case, the power source is a wall adapter delivering 12V DC.