You are on page 1of 17

Microcontroller: Comparison between microprocessor and micro controller, Organization of a

microcontroller system, Architecture of MCS 51 /ATMEL /PIC controller, Pin diagram of 8051,
Addressing modes, Instruction types and set, Selection and Applications of Microcontroller

1. Internal Architecture of 8085 Microprocessor

a. Control Unit
Generates signals within Microprocessor to carry out the instruction, which has been decoded. In reality
causes certain connections between blocks of the Microprocessor to be opened or closed, so that data goes
where it is required, and so that ALU operations occur.
b. Arithmetic Logic Unit
The ALU performs the actual numerical and logic operation such as ‘add’, ‘subtract’, ‘AND’, ‘OR’, etc.
Uses data from memory and from Accumulator to perform arithmetic. Always stores result of operation
in Accumulator.
c. Registers
The 8085/8080A-programming model includes six registers, one accumulator, and one flag
register, as shown in Figure. In addition, it has two 16-bit registers: the stack pointer and the
program counter. They are described briefly as follows.
The 8085/8080A has six general-purpose registers to store 8-bit data; these are identified as
B, C, D, E, H, and L as shown in the figure. They can be combined as register pairs - BC, DE,
and HL - to perform some 16-bit operations. The programmer can use these registers to store or
copy data into the registers by using data copy instructions.

i. Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit (ALU). This register is
used to store 8-bit data and to perform arithmetic and logical operations. The result of an
operation is stored in the accumulator. The accumulator is also identified as register A.
ii. Flags
The ALU includes five flip-flops, which are set or reset after an operation according to data
conditions of the result in the accumulator and other registers. They are called Zero(Z), Carry
(CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags; they are listed in the Table and their
bit positions in the flag register are shown in the Figure below.
The most commonly used flags are Zero, Carry, and Sign. The microprocessor uses these flags to
test data conditions..
Carry (CY) :- after an addition of two numbers, if the sum in the accumulator id larger
than eight bits, the flip-flop uses to indicate a carry -- called the Carry flag (CY) – is set
to one.
Zero flag (Z) :-When an arithmetic operation results in zero, the flip-flop called the
Zero(Z) flag is set to one.
Flag register:- The first Figure shows an 8-bit register, called the flag register, adjacent
to the accumulator. However, it is not used as a register; five bit positions out of eight are
used to store the outputs of the five flip-flops. The flags are stored in the 8-bit register so
that the programmer can examine these flags (data conditions) by accessing the register
through an instruction. These flags have critical importance in the decision-making
process of the microprocessor. The conditions (set or reset) of the flags are tested through
the software instructions.
For example, the instruction JC (Jump on Carry) is implemented to change the sequence of a
program when CY flag is set. The thorough understanding of flag is essential in writing assembly
language programs.
d. Program Counter (PC)
This 16-bit register deals with sequencing the execution of instructions. This register is a
memory pointer. Memory locations have 16-bit addresses, and that is why this is a 16-bit
register. The microprocessor uses this register to sequence the execution of the instructions. The
function of the program counter is to point to the memory address from which the next byte is to
be fetched. When a byte (machine code) is being fetched, the program counter is incremented by
one to point to the next memory location.
e. Stack Pointer (SP)
The stack pointer is also a 16-bit register used as a memory pointer. It points to a memory
Location in R/W memory, called the stack. The beginning of the stack is defined by loading 16-
bit address in the stack pointer. The stack concept is explained in the chapter "Stack and
Subroutines.

f. Instruction Register/Decoder
Temporary store for the current instruction of a program. Latest instruction sent here from
memory prior to execution. Decoder then takes instruction and ‘decodes’ or interprets the
instruction. Decoded instruction then passed to next stage.
g. Memory Address Register
Holds address, received from PC, of next program instruction. Feeds the address bus with
addresses of location of the program under execution.
h. Control Generator
Generates signals within uP to carry out the instruction which has been decoded. In reality causes
certain connections between blocks of the uP to be opened or closed, so that data goes where it is
required, and so that ALU operations occur.
i. Register Selector
This block controls the use of the register stack in the example. Just a logic circuit which
Switches between different registers in the set will receive instructions from Control Unit.
j. General Purpose Registers
uP requires extra registers for versatility. Can be used to store additional data during a program.
More complex processors may have a variety of differently named registers.

2.8085 Pin description.


The 8085 and Its Buses
 The 8085 is an 8-bit general purpose microprocessor that can address 64K Byte of
memory.
 It has 40 pins and uses +5V for power. It can run at a maximum frequency of 3 MHz
-The pins on the chip can be grouped into 6 groups:
 Address Bus.
 Data Bus.
 Control and Status Signals.
 Power supply and frequency.
 Externally Initiated Signals.
 Serial I/O ports.
Fig:- 8085 Pin diagram
The following describes the function of each pin:
A6 - A1s (Output 3 State):-Address Bus; The most significant 8 bits of the memory
address or the 8 bits of the I/0 address,3 stated during Hold and Halt modes.
AD0 - 7 (Input /Output 3state):-Multiplexed Address/Data Bus; Lower 8 bits of the
memory address (or I/0 address) appear on the bus during the first clock cycle of a
machine state. It then becomes the data bus during the second and third clock cycles. 3
stated during Hold and Halt modes.
ALE (Output):-Address Latch Enable: It occurs during the first clock cycle of a machine
state and enables the address to get latched into the on chip latch of peripherals. The
falling edge of ALE is set to guarantee setup and hold times for the address
information.ALE can also be used to strobe the status information. ALE is never 3stated.
RD (Output 3state):-READ; indicates the selected memory or 1/0 device is to be read
and that the Data Bus is available for the data transfer.
WR (Output 3state):-WRITE; indicates the data on the Data Bus is to be written into the
selected memory or 1/0 location. Data is set up at the trailing edge of WR. 3 stated during
Hold and Halt modes.
SO, S1 (Output):-Data Bus Status. Encoded status of the bus cycle:
S1 S0
. 0 0 Halt
0 1 Write
1 0 Read
1 1 Fetch
READY (Input):-If Ready is high during a read or writes cycle, it indicates that the
memory or peripheral is ready to send or receive data. If Ready is low, the CPU will wait
for Ready to go high before completing the read or write cycle.
HOLD (Input):0HOLD; indicates that another Master is requesting the use of the
Address and Data Buses. The CPU, upon receiving the Hold request. It will relinquish the
use of buses as soon as the completion of the current machine cycle. Internal processing
can continue. The processor can regain the buses only after the Hold is removed. When
the Hold is acknowledged, the Address, Data, RD, WR, and IO/M lines are 3stated.
HLDA (Output):-HOLD ACKNOWLEDGE; indicates that the CPU has received the
Hold request and that it will relinquish the buses in the next clock cycle. HLDA goes low
after the Hold request is removed. The CPU takes the buses one half clock cycles after
HLDA goes low.
INTR (Input):-INTERRUPT REQUEST; is used as a general purpose interrupt. It is
sampled only during the next to the last clock cycle of the instruction. If it is active, the
Program Counter (PC) will be inhibited from incrementing and an INTA will be issued.
During this cycle a RESTART or CALL instruction can be inserted to jump to the
interrupt service routine. The INTR is enabled and disabled by software. It is disabled by
Reset and immediately after an interrupt is accepted.
INTA (Output) :-INTERRUPT ACKNOWLEDGE; is used instead of (and has the same
timing as) RD during the Instruction cycle after an INTR is accepted.
RST 5.5
RST 6.5 - (Inputs)
RST 7.5
RESTART INTERRUPTS:-These three inputs have the same timing as I NTR except
they cause an internal RESTART to be automatically inserted.
RST 7.5 ~~ Highest Priority
RST 6.5
RST 5.5 o Lowest Priority
The priority of these interrupts is ordered as shown above. These interrupts have a higher
priority than the INTR.
TRAP (Input):-Trap interrupt is a non-maskable restart interrupt. It is recognized at the
same time as INTR. It is unaffected by any mask or Interrupt Enable. It has the highest
priority of any interrupt.
RESET IN (Input) :-Reset sets the Program Counter to zero and resets the Interrupt
Enable and HLDA flip-flops. None of the other flags or registers (except the instruction
register) are affected The CPU is held in the reset condition as long as Reset is applied.
RESET OUT (Output):- It Can be used as a system RESET. The signal is synchronized
to the processor clock.
X1, X2 (Input):-Crystal or R/C network connections to set the internal clock generator
X1 can also be an external clock input instead of a crystal. The input frequency is divided
by 2 to give the internal operating frequency.
CLK (Output):-Clock Output for use as a system clock when a crystal or R/ C network
is used as an input to the CPU. The period of CLK is twice the X1, X2 input period.
IO/M (Output):-IO/M indicates whether the Read/Write is to memory or l/O Tri-stated
during Hold and Halt modes.
SID (Input):-(Serial input data line) The data on this line is loaded into accumulator bit 7
whenever a RIM instruction is executed.
SOD (output) (Serial output data line)- The output SOD is set or reset as specified by the
SIM instruction.
Vcc -+5 volt supply.
Vss- Ground Reference.

3. The 8085 Addressing Modes


The instructions MOV B, A or MVI A, 82H are to copy data from a source into a destination. In
these instructions the source can be a register, an input port, or an 8-bit number (00H to FFH).
Similarly, a destination can be a register or an output port. The sources and destination are
operands. The various formats for specifying operands are called the ADDRESSING MODES.
For 8085, they are:
1. Immediate addressing.
2. Register addressing.
3. Direct addressing.
4. Indirect addressing.
Immediate addressing
Data is present in the instruction. Load the immediate data to the destination provided.
Example: MVI R,data
Register addressing
Data is provided through the registers.
Example: MOV Rd, Rs
Direct addressing
Used to accept data from outside devices to store in the accumulator or send the data stored
in the accumulator to the outside device. Accept the data from the port 00H and store them into
the accumulator or Send the data from the accumulator to the port 01H.
Example: IN 00H or OUT 01H
Indirect Addressing
This means that the Effective Address is calculated by the processor. And the contents of the
address used to form a second address. The second address is where the data is stored. Note that
this requires several memory accesses; two accesses to retrieve the 16-bit address and a further
access (or accesses) to retrieve the data which is to be loaded into the register.

4. Instruction Set Classification


An instruction is a binary pattern designed inside a microprocessor to perform a specific
function. The entire group of instructions, called the instruction set, determines what functions
the microprocessor can perform. These instructions can be classified into the following five
functional categories: data transfer (copy) operations, arithmetic operations, logical operations,
branching operations, and machine-control operations.
a. Data Transfer (Copy) Operations:- This group of instructions copy data from a location
Called a source to another location called a destination, without modifying the contents of the
source. In technical manuals, the term data transfer is used for this copying function. However,
the term transfer is misleading; it creates the impression that the contents of the source are
destroyed when, in fact, the contents are retained without any modification
b. Arithmetic Operations
These instructions perform arithmetic operations such as addition, subtraction, increment, and
decrement.
Addition - Any 8-bit number, or the contents of a register or the contents of a memory
location can be added to the contents of the accumulator and the sum is stored in the
accumulator. No two other 8-bit registers can be added directly (e.g., the contents of
register B cannot be added directly to the contents of the register C). The instruction
DAD is an exception; it adds 16-bit data directly in register pairs.
Subtraction - Any 8-bit number, or the contents of a register, or the contents of a
memory location can be subtracted from the contents of the accumulator and the results
stored in the accumulator. The subtraction is performed in 2's compliment, and the results
if negative, are expressed in 2's complement. No two other registers can be subtracted
directly.
Increment/Decrement - The 8-bit contents of a register or a memory location can be
incremented or decrement by 1. Similarly, the 16-bit contents of a register pair (such
as BC) can be incremented or decrement by 1. These increment and decrement operations
differ from addition and subtraction in an important way; i.e., they can be performed in
any one of the registers or in a memory location.

c. Logical Operations
These instructions perform various logical operations with the contents of the accumulator.
AND, OR Exclusive-OR - Any 8-bit number, or the contents of a register, or of
a memory location can be logically AND, Or, or Exclusive-OR with the contents of the
accumulator. The results are stored in the accumulator.
Rotate- Each bit in the accumulator can be shifted either left or right to the next position.
Compare- Any 8-bit number, or the contents of a register, or a memory location can be
Compared for equality, greater than, or less than, with the contents of the accumulator.
Complement - The contents of the accumulator can be complemented. All 0s are
replaced by 1s and all 1s are replaced by 0s.
d. Branching Operations
This group of instructions alters the sequence of program execution either conditionally or
unconditionally.
Jump - Conditional jumps are an important aspect of the decision-making process in the
programming. These instructions test for a certain conditions (e.g., Zero or Carry flag)
and alter the program sequence when the condition is met. In addition, the instruction set
includes an instruction called unconditional jump.
Call, Return, and Restart - These instructions change the sequence of a program either
by calling a subroutine or returning from a subroutine. The conditional Call and Return
instructions also can test condition flags.
e. Machine Control Operations
These instructions control machine functions such as Halt, Interrupt, or do nothing. The
microprocessor operations related to data manipulation can be summarized in four functions:
i. Copying data
ii. Performing arithmetic operations
iii. Performing logical operations
iv. Testing for a given condition and alerting the program sequence
Some important aspects of the instruction set are noted below:
i. In data transfer, the contents of the source are not destroyed; only the contents of the
destination are changed. The data copy instructions do not affect the flags.
ii. Arithmetic and Logical operations are performed with the contents of the accumulator, and the
results are stored in the accumulator (with some expectations). The flags are affected according
to the results.
iii. Any register including the memory can be used for increment and decrement.
iv. A program sequence can be changed either conditionally or by testing for a given data
condition.

5. Instruction Format
An instruction is a command to the microprocessor to perform a given task on a specified data.
Each instruction has two parts: one is task to be performed, called the operation code (op-code),
and the second is the data to be operated on, called the operand. The operand (or data) can be
specified in various ways. It may include 8-bit (or 16-bit ) data, an internal register, a memory
location, or 8-bit (or 16-bit) address. In some instructions, the operand is implicit.
Instruction word size The 8085 instruction set is classified into the following three groups
according to word size:
One-word or 1-byte instructions
Two-word or 2-byte instructions
Three-word or 3-byte instructions
In the 8085, "byte" and "word" are synonymous because it is an 8-bit microprocessor. However,
instructions are commonly referred to in terms of bytes rather than words.
One-Byte Instructions
A 1-byte instruction includes the op-code and operand in the same byte. Operand(s)
are internal register and are coded into the instruction.
For example:
Task Op code Operand
Copy the contents of the MOV C,A
accumulator in the register C.
Add the contents of register B ADD B
to the contents of the
accumulator
Invert (compliment) each bit CMA
in the accumulator.
These instructions are 1-byte instructions performing three different tasks. In the first
instruction, both operand registers are specified. In the second instruction, the operand . B is
specified and the accumulator is assumed. Similarly, in the third instruction, the accumulator is
assumed to be the implicit operand. These instructions are stored in 8-bit binary format in
memory; each requires one memory location.
MOV rd, rs
rd <-- rs copies contents of rs into rd.
Example: MOV A,B
Two-Byte Instructions
In a two-byte instruction, the first byte specifies the operation code and the second byte
specifies the operand. Source operand is a data byte immediately following the opcode.
For example:
Task Op code Operand
Load an 8-bit data byte in the MVI MVI
accumulator.

MVI r,data
r <-- data
Example: MVI A, 30H
Three-Byte Instructions
In a three-byte instruction, the first byte specifies the opcode , and the following two bytes
specify the 16-bit address. Note that the second byte is the low-order address and the third byte is
the high-order address. Opcode + data byte + data byte
For example
Task Op code Operand
Transfer the program JMP 2085H
sequence to
the memory
location
2085H.
This instruction would require three memory locations to store in memory.
Three byte instructions - opcode + data byte + data byte
LXI rp, data16
rp is one of the pairs of registers BC, DE, HL used as 16-bit registers. The two data
bytes are 16-bit data in L H order of significance.
rp <-- data16
Example:
LXI H,0520H coded as 21H 20H 50H in three bytes. This is also immediate addressing

6. Sample Programs for Microprocessor 8085


a. Write an assembly program to add two numbers
Program
MVI D, 8BH
MVI C, 6FH
MOV A, C
ADD D
OUT PORT1
HLT
b. Write an assembly program to multiply a number by 8
Program
MVI A, 30H
RRC
RRC
RRC
OUT PORT1
HLT
c. Write an assembly program to find greatest between two numbers
Program
MVI B, 30H
MVI C, 40H
MOV A, B
CMP C
JZ EQU
JC GRT
OUT PORT1
HLT
EQU: MVI A, 01H
OUT PORT1
HLT
GRT: MOV A, C
OUT PORT1

Architecture Of 8051 Microcontroller.


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 up to 64kb
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 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:
i. 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.
ii. Data Bus: Microcontroller 8051 comprise of 8 bits data bus. It is employed to cart data

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 is 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 arithmtical 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 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.
i. 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).
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.
ii. F0 - Flag 0. This is a general-purpose bit available for use.
iii. AC - Auxiliary Carry Flag is used for BCD operations only.
iv. 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 8-bit 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 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.
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.
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:
i. 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.
ii. 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 setting this bit the microcontroller enters the Power Down mode.
 IDL By setting this bit the microcontroller enters the idle mode

