You are on page 1of 18

EXPT NO: 1

DATE: 8.7.13

ARCHITECTURE OF 8051 MICROCONTROLLER

Aim:
To study about the architecture of 8051 microcontroller.
Introduction:
The 8051 Microcontroller was designed in 1980’s by Intel. Its foundation
was on Harvard Architecture and was developed principally for bringing
into play in Embedded Systems. At first it was created by means of NMOS
technology but as NMOS technology needs more power to function therefore
Intel re-intended Microcontroller 8051 employing CMOS technology and a
new edition came into existence with a letter ‘C’ in the title name, for
illustration: 80C51.
There are two buses in 8051 Microcontroller one for program and other for
data. As a result, it has two storage rooms for both program and data of 64K
by 8 size. The microcontroller comprise of 8 bit accumulator & 8 bit
processing unit. It also consists of 8 bit B register as majorly functioning
blocks. It also has a number of other 8 bit and 16 bit registers.
Features of 8051 microcontroller:

The features of 8051 microcontroller are:• It is 8 bit Micro Controller
• It has on chip oscillator and clock generator circuit with operating
frequency 12MHz.
• It has on chip 4Kb ROM which can be expanded up to 64 kb
• It has 128 bytes of on chip RAM
• It has 4 register banks: bank 0, bank 1, bank 2, and bank 3. Each register
bank consists of 8 register.
• 16 memory location of data memory are bit/byte addressable
• The data memory can be expanded upto 64kb
1

• It has 4 parallel I/O port: port0, port1, port2, port3. Each port is 8-bit
directional I/O port. Each port is bit/byte addressable.
• It has two 16 bit multi-mode programmable timer/counter
• It has multi-mode high speed programmable full duplex serial port.
• It has 5 hardware interrupt: 3 internal interrupt and 2 external
interrupt. All 5 interrupt are operated in two priority level
• It has on chip power saving circuit operated in two modes: 1. idle mode, 2.
Power down mode.
• It has 11 special function register.
• It has 111 instructions, 64 instructions are single cycle.
• It has on chip Boolean processor for single bit manipulation.
Block Diagram of 8051 Microcontroller:
The bock diagram of 8051 microcontroller is explained below:
CPU (Central Processor Unit):
The Central Processor Unit or CPU is the mind of any processing machine. It
scrutinizes and manages all processes that are carried out in the
Microcontroller. User has no power over the functioning of CPU. It interprets
program printed in storage space (ROM) and carries out all of them and do
the projected duty.
Interrupts:
Interrupt is a sub-routine call that reads the Microcontroller’s key function or
job and helps it to perform some other program which is extra important at
that point of time. The characteristic of Interrupt is extremely constructive as
it aids in emergency cases. Interrupts provides us a method to postpone or
delay the current process, carry out a sub-routine task and then all over
again restart standard program implementation.
The Micro-controller 8051 can be assembled in such a manner that it
momentarily stops or break the core program at the happening of interrupt.
When sub-routine task is finished then the implementation of core program
3

initiates automatically as usual. There are 5 interrupt supplies in 8051
Microcontroller, two out of five are peripheral interrupts, two are timer
interrupts and one is serial port interrupt.
Memory:
Micro-controller needs a program which is a set of commands. This program
enlightens Microcontroller to perform precise tasks. These programs need a
storage space on which they can be accumulated and interpret by
Microcontroller to act upon any specific process. The memory which is
brought into play to accumulate the program of Microcontroller is recognized
as Program memory or code memory. In common language it’s also known as
Read Only Memory or ROM.
Micro-controller also needs a memory to amass data or operands for the short
term. The storage space which is employed to momentarily data storage for
functioning is acknowledged as Data Memory and we employ Random Access
Memory or RAM for this principle reason. Microcontroller 8051 contains code
memory or program memory 4K so that it has 4KB Rom and it also comprise
of data memory (RAM) of 128 bytes.
Bus:
Fundamentally Bus is a group of wires which functions as a communication
canal or mean for the transfer Data. These buses comprise of 8, 16 or more
cables. As a result, a bus can bear 8 bits, 16 bits all together. There are two
types of buses:
1. Address Bus: Microcontroller 8051 consists of 16 bit address bus. It is
brought into play to address memory positions. It is also utilized to
transmit the address from Central Processing Unit to Memory.
2. Data Bus: Microcontroller 8051 comprise of 8 bits data bus. It is
employed to cart data.
5

