0% found this document useful (0 votes)
25 views64 pages

Es Unit1-2

The document discusses the 8051 microcontroller. It provides details about its architecture, components, memory organization, ports and applications. The 8051 microcontroller is popular and commonly used in embedded systems and electronics due to its on-chip memory and I/O ports.

Uploaded by

Namadi Swetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views64 pages

Es Unit1-2

The document discusses the 8051 microcontroller. It provides details about its architecture, components, memory organization, ports and applications. The 8051 microcontroller is popular and commonly used in embedded systems and electronics due to its on-chip memory and I/O ports.

Uploaded by

Namadi Swetha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 64

8051

MICROCONTROLLER
MOTIVATION

 The 8051 Microcontroller is one of the most popular


and most commonly used microcontrollers in various
fields like embedded systems, consumer electronics,
automobiles, etc.
 8051 Microcontroller finds many application in
device needing Real time processing/control systems.
MICROCONTROLLER
 A microcontroller is a highly integrated single chip,
which consists of on chip CPU (Central Processing
Unit), RAM (Random Access Memory),
EPROM/PROM/ROM (Erasable Programmable
Read Only Memory), I/O (input/output) – serial
and parallel, timers, interrupt controller.
Introduction to
8051Microcontroller
 In 1981, Intel introduced an 8-bit microcontroller
called the 8051.
 A microcontroller can be thought of a
microprocessor with inbuilt peripherals.
 Both microcontrollers and microprocessors are
complex sequential digital circuits meant to carry
out job according to the program / instructions.
 It functions as a stand alone system. The operation
of a microcontroller is multipurpose.
Contd....
 A microcontroller has required on-chip memory with
associated peripherals.
 Microcontrollers are also called embedded
controllers.
 Microcontrollers are numerous and many of them are
application specific.
 Originally, 8051 Microcontrollers were developed
using N-MOS Technology
 Due to reduction in size and power ,CMOS
Technology in fabrication
Development of Microcontrollers (Invisible)

Microcontrollers have gone through a silent evolution (invisible). The


evolution can be rightly termed as silent as the impact or application of a
microcontroller is not well known to a common user, although
microcontroller technology has undergone significant change since early
1970's. Development of some popular microcontrollers is given as
follows.
Components of Microcontroller
Necessary parts of any Microprocessor/controller

 CPU: Central Processing Unit


 I/O: Input /Output

 Bus: Address bus , Data bus , Control bus

 Memory: RAM & ROM

 Timer

 Interrupt

 Serial Port

 Parallel Port
Microprocessor
 No RAM, ROM, I/O, ports on CPU chip itself
 They are connected externally
 Example : Intel’s 8086, Motorola’s 680x0
Microcontroller
 A control device which incorporates a
microprocessor.
 On-chip RAM, ROM, I/O ports...
 Example: Motorola’s 6811, Intel’s 8051, Zilog’s
Z8 and PIC 16X
Definition of microcontroller
 An Integrated circuit that contains a
Microprocessor along with memory and associated
circuits and that controls some or all of the
functions of an electronic device (such as a home
appliance) or system.
Comparison
Features of 8051
 40 pin DIP.
 8-bit data bus & 8-bit ALU
 16-bit address bus
 4 KB on chip program memory (ROM or EPROM)).
 128 bytes on chip data memory(RAM).
 32 general purpose registers each of 8 bits
 Two -16 bit timers T0 and T1
 Five Interrupts (3 internal and 2 external).
 Four Parallel ports each of 8-bits (PORT0, PORT1,PORT2,PORT3) with a
total of 32 I/O lines.
 One 16-bit program counter and One 16-bit DPTR ( data pointer)
 One 8-bit stack pointer
 One full duplex serial communication port
Types of Microcontrollers
 Bit
 8-bit microcontroller − This type of microcontroller is
used to execute arithmetic and logical operations like
addition, subtraction, multiplication division, etc. For
example, Intel 8031 and 8051 are 8 bits microcontroller.
 16-bit microcontroller − This type of microcontroller is
