SlideShare a Scribd company logo
UNIT IV MICROCONTROLLER
• Architecture of 8051 – Special Function
Registers(SFRs) - I/O Pins Ports and Circuits -
Instruction set - Addressing modes - Assembly
language programming.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
1
INTRODUCTION
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
2
• Microcontrollers as the name suggests, are small
controllers. They are like single chip computers
that often embedded into other systems to
function as processing / controlling unit.
• Microcontrollers are single - chip
Microcomputers.
• A microcontroller has a CPU (a microprocessor) in
addition to a fixed amount of RAM, ROM and I/O
parts and a timer on a single chip.
• The fixed amount of on - chip RAM, ROM, timer
and I/O parts in microcontrollers makes them
ideal for many applications in which cost and
space are less.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
3
• The word microprocessor means a CPU only.
• The functional blocks like memory and other
peripherals are to be connected externally to
a microprocessor chip to make a complete
microcomputer.
• But the microcontrollers are having all these
facilities in a single chip.
• The examples for microcontrollers are Intel
MCS - 51 (8051), Atmel 89 C XX, Motorola
68HC X 11XX, PIC family by microchip (PIC
16C64X).
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
4
Differences between microprocessors
and microcontrollers
• Microprocessors are intended to be general -
purpose digital computers whereas
microcontrollers are intended to be special -
purpose digital controllers.
• Microprocessors contain a CPU, memory
addressing circuits and interrupt handling
circuits. Microcontrollers have these features
as well as timers, parallel and serial I/O and
internal RAM and ROM.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
5
Features of microcontrollers
• High integration of functionality : Microcontrollers are
called as single chip computers because they have on -
chip memory and I/O circuitry and other circuitries that
enable them to function as small stand - alone
computers without other supporting circuitry.
• Field programmability, flexibility : Microcontrollers
often use EPROM or E2PROM as their storage device to
allow field programmability so they are flexible to use.
Once the program is tested to be correct then large
quantities of microcontrollers can be programmed to
be used in embedded systems.
• Easy to use.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
6
Advantages of microcontrollers
• The overall system cost is low, as the peripherals
are integrated in a single chip.
• The product is of small size as compared to the
microprocessor based system and is very handy.
• The system is more reliable.
• The system is easy to troubleshoot and maintain.
• If required additional RAM, ROM and I/O ports
may be interfaced.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
7
Intel 8051 microcontroller
• The 8 bit microcontroller 8051 family has
numbers ranging from 8031 to 8751 and are
available in N-channel Metal Oxide
Semiconductor (NMOS) and Complementary
MOS [CMOS] construction in a variety of package
types.
• The intel corporation introduced an 8 bit
microcontroller 8051 in 1981.
• This microcontroller had 128 bytes of RAM, 4k
bytes of on - chip ROM, two timers, one serial
port and 4 eight bit ports all on a single chip.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
8
Comparison between 8051 and 8031
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
9
ARCHITECTURE OF 8051
The features of the 8051 are :
• 8 bit CPU with registers A (the accumulator) and B
• 16 bit Program Counter (PC) and Data Pointer (DPTR)
• 8 bit Program Status Word (PSW)
• 64K Program memory address space
• 64K Data memory address space
• 128 bytes of on chip data memory
• 32 I/O pins for four 8 bit ports : Port 0, Port 1, Port 2,
Port 3
• Two 16 bit timers / counters : T0 and T1
• Full duplex UART : SBUF
• Two external and three internal interrupt sources
• On chip clock oscillator.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
10
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
11
• The intel 8051 contains two separate buses for
both program and data. So, it has two distinctive
memory spaces of 64K x 8 size for both program
and data.
• It is based on an 8 bit central processing unit with
an 8 bit accumulator and another 8 bit B register
as main processing blocks.
• Other portions of the architecture include few 8
bit and 16 bit registers and 8 bit memory
locations.
• It has some amount of data RAM built in the
device for internal processing.
• 8051 is supported with on-chip peripheral
functions like I/O ports, Timers / Counters, serial
communication port.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
12
Central processing unit
• The CPU is the brain of the microcontrollers reading user’s
programs and executing the expected task as per
instructions stored there in.
• It’s primary elements are an Accumulator (ACC), B register
(B), Stack pointer (SP), Program counter (PC), Program
status word (PSW), Data pointer register (DPTR) and few
more 8 bit registers.
Accumulator
• The accumulator performs arithmetic and logic functions
on 8 bit input variables. Arithmetic operations include
basic addition, subtraction, multiplication and division.
Logical operations are AND, OR XOR as well as rotate,
clear, complement.
• accumulator is responsible for conditional branching
decisions and provides a temporary place in a data
transfer operations within the device.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
13
B Register
• B register is used in multiply and divide
operations. During execution B register either
keeps one of the two inputs and then retains a
portion of the result. For other instructions it is
used as general purpose register.
Stack Pointer
• Stack Pointer (SP) is an 8 bit register. This pointer
keeps track of memory space where the
important register information are stored when
the program flow gets into executing a
subroutine.
• The SP is automatically incremented or
decremented for all PUSH or POP instructions
and for all subroutine calls and returns.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
14
Program Counter
• The Program Counter (PC) is the 16 bit register
giving address of next instruction to be
executed during program execution and it
always points to the program memory space.
Data Pointer Register
• The Data Pointer Register (DPTR) is the 16 bit
addressing register that can be used to fetch
any 8 bit data from the data memory space.
When it is not being used for this purpose, it
can be used as two eight bit registers, DPH and
DPL.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
15
Program Status Word
• The Program Status Word (PSW) keeps the
current status of the arithmetic and logic
operations in different bits. The 8051 has four
math flags that respond automatically to the
outcomes of arithmetic and logic operations and
3 general purpose user flags that can be set 1 or
cleared to 0 by the programmer as desired.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
16
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
17
Input / Output Ports
• 8051 has 32 I/O pins configured as 4 eight bit parallel ports
(P0, P1, P2 and P3).
• Each pin can be used as an input or as an output under the
software control. These I/O pins can be accessed directly by
memory instructions during program execution to get
require flexibility.
• These port lines can be operated in different modes and all
the pins can be made to do many different tasks apart from
their regular I/O function executions.
• Any instruction that accesses external program memory
will output the higher order byte (A8 - A15) on Port 2
during read cycle.
• Port 1 and Port 3 are available for standard I/O functions.
• Port 3 pins has the additional functions : 2 external
interrupt lines, 2 counter inputs, 2 serial port data lines and
2 timing control storbe lines.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
18
Timers / Counters
• 8051 has two 16 bit Timers / Counters, T0 and
T1 capable of working in different modes.
Each consists of a ‘HIGH’ byte and a ‘LOW’
byte which can be accessed under software.
• There is a mode control register (TMOD) and a
control register (TCON) to configure these
timers / counters in number of ways.
• These timers are used to measure time
intervals, determine pulse widths or initiate
events with one microsecond resolution upto
a maximum 65ms. Use software to get longer
delays.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
19
Serial Port
• The 8051 has a high speed full duplex serial port which is
software configurable in 4 basic modes :
• Shift register mode
• Standard UART mode
• Multiprocessor mode
• 9 bit UART mode.
• Full duplex means the data can go both ways at the same time.
Interrupts
• The 8051 has five interrupt sources : One from the serial port
(RI / TI) when a transmission or reception operation is
executed.
• two from the timers (TF0, TF1) when overflow occurs and two
come from the two input pins INT0, INT1. Each interrupt may
be independently enabled or disabled to allow polling on same
sources and each may be classified as high or low priority.
• These operations are selected by Interrupt Enable (IE) and
Interrupt Priority (IP) registers.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
20
Oscillator and Clock
• The 8051 generates the clock pulses by which all
internal operations are synchronized.
• Pins XTAL 1 and XTAL 2 are provided for
connecting a resonant network to form an
oscillator. A quartz crystal is used for oscillator.
• The crystal frequency is the basic internal clock
frequency of the microcontroller
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
21
MEMORY ORGANIZATION
• The 8051 architecture provide both on chip
memory expansion capabilities. It supports
several distinctive ‘physical’ address spaces,
functionally separated at the hardware level by
different addressing mechanisms, read and write
controls signals or both :
• On chip Program Memory
• On chip Data Memory
• Off chip Program Memory
• Off chip Data Memory
• On chip Special Function Registers
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
22
• The Program Memory area (EPROM incase of
external memory or Flash / EPROM incase of
internal one) is extremely large and never lose
information when the power is removed.
• On chip data memory is smaller and therefore
quicker than Program Memory and it goes into a
random state when power is removed. On chip
RAM is used for variables which are calculated
when the program is executed.
• Different addressing mechanisms are used to
access these different memory spaces and this
greatly contributes to microcomputer’s operating
efficiency.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
23
Total internal Data Memory is divided into three blocks :
Lower 128 bytes
Higher 128 bytes.
Special Function Register Space.
Higher 128 bytes are available only in 8032 / 8052 devices.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
24
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
25
SPECIAL FUNCTION REGISTERS (SFRS)
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
26
Physical view
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
27
PINOUTS OF 8051
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
28
Signals of 8051
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
29
• The remaining 8 pins are VCC, GND, XTAL1, XTAL2, RST,
EA , PSEN and ALE / PROG and ALE / . The functions
of these pins are described as follows :
1. Vcc
• Pin 40 of 8051 provides supply voltage to the chip
from the +5V voltage source.
2. GND
• Pin 20 is the ground for the chip,
3. RST
• Pin 9 is the RESET pin. This is referred as a power-on
reset. When activating (high pulse) this pin the
microcontroller will reset and all values in the
registers to be lost. Table 4.4 gives the reset values of
some registers.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
30
4.EA (External Access)
• This input pin is connected to either Vcc or GND. The 8051
family members has ON – CHIP ROM to store programs. EA
pin (31) is connected to Vcc in 8051 Here, EA pin is
connected to GND to indicate that the code is stored
externally.
5. PSEN (Program Store Enable)
• This is an output pin and pin number is 29. In an 8051 -
based system in which an external ROM holds the program
code, this pin is connected to the OE pin of the ROM.
6. ALE (Addres Latch Enable)
This is an output pin (30) and is active high. When
connecting an 8051 to external memory, port 0 provides
both address and data. In other words, 8051 multiplexes
address and data through port 0 to save pins. If ALE = 0,
port 0 provides data (D0 - D7). If ALE=1, it has address (A0-
A7).
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
31
7. XTAL 1 and XTAL 2
• The 8051 has an on - chip oscillator and it requires
an external clock to return it. The quartz crystal
oscillator (12 MHz / 20 MHz) is connected to XTAL 1
(pin 19) and XTAL 2 (pin 18) with two 30pF capacitors
as shown in Fig.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
32
I/O PORTS
Port 0 (P0.0 - 0.7)
• Port 0 is used for both address and data bus (AD0 – AD7).
When the microcontroller chip is connected to an external
memory, Port 0 provides both address and data. ALE pin
indicates if Port 0 has address or data.
• When ALE = 0, Port 0 provides data (D0 – D7)
• = 1, Port 0 provides address (A0 – A7)
• ALE is used for demultiplexing address and data with the
help of a latch.
Port 1 (P1.0 - P1.7)
• Port 1 pins are used as input or output. To make port 1 as
an input port, write 1 to all its 8 bits. To make port 1 as
output port, write 0 to all its 8 bits. Thus port 1 pins have
no dual functions.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
33
Port 2 (P2.0 - P2.7)
• Port 2 pins are used as input / output pins similar in operation to port 1.
The alternate use of port 2 is to supply a high order address byte (A8 –
A15) when the microcontroller is connected to external memory.
Port 3 (P3.0 - P3.7)
• Port 3 pins are used as input or output. Port 3 has the additional
functions
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
34
ADDRESSING MODES
• The addressing modes are the ways of accessing data in
register or in memory or be provided as an immediate
value. The 8051 mnemonics are written with the
destination address named first, followed by the source
address.
The following addressing modes are used to access data :
• Immediate addressing mode
• Register addressing mode
• Direct addressing mode
• Register indirect addressing mode
• Indexed addressing mode.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
35
Immediate Addressing Mode
• When a source operand is a constant rather than a
variable, then the constant can be embedded into the
instruction itself.
• This kind of instructions take two bytes and first one
specifies the opcode and second byte gives the required
constant.
• The operand comes immediately after the opcode. The
mnemonic for immediate data is the pound sign (#).
• This addressing mode can be used to load information into
any of the registers including DPTR register.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
36
Register Addressing Mode
• Register addressing accesses the eight working
registers (R0 - R7) of the selected register bank. The
least significant three bits of the instruction opcode
indicate which register is to be used for the operation.
• One of the four banks of registers is to be predefined in
the PSW before using register addressing instruction.
ACC, B and DPTR can also be addressed in this mode.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
37
Direct Addressing Mode
• In the direct addressing mode, all 128 bytes of
internal RAM and the SFRs may be addressed directly
using the single - byte address assigned to each RAM
location and each SFR.
• Internal RAM uses address from 00H to 7FH to
address each byte. The SFR addresses exist from 80H
to FFH.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
38
• Register Indirect Addressing Mode
• In this mode a register is used as a pointer to the data. If
the data is inside the CPU, only registers R0 and R1 are used
for this purpose. When R0 and R1 hold the addresses of
RAM locations, they must be preceded by the “@” sign.
Indexed Addressing Mode
Only the program memory can be accessed by this mode. This mode is intended
for reading lookup tables in the program memory. A 16 bit base register (DPTR or
PC) points to the base of the lookup tables and accumulator carries the constant
indicating table entry number. The address of the exact location of the table is
formed by adding the accumulator data to the base pointer.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
39
INSTRUCTION SET
• An instruction is a command given to the computer to
perform a specified operation on given data. The
instruction set is the collection of instructions that the
microcontroller is designed to execute.
• These instructions have been classified into the following
groups.
Data transfer group
Arithmetic group
Logical group
Boolean variable manipulation
Program branching
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
40
Data Transfer Instructions
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
41
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
42
Note :
• Rn = Any of the eight registers, R0 to R7, in the
selected bank.
• Ri = Either of the pointing registers R0 to R1 in the
selected bank.
• addr = Address of the internal RAM from 00H to
FFH.
• L = Least significant nibble.
• ^ = External memory location.
• ( ) = Contents of the location inside the
parentheses.
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
43
Arithmetic Instructions
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
44
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
45
Logical Instructions
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
46
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
47
Boolean Variable Manipulation
Instructions
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
48
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
49
Program Branching Instructions
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
50
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
51
PROGRAMS
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
52
8 bit subtraction
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
53
8 Bit Multiplication
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
54
8 Bit Division
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
55
5/25/2021
Kongunadu College of Engineering and
Technology(Autonomous)
56

More Related Content

PDF
Unit 3 mpmc
PPT
8051 Addressing Modes
PPTX
RTC Interfacing and Programming
PPTX
8051 Microcontroller PPT's By Er. Swapnil Kaware
PDF
Memory interfacing of microprocessor 8085
PPTX
Intel 8051 Programming in C
PDF
Unit 5
PPT
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )
Unit 3 mpmc
8051 Addressing Modes
RTC Interfacing and Programming
8051 Microcontroller PPT's By Er. Swapnil Kaware
Memory interfacing of microprocessor 8085
Intel 8051 Programming in C
Unit 5
8051 microcontroller lecture ppt by Tarun Khaneja ( 9034406598 )

