AVR Memory Architecture

The AVR family of microcontrollers use a modified Harvard Architecture which uses 3 types of memory, most of which are on chip.

  • Flash
  • RAM
  • EEPROM

Flash

Flash is non volatile memory, which means it perisists when power is removed. Its purpose is to hold intructions that the microcontroller executes. The amount of flash can range from 512 bytes on an ATTiny to 384K on an ATxmega384A1. AVR microcontrollers can be thought of having 2 modes, a flash programming and a flash executing mode.

By modifying fuse settings (BOOTSZ0 & BOOTSZ1 on the ATmega168) some AVR microcontrollers allow you to reserve sections of flash for a bootloader and reserved application flash section. The bootloader allows the flash programming process to be controlled by a flash resident program. Some bootloader applications might include.

  • Decrypt encrypted flash files to prevent reverse engineering
  • Implement a self destruct sequence triggered by a tamper sensor
  • Allow the device to be programmed from a TFTP server

RAM

RAM is volatile memory that stores the runtime state of the program being executed. The amount of RAM can range from 32 byes on an ATTiny28L to 32KB on an ATxmega384A1. In many AVR microcontrollers RAM is split into 4 subsections:

  • General purpose registers
  • I/O registers
  • Extended I/O registers
  • Internal RAM

AVR microcontrollers have RAM on-chip but some AVRs (e.g. ATMega128) can use external RAM modules to extent what is built into the microcontroller.

EEPROM

EEPROM is non volatile memory which is used to store data. The most common use is to store configurable parameters. The amount of EEPROM can range from 32 bytes on an ATTiny to 4KB on an XMega.