used to perform arithmetic and logical operations where
higher accuracy and performance is required. For example,
Intel 8096 is a 16-bit microcontroller.
 32-bit microcontroller − This type of microcontroller is
generally used in automatically controlled appliances like
automatic operational machines, medical appliances, etc.
 Memory
 External memory microcontroller − This type of
microcontroller is designed in such a way that they do not
have a program memory on the chip. Hence, it is named as
external memory microcontroller. For example: Intel 8031
microcontroller.
 Embedded memory microcontroller − This type of
microcontroller is designed in such a way that the
microcontroller has all programs and data memory,
counters and timers, interrupts, I/O ports are embedded on
the chip. For example: Intel 8051 microcontroller.
 Instruction Set
 CISC − CISC stands for complex instruction set computer.
It allows the user to insert a single instruction as an
alternative to many simple instructions.
 RISC − RISC stands for Reduced Instruction Set
Computers. It reduces the operational time by shortening
the clock cycle per instruction.
ARCHITECTURE & BLOCK DIAGRAM
OF 8051 MICROCONTROLLER:
 It consists of an 8-bit ALU, one 8-bit PSW(Program Status
Register), A and B registers , one 16-bit Program counter ,
one 16-bit Data pointer register(DPTR),128 bytes of RAM
and 4kB of ROM and four parallel I/O ports each of 8-bit
width.
Architecture
Components included in 8051 Architecture

 It is built with 40 pins DIP (dual inline package),


 It consists of an 8-bit ALU,
 one 8bit PSW(Program Status Register),
 A and B registers ,
 one 16-bit Program counter ,
 one 16-bit Data pointer register(DPTR),
 128 bytes of RAM and 4kB of ROM and
 four parallel I/O ports each of 8-bit width.
 An on-chip crystal oscillator is integrated in the
microcontroller having crystal frequency of 12 MHz.
Contd..
 ALU
 8051 has 8-bit ALU which can perform all the 8-bit arithmetic and
logical operations in one machine cycle.
 The ALU is associated with two registers A & B
 A and B Registers :
 The A and B registers are special function registers which hold the
results of many arithmetic and logical operations of 8051.
 The A register is also called the Accumulator and as it’s name suggests,
is used as a general register to accumulate the results of a large number
of instructions.
 By default it is used for all mathematical operations and also data
transfer operations between CPU and any external memory.
 B Register:
 The B register is mainly used for multiplication and division
operations along with A register.
MUL AB, DIV AB.
 The B register can also be used as general purpose register for
programming
 The R registers: The "R" registers are a set of eight registers
that are named R0, R1, etc. up to and including R7.
 These registers are used as auxiliary registers in many
operations.
 The "R" registers are also used to store temporary values.
PROGRAM STATUS
WORD(PSW)
 The program status word (PSW) register is an 8-bit
register. It is also referred to as the flag register.
 Although the PSW register is 8 bits wide, only 6 bits
of it are used by the 8051.
 The two unused bits are user-definable flags.
 Four of the flags are called conditional
flags, meaning that they indicate some conditions
that result after an instruction is executed.
 These four are CY (carry), AC (auxiliary carry), P
(parity), and OV (overflow).
The result of
signed number
operation is too
large, causing
the high-order
bit to overflow
into the sign bit
STACK POINTER(SP):-
 This is an 8 bit register holding the current address
of stack memory
 SP is incremented before the data is stored onto the
stack using PUSH/CALL instructions execution.
 During PUSH, first SP is incremented and then
copy the data.
 In the POP operation, initially copy the data and
then decrement the SP.
8051 Pin Diagram

Ground
1-8=P1, 10-17=P3, 39-32=P0, 28-21=P2
Port 0,1,2,3 Zero---Output, One---Input
• One of the most useful features of the 8051 is that it contains four I/O
ports (P0 - P3)

• Port 0 ( pins 32-39 ): P0 ( P0.0 ~ P0.7 )