What's hot (20)

PPTX
8255 PPI
PDF
Unit 2 mpmc
PPT
Interfacing 8255
PPT
Assembly Language Programming Of 8085
PDF
Question Bank microcontroller 8051
PPTX
DMA and DMA controller
PPTX
8085 MICROPROCESSOR ARCHITECTURE AND ITS OPERATIONS
PPT
8255 presentaion.ppt
PPTX
Direct Memory Access
PPTX
8251 USART
PPTX
Interrupts on 8086 microprocessor by vijay kumar.k
PPT
Architecture of 8086 Microprocessor
PDF
Microprocessor Part 2
PPT
8237 / 8257 DMA
PPT
8085 interrupts
PPTX
Pentium processor
PPTX
Stacks & subroutines 1
PPT
8085-microprocessor
PPTX
4.programmable dma controller 8257
PPTX
Pic microcontroller architecture
8255 PPI
Unit 2 mpmc
Interfacing 8255
Assembly Language Programming Of 8085
Question Bank microcontroller 8051
DMA and DMA controller
8085 MICROPROCESSOR ARCHITECTURE AND ITS OPERATIONS
8255 presentaion.ppt
Direct Memory Access
8251 USART
Interrupts on 8086 microprocessor by vijay kumar.k
Architecture of 8086 Microprocessor
Microprocessor Part 2
8237 / 8257 DMA
8085 interrupts
Pentium processor
Stacks & subroutines 1
8085-microprocessor
4.programmable dma controller 8257
Pic microcontroller architecture
Ad

