SlideShare a Scribd company logo
8-15TH JANUARY 2018
Architecture of the 8051
Microcontroller
Sudhanshu Janwadkar, TA, SV National Institute of Technology, Surat
Learning Objectives
 Getting started with Microcontrollers
 Study Architecture of 8051 Microcontroller
 Understand 8051 Registers
 Learn Pin Diagram and function of each pin
 Understand On-Chip ROM Address Range, RAM
Allocation, Memory Bank and SFRs
 Learn concept of Program and Data Memory
 Study I/O Ports
 Study Stack
 Microcontrollers can be considered as self-contained
systems with a processor, memory and I/O ports.
 In most cases, all that is missing is the software to define
the operation of the embedded system
Getting Started with Microcontrollers
The Architectural Needs of a Microcontroller
What architectural features might be needed in a microcontroller?
What are the expected applications?
– Sensing the environment
> Input port/pins
– Producing a response
> Output port/pins
– The response may be delayed
> Timer/Counter
– Prioritized response may be expected
> Interrupts
– Software to control the process
> Non-volatile Memory
– Temporary data
> RAM.
Microcontroller Families
 There are several major “families” of microcontrollers
available from different manufacturers.
 A family is defined as a group of products that share the
same basic internal architectures and who are code-
compatible.
 Manufacturers usually define an architecture and
then make variants of that design producing a family
of products.
 Code written for a member of the family should be
compatible with all other members of the same
family.
Example: Comparison of 8051 Family Members
Microcontrollers compatible with Intel 8051
 Atmel: AT89C51, AT89S51, AT83C5134
 Infineon: XC800
 Mentor Graphics: M8051ew
 Megawin: 74, 82, 84, 86, 87, and 89 series
 NXP: NXP700 and NXP900 series
 Silicon Labs: C8051 series
 Texas Instruments: CC111x, CC24xx and CC25xx
 STC Micro: STC89C51RC, STC90C51RC etc
That would imply: All these Microcontrollers share
common architecture and Instruction Set
Intel 8051 (MCS-51)
The Intel MCS-51 (commonly termed 8051) is an
 internally Harvard architecture
 Complex instruction set computer (CISC) Instruction set
 single chip microcontroller (µC) series
 developed by Intel
in 1980 for use in embedded systems.
Common Features of MCS51
 Originally introduced by Intel in 1981.
 Currently, the most widely studied 8-bit microcontroller.
 2 distinct separately addressable memory areas.
• Maximum of 64K on-chip ROM
• Maximum of 64K external data memory
• Maximum of 64K external code memory
 Basic version (8051) contains:
• 4K Bytes of on-chip ROM instruction memory
• 256 Bytes of On-chip RAM - (128) Bytes of on-chip RAM
for temporary data storage and the stack + (128) SFR
space
• 2 timers, one serial port, and four 8-bit parallel I/O ports.
• Speeds starting from ~12 MHz
Block Diagram of MCS-51
MCS51 Architecture
 Programmer’s View
– Memory Organization
– Register Set
– Instruction Set
 Hardware Designer’s View
– Pin Configurations
– Timing characteristics
– Current / Voltage requirements
Memory Organisation of MCS-51
 The 8051 has separate address spaces for program storage
and data storage.
 Depending on the type of instruction, the same address
can refer to two logically & physically different memory
locations.
Memory Organisation of MCS-51
Program Memory
 After reset, the MCS-51 starts fetching instructions
from 0000H.
 This can be either on-chip or external depending on
the value of the EA input pin.
• We connect the EA pin to Vcc to indicate that the
program code is stored in the microcontroller’s
on-chip ROM.
• To indicate that the program code is stored in
external ROM, EA pin must be connected to
GND.
 To use external program memory, All we have to do
is to connect the EA pin to ground and connect the
(microcontroller) chip to external ROM containing
the program code
Architecture of the Intel 8051 Microcontroller
 Since the PC (program counter) of the 8051 is 16-bit, it is
capable of accessing up to 64K bytes of program code.
 In the 8051, port 0 and port 2 provide the 16-bit address
to access external memory.
 Of these two ports, PO provides the lower 8 bit addresses
AO – A7, and P2 provides the upper 8 bit addresses A8 –
A15.
 More importantly, PO is also used to provide the 8-bit
data bus DO – D7. In other words, pins PO.O – P0.7 are
used for both the address and data paths. This is called
address/data multiplexing in chip design
 How do we know when P0 is used for the data path
and when it is used for the address path?
 This is the job of the ALE (address latch enable) pin.
 When ALE = 0 the 8051 uses P0 for the data path,
and when ALE = 1, it uses it for the address path.
 To extract the addresses from the P0 pins we connect
P0 to a latch and use the ALE pin to latch the
address
Architecture of the Intel 8051 Microcontroller
Program Memory(External Access Cycle)
 Port 0 acts as a multiplexed address/data bus sending
the low byte of the program counter (PCL) as an
address(through latch)
 Port 2 sends the program counter high byte of the
program counter (PCH) as an address directly to the
external memory.
 The signal ALE allows an external latch to store the
PCL byte while the multiplexed bus is made ready to
receive the code byte from the external memory.
 Port 0 then switches function and becomes the data
bus receiving the byte from memory
Memory Organisation of MCS-51
 The Lower 128 bytes house the
8051’s registers, its default stack
area, and other features.
The 8051 has 256 bytes of RAM on-chip.
– The lower 128 bytes are intended for internal data storage.
– The upper 128 bytes are the Special Function Registers (SFRs).
Data Memory
Memory Organisation of MCS-51
Data Memory
 The lowest 32 bytes of the on-chip RAM form
4 banks of 8 registers each.
– Only one of these banks can be active at
any time.
– Bank is chosen by setting 2 bits in PSW
– Default bank (at power up) is Bank 0
 The 8 registers in any active bank are referred
to as R0 through R7
 Given that each register has a specific address,
it can be accessed directly using that address
even if its bank is not the active one
Memory Organisation of MCS-51
Data Memory
 The next 16 bytes – locations
20H to 2FH – form a block that
can be addressed as either bytes
or individual bits.
 Locations 30H to 7FH are
general purpose RAM.
– The bytes have addresses 20H to 2FH.
– The bits have addresses 00H to 7FH.
– Specific instructions are used for
accessing the bits.
Memory Organisation of MCS-51
Data Memory
 The Lower 128 bytes
Memory Organisation of MCS-51
SFRs
 The upper 128 bytes of the on-chip RAM are used to
house Special Function Registers.
 In reality, only about 21 of these bytes are actually used.
(The others are reserved for future versions of the 8051.)
– These are registers associated with important
functions in the operation of the MCS-51.
– Some of these registers are bit-addressable as well
as byte-addressable.
 The address of bit 0 of the register will be the same as
the address of the register.
Memory Organisation of MCS-51
SFRs
SFRs in 8051
 Accumulator(A or ACC) and B register – 8 bit each
 DPTR - [DPH:DPL] – 16 bit combined
 PC : Program Counter – 16 bits
 Stack pointer SP – 8 bit
 PSW : Program Status Word
 Port Latches
 Serial Data Buffer
 Timer Registers
 Control Registers
SFRs in 8051
Accumulator
 Almost all the data transfer& arithmetic instructions
involve accumulator
 Can be referred to in several ways:
– Implicitly in opcodes.
– Referred to as ACC (or A) for instructions that
allow specifying a register.
– By its SFR address 0E0H.
 Bit addressable.
– ACC.2 means bit 2 of the ACC register
SFRs in 8051
The B Register
 The B register is not frequently used, when used it acts as
a temporary register, much like a 9th R register.
 Used Specifically by two instructions
– mul AB
– div AB
 Here, B register holds the second operand initially and
will hold part of the result after the execution of
instruction
– It houses upper 8 bits of the multiplication result
– It houses Remainder in case of division.
 Can also be accessed through its SFR address of 0F0H.
 Bit addressable
SFRs in 8051
The DPL and DPH Registers
 The 2 8-bit registers that can be combined into a 16-
bit DPTR
 Used as Data pointer to access external memory