Oscillator:
Microcontroller 8051 consists of an on-chip oscillator which toils as a time
source for CPU (Central Processing Unit). As the productivity thumps of
oscillator are steady as a result, it facilitates harmonized employment of all
pieces of 8051 Microcontroller.
Input/output Port:
Micro-controller 8051 consists of 4 input/output ports to unite it to other
peripherals.
Timers/Counters:
Micro-controller 8051 is incorporated with two 16 bit counters & timers. The
counters are separated into 8 bit registers. The timers are utilized for
measuring the intervals, to find out pulse width etc.
Special Function Registers (SFRs)
Special Function Registers (SFRs) are a sort of control table used for running
and monitoring the operation of the microcontroller. Each of these registers
as well as each bit they include, has its name, address in the scope of RAM
and precisely defined purpose such as timer control, interrupt control, serial
communication control etc. Even though there are 128 memory locations
intended to be occupied by them, the basic core, shared by all types of 8051
microcontrollers, has only 21 such registers. Rest of locations are
intentionally left unoccupied in order to enable the manufacturers to further
develop microcontrollers keeping them compatible with the previous versions.
A Register (Accumulator)
A register is a general-purpose register used for storing intermediate results
obtained during operation. Prior to executing an instruction upon any
number or operand it is necessary to store it in the accumulator first. All
results obtained from arithmetical operations performed by the ALU are
stored in the accumulator. Data to be moved from one register to another
must go through the accumulator. In other words, the A register is the most
7

commonly used register and it is impossible to imagine a microcontroller
without it. More than half instructions used by the 8051 microcontroller use
somehow the accumulator.
B Register
Multiplication and division can be performed only upon numbers stored in
the A and B registers. All other instructions in the program can use this
register as a spare accumulator (A).
R Registers (R0-R7)
This is a common name for 8 general-purpose registers (R0, R1, R2 ...R7).
Even though they are not true SFRs, they deserve to be discussed here
because of their purpose. They occupy 4 banks within RAM. Similar to the
accumulator, they are used for temporary storing variables and intermediate
results during operation. Which one of these banks is to be active depends on
two bits of the PSW Register. Active bank is a bank the registers of which are
currently used.
Program Status Word (PSW) Register
PSW register is one of the most important SFRs. It contains several status
bits that reflect the current state of the CPU. Besides, this register contains
Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity
bit and user-definable status flag.
P - Parity bit. If a number stored in the accumulator is even then this bit
will be automatically set (1), otherwise it will be cleared (0). It is mainly used
during data transmit and receive via serial communication.
- Bit 1. This bit is intended to be used in the future versions of
microcontrollers.
OV Overflow occurs when the result of an arithmetical operation is larger
than 255 and cannot be stored in one register. Overflow condition causes the
OV bit to be set (1). Otherwise, it will be cleared (0).
9

RS0, RS1 - Register bank select bits. These two bits are used to select one of
four register banks of RAM. By setting and clearing these bits, registers R0-R7
are stored in one of four banks of RAM.
F0 - Flag 0. This is a general-purpose bit available for use.
AC - Auxiliary Carry Flag is used for BCD operations only.
CY - Carry Flag is the (ninth) auxiliary bit used for all arithmetical
operations and shift instructions.
Data Pointer Register (DPTR)
DPTR register is not a true one because it doesn't physically exist. It consists
of two separate registers: DPH (Data Pointer High) and (Data Pointer Low).
For this reason it may be treated as a 16-bit register or as two independent 8bit registers. Their 16 bits are primarily used for external memory
addressing. Besides, the DPTR Register is usually used for storing data and
intermediate results.
Stack Pointer (SP) Register
A value stored in the Stack Pointer points to the first free stack address and
permits stack availability. Stack pushes increment the value in the Stack
Pointer by 1. Likewise, stack pops decrement its value by 1. Upon any reset
and power-on, the value 7 is stored in the Stack Pointer, which means that
the space of RAM reserved for the stack starts at this location. If another
value is written to this register, the entire Stack is moved to the new memory
location.
P0, P1, P2, P3 - Input/output Registers
If neither external memory nor serial communication system are used then 4
ports within total of 32 input/output pins are available for connection to
peripheral environment. Each bit within these ports affects the state and
performance of appropriate pin of the microcontroller. Thus, bit logic state is
reflected on appropriate pin as a voltage (0 or 5 V) and vice versa, voltage on
a pin reflects the state of appropriate port bit.
11

