ATMEGA 328p - Crystal Oscillator Troubleshooting

I built a circuit on a breadboard using a 328p.
I tested it out and used a USBtinyISP to burn the bootloader and program it.
Everything worked great.

I was using a 16Mhz crystal and (2) 22pF ceramic caps for that prototype.

Upon success I drafted a PCB design for this same circuit.
I had been reading around on the web and most people were saying 20pF was the right value for the crystal oscillator on the 328p.
I chose a crystal oscillator that was the same values and ratings as the one I had used for testing, but a SMD version for my PCB.

The crystal cap values were the only change I made between breadboard and PCB.

I have burned the bootloader and uploaded a sketch to my PCB with the same circuit and it works exactly as intended while the USBtinyISP is connected to the circuit.
When I remove the USBtiny, it goes all wonky.

For example: I tested blink sketch.
When I remove the programmer, the LED flashes rapidly and irregularly.

I believe it may be an issue with the crystal and capacitor setup.
My hypothesis is that the timer of the 328p is being controlled by the programmer while connected and that is why is works only then.

Parts on breadboard:
Crystal: ABL-16.000MHz-B4Y
Caps: K220J10C0GF5UH5

Parts on PCB:
Crystal: ABM3-16.000MHZ-B2-T
Caps: C0805C200J5GACTU

Please advise.


You do not find the correct crystal load capacitance on the web, you find it on your crystal’s datasheet which in your case, happens to be 18pf.

If you have 20pf in there, that’s not the problem at all, it’s something else, likely a reset problem like the lack of a 10k pullup on the processors reset line.

To start the process, please post a schematic.

Here is a circuit schematic for my board.

I do have a 10K pullup resistor on RESET.

K28_SMT_Board.pdf (38.4 KB)

Perhaps the issue isnt in the electrial schematic, but in my execution of applying it to the PCB.

The only possible issue I’m seeing is the traces routed under the the 328p.
Perhaps there is some issue here causing the RESET line to short to ground?

PCB layout attached for reference. All SMT components top side, purple are top traces, red are bottom traces.

  1. You are missing the decoupling capacitors for the ATMega328.
  2. You are missing the output capacitor for the voltage regulator.

I think that the programmer is supplying the circuit, and when you remove that the regulator isn't able to maintain its output voltage so the ATMega keeps resetting.

Could you explain the decoupling capacitors please?
I’ve done some brief research after you posted that, and I’m looking for where to place them and how to choose the values. Thanks.

Courtesy of member Grumpy Mike:

Explained in the blog posting but to reiterate, they need to be as close as physically possible to the processor or component they are supplying to have the necessary effect.

How to set up a "minimal Arduino" here.

All digital ICs need a decoupling cap (commonly 100 nF) placed physically as close as possible to the Vcc pin. If a chip has multiple Vcc pins, it needs one cap for each pin. This to stabilise the supply voltage.

Thanks everyone so much.

I believe this explanation for why it functions as intended on the breadboard but not on the PCB makes sense.

I also found an AVR Hardware design consideration pdf that goes into detail about the decoupling caps and more regarding the basic configuration of these chips.

I’ll also be reviewing the links you both shared.