Microprocessor & Microcontroller
Microprocessor & Microcontroller
Microprocessor & Microcontroller
Microprocessor-based system
2. Key Concepts
● Bit and Word:
○ Bit: Smallest unit of data in computing, represented by 0 or 1.
○ Word: A fixed-sized piece of data handled as a unit by the microprocessor
(e.g., 16-bit, 32-bit).
● Bus System:
○ Data Bus: Carries data between the processor, memory, and peripherals.
○ Address Bus: Transmits the address of the data.
○ Control Bus: Manages control signals and the coordination of different
parts of the computer.
3. Microprocessor Architecture
● ALU (Arithmetic and Logic Unit):
○ Performs arithmetic (addition, subtraction) and logic operations (AND,
OR).
○ Stores result in the accumulator.
● Registers:
○ General-Purpose Registers: Six 8-bit registers (B, C, D, E, H, L) that can
form 16-bit register pairs (BC, DE, HL).
○ Accumulator (A): An 8-bit register used for arithmetic and logic
operations.
○ Flag Register: Consists of five flags (Zero, Sign, Parity, Carry, Auxiliary
Carry) that indicate the outcome of operations.
● Control Unit: Directs the operation of the processor by generating control
signals.
4. Microprocessor Classification
● Data Bus Width:
○ 4-bit, 8-bit, 16-bit, 32-bit processors: Refers to the size of the data bus,
determining how much data can be processed at a time.
● Application-Based:
○ General-Purpose Microprocessors: Used in general computing (e.g.,
Intel Pentium).
○ Microcontrollers: Integrated with memory and I/O ports for specific
control applications (e.g., 8051).
○ Special-Purpose Processors: Designed for specific tasks like signal
processing (DSPs, ASICs).
● Architecture-Based:
○ RISC (Reduced Instruction Set Computer): Simplified instructions for
fast execution.
○ CISC (Complex Instruction Set Computer): More complex instructions
that can perform multiple operations.
● Registers:
○ Accumulator (A): Core register for arithmetic operations.
○ Flag Registers:
Flag register
■ Zero (Z) Flag: Set to 1 if the result of an operation is zero.
■ Carry (CY) Flag: Set to 1 if an arithmetic operation results in a
carry out of the most significant bit.
■ Sign (S) Flag: Copies the most significant bit of the result to
indicate its sign (1 for negative, 0 for positive).
■ Parity (P) Flag: Set to 1 if the result has an even number of 1s.
■ Auxiliary Carry (AC) Flag: Set to 1 if there is a carry from bit D3 to
bit D4.
○ General Purpose Registers: B, C, D, E, H, L, used for temporary data
storage.
○ Stack Pointer (SP): Points to the top of the stack, a special region in
memory used for temporary storage during function calls.
○ Program Counter (PC): Holds the address of the next instruction to be
executed.
● Instruction Set:
○ Data Transfer: MOV, MVI (move instructions).
○ Arithmetic: ADD, SUB, INR, DCR.
○ Logical: ANA, XRA, CMP.
○ Branching: JMP, CALL, RET, conditional branches.
○ Machine Control: HLT, NOP (No Operation), DI (Disable Interrupts), EI
(Enable Interrupts).
● Timing and Control Unit:
○ Generates control signals for data bus, address bus, and control bus
coordination.
○ Controls machine cycles: Fetch, decode, and execute.
3. Instruction Cycle
● Fetch-Decode-Execute:
○ Fetch: Retrieve the instruction from memory.
○ Decode: Interpret the instruction.
○ Execute: Perform the operation.
4. 8085 Pin Configuration and Signals
SI S0 States
0 0 Halt
0 1 Write
1 0 Read
1 1 Fetch
3. Masking Interrupts
● Masking: Selectively disabling specific interrupts.
● EI: Enable interrupts.
● DI: Disable interrupts.
● SIM/RIM Instructions: Set Interrupt Mask and Read Interrupt Mask.
The 8051 microcontroller is one of the most widely used microcontrollers in embedded systems.
Its architecture, memory management, and features make it a powerful tool for controlling
various electronic devices.
Key Features:
Pin 9 (RST):
Architecture:
The 8051 architecture is designed to be efficient and straightforward, making it ideal for a range
of applications. It includes:
FLAG:
● Carry Flag(CY): During addition and subtraction any carry or borrow is generated then
carry flag is set otherwise carry flag resets. It is used in arithmetic, logical, jump, rotate
● Auxiliary carry flag(AC): If during addition and subtraction any carry or borrow is
generated from lower 4 bit to higher 4 bit then AC sets else it resets. It is used in BCD
arithmetic operations.
● Overflow flag(OV): If in signed arithmetic operations result exceeds more than 7 bit
than OV flag sets else resets.It is used in signed arithmetic operations only.
● Parity flag(P): If in result, even no. Of ones "1" are present than it is called even parity
and parity flag sets. In result odd no. Of ones "1"are present than it is called odd parity
Memory Organization:
● Program Memory (ROM): Used to store the program code. Early models used external
memory for this purpose, but later versions included internal ROM.
● Data Memory (RAM): Used for storing data and intermediate results. The internal RAM
is divided into three main areas:
○ Working Registers: 32 bytes from 00h to 1Fh.
○ Bit-Addressable Area: 16 bytes from 20h to 2Fh.
○ General-Purpose RAM: 80 bytes from 30h to 7Fh.
2. Arithmetic Instructions
3. Logical Instructions
These instructions are used for bitwise logical operations, including AND, OR, XOR, and rotate
operations.
● ANL dest, src: Perform bitwise AND operation between source and destination.
○ Example: ANL A, R1 (AND the contents of R1 with the accumulator).
● ORL dest, src: Perform bitwise OR operation between source and destination.
● XRL dest, src: Perform bitwise XOR operation between source and destination.
● CLR A: Clear the accumulator.
● CPL A: Complement the bits of the accumulator.
● RL A: Rotate the bits of the accumulator left.
● RLC A: Rotate the bits of the accumulator left through the carry.
● RR A: Rotate the bits of the accumulator right.
● RRC A: Rotate the bits of the accumulator right through the carry.
4. Control Instructions
Control instructions are used for controlling the flow of the program, including jumps, calls, and
returns.
● ACALL addr11: Absolute call to a subroutine within the same 2K block.
● LCALL addr16: Long call to a subroutine located anywhere in the 64K code memory.
● LJMP addr16: Long jump to any location in the 64K code memory.
● SJMP rel: Short jump relative to the current PC.
● JZ rel: Jump if the accumulator is zero.
● JNZ rel: Jump if the accumulator is not zero.
● CJNE dest, src, rel: Compare and jump if not equal.
● DJNZ reg, rel: Decrement the register and jump if not zero.
These instructions are used to operate on individual bits in the registers or memory.
These instructions provide direct control over the individual bits, allowing detailed and efficient
manipulation of data.
7. Miscellaneous Instructions
These include other operations that do not fit into the above categories.
Interrupt System:
The 8051 has a robust interrupt system that allows it to handle external and internal events
efficiently. The interrupt system can pause the main program, execute a predefined routine, and
then resume the program. Key features include: