Unit-4 MMC 8051
Unit-4 MMC 8051
Unit-4 MMC 8051
ARCHITECTURE OF 8051
The Intel MCS-51 (commonly referred to as 8051) is a Harvard architecture, single chip microcontroller (μC)
series which was developed by Intel in 1980 for use in embedded systems. The 8051 architecture provides many
functions (CPU, RAM, ROM, I/O, interrupt logic, timer,etc.) in a single package
Features of 8051:
8-bit ALU, Accumulator, 8-bit Registers and 8-bit data bus; hence it is an 8-bit microcontroller
16-bit program counter
8-bit Processor Status Word(PSW)
8-bit Stack Pointer
Internal RAM of128bytes
On chip ROM is4KB
Special Function Registers (SFRs) of 128bytes
32 I/O pins arranged as four 8-bit ports (P0 -P3)
Two 16-bit timer/counters : T0 andT1
Two external and three internal vectored interrupts
Full duplex UART (serialport)
A register is a storage element that can be store bits of information. 8051 microcontroller has 4 registers bank .
These are B0, B1, B2, and B3 stand for Bank0, Bank1, Bank2, Bank3 respectively and each bank contains eight
general purpose registers ranging from ‘R0’ to ‘R7’.
These are 32 general purpose registers address from 00h to 1Fh.
The address range of Register Bank 0 ( 00 h to 07 h)
The address range of Register Bank 1 ( 08 h to F h)
The address range of Register Bank 2 ( 10 h to 17 h)
The address range of Register Bank 3 ( 18 h to 1F h)
These Register Banks are selected with the help of PSW (Program Status Word)Register bits i.e. RS0, RS1.
Accumulator (A register):
It is an 8-bit register.
It holds a data and receives the result of the arithmetic instructions.
ACC is usually accessed by direct addressing and its physical address is E0H. Accumulator is both byte
and bit addressable.
B Register:
It is 8-bit register.
It is bit and byte-addressable register.
You can access 1-bit or all 8-bits by a physical address F0h. Suppose to access a bit 1, we have to use f1.
The B register is only used for multiplication and division arithmetic operations.
PSW (Program Status Word) Register:
The PSW (Program Status Word) Register is also called as Flag Register. It is one of the important SFRs in
8051 microcontrollers. It is also an 8-bit register. It consists of Flag Bits or status bits that reflect the current
state of the CPU. This will help the programmer in checking the condition of the result and also make decisions.
PSW flag register is both bit and byte addressable. The physical address of PSW starts from D0H. The two
unused bits are user-defined flags. Four of the flags are called conditional flags, which means that they indicate
a condition which results after an instruction is executed. These four are CY (Carry), AC (auxiliary
carry), P (parity), and OV (overflow).
Timer/Counter Registers:
The 8051 has two 16-bit Programmable timers / counters (Timer 0 – Timer 1). Which can be used either
as timer to generate a time delay or as counter to count events happening outside the microcontroller.
The Counters and Timers in 8051 microcontrollers contain two special function registers: TMOD
(Timer Mode Register) and TCON (Timer Control Register).
TMODE Registers:
TMODE register is an 8-bit register.
Gate: when Gate control is set. Timer/counter is enable only while the INTx pin is high and the TRx
control pin is set. When it is cleared, the timer is enabled whenever the TRx control bit is set.
C/T: The Timer or counter selection. When cleared for timer operation (input from internal system
clock). Set for counter operation (input from Tx input pin).
Mode selects bits of TMODE register: The M1 and M0 are mode select bits, which are used to select
the timer operations. There are four modes to operate the timers.
TCON Registers:
— —
ET2 Reserved
IP (Interrupt Priority)
The IP or Interrupt Priority Register is used to set the priority of the interrupt as High or Low. If a bit is
CLEARED, the corresponding interrupt is assigned low priority and if the bit is SET, the interrupt is assigned
high priority.
PT2 - Reserved, PS- Priority of Serial Port Interrupt, PT1- Priority of Timer 1 Overflow Interrupt,
PX1- Priority of Ext. Interrupt 1, PT0- Priority of Timer 0 Overflow Interrupt
SP (Stack Pointer)
The stack is a portion of a RAM Used by the CPU to store data or memory address on temporary basis.
The stack pointer register is used to access the stack is known as SP register. The stack pointer register is
8-bits wide. It can take a value of 00 to FFH. The RAM memory location 08H is the first location used
for the stack. When the 8051 microcontroller is initialized, the SP register contains the value 07H.
If we want to store CPU register data into the stack this is known as PUSH operation and if we getting
the data from stack back into a CPU register this is known as a POP operation.
DP (Data pointer register):
The data pointer is a 16-bit register used to hold the 16-bit address of data memory. This can also be
used as two 8-bit register namely DPH and DPL. Data Pointer can be used as a single 16-bit register (as
DPTR) or two 8-bit registers (as DPL and DPH).
The 8-bit data pointers are used for accessing internal RAM and SFR. The 16-bit data pointer is used for
accessing external data memory.
The contents of data pointer are programmable using instructions. It is used by the 8051 to access
external memory using the address indicated by DPTR.
PC (program Counter):
It is a 16-bit register. It is use to hold the address of the memory location from where the next instruction to be
fetched. when the 8051 initializes PC starts at 0000h and it is automatically is incremented every time after an
instruction is executed. (So in this way PC maintain the sequence of program execution). Due to this the width
of the PC decides the max program length in bytes.
Port Registers:
8051 microcontrollers have 4 bidirectional I/O ports. Port 0, Port 1, Port 2 and Port 3 (P0, P1, P2 and P3) Which
can be work as input or output port. Each port having 8-bits. Hence, total 32 input/output pins allow the
microcontroller to communicate with outside world means this port allow to be connected with the peripheral
devices.