– mov DPTR, #data16 ; setup DPTR with 16bit external address
– movx A, @DPTR ; copy mem[DPTR] to A
(Other examples: MOVC A,@A+DPTR MOVX A,@DPTR MOVX @DPTR,A )
 Can be accessed as 2 separate 8-bit registers if
needed.
– mov DPL, #data8
SFRs in 8051
The Stack Pointer
 SP points to the last used location of the stack.
– Push operation will first increment SP and then copy
data.
–Pop operation will first copy data and then
decrement SP.
 In 8051, stack grows upwards (from low memory to high
memory) and can be in the internal RAM only.
 On power-up, SP points to 07H.
– Register banks 2,3,4 (08H to 1FH) form the default
stack area.
 Stack can be relocated by setting SP to the upper memory
area in 30H to 7FH.
– mov SP, #32H
SFRs in 8051
Program Status word(PSW)
CY AC F0 RS1 RS0 OV - P
Bit
position
Function
CY PSW.7 Carry Flag
AC PSW.6 Auxiliary Carry Flag, for BCD Operations
F0 PSW.5 Flag 0. Available to the user for general purposes.
RS1 PSW.4 Register bank select bits. Set by software to
determine which register bank is being used.RS0 PSW.3
OV PSW.2 Overflow Flag
- PSW.1 Reserved
P PSW.0 Parity Flag
SFRs in 8051
Program Status word(PSW)
RS1 RS0 Register
Bank
Address
0 0 Register
Bank 0
00H -07H
0 1 Register
Bank 1
08H-0FH
1 0 Register
Bank 2
10H-17H
1 1 Register
Bank 3
18H-1FH
CY, the carry flag
 This flag is set whenever there is a carry out from the D7 bit. This flag bit is
affected after an 8-bit addition or subtraction. It can also be set to 1 or 0
directly by an instruction such as “SETB C” and “CLR C” where “SETB C”
stands for “set bit carry” and “CLR C” for “clear carry”.
AC, the auxiliary carry flag
 If there is a carry from D3 to D4 during an ADD or SUB operation, this bit
is set; otherwise, it is cleared. This flag is used by instructions that perform
BCD (binary coded decimal) arithmetic.
P, the parity flag
 The parity flag reflects the number of 1’s in the A (accumulator) register
only. If the A register contains an odd number of Is, then P = 1. Therefore, P
= 0 if A has an even number of 1’s.
OV, the overflow flag
 This flag is set whenever the result of a signed number operation is too
large, causing the high-order bit to overflow into the sign bit. The overflow
flag is only used to detect errors in signed arithmetic operations.
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 Microcontroller
SFRs in 8051
Port Latches (P0,P1,P2,P3)
 Specify the value to be output on the specific output
port or the value read from the specific input port.
 Bit addressable.
 First bit has the same address as the register.
– Example: P1 has address 90H in the SFR, so P1.7
or 97H refer to the same bit
SFRs in 8051
The SBUF Register
 Serial Port Data Buffer.
 2 registers at the same location
 One is read-only used for reading serial input data:
Serial Data Receive Buffer.
 The other is write-only used for storing serial output
data: Serial Data Transmit Buffer
SFRs in 8051
Timer Registers – TH0 and TL0
 The high and low bytes of the 16-bit counting register
for timer/counter T0.
 There is also a TH1 / TL1 pair for the T1 timer.
 In the 8052, one more pair exists (TH2) / (TL2) for
the T2 timer.
SFRs in 8051
Control Registers
 IP – Interrupt Priority
 IE – Interrupt Enable
 TMOD – Timer Mode
 TCON – Timer Control
 T2CON – Timer 2 Control (8052)
 SCON – Serial Port Control
 PCON – Power Control
Program Counter(PC)
 PC is not a SFR!!
 PC is a 16-bit register (consist of PCL and PCH- 8bits
each)
 PC is the only register which does not have an
internal address
 PC holds the address of next instruction to be
executed
 PC automatically increments (+1) after every
instruction byte is fetched

More Related Content

What's hot (20)

PPTX
Microcontroller presentation
xavierpaulino
 
