Home / Learn Chip Programming / AVR Architecture: ATmega328P Inside the Arduino Uno

AVR Architecture: ATmega328P Inside the Arduino Uno

The 8 bit chip behind Arduino Uno and Nano. Learn its memories, registers and pins.

In shortThe 8 bit chip behind Arduino Uno and Nano. Learn its memories, registers and pins.

Theory in plain words

ATmega328P blocksCPU: 8 bit AVR core, 32 registers, 1 MIPS/MHzMemory: 32 KB flash, 2 KB SRAM, 1 KB EEPROMPeripherals: 3 timers, 10 bit ADC, UART, SPI, I2C, watchdogI/O: PORTB, PORTC, PORTD (23 pins)
ATmega328P blocks

What it is

ATmega328P is an 8 bit Harvard RISC MCU: 32 KB flash, 2 KB SRAM, 1 KB EEPROM, 32 general registers, 23 I/O pins, 16 MHz.

Why we use it

It is the best first chip: simple, 5 V tolerant, huge community. Everything you learn transfers to bigger MCUs.

How it works

Harvard means separate program and data buses. Peripherals are mapped into the data space and controlled via registers (DDRx, PORTx, PINx, TCCRx, ADCSRA, UCSR0x).

Where it is used

  • Arduino Uno, Nano, Pro Mini
  • Learning register level programming
  • Simple low cost products

Arduino pin to AVR port map

Find the port and bit for an Arduino pinTry it Yourself

Arduino pin 13 is PB5. digitalWrite(13, HIGH) becomes PORTB |= (1 << 5), about 50 times faster.

ResourceATmega328PATtiny85ATmega2560
Flash32 KB8 KB256 KB
SRAM2 KB512 B8 KB
I/O pins23686
Timers326
Used inUno, Nanotiny projectsArduino Mega
Tip:Registers DDRx (direction: 1 = output), PORTx (output value or pull-up), PINx (read input) exist for every port. Learn these three and you can drive any AVR pin.

Quick quiz

1. Which register sets pin direction?

2. Arduino pin 13 is...