AVR
AVR
AVR
What is AVR ?
Modified Harvard architecture 8-bit RISC single chip microcontroller Complete System-on-a-chip
On Board Memory (FLASH, SRAM & EEPROM) On Board Peripherals
Advanced (for 8 bit processors) technology Developed by Atmel in 1996 First In-house CPU design by Atmel
AVR Family
8 Bit tinyAVR
Small package as small as 6 pins
8 Bit megaAVR
Wide variety of configurations and packages
Harvard Architecture
AVR Architecture
What is RISC?
Reduced Instruction Set Computer As compared to Complex Instruction Set Computers, i.e. x86 Assumption: Simpler instructions execute faster Optimized most used instructions Other RISC machines: ARM, PowerPC, SPARC Became popular in mid 1990s
Register File
7 0
addr 0x00 0x01 0x02 0x03 0x04 0x05
x register low byte x register high byte y register low byte y register high byte z register low byte z register high byte
AVR Memory
FLASH
Non-volatile program space storage 16 Bit width Some devices have separate lockable boot section At least 10,000 write/erase cycles
AVR Memories
FLASH Memory Map
ATmega 48
0x000
ATmega 88/168/328
0x000
Application Flash
Application Flash
0x7FF
Boot Flash
AVR Memories
SRAM
AVR Memories
SRAM - Memory Map
32 Registers 64 I/O Registers 160 External I/O Reg Internal SRAM (512/1024/2048x8)
0x0000 0x001F 0x0020 0x005F 0x00060 0x00FF 0x0100
0x04FF/0x6FF/0x8FF
External SRAM
AVR Memories
EEPROM Electrically Erasable Programmable Read Only Memory 8 bit width Requires special write sequence Non-volatile storage for program specific data, constants, etc. At least 100,000 write/erase cycles
AVR Memories
DEVICE
ATmega48A ATmega48PA ATmega88A ATmega88PA ATmega168A ATmega168PA ATmega328
FLASH
4K Bytes 4K Bytes 8K Bytes 8K Bytes 16K Bytes 16K Bytes 32K Bytes
EEPROM
256 Bytes 256 Bytes 512 Bytes 512 Bytes 512 Bytes 512 Bytes 1K Bytes
SRAM
512 Bytes 512 Bytes 1K Bytes 1K Bytes 1K Bytes 1K Bytes 2K Bytes
ATmega328P
32K Bytes
1K Bytes
2K Bytes
Instruction Set
131 instructions
Arithmetic & Logic Branch Bit set/clear/test Data transfer MCU control
Instruction Timing
Register register in 1 cycle Register memory in 2 cycles Branch instruction 1-2 cycles Subroutine call & return 3-5 cycles Some operations may take longer for external memory
Pipelined Execution
Clock Sources
Timer/Counter Oscillator Timer/ Counters Crystal Oscillator IO Modules
Clock Mux
CPU Core
8
RAM
Calibrated RC Oscillator
Power Management
Multiple power down modes
Power down mode
Wake on external reset or watchdog reset
Reset Sources
Power on reset External reset Watchdog system reset Brown out detect (BOD) reset
23 General Purpose IO Bits Two 8 bit & one 16 bit timer/counters Real time counter with separate oscillator 6 PWM Channels 6 or 8 ADC channels (depends on package) Serial USART SPI & I2C Serial Interfaces Analog comparator Programmable watchdog timer
ATmega Peripherals
Instruction Set