8051 Architecture, Harvard Memory & On-Chip RAM Map
Computer-on-a-chip, 128 bytes RAM (Register Banks 0–3, Bit-Addressable Area, Scratchpad), SFR register space, and PSW flags.
Knova editors12 min readQuick checkSources
The 8051 Microcontroller Architecture
Introduced by Intel in 1980, the 8051 is an 8-bit microcontroller designed specifically for embedded control systems.
Unlike a general-purpose microprocessor (such as the 8085 or 8086) which contains only a CPU and requires external chips for RAM, ROM, timers, and I/O ports, the 8051 is a self-contained "computer on a chip".
Key Hardware Specifications
A standard 8051 microcontroller integrates the following on a single silicon die:
- 8-bit CPU with Boolean bit-processing capabilities.
- 4 KB of On-Chip Program Memory (ROM/EPROM/Flash): Expandable to 64 KB externally.
- 128 Bytes of On-Chip Data Memory (RAM): Expandable to 64 KB externally.
- 32 Bidirectional I/O Lines: Organized as four 8-bit ports ().
- Two 16-bit Timers/Counters: Timer 0 and Timer 1.
- Full-Duplex UART Serial Channel: Supports programmable baud rates.
- Five-Vector, Two-Priority Interrupt Architecture.
- On-chip crystal oscillator generating system timing (typically or ).
Harvard Architecture: Separate Code and Data Spaces
The 8051 employs a Harvard Architecture, where program code (ROM) and data memory (RAM) exist in completely separate physical address spaces and utilize independent bus paths:
| Memory Space | Address Range | Access Instruction | Control Strobe |
|---|---|---|---|
| Internal Program ROM | MOVC A, @A+DPTR | ||
| External Program ROM | MOVC A, @A+PC | ||
| Internal Data RAM | MOV A, direct / @Ri | Internal CPU bus | |
| Special Function Regs | MOV direct | Internal CPU bus | |
| External Data RAM | MOVX A, @DPTR |
Internal RAM Organization (128 Bytes)
The bytes of on-chip RAM () are partitioned into three functional areas:
1. Working Register Banks ()
Thirty-two bytes allocated as four distinct banks (Bank 0, Bank 1, Bank 2, Bank 3), each containing eight 8-bit registers (). The active bank is chosen dynamically by the and bits of the Program Status Word (PSW):
| Active Register Bank | RAM Address Range | ||
|---|---|---|---|
| 0 | 0 | Bank 0 (Default on reset) | |
| 0 | 1 | Bank 1 | |
| 1 | 0 | Bank 2 | |
| 1 | 1 | Bank 3 |
2. Bit-Addressable RAM ()
Sixteen bytes () that can be accessed either as standard 8-bit bytes () or as 128 individually addressable bits numbered to .
Instructions such as SETB 05H, CLR 2AH, or JB 7FH, TARGET test and modify individual boolean flags in a single clock cycle without requiring byte masking.
3. General-Purpose Scratchpad RAM ()
Eighty bytes of general-purpose read/write storage for variables, buffers, and the system stack.
The Program Status Word (PSW)
The 8-bit Program Status Word () contains math flags and bank selection bits:
| CY | AC | OV | - | P |
- CY (Carry Flag): Also functions as the 1-bit accumulator for Boolean operations.
- AC (Auxiliary Carry): Carries between BCD nibbles during addition.
- F0 (User Flag 0): General-purpose programmable bit flag.
- RS1, RS0 (Register Bank Select): Selects active register bank .
- OV (Overflow Flag): Indicates signed arithmetic overflow.
- P (Parity Flag): Automatically tracks even parity in the Accumulator ().
Intel 8051 Internal RAM & Special Function Registers (SFR)
Explore 128 bytes of low internal RAM (Register Banks 0–3, Bit-Addressable Area, Scratchpad) and Special Function Registers (SFRs).