Selection of Microcontroller
There are many factors to consider.
Power efficiency:-There is a trade-off between processing performance and power
onsumption: a device with higher processing power will consume more energy. 
Therefore, if your microcontroller is wireless and running on a rechargeable battery, you
need to weigh sacrificing power efficiency against getting more processing power, or
vice versa.
Temperature tolerance:-Depending on the environment in which your microcontrollers
operate, you may want devices that withstand extreme temperature. There will be a trade-
off between temperature tolerance and cost.
Security.:- Hacking which targets  IoT devices is rising, a threat that is especially relevant
to microcontrollers used in automobiles.  In response, microcontroller makers are
implementing layers of security such as cryptography and physical security. Now, users
can purchase microcontrollers that have been certified to the latest security standards or
use MCUs with on-chip secure hardware. 
Hardware architecture.:- A microcontroller’s packaging directly influences its size and
performance.  Dual in-line packaging is the most common type. Small-outline transistors
have a small footprint, and quad flat packs take up more areas but less vertical space. 
Wafer level chip-scales are much smaller and pack in more processing power but are
more expensive to manufacture.  Flat no-lead packages are better in heat diffusion. Ball
grid arrays (BGAs) have high performance due to the compact package but also cost
more to fabricate.
Processing power:-  How much processing power do you require for the task, will a
single core processor suffice, or do you need a dual-core? A multi-core processor will be
significantly faster, but it will also consume more energy. Also, will a graphics
processing unit (GPU) be necessary?
Memory:- The amount of memory (RAM and ROM) you need will depend on the
programs you will be running. More programs need more random access memory
(RAM). In addition, a GPU will require not only more RAM but faster read/write time as
well.
Hardware interface:- The nature of the task will dictate the need for hardware interfaces
such as USB, Wi-Fi, Bluetooth, audio, video, or camera.
Software architecture: Some microcontrollers are operable on multiple OSs, and others
are not. If you need to scale, it is better to use the same software architecture to increase
interoperability.
Cost:- Microcontrollers fall within a wide price range, from a hundred units for a few
dollars to a few dollars per unit. If you want to scale, you need to consider the overall
cost versus the individual performance power of a microcontroller.