PDF
Programmable Peripheral Interface 8255
Dr.P.Parandaman
 
PPT
UART
Naveen Kumar
 
PPTX
Verilog
Mohamed Rayan
 
PPTX
Xilinx 4000 series
dragonpradeep
 
PPT
Architecture of 8086 Microprocessor
Mustapha Fatty
 
PPTX
Interfacing with peripherals: analog to digital converters and digital to ana...
NimeshSingh27
 
PPTX
8257 DMA Controller
ShivamSood22
 
PPTX
PLDs
VisualBee.com
 
PPTX
Verilog presentation final
Ankur Gupta
 
PPT
Verilog hdl
Muhammad Uzair Rasheed
 
PPTX
Linear & Non-Linear Systems |Solved problems|
National Engineering College
 
PPT
I2C protocol and DS1307 RTC interfacing
Bhargav Kakadiya
 
PPTX
8251 USART
coolsdhanesh
 
PPTX
Sensor interfacing in 8051
Irfan Ahmad
 
PPT
Serial Peripheral Interface(SPI)
Dhaval Kaneria
 
PPTX
CMOS TG
aghila1994
 
PPT
8086 micro processor
Poojith Chowdhary
 
PDF
Serial communication of microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
PDF
Communication Protocols (UART, SPI,I2C)
Emertxe Information Technologies Pvt Ltd
 
Microcontroller presentation
xavierpaulino
 
Programmable Peripheral Interface 8255
Dr.P.Parandaman
 
Verilog
Mohamed Rayan
 
Xilinx 4000 series
dragonpradeep
 
Architecture of 8086 Microprocessor
Mustapha Fatty
 
Interfacing with peripherals: analog to digital converters and digital to ana...
NimeshSingh27
 
8257 DMA Controller
ShivamSood22
 
Verilog presentation final
Ankur Gupta
 
Linear & Non-Linear Systems |Solved problems|
National Engineering College
 
I2C protocol and DS1307 RTC interfacing
Bhargav Kakadiya
 
8251 USART
coolsdhanesh
 
Sensor interfacing in 8051
Irfan Ahmad
 
Serial Peripheral Interface(SPI)
Dhaval Kaneria
 
CMOS TG
aghila1994
 
8086 micro processor
Poojith Chowdhary
 
Serial communication of microcontroller 8051
Nilesh Bhaskarrao Bahadure
 
Communication Protocols (UART, SPI,I2C)
Emertxe Information Technologies Pvt Ltd
 

Similar to Architecture of the Intel 8051 Microcontroller (20)

PPTX
8051 microcontroller
nitugatkal
 
PPTX
MICROCONTROLLER 8051- Architecture and registers
C.Helen Sulochana
 
PDF
8051 Architecture and PIN Configuration.pdf
Srikrishna Thota
 
PPTX
Micro 8051
Pranjali Deshmukh
 
PPTX
8051 Microcontroller_module_4.1.pptx
ARYAKUMARNIRAV
 
PPT
Micro controller
Dr. Ashok Kumar K
 
DOCX
Unit 5
Saurabh Yadav
 
PDF
MICROCONTROLLER - INTEL 8051
DEPARTMENT OF PHYSICS
 
PPTX
Unit 4.pptx
BLACKSPAROW
 
DOCX
Study of 8051 microcontroller
918007165995
 
PPTX
8051 Microcontroller
Jai Sudhan
 
PDF
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...
sangeeta jogade
 
DOC
4th yr dmumicrocontroller1
haymanotyehuala
 
PPT
The hardware of the Mcs 51 microcontroller
Garba Geidam
 
PPT
8051.ppt
Samarth Varshney
 
PDF
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
eceprinter6
 
PPT
Architecture of 8051 microcontroller))
Ganesh Ram
 
PDF
Microprocessor and Microcontroller Notes
premkumar1891
 
PPTX
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
itsmeaswin03
 
PDF
8051 final word
handson28
 
8051 microcontroller
nitugatkal
 
MICROCONTROLLER 8051- Architecture and registers
C.Helen Sulochana
 
8051 Architecture and PIN Configuration.pdf
Srikrishna Thota
 
