8051 - Micro Controllers
8051 - Micro Controllers
Introduction
Architecture
Signal Description
Micro controller
microprocessor
Difference of MC and MP
differences
INTEL 8051
40
PIN IC
Did not have a on chip EPROM
8751 was first MC with EPROM
8951 is 8051 + EEPROM
128
byte RAM
4kb ROM
4 , 8 bit I/o PORTS
2 timers 16 bit
UART- universal asynchronous remote
transceiver
Architecture
Architecture of 8051
ACC-
Accumulator
ACC or A, 8 bit
B-
reg
The reg is used to store one of the operands for multiply and
divide instructions.
PSW-
Pointer SP-
8 bit reg, incremented before the data stored onto the stack
using the push or call.
After reset SP is initialized to 07H.
Here the stack pointer is incremented.
Data
Pointer: DTPR
16 bit reg contains a higher byte (DPH) and lower byte (DPL) of a
16 bit external RAM address.
PORT
Timer
Registers:
Registers
Timing
Reg:
ram
ALU:
Performs 8 Bit arithmetic and logical oerations
Special
Pin diagram
Vcc- 5V supply
Vss- Ground
RESET- resets 8051 if high for
2 machine cycles
ALE/PROG: - used if external
addressing is used. Else if
EPROM is used.
EA- external enable
PSEN- program store enable
PORT 0.0-0.7- Along with
address
PORT 1.0-1.7- 8 bit
bidirectional
PORT 2.0-2.7- along with
address
PORT 3.0-3.7
XTAL1,XTAL2Inbuilt oscillator and external
crystal pins
8051- 12MHz to 16Mhz freq.
Registers
14
Example:
MOV SP,#5FH
Data Pointer
Data pointer (DPTR): is used to
access external data or code.
DPTR is a 16 bit register at
addresses 82H (low byte) and
83H (high byte).
The data pointer is used in
operations regarding external
RAM and some instructions
involving code memory.
One of the
most useful
features of the
8051 is four
bidirectional
I/O ports.
Each port also
has an output
drive and an
input buffer.
Addressing Modes
There are 5 types of addressing
modes.
1.
2.
3.
4.
5.
Register addressing.
Direct addressing.
Register indirect addressing.
Immediate addressing.
Index addressing.
In
1.
2.
Immediate Addressing
Mode
1.
Instruction Set
1.
2.
3.
4.
5.
Data
Arithmetic Instructions
ADD
8-bit addition between the accumulator (A) and a
second operand.
The result is always in the accumulator.
The CY flag is set/reset appropriately.
ADD A, # 34H
ADDC
8-bit addition between the accumulator, a second
operand and the previous value of the CY flag.
Useful for 16-bit addition in two steps.
The CY flag is set/reset appropriately.
ADDC A , Rx
28
SUBB
Logical Instructions
ANL
/ ORL
ANL
ANL
ANL
ANL
ANL
ANL
A, Rn
A, direct
A, @Ri
A, #data
direct, A
direct, #data
Logical Instructions
SWAP
RLA
RLC
RRA
RRC
Branching Instructions
32
CJNE
CJNE
CJNE
CJNE
A, direct, rel
A, #data, rel
Rn, #data, rel
@Ri, #data, rel
Branching Instructions
No Operation
NOP
33