Past exam question: Assignment 3, Q9
Open in the Padhaiko appQuestion
Briefly explain Atmega328 Architecture in detail.
Solution
Overview & Core Harvard Architecture: The ATmega328 / ATmega328P is an 8-bit AVR RISC microcontroller by Microchip (Atmel), operating at with up to clock ( on Arduino Uno, delivering up to ).
- Modified Harvard Architecture: Separate Program Bus (fetches 16-bit instructions from Flash) and Data Bus (accesses SRAM and I/O registers) allow simultaneous instruction fetch and execution via a 2-stage pipeline (Fetch + Execute).
- AVR CPU Core:
- ALU: Performs 8-bit arithmetic and logic operations directly between any two of the 32 general-purpose working registers (
R0–R31) in a single clock cycle. - Status Register (
SREG): 8-bit flag register (I, T, H, S, V, N, Z, C). - Program Counter (
PC) and Stack Pointer (SP) (in SRAM).
- ALU: Performs 8-bit arithmetic and logic operations directly between any two of the 32 general-purpose working registers (
ATmega328 Architecture Block Diagram:
+---------------------------+
| 32 KB Flash Program Mem |
| & Instruction Decoder |
+-------------+-------------+
| Program Bus (16-bit)
+------------------+ +--------v--------+ +--------------------+
| 2 KB SRAM |<-->| AVR CPU Core |<-->| 1 KB EEPROM |
| 32x8 GP Regs | | ALU + SREG + PC | +--------------------+
+------------------+ +--------+--------+
| 8-bit Data Bus
+-------------+---------------+---------------+-------------+
| | | | |
+--v---+ +-----v-----+ +-----v-----+ +-----v-----+ +---v----+
|Timers| | 10-bit | | USART / | | Watchdog | | 23 I/O |
|0,1,2 | | 6-ch ADC | | SPI / I2C | | & Sleep | | Ports |
|(PWM) | | & Analog | | | | Control | | B,C,D |
+------+ | Comp. | +-----------+ +-----------+ +--------+
+-----------+Memory Organization and Integrated Peripherals:
- Memories:
- 32 KB In-System Self-Programmable Flash: Non-volatile program storage (with boot-loader section).
- 2 KB Internal SRAM: Volatile run-time data, stack, and variables.
- 1 KB EEPROM: Non-volatile byte-addressable storage for calibration constants and configuration.
- I/O Ports: 23 programmable GPIO lines grouped into Port B (
PB0–PB7), Port C (PC0–PC6), and Port D (PD0–PD7). - Timers/Counters & PWM: Two 8-bit timers (Timer0, Timer2) and one 16-bit timer (Timer1), providing 6 hardware PWM channels (Arduino pins
3, 5, 6, 9, 10, 11), Input Capture, and Output Compare. - Analog Subsystem: 10-bit Successive Approximation ADC multiplexed across 6 analog channels (
ADC0–ADC5on DIP-28; 8 on SMD), plus an on-chip Analog Comparator. - Serial Communication Interfaces: Hardware USART (
PD0/RXD, PD1/TXD), SPI (PB2–PB5), and I²C / TWI (PC4/SDA, PC5/SCL). - Interrupts, Clock & Power Management: Internal/external interrupt controller (26 vectors including
INT0,INT1, pin-change, timers, ADC), Watchdog Timer with dedicated oscillator, and 6 sleep modes (Idle, ADC Noise Reduction, Power-down, Power-save, Standby, Extended Standby).
Answer:
The ATmega328 uses an 8-bit AVR RISC Harvard architecture with a single-cycle ALU, 32 general-purpose registers, 32 KB Flash, 2 KB SRAM, 1 KB EEPROM, 23 I/O lines (Ports B, C, D), three timers (two 8-bit, one 16-bit) with 6 PWM channels, a 10-bit 6-channel ADC, hardware USART/SPI/I²C, and 6 low-power sleep modes.