Micro 8051
Pranjali Deshmukh
 
8051 Microcontroller_module_4.1.pptx
ARYAKUMARNIRAV
 
Micro controller
Dr. Ashok Kumar K
 
MICROCONTROLLER - INTEL 8051
DEPARTMENT OF PHYSICS
 
Unit 4.pptx
BLACKSPAROW
 
Study of 8051 microcontroller
918007165995
 
8051 Microcontroller
Jai Sudhan
 
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...
sangeeta jogade
 
4th yr dmumicrocontroller1
haymanotyehuala
 
The hardware of the Mcs 51 microcontroller
Garba Geidam
 
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
eceprinter6
 
Architecture of 8051 microcontroller))
Ganesh Ram
 
Microprocessor and Microcontroller Notes
premkumar1891
 
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
itsmeaswin03
 
8051 final word
handson28
 
Ad

More from Sudhanshu Janwadkar (20)

PPTX
Presentation on Elementary Data Link Protocols
Sudhanshu Janwadkar
 
PPTX
Error Correcting and Error Detecting Codes.pptx
Sudhanshu Janwadkar
 
PPTX
DSP Processors versus ASICs
Sudhanshu Janwadkar
 
PDF
Keypad Interfacing with 8051 Microcontroller
Sudhanshu Janwadkar
 
PPT
ASIC design Flow (Digital Design)
Sudhanshu Janwadkar
 
PPTX
Fpga architectures and applications
Sudhanshu Janwadkar
 
PPTX
LCD Interacing with 8051
Sudhanshu Janwadkar
 
PPTX
Interrupts in 8051
Sudhanshu Janwadkar
 
PPTX
Serial Communication in 8051
Sudhanshu Janwadkar
 
PPT
SPI Bus Protocol
Sudhanshu Janwadkar
 
PPTX
I2C Protocol
Sudhanshu Janwadkar
 
PPTX
Introduction to 8051 Timer/Counter
Sudhanshu Janwadkar
 
PPTX
Intel 8051 Programming in C
Sudhanshu Janwadkar
 
PPTX
Hardware View of Intel 8051
Sudhanshu Janwadkar
 
PPTX
Introduction to Embedded Systems
Sudhanshu Janwadkar
 
PPTX
CMOS Logic
Sudhanshu Janwadkar
 
PPTX
Interconnects in Reconfigurable Architectures
Sudhanshu Janwadkar
 
PPTX
Introduction to FPGAs
Sudhanshu Janwadkar
 
PDF
Design and Implementation of a GPS based Personal Tracking System
Sudhanshu Janwadkar
 
PDF
Embedded Logic Flip-Flops: A Conceptual Review
Sudhanshu Janwadkar
 
Presentation on Elementary Data Link Protocols
Sudhanshu Janwadkar
 
Error Correcting and Error Detecting Codes.pptx
Sudhanshu Janwadkar
 
DSP Processors versus ASICs
Sudhanshu Janwadkar
 
Keypad Interfacing with 8051 Microcontroller
Sudhanshu Janwadkar
 
ASIC design Flow (Digital Design)
Sudhanshu Janwadkar
 
Fpga architectures and applications
Sudhanshu Janwadkar
 
LCD Interacing with 8051
Sudhanshu Janwadkar
 
Interrupts in 8051
Sudhanshu Janwadkar
 
Serial Communication in 8051
Sudhanshu Janwadkar
 
SPI Bus Protocol
Sudhanshu Janwadkar
 
I2C Protocol
Sudhanshu Janwadkar
 
Introduction to 8051 Timer/Counter
Sudhanshu Janwadkar
 
Intel 8051 Programming in C
Sudhanshu Janwadkar
 
Hardware View of Intel 8051
Sudhanshu Janwadkar
 
Introduction to Embedded Systems
Sudhanshu Janwadkar
 
Interconnects in Reconfigurable Architectures
Sudhanshu Janwadkar
 
Introduction to FPGAs
Sudhanshu Janwadkar
 
Design and Implementation of a GPS based Personal Tracking System
Sudhanshu Janwadkar
 
