1.
Fundamentals of Microprocessors
A microprocessor is the central processing unit (CPU) of a computer, integrated into a single
chip. It's the "brain" of a digital system, executing instructions and performing calculations.
● Key Components:
○ ALU (Arithmetic Logic Unit): Performs arithmetic (addition, subtraction) and
logical (AND, OR, NOT) operations.
○ Control Unit: Directs and coordinates all microprocessor operations, including
fetching, decoding, and executing instructions.
○ Registers: Small, high-speed memory locations for temporary data storage.
Examples include the Accumulator (A), Data Pointer (DPTR), and Program Counter
(PC).
○ Buses: Communication pathways.
■ Data Bus: Carries data between the CPU, memory, and I/O devices.
■ Address Bus: Carries memory addresses from the CPU to memory and I/O
devices.
■ Control Bus: Carries control signals to manage the flow of data.
● Fetch-Decode-Execute Cycle: This is the basic operation cycle of a microprocessor.
1. Fetch: The CPU fetches an instruction from memory.
2. Decode: The instruction is decoded to determine the operation.
3. Execute: The operation is performed.
2. The 8051 Microcontroller Architecture
The 8051 is a popular 8-bit microcontroller known for its simple architecture and widespread use
in embedded systems.
● Key Features:
○ CPU: 8-bit.
○ On-chip Memory:
■ ROM: 4KB (Read-Only Memory) for storing the program code.
■ RAM: 128 bytes (Random Access Memory) for data storage.
○ I/O Ports: Four 8-bit I/O ports (P0, P1, P2, P3).
○ Timers/Counters: Two 16-bit timers/counters.
○ Interrupts: Five interrupt sources.
○ Serial Communication: Built-in serial port (UART).
● Harvard Architecture: The 8051 uses a Harvard architecture, which means it has
separate memory spaces and buses for program code (ROM) and data (RAM). This
allows for simultaneous fetching of instructions and data, improving performance.
3. Instruction Set and Programming
The instruction set is the list of all commands a microprocessor can understand and execute.
The 8051 has a powerful instruction set categorized as:
● Arithmetic Instructions: Add, subtract, multiply, divide, increment, decrement. (e.g.,
ADD A, R0)
● Logical Instructions: Bit-wise AND, OR, XOR, complement. (e.g., ANL A, R1)
● Data Transfer Instructions: Move data between registers, memory, and I/O ports. (e.g.,
MOV A, #55H)
● Jump & Call Instructions: For controlling program flow. JMP for unconditional jumps, JZ
for jump if zero, etc. CALL for calling subroutines. (e.g., LJMP label)
● Bit-Oriented Instructions: Used for single-bit manipulation, which is a key feature of the
8051. (e.g., SETB P1.0)
4. Addressing Modes
Addressing modes define how the microprocessor accesses the operands (data) for an
instruction. The 8051 supports five main addressing modes:
● Immediate Addressing: The operand value is part of the instruction itself.
○ Example: MOV A, #25H (moves the value 25H to the accumulator A). The #
symbol indicates an immediate value.
● Register Addressing: The operand is in one of the 8051's internal registers (A, B,
R0-R7).
○ Example: ADD A, R1 (adds the content of R1 to the accumulator A).
● Direct Addressing: The instruction specifies the direct address of the operand in internal
RAM or Special Function Registers (SFRs).
○ Example: MOV P1, A (moves the content of A to Port 1).
● Register-Indirect Addressing: The register (R0 or R1) holds the address of the operand
in internal or external RAM.
○ Example: MOV A, @R0 (moves the content of the memory location pointed to by
R0 to A).
● Indexed Addressing: The effective address is calculated by adding the value of a base
register (DPTR or PC) and the accumulator (A). This is used for reading from code
memory (ROM).
○ Example: MOVC A, @A+DPTR (moves a byte from code memory to A).
5. Memory and I/O Expansion
The 8051 has a limited amount of on-chip memory. For applications requiring more memory or
I/O, external chips can be interfaced.
● Memory Expansion: External ROM and RAM can be connected using the 8051's
dedicated pins. The PSEN (Program Store Enable) pin is used to enable external ROM,
while the RD (Read) and WR (Write) pins are used for external RAM. Ports P0 and P2 are
multiplexed to serve as the address and data buses for external memory.
● I/O Expansion: The 8051's four ports can be used for I/O, and additional I/O devices can
be interfaced by mapping them to external memory addresses.
6. Interfacing of Peripheral Devices
Interfacing is the process of connecting external devices to the microprocessor.
● Control Signals: The ALE (Address Latch Enable) and PSEN signals are crucial for
demultiplexing the address/data buses to correctly access external memory and
peripherals. The RD and WR signals control read and write operations.
● Interfacing ADC/DAC:
○ ADC (Analog-to-Digital Converter): Converts analog signals (like temperature or
pressure) into digital data that the microprocessor can process. The microprocessor
sends a Start of Conversion (SOC) signal and then waits for an End of
Conversion (EOC) signal before reading the digital output.
○ DAC (Digital-to-Analog Converter): Converts digital data from the microprocessor
into an analog signal (e.g., for controlling motor speed).
● Timers & Counters: The 8051 has built-in timers that can be used for:
○ Timers: Generating precise time delays or timing events.
○ Counters: Counting external events (e.g., pulses from a sensor).
● Memory Devices: External RAM (like SRAM or DRAM) and ROM (like EPROM or Flash)
can be interfaced to expand the system's memory capacity.