Explanation on 8051 Pin Diagram:
The 8051 pin diagram is explained below:
Pins 1 – 8:- recognized as Port 1. Port 1 is a domestically pulled up, quasi bi
directional Input/output port.
Pin 9:- As made clear previously RESET pin is utilized to set the microcontroller 8051 to its primary values, whereas the micro-controller is
functioning or at the early beginning of application. The RESET pin has to be
set elevated for two machine rotations.
Pins 10 – 17:- recognized as Port 3. This port also supplies a number of other
functions such as timer input, interrupts, serial communication indicators
TxD&RxD, control indicators for outside memory interfacing WR & RD, etc.
This is a domestic pull up port with quasi bi directional port within.
Pins 18 and 19:- These are employed for interfacing an outer crystal to give
system clock.
Pin 20:- Titled as Vss – it symbolizes ground (0 V) association.
Pins- 21-28:- recognized as Port 2 (P 2.0 – P 2.7) – other than serving as
Input/output port, senior order address bus indicators are multiplexed with
this quasi bi directional port.
Pin- 29:- Program Store Enable or PSEN is employed to interpret sign from
outer program memory.
Pin-30:- External Access or EA input is employed to permit or prohibit outer
memory interfacing. If there is no outer memory need, this pin is dragged
high by linking it to Vcc.

13

Pin-31:- Address Latch Enable or ALE is brought into play to de-multiplex
the address data indication of port 0 (for outer memory interfacing).
Pins 32-39: recognized as Port 0 (P0.0 to P0.7) – other than serving as
Input/output port, low order data & address bus signals are multiplexed with
this port (to provide the use of outer memory interfacing). This pin is a bi
directional Input/output port (the single one in microcontroller 8051) and
outer pull up resistors are necessary to utilize this port as Input/output.
Pin-40: termed as Vcc is the chief power supply. By and large it is +5V DC.
Counters and Timers:
TMOD Register (Timer Mode)
The TMOD register selects the operational mode of the timers T0 and T1. As
seen in figure, the low 4 bits (bit0 - bit3) refer to the timer 0, while the high 4
bits (bit4 - bit7) refer to the timer 1. There are 4 operational modes and each
of them is described.
Timer Control (TCON) Register
TCON register is also one of the registers whose bits are directly in control of
timer operation. Only 4 bits of this register are used for this purpose, while
rest of them is used for interrupt control.
Power Control (PCON) Register
The purpose of the Register PCON bits is:

SMOD Baud rate is twice as much higher by setting this bit.

GF1 General-purpose bit (available for use).

GF1 General-purpose bit (available for use).

GF0 General-purpose bit (available for use).

PD By setting this bit the microcontroller enters the Power Down mode.

IDL By setting this bit the microcontroller enters the idle mode.

15

8051 Microcontroller Applications:
The microcontroller 8051 has been in application in a large amount of
machines, principally because it is simple to incorporate in a project or to
assemble a machine around it. The following are the key spots of spotlight:
Energy

Management: Competent

measuring

device

systems aid in

calculating energy consumption in domestic and industrialized applications.
These meter systems are prepared competent by integrating microcontrollers.
Touch screens: A high degree of microcontroller suppliers integrate touch
sensing abilities in their designs. Transportable devices such as media
players, gaming devices & cell phones are some illustrations of microcontroller integrated with touch sensing screens.
Automobiles: The microcontroller 8051 discovers broad recognition in
supplying automobile solutions. They are extensively utilized in hybrid motor
vehicles to control engine variations. In addition, works such as cruise power
and anti-brake mechanism has created it more