Similar to Unit 4 (20)

PPTX
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
PPTX
Microcontrollers and its applications unit 1
PPTX
8051 microcontroller
PDF
Architecture and Programmingpart1_Microcontroller
PDF
Architecture of 8051 Microcontroller.pdf
PDF
Unit1 5-mpi-lecture-notes
PDF
microcontroller 8051 17.07.2023.pdf
PPTX
MPMC UNIT II edited . ppt X and communication
PPT
MICROCONTROLLER MODULE-1 PPT Includes basics of microcontroller , application...
PPT
8051 microcontroller and it’s interface
PDF
MICROCONTROLLER - INTEL 8051
PPTX
Vinod ppt on es31 08 15
PPTX
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
PPT
Lecture 1 (course overview and 8051 architecture) rv01
PPTX
MPI UNIT 5 - (INTERRUPTS OF 8086, INTRODUCTION TO 8051).pptx
PPTX
8051 microcontroller and embedded training (sahil gupta 9068557926)
PPT
janakiraman I msc 4 unit
PPT
janakiraman egsp collage I msc 4 unit
PPT
8051 Microcontroller slides foe electronics
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
Microcontrollers and its applications unit 1
8051 microcontroller
Architecture and Programmingpart1_Microcontroller
Architecture of 8051 Microcontroller.pdf
Unit1 5-mpi-lecture-notes
microcontroller 8051 17.07.2023.pdf
MPMC UNIT II edited . ppt X and communication
MICROCONTROLLER MODULE-1 PPT Includes basics of microcontroller , application...
8051 microcontroller and it’s interface
MICROCONTROLLER - INTEL 8051
Vinod ppt on es31 08 15
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
Lecture 1 (course overview and 8051 architecture) rv01
MPI UNIT 5 - (INTERRUPTS OF 8086, INTRODUCTION TO 8051).pptx
8051 microcontroller and embedded training (sahil gupta 9068557926)
janakiraman I msc 4 unit
janakiraman egsp collage I msc 4 unit
8051 Microcontroller slides foe electronics
Ad