– 8-bit R/W - General Purpose I/O
– Or acts as a multiplexed low byte address and data bus for external memory design

• Port 1 ( pins 1-8 ) : P1 ( P1.0 ~ P1.7 )


– Only 8-bit R/W - General Purpose I/O

• Port 2 ( pins 21-28 ): P2 ( P2.0 ~ P2.7 )


– 8-bit R/W - General Purpose I/O
– Or high byte of the address bus for external memory design

• Port 3 ( pins 10-17 ): P3 ( P3.0 ~ P3.7 )


– General Purpose I/O
– if not using any of the internal peripherals (timers) or external interrupts.
• Each port can be used as input or output (bi-direction)
Port 3 Alternate Functions
8051 Microcontroller Memory
Organization
 8051 is built around the Harvard processor
Architecture.
 The program and data memory are logically
separated and the physically reside separately.

Harvard Architecture
8051 Microcontroller Memory Organization

 The 8051 Microcontroller Memory is separated in


Program Memory (ROM) and Data Memory (RAM).
 The Program Memory of the 8051 Microcontroller is
used for storing the program to be executed i.e.
instructions.
 The Data Memory on the other hand, is used for storing
temporary variable data and intermediate results.
 8051 Microcontroller has both Internal ROM and
Internal RAM. (On-chip memory)
 If the internal memory is inadequate, you can add
external memory using suitable circuits.
Program Memory (ROM) of 8051 Microcontroller

 In 8051 Microcontroller, the code or instructions to


be executed are stored in the Program Memory,
which is also called as the ROM of the
Microcontroller.
 The original 8051 Microcontroller by Intel has
4KB of internal ROM.
Program Memory
 In case of 4KB of Internal ROM, the address space is 0000H to 0FFFH.
 If the address space i.e. the program addresses exceed this value, then the
CPU will automatically fetch the code from the external Program Memory.

When EA=1, Internal program memory access When EA=0,External program


memory access
FFFFH
FFFFH
External program memory(off –chip
ROM)
External program
1000H memory(off –chip
ROM)
0FFFH Internal program memory(on-Chip
ROM)
0000H 0000H
EA=External Access pin, EA=1
 For this, the External Access Pin (EA Pin) must be
pulled HIGH
 i.e. when the EA Pin is high, the CPU first fetches
instructions from the Internal Program Memory in
the address range of 0000H to 0FFFFH
 and if the memory addresses exceed the limit, then
the instructions are fetched from the external ROM
in the address range of 1000H to FFFFH.
EA=0
 There is another way to fetch the instructions:
ignore the Internal ROM and fetch all the
instructions only from the External Program
Memory (External ROM).
 For this scenario, the EA Pin must be connected to
GND.
 In this case, the memory addresses of the external
ROM will be from 0000H to FFFFH.
 Switching between the internal program memory and external
program memory is accomplished by the logic level of EA pin.
 The control signal for external program memory execution is
PSEN.
 For internal program memory fetching PSEN is not activated.
 If the program memory is external, 16 I/O lines are used for
external memory access.
 Port 0 and port 2 are used for external memory access.
 ALE is used primarily to latch the low -order address from
multiplexed bus and generate a separate set of eight address
lines,A7-Ao.
 8051 is capable of pipelining.
 Pipelining makes a processor capable of fetching
the next instruction while executing previous
instruction.
 Its some thing like multi tasking, doing more than
one operation at a time.
 The address from which the program instruction to
be fetched is supplied by 16 bit register , PC
External Program Memory interfacing to 8051

74ls373

Latch
Data Memory (RAM) of 8051
Microcontroller
 The Data Memory or RAM of the 8051
Microcontroller stores temporary data and intermediate
results that are generated and used during the normal
operation of the microcontroller.
 Original Intel’s 8051 Microcontroller had 128B of
internal RAM.
 In the 8051 family, 8051 has total 128 bytes of internal
data RAM and we can interface external data memory
up to 64K. Hence, total size of data memory in 8051
can be up to external 64K + internal 128 bytes.
 The basic 8051 architecture supports 128 bytes of