Embedded Logic Flip-Flops: A Conceptual Review
Sudhanshu Janwadkar
 
Ad

Recently uploaded (20)

PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
PPTX
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
How to Set Up Tags in Odoo 18 - Odoo Slides
Celine George
 
How to Create a PDF Report in Odoo 18 - Odoo Slides
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
community health nursing question paper 2.pdf
Prince kumar
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
0725.WHITEPAPER-UNIQUEWAYSOFPROTOTYPINGANDUXNOW.pdf
Thomas GIRARD, MA, CDP
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
QNL June Edition hosted by Pragya the official Quiz Club of the University of...
Pragya - UEM Kolkata Quiz Club
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 

Architecture of the Intel 8051 Microcontroller

  • 1. 8-15TH JANUARY 2018 Architecture of the 8051 Microcontroller Sudhanshu Janwadkar, TA, SV National Institute of Technology, Surat
  • 2. Learning Objectives  Getting started with Microcontrollers  Study Architecture of 8051 Microcontroller  Understand 8051 Registers  Learn Pin Diagram and function of each pin  Understand On-Chip ROM Address Range, RAM Allocation, Memory Bank and SFRs  Learn concept of Program and Data Memory  Study I/O Ports  Study Stack
  • 3.  Microcontrollers can be considered as self-contained systems with a processor, memory and I/O ports.  In most cases, all that is missing is the software to define the operation of the embedded system Getting Started with Microcontrollers
  • 4. The Architectural Needs of a Microcontroller What architectural features might be needed in a microcontroller? What are the expected applications? – Sensing the environment > Input port/pins – Producing a response > Output port/pins – The response may be delayed > Timer/Counter – Prioritized response may be expected > Interrupts – Software to control the process > Non-volatile Memory – Temporary data > RAM.
  • 5. Microcontroller Families  There are several major “families” of microcontrollers available from different manufacturers.  A family is defined as a group of products that share the same basic internal architectures and who are code- compatible.  Manufacturers usually define an architecture and then make variants of that design producing a family of products.  Code written for a member of the family should be compatible with all other members of the same family.
  • 6. Example: Comparison of 8051 Family Members
  • 7. Microcontrollers compatible with Intel 8051  Atmel: AT89C51, AT89S51, AT83C5134  Infineon: XC800  Mentor Graphics: M8051ew  Megawin: 74, 82, 84, 86, 87, and 89 series  NXP: NXP700 and NXP900 series  Silicon Labs: C8051 series  Texas Instruments: CC111x, CC24xx and CC25xx  STC Micro: STC89C51RC, STC90C51RC etc That would imply: All these Microcontrollers share common architecture and Instruction Set
  • 8. Intel 8051 (MCS-51) The Intel MCS-51 (commonly termed 8051) is an  internally Harvard architecture  Complex instruction set computer (CISC) Instruction set  single chip microcontroller (µC) series  developed by Intel in 1980 for use in embedded systems.
  • 9. Common Features of MCS51  Originally introduced by Intel in 1981.  Currently, the most widely studied 8-bit microcontroller.  2 distinct separately addressable memory areas. • Maximum of 64K on-chip ROM • Maximum of 64K external data memory • Maximum of 64K external code memory  Basic version (8051) contains: • 4K Bytes of on-chip ROM instruction memory • 256 Bytes of On-chip RAM - (128) Bytes of on-chip RAM for temporary data storage and the stack + (128) SFR space • 2 timers, one serial port, and four 8-bit parallel I/O ports. • Speeds starting from ~12 MHz
  • 11. MCS51 Architecture  Programmer’s View – Memory Organization – Register Set – Instruction Set  Hardware Designer’s View – Pin Configurations – Timing characteristics – Current / Voltage requirements
  • 12. Memory Organisation of MCS-51  The 8051 has separate address spaces for program storage and data storage.  Depending on the type of instruction, the same address can refer to two logically & physically different memory locations.
  • 13. Memory Organisation of MCS-51 Program Memory  After reset, the MCS-51 starts fetching instructions from 0000H.  This can be either on-chip or external depending on the value of the EA input pin. • We connect the EA pin to Vcc to indicate that the program code is stored in the microcontroller’s on-chip ROM. • To indicate that the program code is stored in external ROM, EA pin must be connected to GND.
  • 14.  To use external program memory, All we have to do is to connect the EA pin to ground and connect the (microcontroller) chip to external ROM containing the program code
  • 16.  Since the PC (program counter) of the 8051 is 16-bit, it is capable of accessing up to 64K bytes of program code.  In the 8051, port 0 and port 2 provide the 16-bit address to access external memory.  Of these two ports, PO provides the lower 8 bit addresses AO – A7, and P2 provides the upper 8 bit addresses A8 – A15.  More importantly, PO is also used to provide the 8-bit data bus DO – D7. In other words, pins PO.O – P0.7 are used for both the address and data paths. This is called address/data multiplexing in chip design
  • 17.  How do we know when P0 is used for the data path and when it is used for the address path?  This is the job of the ALE (address latch enable) pin.  When ALE = 0 the 8051 uses P0 for the data path, and when ALE = 1, it uses it for the address path.  To extract the addresses from the P0 pins we connect P0 to a latch and use the ALE pin to latch the address
  • 19. Program Memory(External Access Cycle)  Port 0 acts as a multiplexed address/data bus sending the low byte of the program counter (PCL) as an address(through latch)  Port 2 sends the program counter high byte of the program counter (PCH) as an address directly to the external memory.  The signal ALE allows an external latch to store the PCL byte while the multiplexed bus is made ready to receive the code byte from the external memory.  Port 0 then switches function and becomes the data bus receiving the byte from memory
  • 20. Memory Organisation of MCS-51  The Lower 128 bytes house the 8051’s registers, its default stack area, and other features. The 8051 has 256 bytes of RAM on-chip. – The lower 128 bytes are intended for internal data storage. – The upper 128 bytes are the Special Function Registers (SFRs). Data Memory
  • 21. Memory Organisation of MCS-51 Data Memory  The lowest 32 bytes of the on-chip RAM form 4 banks of 8 registers each. – Only one of these banks can be active at any time. – Bank is chosen by setting 2 bits in PSW – Default bank (at power up) is Bank 0  The 8 registers in any active bank are referred to as R0 through R7  Given that each register has a specific address, it can be accessed directly using that address even if its bank is not the active one
  • 22. Memory Organisation of MCS-51 Data Memory  The next 16 bytes – locations 20H to 2FH – form a block that can be addressed as either bytes or individual bits.  Locations 30H to 7FH are general purpose RAM. – The bytes have addresses 20H to 2FH. – The bits have addresses 00H to 7FH. – Specific instructions are used for accessing the bits.
  • 23. Memory Organisation of MCS-51 Data Memory  The Lower 128 bytes
  • 24. Memory Organisation of MCS-51 SFRs  The upper 128 bytes of the on-chip RAM are used to house Special Function Registers.  In reality, only about 21 of these bytes are actually used. (The others are reserved for future versions of the 8051.) – These are registers associated with important functions in the operation of the MCS-51. – Some of these registers are bit-addressable as well as byte-addressable.  The address of bit 0 of the register will be the same as the address of the register.
  • 25. Memory Organisation of MCS-51 SFRs
  • 26. SFRs in 8051  Accumulator(A or ACC) and B register – 8 bit each  DPTR - [DPH:DPL] – 16 bit combined  PC : Program Counter – 16 bits  Stack pointer SP – 8 bit  PSW : Program Status Word  Port Latches  Serial Data Buffer  Timer Registers  Control Registers
  • 27. SFRs in 8051 Accumulator  Almost all the data transfer& arithmetic instructions involve accumulator  Can be referred to in several ways: – Implicitly in opcodes. – Referred to as ACC (or A) for instructions that allow specifying a register. – By its SFR address 0E0H.  Bit addressable. – ACC.2 means bit 2 of the ACC register
  • 28. SFRs in 8051 The B Register  The B register is not frequently used, when used it acts as a temporary register, much like a 9th R register.  Used Specifically by two instructions – mul AB – div AB  Here, B register holds the second operand initially and will hold part of the result after the execution of instruction – It houses upper 8 bits of the multiplication result – It houses Remainder in case of division.  Can also be accessed through its SFR address of 0F0H.  Bit addressable
  • 29. SFRs in 8051 The DPL and DPH Registers  The 2 8-bit registers that can be combined into a 16- bit DPTR  Used as Data pointer to access external memory – mov DPTR, #data16 ; setup DPTR with 16bit external address – movx A, @DPTR ; copy mem[DPTR] to A (Other examples: MOVC A,@A+DPTR MOVX A,@DPTR MOVX @DPTR,A )  Can be accessed as 2 separate 8-bit registers if needed. – mov DPL, #data8
  • 30. SFRs in 8051 The Stack Pointer  SP points to the last used location of the stack. – Push operation will first increment SP and then copy data. –Pop operation will first copy data and then decrement SP.  In 8051, stack grows upwards (from low memory to high memory) and can be in the internal RAM only.  On power-up, SP points to 07H. – Register banks 2,3,4 (08H to 1FH) form the default stack area.  Stack can be relocated by setting SP to the upper memory area in 30H to 7FH. – mov SP, #32H
  • 31. SFRs in 8051 Program Status word(PSW) CY AC F0 RS1 RS0 OV - P Bit position Function CY PSW.7 Carry Flag AC PSW.6 Auxiliary Carry Flag, for BCD Operations F0 PSW.5 Flag 0. Available to the user for general purposes. RS1 PSW.4 Register bank select bits. Set by software to determine which register bank is being used.RS0 PSW.3 OV PSW.2 Overflow Flag - PSW.1 Reserved P PSW.0 Parity Flag
  • 32. SFRs in 8051 Program Status word(PSW) RS1 RS0 Register Bank Address 0 0 Register Bank 0 00H -07H 0 1 Register Bank 1 08H-0FH 1 0 Register Bank 2 10H-17H 1 1 Register Bank 3 18H-1FH
  • 33. CY, the carry flag  This flag is set whenever there is a carry out from the D7 bit. This flag bit is affected after an 8-bit addition or subtraction. It can also be set to 1 or 0 directly by an instruction such as “SETB C” and “CLR C” where “SETB C” stands for “set bit carry” and “CLR C” for “clear carry”. AC, the auxiliary carry flag  If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is cleared. This flag is used by instructions that perform BCD (binary coded decimal) arithmetic. P, the parity flag  The parity flag reflects the number of 1’s in the A (accumulator) register only. If the A register contains an odd number of Is, then P = 1. Therefore, P = 0 if A has an even number of 1’s. OV, the overflow flag  This flag is set whenever the result of a signed number operation is too large, causing the high-order bit to overflow into the sign bit. The overflow flag is only used to detect errors in signed arithmetic operations.
  • 37. SFRs in 8051 Port Latches (P0,P1,P2,P3)  Specify the value to be output on the specific output port or the value read from the specific input port.  Bit addressable.  First bit has the same address as the register. – Example: P1 has address 90H in the SFR, so P1.7 or 97H refer to the same bit
  • 38. SFRs in 8051 The SBUF Register  Serial Port Data Buffer.  2 registers at the same location  One is read-only used for reading serial input data: Serial Data Receive Buffer.  The other is write-only used for storing serial output data: Serial Data Transmit Buffer
  • 39. SFRs in 8051 Timer Registers – TH0 and TL0  The high and low bytes of the 16-bit counting register for timer/counter T0.  There is also a TH1 / TL1 pair for the T1 timer.  In the 8052, one more pair exists (TH2) / (TL2) for the T2 timer.
  • 40. SFRs in 8051 Control Registers  IP – Interrupt Priority  IE – Interrupt Enable  TMOD – Timer Mode  TCON – Timer Control  T2CON – Timer 2 Control (8052)  SCON – Serial Port Control  PCON – Power Control
  • 41. Program Counter(PC)  PC is not a SFR!!  PC is a 16-bit register (consist of PCL and PCH- 8bits each)  PC is the only register which does not have an internal address  PC holds the address of next instruction to be executed  PC automatically increments (+1) after every instruction byte is fetched