Designing a PCB with the ATmega328P
The ATmega328P is Microchip's 8-bit AVR microcontroller with 32 KB of flash and 2 KB of SRAM, running from 1.8 V to 5.5 V at up to 20 MHz. A working board needs 100 nF on each supply pin pair, AVCC tied to VCC through a small LC filter, a pull-up and capacitor on RESET and a 6-pin ISP header. A crystal is optional, but the clock speed you can use depends on the supply voltage.
- Core
- 8-bit AVR, up to 20 MIPS at 20 MHz
- Memory
- 32 KB flash, 1 KB EEPROM, 2 KB SRAM
- Supply
- 1.8 V to 5.5 V
- Speed grade
- 0 to 4 MHz at 1.8 to 5.5 V, 0 to 10 MHz at 2.7 to 5.5 V, 0 to 20 MHz at 4.5 to 5.5 V
- Internal oscillator
- 8 MHz RC, ±10 % factory calibration, ±1 % after user calibration
- ADC
- 10-bit, 8 channels in TQFP and VQFN, 6 channels in SPDIP
- Packages
- 28-pin SPDIP, 32-lead TQFP, 28-pad and 32-pad VQFN
- Board plans in Cuprio using it
- 2 (as of 27 November 2026)
What clock speed can the ATmega328P run at 3.3 V?
The datasheet guarantees 10 MHz from 2.7 V and 20 MHz from 4.5 V, with the limit rising linearly between those points. Read off that line, 3.3 V allows about 13.3 MHz, so a 16 MHz crystal on a 3.3 V board runs outside the specification. Either run at 5 V or drop to 8 MHz. The chip ships running from its internal 8 MHz RC oscillator with the CKDIV8 fuse programmed, so it starts at 1 MHz until the fuses are changed.
How should VCC, AVCC and AREF be decoupled?
Microchip's AN2519 asks for a decoupling capacitor on every power and ground pin pair (the TQFP has two VCC pins and several GND pins besides AVCC), plus a tantalum or ceramic capacitor on the main supply. Keep each capacitor's loop to its pins small and don't route the current spikes through the planes. AVCC powers the ADC and PC0 to PC3. It must connect to VCC even if the ADC is unused, and through a low-pass filter if the ADC is used. The datasheet shows a 10 µH inductor with 100 nF to the analog ground. AN2519 gives 100 nF as the typical capacitor for AREF. On VQFN packages the bottom pad must be soldered to ground.
Which crystal and load capacitors does the ATmega328P need?
For a quartz crystal, the datasheet recommends equal capacitors C1 and C2 of 12 to 22 pF, for both the low-power oscillator (up to 16 MHz) and the full-swing oscillator (0.4 to 20 MHz). The low-power mode saves current, but it cannot drive other clock inputs and is more sensitive to noise. Pick full swing for noisy boards. For ceramic resonators, use the capacitor values from the resonator's manufacturer. AN2519 asks for the resonator as close as possible to the chip, surrounded by ground. Without a crystal, the RC oscillator is only ±10 % from the factory. That can be too loose for a UART link, so either fit a crystal or calibrate the oscillator in firmware, which brings it to ±1 %.
How do I wire RESET and the ISP header?
RESET is PC6. It has an internal 30 to 60 kΩ pull-up, which AN2519 says may not be enough in noisy environments. Its recommended circuit adds a 4.7 kΩ pull-up and 100 nF to ground; if you use debugWIRE, make the pull-up at least 10 kΩ and leave the capacitor off. No ESD diode runs from RESET to VCC inside the chip, because high-voltage programming drives the pin to 11.5 to 12.5 V. If you never use that mode, add a diode externally. Give a reset button a series resistor.
Program the chip over the 6-pin ISP header: SCK (PB5), MISO (PB4), MOSI (PB3), RESET, VCC and GND. If other parts share the SPI bus, add about 330 Ω in series. Programming the RSTDISBL fuse turns PC6 into a GPIO, after which only high-voltage programming can reach the chip. A serial bootloader can live in the optional boot section, but the bootloader itself goes in over ISP.
Common ATmega328P mistakes
- A 16 MHz crystal on a 3.3 V supply, beyond the speed grade.
- AVCC left unconnected because the ADC is not used.
- A 100 nF reset capacitor on a board that will be debugged over debugWIRE.
- No USB: the chip has a UART, not a USB port, so a USB board needs a bridge such as the CH340 or a USB-capable AVR such as the ATmega32U4.
- Crystal placed far from XTAL1/XTAL2 with signal traces running between them.
Checking an ATmega328P board
An open AVCC pin or a missing decoupling capacitor shows up in the netlist before layout. Cuprio checks the schematic with electrical rule checks.
Sources
- Microchip: ATmega48A/PA/88A/PA/168A/PA/328/P megaAVR Data Sheet DS40002061Bww1.microchip.com
Memory, supply range, speed grades, packages, AVCC connection and LC filter, crystal capacitor ranges, RC oscillator accuracy, CKDIV8, RESET pull-up, debugWIRE rules, RSTDISBL, ISP pins
- Microchip: AN2519 AVR Microcontroller Hardware Design Considerations (DS00002519B)ww1.microchip.com
Decoupling per supply pair, AREF capacitor, reset circuit values, diode and high-voltage programming, reset switch, ISP series resistors, crystal placement
