Microprocessor & Microcontroller
Complete formula & architecture reference for Intel 8085 (µP) and 8051 (µC). Features interactive simulators, block diagrams, addressing modes, and interface logic.
UNIT 1 — Microprocessor Basics (8085)
1.1 Generation & Evolution Timeline
| Gen | Year | Bits | Example Processors |
|---|---|---|---|
| 1st Gen | 1971-1972 | 4-bit | Intel 4004, 4040 |
| 2nd Gen | 1974-1977 | 8-bit | Intel 8080, 8085, Zilog Z80 |
| 3rd Gen | 1978-1982 | 16-bit | Intel 8086, 8088, Zilog Z8000 |
| 4th Gen | 1985-1992 | 32-bit | Intel 80386, 80486, Motorola 68000 |
| 5th Gen | 1993-2000 | 32/64-bit | Intel Pentium I,II,III,IV |
| 6th Gen | 2003+ | 64-bit | Intel Core 2, i3/i5/i7/i9, AMD Ryzen |
| Latest | 2020+ | 64-bit | Intel Core Ultra, AMD Ryzen 9, Apple M3 |
- Intel 4004 (1971): 2300 transistors @ 108 kHz
- Intel Core i9 (Modern): ~26 billion transistors @ ~6.0 GHz
- Data bus: 4-bit $\rightarrow$ 64-bit
- Address bus: 12-bit $\rightarrow$ 64-bit
1.2 Intel 8085 Architecture & Bus Structure
Multiplexed Lower Address Bus
1.3 Arithmetic Logic Unit (ALU) & Flags
- Arithmetic: ADD, SUB, INR, DCR, DAA
- Logical: ANA, ORA, XRA, CMA, CMC
- Rotate: RLC, RRC, RAL, RAR
Flag Register (F)
2's Complement Subtraction
1.4 Register Organization
- Accumulator (A): 8-bit, main working register
- General Purpose: B, C, D, E, H, L (6 x 8-bit)
- Register Pairs: BC, DE, HL (16-bit pairs)
- Stack Pointer (SP): 16-bit, points to stack top
- Program Counter (PC): 16-bit, next instruction
1.5 8085 Interrupts
| Interrupt | Priority | Type | Vector Addr | Maskable? |
|---|---|---|---|---|
| TRAP | 1 (High) | Edge/Level | 0024H | No |
| RST 7.5 | 2 | Edge | 003CH | Yes |
| RST 6.5 | 3 | Level | 0034H | Yes |
| RST 5.5 | 4 | Level | 002CH | Yes |
| INTR | 5 (Low) | Level | Ext (8259) | Yes |
SIM (Set Interrupt Mask) Bit Pattern
RIM (Read Interrupt Mask) Bit Pattern
1.6 8085 Pin Description (40-pin DIP)
1.7 Machine & Instruction Cycles
- Opcode Fetch (M1): 4 to 6 T-states
- Memory Read/Write: 3 T-states
- I/O Read/Write: 3 T-states
- Example (MVI A, 3EH): M1(4) + M2(3) = 7 T-states
- Example (STA 2050H): M1(4) + M2(3) + M3(3) + M4(3) = 13 T-states
UNIT 2 — Microprocessor Programming (8085)
2.1 Instruction Set & Word Size
Instruction Word Sizes
- 1-Byte Instruction: Opcode only. Example:
MOVA, B(78H) - 2-Byte Instruction: Opcode + 8-bit Data/Address. Example:
MVIA, 32H(3EH 32H) - 3-Byte Instruction: Opcode + 16-bit Address. Example:
LDA2050H(3AH 50H 20H)
Classification of Instructions
| Group | Function | Examples |
|---|---|---|
| Data Transfer | Copy data (no flags affected) | MOV, MVI, LDA, STA, LXI, XCHG |
| Arithmetic | Math ops (affects flags) | ADD, SUB, INR, DCR, DAA |
| Logical | Boolean ops, rotates | ANA, ORA, XRA, CMP, RLC, RAR |
| Branching | Change execution flow | JMP, JZ, JC, CALL, RET |
| Machine Control | Halt, interrupt, stack ops | HLT, NOP, PUSH, POP, EI, DI |
2.2 8085 Addressing Modes
2.3 Interactive 8085 Program Executor (Addition)
UNIT 3 — Microprocessor Applications
3.1 Interfacing ADC & DAC
Digital to Analog Converter (DAC 0808)
- Converts 8-bit digital input to analog current output.
- Usually employs an R-2R ladder network.
Analog to Digital Converter (ADC 0809)
- Successive Approximation Register (SAR) type.
- Requires START (SOC) and End of Conversion (EOC) signals.
Interactive 8-bit DAC Simulator
3.2 8255 Programmable Peripheral Interface
The 8255 provides three 8-bit I/O ports (Port A, Port B, Port C). It operates in various modes determined by the Control Word.
| Mode | Description |
|---|---|
| BSR Mode | Configures individual pins of Port C (Set/Reset). |
| I/O Mode 0 | Simple Input/Output for Ports A, B, C. |
| I/O Mode 1 | Handshake I/O (Strobed I/O). |
| I/O Mode 2 | Bidirectional Data Bus (Port A only). |
Control Word Format (I/O Mode)
1
Mdl(A)
Md(A)
PA
PC(Up)
Md(B)
PB
PC(Lo)
- D7 = 1 (I/O Mode active).
- D6, D5: Port A Mode (00=0, 01=1, 1x=2).
- D4, D1, D3, D0: Port Direction (1=Input, 0=Output).
- D2: Port B Mode (0=0, 1=1).
3.3 Waveform Generation & Measurement
Square Wave Generation
By continuously writing alternatiing high (FFH) and low (00H) values to a DAC via 8255 with a delay, a square wave is produced.
3.4 Stepper & DC Motor Control
Stepper Motor Sequence (Full Step)
To rotate a 4-coil stepper, energize coils in a specific sequence using an output port.
DC Motor Speed Control (PWM)
UNIT 4 — Microcontroller Basics (8051)
4.1 Microprocessor vs Microcontroller
| Feature | Microprocessor (MPU) | Microcontroller (MCU) |
|---|---|---|
| Components | CPU only. Memory, I/O, timers must be added externally. | CPU + RAM + ROM + I/O + Timers on a single chip. |
| Application | General-purpose systems (PCs, laptops). | Application-specific systems (Washing machines, ACs). |
| Cost & Size | Higher cost, larger PCB size. | Lower cost, compact size. |
| Power Consumption | High power consumption. | Low power consumption (ideal for batteries). |
4.2 Architecture of 8051 (Harvard Architecture)
8051 Key Features
- 8-bit ALU, Accumulator, and 8-bit Registers.
- 16-bit Program Counter (PC) and Data Pointer (DPTR).
- 4 KB On-chip ROM (Program Memory).
- 128 Bytes On-chip RAM (Data Memory).
- Four 8-bit I/O Ports (P0, P1, P2, P3).
- Two 16-bit Timers/Counters (T0, T1).
- Full-duplex serial port (UART).
4.3 RAM Organization & Special Function Registers (SFRs)
Internal 128-Byte RAM (00H - 7FH)
Program Status Word (PSW)
The PSW is an 8-bit SFR at address D0H. It contains status flags and register bank selection bits.
| RS1 | RS0 | Selected Bank | Address |
|---|---|---|---|
| 0 | 0 | Bank 0 | 00H - 07H |
| 0 | 1 | Bank 1 | 08H - 0FH |
| 1 | 0 | Bank 2 | 10H - 17H |
| 1 | 1 | Bank 3 | 18H - 1FH |
UNIT 5 — 8051 Addressing Modes & Instructions
5.1 Addressing Modes of 8051
| Mode | Syntax | Description |
|---|---|---|
| Immediate | #data |
Data is specified in the instruction. Ex:
MOV A, #55H
|
| Register | Rn or A |
Operand is in a register (R0-R7, A). Ex:
MOV A, R1
|
| Direct | address |
8-bit internal RAM address given. Ex:
MOV 50H, A (Move A to RAM 50H)
|
| Register Indirect | @Ri |
Address is held in R0 or R1. Ex:
MOV A, @R0
|
| Indexed | @A+DPTR |
Accesses lookup tables in ROM. Ex:
MOVC A, @A+DPTR
|
| Bit Addr. | bit |
Operates on a single bit. Ex:
SETB P1.0
|
Interactive Indexed Addressing (MOVC)
Indexed addressing is widely used to retrieve values from ROM lookup tables, such as 7-segment display codes.
5.2 8051 Assembly Programs
Addition of Two 8-bit Numbers
- Load numbers into A and B.
- Add. Store result and save carry.
Data Transfer (Block Move)
- Move 10 bytes from SRC (30H) to DST (40H).
UNIT 6 — 8051 Interrupts & Timers
6.1 8051 Interrupt System
The 8051 has 5 interrupt sources. The Interrupt Enable (IE) and Interrupt Priority (IP) SFRs control them.
| Interrupt | Flag | Vector Addr. | Priority* |
|---|---|---|---|
| External 0 (INT0) | IE0 | 0003H |
1 (Highest) |
| Timer 0 (TF0) | TF0 | 000BH |
2 |
| External 1 (INT1) | IE1 | 0013H |
3 |
| Timer 1 (TF1) | TF1 | 001BH |
4 |
| Serial (RI / TI) | RI/TI | 0023H |
5 (Lowest) |
Interrupt Enable (IE) Register
(D7)
(D6)
(D5)
(D4)
(D3)
(D2)
(D1)
(D0)
Enable All (EA) bit must be 1 for any generic interrupt to trigger.
Interrupt Priority (IP) Logic
Setting an IP bit to '1' makes it a high priority interrupt. High priority interrupts can break into low priority ISRs.
6.2 Timers and Counters (TMOD & TCON)
Timer Modes (TMOD)
- Mode 0: 13-bit Timer (rarely used).
- Mode 1: 16-bit Timer (counts 0000H to FFFFH).
- Mode 2: 8-bit Auto-Reload Timer (TH auto-loads into TL upon overflow).
- Mode 3: Split Timer (Timer 0 only).
Timer Delay Calculation
Assuming Crystal Freq = 11.0592 MHz, Machine Cycle Freq = $\frac{11.0592}{12} = 921.6$ kHz.
Mode 1 (16-bit) Count Calculator
UNIT 7 — Application of Microcontroller
7.1 Motor Speed Control (PWM via Timers)
Pulse Width Modulation
By rapidly switching a pin HIGH and LOW using 8051 timers, we constrain the average voltage seen by a DC motor, controlling its speed.
Implementation
- Setup Timer 0 to generate a fixed frequency interrupt (e.g., 10kHz).
- Maintain a software counter (0-100) inside the ISR.
- If Counter < DutyCycle, Set Motor Pin=1. Else, Motor Pin=0.