More from tamilnesaner (12)

PPT
BEEME UNIT V.ppt
PDF
Unit 1 MPMC
PPTX
Smart meter
PPTX
Lcr meter
PPTX
Tachometer and clamp meter
PPT
Unit 5
PPTX
Unit 4
PPTX
Unit 3
PPTX
Unit 2
PPTX
Unit 1
PPTX
Unit 1 static and dynamic
PPTX
Three phase voltage source inverter
BEEME UNIT V.ppt
Unit 1 MPMC
Smart meter
Lcr meter
Tachometer and clamp meter
Unit 5
Unit 4
Unit 3
Unit 2
Unit 1
Unit 1 static and dynamic
Three phase voltage source inverter

Recently uploaded (20)

PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
web development for engineering and engineering
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PDF
Well-logging-methods_new................
PDF
Digital Logic Computer Design lecture notes
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
UNIT 4 Total Quality Management .pptx
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
additive manufacturing of ss316l using mig welding
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Welding lecture in detail for understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Foundation to blockchain - A guide to Blockchain Tech
DOCX
573137875-Attendance-Management-System-original
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
web development for engineering and engineering
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Well-logging-methods_new................
Digital Logic Computer Design lecture notes
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
UNIT 4 Total Quality Management .pptx
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
additive manufacturing of ss316l using mig welding
Arduino robotics embedded978-1-4302-3184-4.pdf
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Welding lecture in detail for understanding
Operating System & Kernel Study Guide-1 - converted.pdf
Foundation to blockchain - A guide to Blockchain Tech
573137875-Attendance-Management-System-original
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
CYBER-CRIMES AND SECURITY A guide to understanding