internal data memory and 128 bytes of SFR(Special
function Register) Memory.
 SFR Memory is not available for the user for
general data memory applications.
 The Address range of internal user data memory is
00H to7FH.
 SFR’s are residing at memory area from 80H to
FFH.
DATA MEMORY
RAM is divided into 3 parts:- 1) Register banks 2) Bit
addressable area 3) Scratch pad area.
Register banks
 There are 4 register banks in 8051 bank 0,1, 2 and 3.
 Each bank has 8 registers of 1 byte R0,R1…R7
respectively.
 Hence, register banks consist of the lowest 32 bytes of
on chip RAM
 At a time only one register bank can be selected for
operations and bank registers are accessed using
mnemonics R0..R1.. etc.
 By default register bank 0 is selected when we reset
the system.
Bit addressable area
 The bit addressable area is 16 bytes next to register banks.
 We can access each bit separately of bit addressable area, Each
bit have unique address of bit addressable area.
 Bit addressable area is mainly used to store bit variables from
application program, like status of an output device like LED or
Motor (ON/OFF) etc. We need only a bit to store this status
 The area of bit addressable space of 8051 is usually used to store
bit variables. address range 20H to 2FH (total 128 bits)
 Each bits can be accessed from 00H to 7FH within this 128 bits
from 20H to 2FH.
 Sometimes programming using bit addressable area saves
wastage of memory.
Scratch pad area
 The upper 80 bytes are nothing but scratch pad area
which is used for general purpose storing of data.
 Scratch pad area is in the address range 30H to
7FH .
 Scratch pad area can be used for stack memory also
if default stack area is insufficient.
External Data Memory interfacing to 8051

 The control signals used for external data memory


access are RD and WR.
 DPTR(Data Pointer) -16 bit Register
 It holds the address of external data memory to be
accessed.
External Data Memory interfacing to 8051

Data bus D0..D7


8051 P0 D0...D7

EA Latch(e.e. A0...A7
Ground 74LS373)
ALE
External data
memory
Higher order Address bus
P2 A8..A15
RD OE
P3
WR WR

External Data Memory Access


Interfacing External Memory with 8051
Microcontroller

EA
Ground
Instruction Set of 8051
 As you studied in the basic 8085/8086 microprocessor class,
an instruction consists of 2 parts:
1. Opcode and
2. Operands
 The opcode tells the processor what to do on executing an
instruction.
 The operands is the parameters required by opcode to
complete the action.
 The term instruction set refers to set of instructions supported
by the processor/controller architecture.
Contd..
 A computer instruction is made up of an operation code (op-code)
followed by either zero, one or two bytes of operands
 The op-code identifies the type of operation to be performed while
the operands identify the source and destination of the data
 The operand can be:
 The data value itself

 A CPU register

 A memory location

 An I/O port

 If the instruction is associated with more than one operand, the


format is always:
 Mnemonic Destination, Source
Instruction Set of 8051
 The commands to the Microcontroller are known as
a Microcontroller’s Instruction Set.

 Data transfer instructions


 Arithmetic instructions

 Logical instructions

 Boolean variable instructions

 Program branching instructions


Data transfer instructions

This instructions are used to copy the content of source


operand to Destination operand.

MOV Ro, 89H----Address


MOV R0, #89H-----Immediate Data
MOV A, R4------Direct register
MOV A, @R0 ---- Indirect register Addressing
Arithmetic instructions
Logical Instructions
Boolean or Bit manipulation instructions
Program control transfer
instructions
Important Questions
1) Explain the architecture of 8086 with neat diagram.
2) Explain the flag register of 8086.
3) Discuss memory segmentation & mention its advantages.
4) Explain the various addressing modes of 8086 with
examples.
5) Discuss the instruction set of 8086.
6) Discuss internal architecture of 8051 microcontroller in
detail.
7) Discuss the memory organization of the 8051
microcontroller.
8) Discuss the instruction set of 8051.

You might also like