capable with the

amalgamation of micro-controllers.

Medical Devices: Handy medicinal gadgets such as glucose & blood
pressure monitors bring into play micro-controllers, to put on view the
measurements, as a result, offering higher dependability in giving correct
medical results.

Result:
Thus the architecture of 8051 microcontroller was studied.

17

8051 BLOCK DIAGRAM

8051 PIN DIAGRAM

2

FLAG BITS AND THE PSW REGISTER

TMOD (Timer/Counter Mode control Register)




GATE1 enables and disables Timer 1 by means of a signal brought to the
INT1 pin (P3.3):
1 - Timer 1 operates only if the INT1 bit is set.
0 - Timer 1 operates regardless of the logic state of the INT1 bit.
C/T1 selects pulses to be counted up by the timer/counter 1:
1 - Timer counts pulses brought to the T1 pin (P3.5).
0 - Timer counts pulses from internal oscillator.
T1M1, T1M0these two bits select the operational mode of the Timer 1.
GATE0 enables and disables Timer 1 using a signal brought to the INT0
pin (P3.2):
1 - Timer 0 operates only if the INT0 bit is set.
0 - Timer 0 operates regardless of the logic state of the INT0 bit.
C/T0 selects pulses to be counted up by the timer/counter 0:
1 - Timer counts pulses brought to the T0 pin (P3.4).
0 - Timer counts pulses from internal oscillator.
T0M1, T0M0these two bits select the operational mode of the Timer 0.

4

Timer Control (TCON) Register


TF1 bit is automatically set on the Timer 1 overflow.
TR1 bit enables the Timer 1.
1 - Timer 1 is enabled.
0 - Timer 1 is disabled.
• TF0 bit is automatically set on the Timer 0 overflow.
• TR0 bit enables the timer 0.
1 - Timer 0 is enabled.
0 - Timer 0 is disabled.

Serial Port Control (SCON) Register



SM0 - Serial port mode bit 0 is used for serial port mode selection.
SM1 - Serial port mode bit 1.
SM2 - Serial port mode 2 bit, also known as multiprocessor communication
enable bit. When set, it enables multiprocessor communication in mode 2 and 3, and
eventually mode 1. It should be cleared in mode 0.
• REN - Reception Enable bit enables serial reception when set. When cleared,
serial reception is disabled.
• TB8 - Transmitter bit 8. Since all registers are 8-bit wide, this bit solves the
problem of transmitting the 9th bit in modes 2 and 3. It is set to transmit logic 1 in
the 9th bit.
• RB8 - Receiver bit 8 or the 9th bit received in modes 2 and 3. Cleared by
hardware if 9th bit received is logic 0. Set by hardware if 9th bit received is logic 1.
• TI- Transmit Interrupt flag is automatically set at the moment the last bit of
one byte is sent. It's a signal to the processor that the line is available for a new
byte transmit. It must be cleared from within the software.

6

• RI

- Receive Interrupt flag is automatically set upon one byte receive. It signals
that byte is received and should be read quickly prior to being replaced by a new
data. This bit is also cleared from within the software.

Power Control (PCON) register

IE Register (Interrupt Enable)

EA - global interrupt enable/disable:
•0
•1

- disables all interrupt requests.
- enables all individual interrupt requests.
ES - enables or disables serial interrupt:

•0
•1

- UART system cannot generate an interrupt.
- UART system enables an interrupt.
ET1 - bit enables or disables Timer 1 interrupt:

•0
•1

- Timer 1 cannot generate an interrupt.
- Timer 1 enables an interrupt.
EX1 - bit enables or disables external 1 interrupt:

•0
•1

- change of the pin INT0 logic state cannot generate an interrupt.
- enables an external interrupt on the pin INT0 state change.
ET0 - bit enables or disables timer 0 interrupt:
•0
•1

- Timer 0 cannot generate an interrupt.
- enables timer 0 interrupt.
EX0 - bit enables or disables external 0 interrupt:

•0
•1

- change of the INT1 pin logic state cannot generate an interrupt.
- enables an external interrupt on the pin INT1 state change
8

10

12

14

16