MICROCONTROLLER 8051 - TNPSC COMPLETE NOTES
1. INTRODUCTION:
- Microcontroller: A compact integrated circuit designed to govern a specific operation in an embedded
system.
- 8051 Microcontroller: Developed by Intel in 1981; based on Harvard Architecture.
2. BASIC FEATURES OF 8051:
- 8-bit processor (ALU operates on 8-bit data)
- Clock Speed: 12 MHz (typical)
- ROM: 4 KB (on-chip program memory)
- RAM: 128 bytes (internal data memory)
- I/O Ports: 4 ports (P0, P1, P2, P3), each 8-bit
- Timers: 2 (16-bit Timer 0 and Timer 1)
- Serial Communication: Full Duplex UART
- Interrupts: 5 interrupt sources with two external interrupts
3. ARCHITECTURE BLOCKS:
- CPU: Controls data flow and instruction execution
- RAM: Temporary data storage
- ROM: Program storage (code memory)
- Timers/Counters: For delay generation and event counting
- Serial Port: Communicates with external devices (TXD/RXD)
- I/O Ports: Used for interfacing sensors and devices
- Oscillator Circuit: Connected to XTAL1/XTAL2 for clock input
- Interrupt Control: Handles external and internal interrupts
4. PIN DIAGRAM EXPLANATION (40 PINS):
- Vcc: +5V Power Supply
- GND: Ground
- XTAL1, XTAL2: Crystal oscillator inputs
- RST: Reset input (active high)
- Port 0 (P0.0 to P0.7): Address/Data lines (multiplexed)
- Port 1 (P1.0 to P1.7): I/O operations
- Port 2 (P2.0 to P2.7): Higher address byte
- Port 3 (P3.0 to P3.7): Special functions like interrupts, serial I/O, timers
- PSEN: Program Store Enable (for external ROM)
- ALE: Address Latch Enable
- EA: External Access input
5. MEMORY ORGANIZATION:
- Code Memory: 4 KB internal ROM (can be expanded externally)
- Data Memory: 128 bytes internal RAM (registers, stack, SFRs)
- SFR (Special Function Registers): Control various operations like timers, serial, interrupts
6. REGISTERS IN 8051:
- Accumulator (A): Primary register for arithmetic/logical ops
- B Register: Used for multiplication/division
- R0-R7: General purpose registers (Bank switching possible)
- DPTR: Data Pointer (16-bit)
- PC: Program Counter (16-bit)
- PSW: Program Status Word (flags: CY, AC, OV, P)
- SP: Stack Pointer
7. TIMERS/COUNTERS:
- Timer 0 and Timer 1: 16-bit each
- Modes: Mode 0 (13-bit), Mode 1 (16-bit), Mode 2 (8-bit auto reload), Mode 3 (split timer)
- Used to generate time delays or count external events
8. INTERRUPTS:
- 5 interrupt sources:
- INT0, INT1 (external interrupts)
- Timer 0, Timer 1 overflow
- Serial communication interrupt (RI/TI)
- Interrupt Priority & Enable controlled by IE and IP registers
9. SERIAL COMMUNICATION:
- UART: Full-duplex
- TXD: Transmit Data, RXD: Receive Data
- Baud rate generation via Timer 1
10. INSTRUCTION SET:
- Data Transfer: MOV, XCH, PUSH, POP
- Arithmetic: ADD, SUBB, INC, DEC, MUL, DIV
- Logical: ANL, ORL, XRL, CLR, CPL
- Branching: SJMP, LJMP, AJMP, JC, JNC, JZ, JNZ
- Bit Manipulation: SETB, CLR, CPL, ANL, ORL
11. ADDRESSING MODES:
- Immediate: MOV A, #0x25
- Register: MOV A, R1
- Direct: MOV A, 30H
- Indirect: MOV A, @R0
- Indexed: MOVC A, @A+DPTR (for ROM lookup)
12. PROGRAMMING EXAMPLES:
- LED Blinking, Delay Loop using Timer, Serial Transmission
13. APPLICATIONS OF 8051:
- Consumer electronics (TV remotes, washing machines)
- Industrial automation
- Robotics and sensor interfacing
- Communication systems
14. ADVANTAGES OF 8051:
- Simple instruction set
- Versatile applications
- Cost-effective
- Wide industry support
15. KEY POINTS FOR TNPSC EXAM:
* Understand architecture and block diagram
* Memorize pin functions
* Know register purposes (Accumulator, DPTR, SP, PSW)
* Clear on instruction types and addressing modes
* Focus on applications in real-time systems
* Learn simple embedded C/Assembly examples