Application of Microcontroller

Common microcontroller Peripheral functions and their applications


Function Automotive Consumer Computer
Peripheral
4-bit central Radio Microwave oven Keyboard
processing unit
(CPU)
16-bit CPU Antilock brake system Audio Disk drive
32-bit CPU Engine control - Intelligent disk
controller
Electrically erasable odometer Television channel Modern configuration
Programmable programming parameters
ROM
Timer Fuel injection timing Camera shutter speed Mouse optical shaft
encoder
Asynchronous serial Communication Alarm system keypad Real-time clock
throughout car communication interface on PC
Analog/digital Manifold air pressure Temperature sensor Battery voltage for
converter for air conditioning portable PC
Parallel I/O Dashboard lamp Videocassette Status lights on
driver recorder from panel keyboard
Sample Programs for Microcontroller 8051

1. Write a program to add the values of locations 50H and 51H and store the result in
locations in 52h and 53H.

ORG 0000H ; Set program counter 0000H


MOV A,50H ; Load the contents of Memory location 50H into A ADD ADD A,51H ; Add the
contents of memory 51H with CONTENTS A
MOV 52H,A ; Save the LS byte of the result in 52H
MOV A, #00 ; Load 00H into A
ADDC A, #00 ; Add the immediate data and carry to A
MOV 53H,A ; Save the MS byte of the result in location 53h
END

2. Write a program to multiply two 8 bit numbers stored at locations 70H and 71H and
store the result at memory locations 52H and 53H. Assume that the least significant byte of
the result is stored in low address.
ORG 0000H ; Set program counter 00 OH
MOV A, 70H ; Load the contents of memory location 70h into A
MOV B, 71H ; Load the contents of memory location 71H into B
MUL AB ; Perform multiplication
MOV 52H,A ; Save the least significant byte of the result in location 52H MOV 53H,B ; Save
the most significant byte of the result in location 53
END

You might also like