Professional Documents
Culture Documents
High Impedance: output is not being driven to any defined logic level
by the output circuit.
3
Microprocessor
• Mi ropro essor µP is the brain of a o puter
that has been implemented on one
semiconductor chip.
• The word comes from the combination micro and
processor.
• Processor means a device that processes
hate er i ar u ers, s a d s
To process means to manipulate. It describes all
manipulation.
Micro - > extremely small
4
Definition of a Microprocessor.
The microprocessor is a
programmable device that takes in numbers,
performs on them arithmetic or logical
operations according to the program stored in
memory and then produces other numbers as
a result.
5
Microprocessor ?
A microprocessor is multi
programmable clock driven
register based semiconductor
device that is used to fetch ,
process & execute a data
within fraction of seconds.
6
Applications
• Calculators
• Accounting system
• Games machine
• Instrumentation
• Traffic light Control
• Multi user, multi-function environments
• Military applications
• Communication systems
8
Microprocessors
• CPU for Computers
• No RAM, ROM, I/O on CPU chip itself
• E a ple: I tel's 8 , Motorola s 8
9
Microcontroller
• A smaller computer
• On-chip RAM, ROM, I/O ports...
• E a ple: Motorola s 8 , I tel s 8 , Zilog s Z8
and PIC
10
Microprocessor vs. Microcontroller
Microprocessor Microcontroller
• CPU is stand-alone, RAM, • CPU, RAM, ROM, I/O and timer
ROM, I/O, timer are separate are all on a single chip
Office
– Telephones, computers, security systems, fax machines,
microwave, copier, laser printer, color printer, paging etc.
• Auto
– Trip computer, engine control, air bag, ABS, instrumentation,
security system, transmission control, entertainment, climate
control, cellular phone, keyless entry
12
8051 CPU Operation
1. Pin Diagram
2. Block Diagram
14
Pin Diagram of the 8051
15
General Block Diagram of 8051
CPU
Bus Serial
OSC 4 I/O Ports
Control Port
TXD RXD 16
P0 P1 P2 P3
Detailed Block Diagram
17
Program Status Word [PSW]
C AC F0 RS1 RS0 OV F1 P
Carry Parity
Auxiliary Carry User Flag 1
18
19
BEFORE EXECUTION AFTER EXECUTION
20
BEFORE EXECUTION AFTER EXECUTION
B F8H B F8H
AC
1
A = 0000 1100
B = 1111 1000 A = 0CH
0000 0100 B = F8H
1
1 04H
CY
CY
21
8051 instructions that affects flag
22
Special
Function
Register [SFR]
23
Special Function Registers [SFR]
24
SFR Registers & their Addresses
MOV 0E0H,#55H ;is the same as
MOV A,#55H ;which means load 55H into A (A=55H)
25
8051
Memory Space
26
8051 Memory Structure
External
External
60K
64K 64K
SFR
EXT INT 4K
128
EA = 0 EA = 1
29
8051 Register Bank Structure
Bank 3 R0 R1 R2 R3 R4 R5 R6 R7
Bank 2 R0 R1 R2 R3 R4 R5 R6 R7
Bank 1 R0 R1 R2 R3 R4 R5 R6 R7
Bank 0 R0 R1 R2 R3 R4 R5 R6 R7
30
8051 Register Banks with address
31
8051 Programming Model
32
8051 Stack
• The stack is a section of RAM used by the CPU to
store information temporarily.
– This information could be data or an address
33
8051 Stack
• The storing of a CPU register in the stack is called a PUSH
– SP is pointing to the last used location of the stack
– As we push data onto the stack, the SP is incremented
by one
– This is different from many microprocessors
(1) STACK
POINTER
INCREMENTS SP & STORES DPL
35
BEFORE EXECUTION
SP 07H
09H
08H
DPH 10 DPL 50
07H
PUSH DPL
PUSH DPH
AFTER EXECUTION
09H 10
SP 09H
08H 50
DPH 10 DPL 50
07H
36
POP DPL
POP DPH
INITIAL POSITION AND READS DATA 1
(1) STACK DATA 1
POINTER
DECREMENTS SP
DATA 1
DATA 2
(3) STACK
POINTER 37
BEFORE EXECUTION
09H 30
SP 09H
08H 50
DPH DP
L 07H
POP DPL
POP DPH
AFTER EXECUTION
09H 30
SP 07H 08H 50
DP 5 DP 30 07H
H 0 L 38
External memory
8051
Addressing
Modes
40
8051 Addressing Modes
42
2. Register Addressing Mode
• Use registers to hold the data to be manipulated.
44
4. Stack Addressing Mode
• Only direct addressing mode is allowed for
pushing or popping the stack.
• PUSH A is invalid.
45
5. Register Indirect Addressing Mode
• A register is used as a pointer to the data.
• Only register R0 and R1 are used for this purpose.
• R2 – R7 cannot be used to hold the address of an
operand located in RAM.
• When R0 and R1 hold the addresses of RAM
locations, they must be preceded by the @
sign.
46
Examples
• Write a program to copy the value 55H into RAM memory locations 40H
to 41H using (a) direct addressing mode, (b) register indirect addressing
mode without a loop, and (c) with a loop.
47
6. External Direct
• External Memory is accessed.
51