Unit 4

  • 1. UNIT IV MICROCONTROLLER • Architecture of 8051 – Special Function Registers(SFRs) - I/O Pins Ports and Circuits - Instruction set - Addressing modes - Assembly language programming. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 1
  • 2. INTRODUCTION 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 2
  • 3. • Microcontrollers as the name suggests, are small controllers. They are like single chip computers that often embedded into other systems to function as processing / controlling unit. • Microcontrollers are single - chip Microcomputers. • A microcontroller has a CPU (a microprocessor) in addition to a fixed amount of RAM, ROM and I/O parts and a timer on a single chip. • The fixed amount of on - chip RAM, ROM, timer and I/O parts in microcontrollers makes them ideal for many applications in which cost and space are less. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 3
  • 4. • The word microprocessor means a CPU only. • The functional blocks like memory and other peripherals are to be connected externally to a microprocessor chip to make a complete microcomputer. • But the microcontrollers are having all these facilities in a single chip. • The examples for microcontrollers are Intel MCS - 51 (8051), Atmel 89 C XX, Motorola 68HC X 11XX, PIC family by microchip (PIC 16C64X). 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 4
  • 5. Differences between microprocessors and microcontrollers • Microprocessors are intended to be general - purpose digital computers whereas microcontrollers are intended to be special - purpose digital controllers. • Microprocessors contain a CPU, memory addressing circuits and interrupt handling circuits. Microcontrollers have these features as well as timers, parallel and serial I/O and internal RAM and ROM. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 5
  • 6. Features of microcontrollers • High integration of functionality : Microcontrollers are called as single chip computers because they have on - chip memory and I/O circuitry and other circuitries that enable them to function as small stand - alone computers without other supporting circuitry. • Field programmability, flexibility : Microcontrollers often use EPROM or E2PROM as their storage device to allow field programmability so they are flexible to use. Once the program is tested to be correct then large quantities of microcontrollers can be programmed to be used in embedded systems. • Easy to use. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 6
  • 7. Advantages of microcontrollers • The overall system cost is low, as the peripherals are integrated in a single chip. • The product is of small size as compared to the microprocessor based system and is very handy. • The system is more reliable. • The system is easy to troubleshoot and maintain. • If required additional RAM, ROM and I/O ports may be interfaced. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 7
  • 8. Intel 8051 microcontroller • The 8 bit microcontroller 8051 family has numbers ranging from 8031 to 8751 and are available in N-channel Metal Oxide Semiconductor (NMOS) and Complementary MOS [CMOS] construction in a variety of package types. • The intel corporation introduced an 8 bit microcontroller 8051 in 1981. • This microcontroller had 128 bytes of RAM, 4k bytes of on - chip ROM, two timers, one serial port and 4 eight bit ports all on a single chip. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 8
  • 9. Comparison between 8051 and 8031 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 9
  • 10. ARCHITECTURE OF 8051 The features of the 8051 are : • 8 bit CPU with registers A (the accumulator) and B • 16 bit Program Counter (PC) and Data Pointer (DPTR) • 8 bit Program Status Word (PSW) • 64K Program memory address space • 64K Data memory address space • 128 bytes of on chip data memory • 32 I/O pins for four 8 bit ports : Port 0, Port 1, Port 2, Port 3 • Two 16 bit timers / counters : T0 and T1 • Full duplex UART : SBUF • Two external and three internal interrupt sources • On chip clock oscillator. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 10
  • 11. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 11
  • 12. • The intel 8051 contains two separate buses for both program and data. So, it has two distinctive memory spaces of 64K x 8 size for both program and data. • It is based on an 8 bit central processing unit with an 8 bit accumulator and another 8 bit B register as main processing blocks. • Other portions of the architecture include few 8 bit and 16 bit registers and 8 bit memory locations. • It has some amount of data RAM built in the device for internal processing. • 8051 is supported with on-chip peripheral functions like I/O ports, Timers / Counters, serial communication port. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 12
  • 13. Central processing unit • The CPU is the brain of the microcontrollers reading user’s programs and executing the expected task as per instructions stored there in. • It’s primary elements are an Accumulator (ACC), B register (B), Stack pointer (SP), Program counter (PC), Program status word (PSW), Data pointer register (DPTR) and few more 8 bit registers. Accumulator • The accumulator performs arithmetic and logic functions on 8 bit input variables. Arithmetic operations include basic addition, subtraction, multiplication and division. Logical operations are AND, OR XOR as well as rotate, clear, complement. • accumulator is responsible for conditional branching decisions and provides a temporary place in a data transfer operations within the device. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 13
  • 14. B Register • B register is used in multiply and divide operations. During execution B register either keeps one of the two inputs and then retains a portion of the result. For other instructions it is used as general purpose register. Stack Pointer • Stack Pointer (SP) is an 8 bit register. This pointer keeps track of memory space where the important register information are stored when the program flow gets into executing a subroutine. • The SP is automatically incremented or decremented for all PUSH or POP instructions and for all subroutine calls and returns. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 14
  • 15. Program Counter • The Program Counter (PC) is the 16 bit register giving address of next instruction to be executed during program execution and it always points to the program memory space. Data Pointer Register • The Data Pointer Register (DPTR) is the 16 bit addressing register that can be used to fetch any 8 bit data from the data memory space. When it is not being used for this purpose, it can be used as two eight bit registers, DPH and DPL. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 15
  • 16. Program Status Word • The Program Status Word (PSW) keeps the current status of the arithmetic and logic operations in different bits. The 8051 has four math flags that respond automatically to the outcomes of arithmetic and logic operations and 3 general purpose user flags that can be set 1 or cleared to 0 by the programmer as desired. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 16
  • 17. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 17
  • 18. Input / Output Ports • 8051 has 32 I/O pins configured as 4 eight bit parallel ports (P0, P1, P2 and P3). • Each pin can be used as an input or as an output under the software control. These I/O pins can be accessed directly by memory instructions during program execution to get require flexibility. • These port lines can be operated in different modes and all the pins can be made to do many different tasks apart from their regular I/O function executions. • Any instruction that accesses external program memory will output the higher order byte (A8 - A15) on Port 2 during read cycle. • Port 1 and Port 3 are available for standard I/O functions. • Port 3 pins has the additional functions : 2 external interrupt lines, 2 counter inputs, 2 serial port data lines and 2 timing control storbe lines. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 18
  • 19. Timers / Counters • 8051 has two 16 bit Timers / Counters, T0 and T1 capable of working in different modes. Each consists of a ‘HIGH’ byte and a ‘LOW’ byte which can be accessed under software. • There is a mode control register (TMOD) and a control register (TCON) to configure these timers / counters in number of ways. • These timers are used to measure time intervals, determine pulse widths or initiate events with one microsecond resolution upto a maximum 65ms. Use software to get longer delays. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 19
  • 20. Serial Port • The 8051 has a high speed full duplex serial port which is software configurable in 4 basic modes : • Shift register mode • Standard UART mode • Multiprocessor mode • 9 bit UART mode. • Full duplex means the data can go both ways at the same time. Interrupts • The 8051 has five interrupt sources : One from the serial port (RI / TI) when a transmission or reception operation is executed. • two from the timers (TF0, TF1) when overflow occurs and two come from the two input pins INT0, INT1. Each interrupt may be independently enabled or disabled to allow polling on same sources and each may be classified as high or low priority. • These operations are selected by Interrupt Enable (IE) and Interrupt Priority (IP) registers. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 20
  • 21. Oscillator and Clock • The 8051 generates the clock pulses by which all internal operations are synchronized. • Pins XTAL 1 and XTAL 2 are provided for connecting a resonant network to form an oscillator. A quartz crystal is used for oscillator. • The crystal frequency is the basic internal clock frequency of the microcontroller 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 21
  • 22. MEMORY ORGANIZATION • The 8051 architecture provide both on chip memory expansion capabilities. It supports several distinctive ‘physical’ address spaces, functionally separated at the hardware level by different addressing mechanisms, read and write controls signals or both : • On chip Program Memory • On chip Data Memory • Off chip Program Memory • Off chip Data Memory • On chip Special Function Registers 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 22
  • 23. • The Program Memory area (EPROM incase of external memory or Flash / EPROM incase of internal one) is extremely large and never lose information when the power is removed. • On chip data memory is smaller and therefore quicker than Program Memory and it goes into a random state when power is removed. On chip RAM is used for variables which are calculated when the program is executed. • Different addressing mechanisms are used to access these different memory spaces and this greatly contributes to microcomputer’s operating efficiency. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 23
  • 24. Total internal Data Memory is divided into three blocks : Lower 128 bytes Higher 128 bytes. Special Function Register Space. Higher 128 bytes are available only in 8032 / 8052 devices. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 24
  • 25. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 25
  • 26. SPECIAL FUNCTION REGISTERS (SFRS) 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 26
  • 27. Physical view 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 27
  • 28. PINOUTS OF 8051 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 28
  • 29. Signals of 8051 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 29
  • 30. • The remaining 8 pins are VCC, GND, XTAL1, XTAL2, RST, EA , PSEN and ALE / PROG and ALE / . The functions of these pins are described as follows : 1. Vcc • Pin 40 of 8051 provides supply voltage to the chip from the +5V voltage source. 2. GND • Pin 20 is the ground for the chip, 3. RST • Pin 9 is the RESET pin. This is referred as a power-on reset. When activating (high pulse) this pin the microcontroller will reset and all values in the registers to be lost. Table 4.4 gives the reset values of some registers. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 30
  • 31. 4.EA (External Access) • This input pin is connected to either Vcc or GND. The 8051 family members has ON – CHIP ROM to store programs. EA pin (31) is connected to Vcc in 8051 Here, EA pin is connected to GND to indicate that the code is stored externally. 5. PSEN (Program Store Enable) • This is an output pin and pin number is 29. In an 8051 - based system in which an external ROM holds the program code, this pin is connected to the OE pin of the ROM. 6. ALE (Addres Latch Enable) This is an output pin (30) and is active high. When connecting an 8051 to external memory, port 0 provides both address and data. In other words, 8051 multiplexes address and data through port 0 to save pins. If ALE = 0, port 0 provides data (D0 - D7). If ALE=1, it has address (A0- A7). 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 31
  • 32. 7. XTAL 1 and XTAL 2 • The 8051 has an on - chip oscillator and it requires an external clock to return it. The quartz crystal oscillator (12 MHz / 20 MHz) is connected to XTAL 1 (pin 19) and XTAL 2 (pin 18) with two 30pF capacitors as shown in Fig. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 32
  • 33. I/O PORTS Port 0 (P0.0 - 0.7) • Port 0 is used for both address and data bus (AD0 – AD7). When the microcontroller chip is connected to an external memory, Port 0 provides both address and data. ALE pin indicates if Port 0 has address or data. • When ALE = 0, Port 0 provides data (D0 – D7) • = 1, Port 0 provides address (A0 – A7) • ALE is used for demultiplexing address and data with the help of a latch. Port 1 (P1.0 - P1.7) • Port 1 pins are used as input or output. To make port 1 as an input port, write 1 to all its 8 bits. To make port 1 as output port, write 0 to all its 8 bits. Thus port 1 pins have no dual functions. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 33
  • 34. Port 2 (P2.0 - P2.7) • Port 2 pins are used as input / output pins similar in operation to port 1. The alternate use of port 2 is to supply a high order address byte (A8 – A15) when the microcontroller is connected to external memory. Port 3 (P3.0 - P3.7) • Port 3 pins are used as input or output. Port 3 has the additional functions 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 34
  • 35. ADDRESSING MODES • The addressing modes are the ways of accessing data in register or in memory or be provided as an immediate value. The 8051 mnemonics are written with the destination address named first, followed by the source address. The following addressing modes are used to access data : • Immediate addressing mode • Register addressing mode • Direct addressing mode • Register indirect addressing mode • Indexed addressing mode. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 35
  • 36. Immediate Addressing Mode • When a source operand is a constant rather than a variable, then the constant can be embedded into the instruction itself. • This kind of instructions take two bytes and first one specifies the opcode and second byte gives the required constant. • The operand comes immediately after the opcode. The mnemonic for immediate data is the pound sign (#). • This addressing mode can be used to load information into any of the registers including DPTR register. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 36
  • 37. Register Addressing Mode • Register addressing accesses the eight working registers (R0 - R7) of the selected register bank. The least significant three bits of the instruction opcode indicate which register is to be used for the operation. • One of the four banks of registers is to be predefined in the PSW before using register addressing instruction. ACC, B and DPTR can also be addressed in this mode. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 37
  • 38. Direct Addressing Mode • In the direct addressing mode, all 128 bytes of internal RAM and the SFRs may be addressed directly using the single - byte address assigned to each RAM location and each SFR. • Internal RAM uses address from 00H to 7FH to address each byte. The SFR addresses exist from 80H to FFH. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 38
  • 39. • Register Indirect Addressing Mode • In this mode a register is used as a pointer to the data. If the data is inside the CPU, only registers R0 and R1 are used for this purpose. When R0 and R1 hold the addresses of RAM locations, they must be preceded by the “@” sign. Indexed Addressing Mode Only the program memory can be accessed by this mode. This mode is intended for reading lookup tables in the program memory. A 16 bit base register (DPTR or PC) points to the base of the lookup tables and accumulator carries the constant indicating table entry number. The address of the exact location of the table is formed by adding the accumulator data to the base pointer. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 39
  • 40. INSTRUCTION SET • An instruction is a command given to the computer to perform a specified operation on given data. The instruction set is the collection of instructions that the microcontroller is designed to execute. • These instructions have been classified into the following groups. Data transfer group Arithmetic group Logical group Boolean variable manipulation Program branching 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 40
  • 41. Data Transfer Instructions 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 41
  • 42. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 42
  • 43. Note : • Rn = Any of the eight registers, R0 to R7, in the selected bank. • Ri = Either of the pointing registers R0 to R1 in the selected bank. • addr = Address of the internal RAM from 00H to FFH. • L = Least significant nibble. • ^ = External memory location. • ( ) = Contents of the location inside the parentheses. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 43
  • 44. Arithmetic Instructions 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 44
  • 45. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 45
  • 46. Logical Instructions 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 46
  • 47. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 47
  • 48. Boolean Variable Manipulation Instructions 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 48
  • 49. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 49
  • 50. Program Branching Instructions 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 50
  • 51. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 51
  • 52. PROGRAMS 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 52
  • 53. 8 bit subtraction 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 53
  • 54. 8 Bit Multiplication 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 54
  • 55. 8 Bit Division 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 55
  • 56. 5/25/2021 Kongunadu College of Engineering and Technology(Autonomous) 56