SlideShare a Scribd company logo
1 of 38
S. Y. B. Sc. (Computer Science)
SEM – III
Electronics Paper I
Microcontroller Architecture & Programming
Presentation
By
Mrs. Neeta Gatkal
Head, Department of Electronics
Pratibha College of Computer and Computer Studies,Chinchwad
Objectives
● To study the basics of 8051microcontroller
● To study the Programming of 8051
● To study the interfacing techniques of 8051
● To design different application circuits using 8051
Course Outcomes
1. To write programs for 8051 microcontroller
2. To interface I/O peripherals to 8051 microcontroller
3. To design small microcontroller based projects
UNIT- 1
Basics of Microcontroller & Intel 8051 architecture
❖ Introduction to microcontrollers, difference in controller and
processor.
❖ Architecture of 8051, Internal block diagram,
❖ Internal RAM organization, SFRS
❖ Pin functions of 8051, I/O port structure & Operation
❖ External Memory Interface.
Internal Organization of Computers
CPU (Central Processing Unit)
 Execute information stored in memory
I/O (Input/output) devices
Provide a means of communicating with CPU
Memory
RAM (Random Access Memory) – temporary storage
of programs that computer is running
 The data is lost when computer is off
ROM (Read Only Memory) – contains programs and
information essential to operation of the computer
 The information cannot be changed by use, and is not lost when
power is off
• – It is called nonvolatilememory
Internal Organization of Computers
The CPU is connected to memory and I/O through
strips of wire called a bus
 Carries information from place to place
 Address bus
 Data bus
 Control bus
CPU
Read/
Write
RAM
Address bus
Data bus
ROM Printer Disk Monitor Keyboard
Control bus
 Address bus
For a device (memory or I/O) to be recognized by the
CPU, it must be assigned an address
 The address assigned to a given device must be unique
 The CPU puts the address on the address bus, and the
decoding circuitry finds the device
 Data bus
The CPU either gets data from the device or sends data to it
 Control bus
Provides read or write signals to the device to indicate if the
CPU is asking for information or sending it information
MICRO-
CONTROLLERS
AND
EMBEDDED
PROCESSORS
Microcontroller
vs. General-
Purpose
Microprocessor
 General-purpose
microprocessors
contains
 No RAM
 No ROM
 No I/O ports
 Microcontroller has
 CPU (microprocessor)
 RAM
 ROM
 I/O ports
 Timer
 ADC and other
peripherals
Microcontroller vs. General- Purpose Microprocessor
Serial
COM
Port
Timer
I/O
ROM
CPU RAM
ller
Microcontro
CPU
RAM
Address bus
Data bus
ROM
I/O
Port
Serial
COM
Port
Timer
General-
purpose
Micro-
Processor
MICRO-
CONTROLLERS
AND
EMBEDDED
PROCESSORS
Microcontroller
vs. General-
Purpose
Microprocessor
Microcontroller vs. General- Purpose Microprocessor
 General-purpose microprocessor
 Must add RAM, ROM, I/O ports, and timers externally to make
them functional
 Make the system bulkier and much more expensive
 Have the advantage of versatility on the amount of RAM,
ROM, and I/O ports
Microcontroller
 The fixed amount of on-chip ROM, RAM, and number of I/O
ports makes them ideal for many applications in which cost and
space are critical
 In many applications, the space it takes, the power it consumes,
and the price per unit are much more critical considerations than
the computing power
What Is a Microcontroller?
 A microcontroller is an integrated circuit (IC)
device used for controlling other portions of an
electronic system, usually via a microprocessor
unit (MPU), memory, and some peripherals.
 A Microcontroller is a VLSI IC that contains a
CPU (Processor) along with some other
peripherals like Memory (RAM and ROM), I/O
Ports, Timers/Counters, Communication
Interface, ADC, etc.
Criteria for Choosing a Microcontroller
 Meeting the computing needs of the task at hand
efficiently and cost effectively
 Speed
 Packaging
 Power consumption
 The amount of RAM and ROM on chip
 The number of I/O pins and the timer on chip
 How easy to upgrade to higher- performance or lower power-consumption
versions
 Cost per unit
 Availability of software development tools, such as compilers,
assemblers, and debuggers
 Wide availability and reliable sources of the microcontroller
8051 Microcontroller
 Intel introduced 8051, referred as MCS- 51, in 1981
 The 8051 is an 8-bit processor
 The CPU can work on only 8 bits of data at a time
 The 8051 had
 128 bytes of RAM
 4K bytes of on-chip ROM
 Two timers
 One serial port
 Four I/O ports, each 8 bits wide
 6 interrupt sources
 The 8051 became widely popular after allowing other
manufactures to make and market any flavor of the 8051, but
remaining code-compatible
8051 Microcontroller
 The 8051 is a subset of the 8052
 The 8031 is a ROM-less 8051
 Add external ROM to it
 You lose two ports, and leave only 2 ports for I/O
operations
Feature 8051 8052 8031
ROM(On chip program
space in bytes)
RAM (bytes) 128 256 128
Timers 2 3 2
I/O pins 32 32 32
Serial port 1 1 1
Interrupt sources 6 8 6
8051 Microcontroller Block diagram
Interrupt
Control
Bus
Control
CPU
OSC I/O
Ports
Serial
Port
Etc.
Timer 0
Timer 1
On-chip
RAM
On-chip
ROM
for code
P0 P1 P2 P3
Address/Data
TXD RXD
Counter
Inputs
External
Interrupts
Architecture of 8051 Microcontroller
The 8051 Architecture consist of these specific features
 The 8 bit CPU with Registers A and B
 Internal ROM
 16-bit program counter(PC) and data pointer(DPTR)
 Internal RAM of 128 bytes
 8-bit Program Status word(PSW)
 Two 16 bit Counter / timers
 4 eight-bit ports
 3 internal interrupts and 2 external interrupts.
 Control register
 Oscillator and clock circuits.
Oscillator and Clock:
 Clock pulses are required to synchronize the internal operation of the
microcontroller, these clock pulses are generated by the resonant circuitry.
 Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form
an oscillator.
 Typically a quartz crystal and capacitors are employed, as shown below.
 The crystal frequency is the basic internal clock frequency for the micro-controller.
ALU:
 It is 8 bit unit.
 It performs arithmetic operation as addition, subtraction, multiplication, division,
increment and decrement.
 It performs logical operations like AND, OR and EX-OR.
 It manipulates 8 bit and 16 bit data
 8051 micro controller contains 34 general purpose registers or working registers.
2 of them are called math registers A & B and 32 are bank of registers.
a. Accumulator (Register A*): Address-E0H
 It is an 8-bit register used for many operations including addition, subtraction,
multiplication, division, and Boolean bit manipulations.
 This is also used for all data transfers between 8051 and any external memory. It
can also be used as a general purpose register. The results obtained from
arithmetic and logical instructions are always stored in Accumulator
Register B*: Address-F0H
 It is an 8-bit register specially used for direct multiplication and division operation with A.
 Both A and B registers are called math registers in 8051 family.
 It can also be used as a general-purpose storage location with its direct address (F0H).
Program Status Word (PSW)*: Address-D0H
 It is an 8-bit register having 5 flags including 4 math flags and one general purpose
user flag. Each flag corresponds to a bit in status register. It has two additional bits
RS0 and RS1 for register bank selection, which can be modified by the user.
 The math flags are set or reset by the results of arithmetic or logic operations.
 The user flag can be set or reset by the programmer as desired.
CY AC -- RS1 RS0 OV -- P
RS1 RS0 Register Bank Address
0 0 0 00H - 07H
0 1 1 08H - 0FH
1 0 2 10H - 17H
1 1 3 18H - 1FH
Program counter(PC):
 It is a 16-bit register,which holds the address of the next instruction to be executed.
 It is also called as Instruction Pointer (IP) and it is used to hold 16 bit address of
internal RAM, external RAM or external ROM locations.
 When the 8051 is initialized PC always starts at 0000h and is incremented each time an
instruction is executed. It is important to note that PC is always incremented by one and
never decremented.
Data pointer register(DTPR):
 It is a 16 bit register used to hold address of external or internal RAM where data is stored
or result is to be stored. It is used to store 16 bit data.
 It is divided into2- 8bit registers, DPH-data pointer higher order (83H) and DPL-data
pointer lower order (82H). Each register can be used as general purpose register to store 8
bit data and can also be used as memory location.
 DPTR does not have single internal address. It functions as Base register in base relative
addressing mode and in-direct jump.
Stack Pointer (SP): Address-81H
 It is an 8-bit register used to keep track of stack. Stack pointer is initialized to 07h on reset.
 Two instructions PUSH and POP modify SP. When PUSH instruction is used, SP is first
incremented and then data is pushed to the stack. When POP instruction is used, the data is
retrieved first and then SP is decremented.
 SP can be reinitialized to any address as desired by the user. Operation of the stack and SP is
shown in the figure below.
Special Function Registers (SFR’s):
SFR Description Address
A* Accumulator E0
B* B Register F0
PC Program Counter ––
DPTR:
DPH Data Pointer Higher Byte 83
DPL Data Pointer Lower Byte 82
SP Stack Pointer 81
PSW* Program Status Word D0
P0* Port 0 80
P1* Port 1 90
P2* Port 2 A0
P3* Port 3 B0
TH0 Timer 0 Higher Byte 8C
TL0 Timer 0 Lower Byte 8A
TH1 Timer 1 Higher Byte 8D
TL1 Timer 1 Lower Byte 8B
TCON* Timer Control 88
TMOD Timer Mode Control 89
SBUF Serial Data Buffer 99
SCON* Serial Port Control 98
PCON Power Mode Control 87
IE* Interrupt Enable A8
IP* Interrupt Priority B8
A. Timer/Counter register: 8051 microcontroller has 2-16 bit Timer/counter registers
called Timer-reg-T0 And Timer/counter Reg-T1.Each register is 16 bit register
divide into lower and higher byte register as shown below: These register are used
to hold initial no. of count. All of the 4 register are byte addressable.
1. Timer control register: 8051 microcontroller has two 8-bit timer control
register i.e. TMOD and TCON register. TMOD Register: it is 8-bit register. Its
address is 89H. It is byte addressable. It used to select mode and control
operation of time by writing control word.
2. TCON register: It is 8-bit register. Its address is 88H. It is byte addressable.
Its MSB 4-bit are used to control operation of timer/ counter and LSB 4-bit are
used for external interrupt control.
Special function Registers(SFR):
The 8051 microcontroller has 11 SFR divided in 4 groups:
B. Serial data register: 8051 micro controller has 2 serial data register
1. Serial buffer register (SBUF): it is 8-bit register. It is byte addressable .Its
address is 99H. It is used to hold data which is to be transferred serially.
2. Serial control register (SCON): it is 8-bit register. It is bit/byte addressable. Its
address is 98H. The 8-bit loaded into this register controls the operation of serial
communication.
C. Interrupt register: 8051 µC has 2 8-bit interrupt register.
1. Interrupt enable register (IE): it is 8-bit register. It is bit/byte addressable. Its
address is A8H.it is used to enable and disable function of interrupt.
2. Interrupt priority register (IP): It is 8-bit register. It is bit/byte addressable. Its
address is B8H. it is used to select low or high level priority of each individual
interrupts
D. Power control register (PCON): it is 8-bit register. It is byte addressable
.Its address is 87H. its bits are used to control mode of power saving circuit,
either idle or power down mode and also one bit is used to modify baud rate of
Communication.
Internal RAM organization
 There are 128 bytes of RAM in the 8051
 Assigned addresses 00 to 7FH
 The 128 bytes are divided into three different groups as
follows:
1) A total of 32 bytes from locations 00 to 1F hex are set
aside for register banks and the stack
2) A total of 16 bytes from locations 20H to 2FH are set
aside for bit-addressable read/write memory
3) A total of 80 bytes from locations 30H to 7FH are used
for read and write storage, called scratch pad
 These 32 bytes are divided
into 4 banks of registers in
which each bank has 8
registers, R0-R7
 RAM location from 0 to 7 are
set aside for bank 0 of R0-
R7 where R0 is RAM
location 0, R1 is RAM
location 1, R2 is RAM
location 2, and so on, until
memory location 7 which
belongs to R7 of bank 0
 It is much easier to refer to
these RAM locations with
names such as R0, R1, and
so on, than by their memory
locations
 Register bank 0 is the
default when 8051 is
powered up
Scratch pad RAM
Bit-Addressable RAM
Register Bank 3
Register Bank 2
0F
Register Bank 1 (stack)
08
07
Register Bank 0
00
10
18
17
20
1F
30
2F
7F
RAM Allocation in 8051
R7
R6
R5
R4
Bank 0 Bank 1 Bank 2 Bank 3
7
6
5
4
F
E
D
C
17
16
15
14
R7
R6
R5
R4
R7
R6
R5
R4
R6
R5
1F R7
1E
1D
1C R4
3 R3 B R3 13 R3 1B R3
2 R2 A R2 12 R2 1A R2
1 R1 9 R1 11 R1 19 R1
0 R0 8 R0 10 R0 18 R0
Register banks and their RAM address
Bank 0 0 0
Bank 1 0 1
Bank 2 1 0
Bank 3 1 1
RS1(PSW.4) RS0(PSW.3)
PSW bank selection
8051/52
(DS89C4x0
AT89C51
8031)
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RS
T
(RXD)P3.0
(TXD)P3.1
(-INT0)P3.2
(-INT1)P3.3
(T0)P3.4
(T1)P3.5
(-WR)P3.6
(-RD)P3.7
XTAL2
XTAL1
GND
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
-EA/VPP
ALE/-PROG
-PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
1
2
3
4
5
6
7
8
9
10
1
1
12
13
14
15
16
17
18
19
20
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
8051 pin diagram
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RS
T
(RXD)P3.0
(TXD)P3.1
(INT0)P3.2
(INT1)P3.3
(T0)P3.4
(T1)P3.5
(WR)P3.6
(RD)P3.7
XTAL2
XTAL1
GND
Vcc
P0.0(AD0)
P0.1(AD1)
P0.2(AD2)
P0.3(AD3)
P0.4(AD4)
P0.5(AD5)
P0.6(AD6)
P0.7(AD7)
-EA/VPP
ALE/PROG
-PSEN
P2.7(A15)
P2.6(A14)
P2.5(A13)
P2.4(A12)
P2.3(A11)
P2.2(A10)
P2.1(A9)
P2.0(A8)
1
2
3
4
5
6
7
8 8051/52
9
10(DS89C4x0
1
1 AT89C51
12
8031)
13
14
15
16
17
18
19
20
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
A total of 32
pins are set
aside for the
four ports P0,
P1, P2, P3,
where each port
takes 8 pins
Grond
-PSEN and ALE are used
mainly in 8031-baded systems
Vcc, GND, XTAL1,
XTAL2, RST, -EA
are used by all
members of 8051 and
8031 families
P1
P3
P2
P0
Provides +5V supply
voltage to the chip
PIN DESCRIPTION
(co’)
PIN DESCRIPTION OF THE 8051
 RST: RESET pin is an input and is active high(Normally High)
 Upon applying a high pulse to this pin, the microcontroller will reset and
terminate all activities
 This is often referred to as a power-on reset
 Activating a power-on reset will cause all values in the registers to be lost
 EA : “External access’’, is an input pin and must be connected to Vcc or GND
EA pin must be connected to GND to indicate that the code is stored externally
 PSEN : “Program store enable’’, is an output pin
This pin is connected to the OE pin of the ROM
 ALE : “Address latch enable”, is an output pin and is active high
 Port 0 provides both address and data
 The 8031 multiplexes address and data through port 0 to save pins
 ALE pin is used for demultiplexing the address and data by connecting
to the G pin of the 74LS373 chip
I/O Port Pins
 The four 8-bit I/O ports P0, P1, P2 and P3 each uses 8
pins
 All the ports upon RESET are configured as input,
ready to be used as input ports
 When the first 0 is written to a port, it becomes an output
 To reconfigure it as an input, a 1 must be sent to the port
 To use any of these ports as an input port, it must be programmed
PORT 0
 It can be used for input or output, each pin must be connected
externally to a 10K ohm pull-up resistor
 This is due to the fact that P0 is an open drain, unlike P1, P2, and P3
 Open drain is a term used for MOS chips in the same way that open
collector is used for TTL
 Port 0 is also designated as AD0-AD7, allowing it to be used for both address
and data When connecting an 8051/31 to an external memory, port 0
provides both address and data
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
Vcc
10 K
8051
Port
0
P0.X
P0.X
P0.X
PORT 1
 Port 1 can be used as input or output
 In contrast to port 0, this port does not need any pull-up resistors since
it already has pull-up resistors internally
 Upon reset, port 1 is configured as an input port
 To make port 1 an input port, it must be programmed as such by
writing 1 to all its bits
Port 1 is configured first as an input port by writing 1s to it, then data
is received from that port and saved in R7 and R5
MOV A,#0FFH ;A=FF hex
MOV P1,A ;make P1 an input port
MOV A,P1
;by writing it all 1s
;get data from P1
MOV R7,A ;save it to in reg R7
ACALL DELAY ;wait
MOV
MOV
A,P1
R5,A
;another data from P1
;save it to in reg R5
PORT 2
 Port 2 can be used as input or output
 Just like P1, port 2 does not need any pull- up resistors since it already has
pull-up resistors internally
 Upon reset, port 2 is configured as an input port
 To make port 2 an input port, it must be programmed as such by writing 1 to
all its bits
 In many 8051-based system, P2 is used as simple I/O
 In 8031-based systems, port 2 must be used along with P0 to provide the 16-
bit address for the external memory
 Port 2 is also designated as A8 – A15, indicating its dual function
 Port 0 provides the lower 8 bits via A0 – A7
 Port 3 can be used as input or output.
PORT 3
 Port 3 has the additional function of providing some extremely important signals
P3 Bit Function Pin
P3.0 RxD 10
P3.1 TxD 11
P3.2 INT0 12
P3.3 INT1 13
P3.4 T0 14
P3.5 T1 15
P3.6 WR 16
P3.7 RD 17
Serial
communications
External
interrupts
Timers
Read/Write signals
of external memories
In systems based on 8751, 89C51 or
DS89C4x0, pins 3.6 and 3.7 are used for I/O
while the rest of the pins in port 3 are
normally used in the alternate function role
Block diagram of Interfacing of External Memory to 8051
Step 1: Connect EA pin to ground
Step 2: Connect the PSEN to the CE and OE.
Step 3: Then, Port 2 (P2.0 – P2.7) to A8 – A12 pins of ext. ROM.
Step 4: Connect ALE to G of 74LS373 latch to enable it.
Step 5: Next, connect the OC of 74LS373 to GND.
Step 6: Connect Port 0 (P0.0 – P0.7), which consists of both address
and data multiplexed into Port 0 to 1D – 8D pins of 74LS373
latch to demultiplex it and 1Q – 8Q of the latch to A0 – A7 of
ext. ROM.
Step 7: Connect Port 0 (P0.0 – P0.7) to D0 – D7 of the ext. ROM.
Step 8: VPP of ext. ROM to VCC.
Interfacing of External Memory to 8051

More Related Content

What's hot (20)

Architecture of 8085
Architecture of 8085Architecture of 8085
Architecture of 8085
 
8085-microprocessor
8085-microprocessor8085-microprocessor
8085-microprocessor
 
8085-microprocessor
8085-microprocessor8085-microprocessor
8085-microprocessor
 
MICROCONTROLLER - INTEL 8051
MICROCONTROLLER - INTEL 8051MICROCONTROLLER - INTEL 8051
MICROCONTROLLER - INTEL 8051
 
MICROCONTROLLER 8051
MICROCONTROLLER 8051MICROCONTROLLER 8051
MICROCONTROLLER 8051
 
8085-microprocessor
8085-microprocessor8085-microprocessor
8085-microprocessor
 
8051 Microcontroller Tutorial and Architecture with Applications
8051 Microcontroller Tutorial and Architecture with Applications8051 Microcontroller Tutorial and Architecture with Applications
8051 Microcontroller Tutorial and Architecture with Applications
 
Ch3 ppt
Ch3 pptCh3 ppt
Ch3 ppt
 
Embedded systems ppt i
Embedded systems ppt iEmbedded systems ppt i
Embedded systems ppt i
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
8051 block diagram
8051 block diagram8051 block diagram
8051 block diagram
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
8051 Micro Controller
8051 Micro Controller 8051 Micro Controller
8051 Micro Controller
 
8051 microcontroller
8051 microcontroller8051 microcontroller
8051 microcontroller
 
8085 Microprocessor
8085 Microprocessor8085 Microprocessor
8085 Microprocessor
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
Mp 8085
Mp 8085Mp 8085
Mp 8085
 
EE8551 MPMC
EE8551  MPMCEE8551  MPMC
EE8551 MPMC
 
Week 1.2 pin diagram
Week 1.2   pin diagramWeek 1.2   pin diagram
Week 1.2 pin diagram
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 

Similar to 8051 microcontroller

8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdfSrikrishna Thota
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerSudhanshu Janwadkar
 
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentsEMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentseceprinter6
 
Unit1 5-mpi-lecture-notes
Unit1 5-mpi-lecture-notesUnit1 5-mpi-lecture-notes
Unit1 5-mpi-lecture-notesPrabhu Mali
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller918007165995
 
8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptxARYAKUMARNIRAV
 
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...sangeeta jogade
 
8086_architecture MMC PPT.ppt
8086_architecture MMC PPT.ppt8086_architecture MMC PPT.ppt
8086_architecture MMC PPT.pptJamesAlpha3
 
B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051MahiboobAliMulla
 
Ashish microcontroller 8051
Ashish microcontroller 8051Ashish microcontroller 8051
Ashish microcontroller 8051ASHISH RAJ
 
UNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxUNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxGowrishankar C
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051OGAGA OTOBOR
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051guest70d48b1
 

Similar to 8051 microcontroller (20)

8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf
 
Architecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 MicrocontrollerArchitecture of the Intel 8051 Microcontroller
Architecture of the Intel 8051 Microcontroller
 
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering studentsEMBEDDED SYSTEMS AND IOT lab manual for enginnering students
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
 
Unit1 5-mpi-lecture-notes
Unit1 5-mpi-lecture-notesUnit1 5-mpi-lecture-notes
Unit1 5-mpi-lecture-notes
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller
 
Architecture of 8085
Architecture of 8085Architecture of 8085
Architecture of 8085
 
8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx
 
Micro 8051
Micro 8051Micro 8051
Micro 8051
 
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...
Fundamentals of Microcontroller 8051 by Dr. Jogade S M, Assistant Professor, ...
 
POA_Unit 5.pptx
POA_Unit 5.pptxPOA_Unit 5.pptx
POA_Unit 5.pptx
 
8086_architecture MMC PPT.ppt
8086_architecture MMC PPT.ppt8086_architecture MMC PPT.ppt
8086_architecture MMC PPT.ppt
 
Unit 4.pptx
Unit 4.pptxUnit 4.pptx
Unit 4.pptx
 
UNIT 4.pptx
UNIT 4.pptxUNIT 4.pptx
UNIT 4.pptx
 
B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051B sc e5.2 mp unit 4 mc-8051
B sc e5.2 mp unit 4 mc-8051
 
8051.pptx
8051.pptx8051.pptx
8051.pptx
 
Ashish microcontroller 8051
Ashish microcontroller 8051Ashish microcontroller 8051
Ashish microcontroller 8051
 
UNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxUNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptx
 
89s52 2
89s52 289s52 2
89s52 2
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
Microcontroller 8051
Microcontroller 8051Microcontroller 8051
Microcontroller 8051
 

Recently uploaded

Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptxArvind Kumar
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIADr. TATHAGAT KHOBRAGADE
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Cherry
 
Cot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNACot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNACherry
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspectsmuralinath2
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryAlex Henderson
 
Pteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecyclePteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecycleCherry
 
Genome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxGenome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxCherry
 
Terpineol and it's characterization pptx
Terpineol and it's characterization pptxTerpineol and it's characterization pptx
Terpineol and it's characterization pptxMuhammadRazzaq31
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxseri bangash
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceAlex Henderson
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsSérgio Sacani
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.Cherry
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusNazaninKarimi6
 
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry Areesha Ahmad
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxRenuJangid3
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.Cherry
 
FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.takadzanijustinmaime
 

Recently uploaded (20)

Role of AI in seed science Predictive modelling and Beyond.pptx
Role of AI in seed science  Predictive modelling and  Beyond.pptxRole of AI in seed science  Predictive modelling and  Beyond.pptx
Role of AI in seed science Predictive modelling and Beyond.pptx
 
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIACURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
CURRENT SCENARIO OF POULTRY PRODUCTION IN INDIA
 
Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.Porella : features, morphology, anatomy, reproduction etc.
Porella : features, morphology, anatomy, reproduction etc.
 
Cot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNACot curve, melting temperature, unique and repetitive DNA
Cot curve, melting temperature, unique and repetitive DNA
 
Dr. E. Muralinath_ Blood indices_clinical aspects
Dr. E. Muralinath_ Blood indices_clinical  aspectsDr. E. Muralinath_ Blood indices_clinical  aspects
Dr. E. Muralinath_ Blood indices_clinical aspects
 
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and SpectrometryFAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
FAIRSpectra - Enabling the FAIRification of Spectroscopy and Spectrometry
 
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICEPATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
PATNA CALL GIRLS 8617370543 LOW PRICE ESCORT SERVICE
 
Pteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecyclePteris : features, anatomy, morphology and lifecycle
Pteris : features, anatomy, morphology and lifecycle
 
Genome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptxGenome sequencing,shotgun sequencing.pptx
Genome sequencing,shotgun sequencing.pptx
 
Terpineol and it's characterization pptx
Terpineol and it's characterization pptxTerpineol and it's characterization pptx
Terpineol and it's characterization pptx
 
The Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptxThe Mariana Trench remarkable geological features on Earth.pptx
The Mariana Trench remarkable geological features on Earth.pptx
 
FAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical ScienceFAIRSpectra - Enabling the FAIRification of Analytical Science
FAIRSpectra - Enabling the FAIRification of Analytical Science
 
Clean In Place(CIP).pptx .
Clean In Place(CIP).pptx                 .Clean In Place(CIP).pptx                 .
Clean In Place(CIP).pptx .
 
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune WaterworldsBiogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
Biogenic Sulfur Gases as Biosignatures on Temperate Sub-Neptune Waterworlds
 
POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.POGONATUM : morphology, anatomy, reproduction etc.
POGONATUM : morphology, anatomy, reproduction etc.
 
development of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virusdevelopment of diagnostic enzyme assay to detect leuser virus
development of diagnostic enzyme assay to detect leuser virus
 
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
GBSN - Biochemistry (Unit 2) Basic concept of organic chemistry
 
Use of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptxUse of mutants in understanding seedling development.pptx
Use of mutants in understanding seedling development.pptx
 
LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.LUNULARIA -features, morphology, anatomy ,reproduction etc.
LUNULARIA -features, morphology, anatomy ,reproduction etc.
 
FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.FS P2 COMBO MSTA LAST PUSH past exam papers.
FS P2 COMBO MSTA LAST PUSH past exam papers.
 

8051 microcontroller

  • 1. S. Y. B. Sc. (Computer Science) SEM – III Electronics Paper I Microcontroller Architecture & Programming Presentation By Mrs. Neeta Gatkal Head, Department of Electronics Pratibha College of Computer and Computer Studies,Chinchwad
  • 2. Objectives ● To study the basics of 8051microcontroller ● To study the Programming of 8051 ● To study the interfacing techniques of 8051 ● To design different application circuits using 8051
  • 3. Course Outcomes 1. To write programs for 8051 microcontroller 2. To interface I/O peripherals to 8051 microcontroller 3. To design small microcontroller based projects
  • 4. UNIT- 1 Basics of Microcontroller & Intel 8051 architecture ❖ Introduction to microcontrollers, difference in controller and processor. ❖ Architecture of 8051, Internal block diagram, ❖ Internal RAM organization, SFRS ❖ Pin functions of 8051, I/O port structure & Operation ❖ External Memory Interface.
  • 5. Internal Organization of Computers CPU (Central Processing Unit)  Execute information stored in memory I/O (Input/output) devices Provide a means of communicating with CPU Memory RAM (Random Access Memory) – temporary storage of programs that computer is running  The data is lost when computer is off ROM (Read Only Memory) – contains programs and information essential to operation of the computer  The information cannot be changed by use, and is not lost when power is off • – It is called nonvolatilememory
  • 6. Internal Organization of Computers The CPU is connected to memory and I/O through strips of wire called a bus  Carries information from place to place  Address bus  Data bus  Control bus CPU Read/ Write RAM Address bus Data bus ROM Printer Disk Monitor Keyboard Control bus
  • 7.  Address bus For a device (memory or I/O) to be recognized by the CPU, it must be assigned an address  The address assigned to a given device must be unique  The CPU puts the address on the address bus, and the decoding circuitry finds the device  Data bus The CPU either gets data from the device or sends data to it  Control bus Provides read or write signals to the device to indicate if the CPU is asking for information or sending it information
  • 8. MICRO- CONTROLLERS AND EMBEDDED PROCESSORS Microcontroller vs. General- Purpose Microprocessor  General-purpose microprocessors contains  No RAM  No ROM  No I/O ports  Microcontroller has  CPU (microprocessor)  RAM  ROM  I/O ports  Timer  ADC and other peripherals Microcontroller vs. General- Purpose Microprocessor Serial COM Port Timer I/O ROM CPU RAM ller Microcontro CPU RAM Address bus Data bus ROM I/O Port Serial COM Port Timer General- purpose Micro- Processor
  • 9. MICRO- CONTROLLERS AND EMBEDDED PROCESSORS Microcontroller vs. General- Purpose Microprocessor Microcontroller vs. General- Purpose Microprocessor  General-purpose microprocessor  Must add RAM, ROM, I/O ports, and timers externally to make them functional  Make the system bulkier and much more expensive  Have the advantage of versatility on the amount of RAM, ROM, and I/O ports Microcontroller  The fixed amount of on-chip ROM, RAM, and number of I/O ports makes them ideal for many applications in which cost and space are critical  In many applications, the space it takes, the power it consumes, and the price per unit are much more critical considerations than the computing power
  • 10. What Is a Microcontroller?  A microcontroller is an integrated circuit (IC) device used for controlling other portions of an electronic system, usually via a microprocessor unit (MPU), memory, and some peripherals.  A Microcontroller is a VLSI IC that contains a CPU (Processor) along with some other peripherals like Memory (RAM and ROM), I/O Ports, Timers/Counters, Communication Interface, ADC, etc.
  • 11. Criteria for Choosing a Microcontroller  Meeting the computing needs of the task at hand efficiently and cost effectively  Speed  Packaging  Power consumption  The amount of RAM and ROM on chip  The number of I/O pins and the timer on chip  How easy to upgrade to higher- performance or lower power-consumption versions  Cost per unit  Availability of software development tools, such as compilers, assemblers, and debuggers  Wide availability and reliable sources of the microcontroller
  • 12. 8051 Microcontroller  Intel introduced 8051, referred as MCS- 51, in 1981  The 8051 is an 8-bit processor  The CPU can work on only 8 bits of data at a time  The 8051 had  128 bytes of RAM  4K bytes of on-chip ROM  Two timers  One serial port  Four I/O ports, each 8 bits wide  6 interrupt sources  The 8051 became widely popular after allowing other manufactures to make and market any flavor of the 8051, but remaining code-compatible
  • 13. 8051 Microcontroller  The 8051 is a subset of the 8052  The 8031 is a ROM-less 8051  Add external ROM to it  You lose two ports, and leave only 2 ports for I/O operations Feature 8051 8052 8031 ROM(On chip program space in bytes) RAM (bytes) 128 256 128 Timers 2 3 2 I/O pins 32 32 32 Serial port 1 1 1 Interrupt sources 6 8 6
  • 14. 8051 Microcontroller Block diagram Interrupt Control Bus Control CPU OSC I/O Ports Serial Port Etc. Timer 0 Timer 1 On-chip RAM On-chip ROM for code P0 P1 P2 P3 Address/Data TXD RXD Counter Inputs External Interrupts
  • 15. Architecture of 8051 Microcontroller
  • 16. The 8051 Architecture consist of these specific features  The 8 bit CPU with Registers A and B  Internal ROM  16-bit program counter(PC) and data pointer(DPTR)  Internal RAM of 128 bytes  8-bit Program Status word(PSW)  Two 16 bit Counter / timers  4 eight-bit ports  3 internal interrupts and 2 external interrupts.  Control register  Oscillator and clock circuits.
  • 17. Oscillator and Clock:  Clock pulses are required to synchronize the internal operation of the microcontroller, these clock pulses are generated by the resonant circuitry.  Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form an oscillator.  Typically a quartz crystal and capacitors are employed, as shown below.  The crystal frequency is the basic internal clock frequency for the micro-controller.
  • 18. ALU:  It is 8 bit unit.  It performs arithmetic operation as addition, subtraction, multiplication, division, increment and decrement.  It performs logical operations like AND, OR and EX-OR.  It manipulates 8 bit and 16 bit data  8051 micro controller contains 34 general purpose registers or working registers. 2 of them are called math registers A & B and 32 are bank of registers. a. Accumulator (Register A*): Address-E0H  It is an 8-bit register used for many operations including addition, subtraction, multiplication, division, and Boolean bit manipulations.  This is also used for all data transfers between 8051 and any external memory. It can also be used as a general purpose register. The results obtained from arithmetic and logical instructions are always stored in Accumulator
  • 19. Register B*: Address-F0H  It is an 8-bit register specially used for direct multiplication and division operation with A.  Both A and B registers are called math registers in 8051 family.  It can also be used as a general-purpose storage location with its direct address (F0H). Program Status Word (PSW)*: Address-D0H  It is an 8-bit register having 5 flags including 4 math flags and one general purpose user flag. Each flag corresponds to a bit in status register. It has two additional bits RS0 and RS1 for register bank selection, which can be modified by the user.  The math flags are set or reset by the results of arithmetic or logic operations.  The user flag can be set or reset by the programmer as desired. CY AC -- RS1 RS0 OV -- P RS1 RS0 Register Bank Address 0 0 0 00H - 07H 0 1 1 08H - 0FH 1 0 2 10H - 17H 1 1 3 18H - 1FH
  • 20. Program counter(PC):  It is a 16-bit register,which holds the address of the next instruction to be executed.  It is also called as Instruction Pointer (IP) and it is used to hold 16 bit address of internal RAM, external RAM or external ROM locations.  When the 8051 is initialized PC always starts at 0000h and is incremented each time an instruction is executed. It is important to note that PC is always incremented by one and never decremented. Data pointer register(DTPR):  It is a 16 bit register used to hold address of external or internal RAM where data is stored or result is to be stored. It is used to store 16 bit data.  It is divided into2- 8bit registers, DPH-data pointer higher order (83H) and DPL-data pointer lower order (82H). Each register can be used as general purpose register to store 8 bit data and can also be used as memory location.  DPTR does not have single internal address. It functions as Base register in base relative addressing mode and in-direct jump.
  • 21. Stack Pointer (SP): Address-81H  It is an 8-bit register used to keep track of stack. Stack pointer is initialized to 07h on reset.  Two instructions PUSH and POP modify SP. When PUSH instruction is used, SP is first incremented and then data is pushed to the stack. When POP instruction is used, the data is retrieved first and then SP is decremented.  SP can be reinitialized to any address as desired by the user. Operation of the stack and SP is shown in the figure below.
  • 22. Special Function Registers (SFR’s): SFR Description Address A* Accumulator E0 B* B Register F0 PC Program Counter –– DPTR: DPH Data Pointer Higher Byte 83 DPL Data Pointer Lower Byte 82 SP Stack Pointer 81 PSW* Program Status Word D0 P0* Port 0 80 P1* Port 1 90 P2* Port 2 A0 P3* Port 3 B0 TH0 Timer 0 Higher Byte 8C TL0 Timer 0 Lower Byte 8A TH1 Timer 1 Higher Byte 8D TL1 Timer 1 Lower Byte 8B TCON* Timer Control 88 TMOD Timer Mode Control 89 SBUF Serial Data Buffer 99 SCON* Serial Port Control 98 PCON Power Mode Control 87 IE* Interrupt Enable A8 IP* Interrupt Priority B8
  • 23. A. Timer/Counter register: 8051 microcontroller has 2-16 bit Timer/counter registers called Timer-reg-T0 And Timer/counter Reg-T1.Each register is 16 bit register divide into lower and higher byte register as shown below: These register are used to hold initial no. of count. All of the 4 register are byte addressable. 1. Timer control register: 8051 microcontroller has two 8-bit timer control register i.e. TMOD and TCON register. TMOD Register: it is 8-bit register. Its address is 89H. It is byte addressable. It used to select mode and control operation of time by writing control word. 2. TCON register: It is 8-bit register. Its address is 88H. It is byte addressable. Its MSB 4-bit are used to control operation of timer/ counter and LSB 4-bit are used for external interrupt control. Special function Registers(SFR): The 8051 microcontroller has 11 SFR divided in 4 groups:
  • 24. B. Serial data register: 8051 micro controller has 2 serial data register 1. Serial buffer register (SBUF): it is 8-bit register. It is byte addressable .Its address is 99H. It is used to hold data which is to be transferred serially. 2. Serial control register (SCON): it is 8-bit register. It is bit/byte addressable. Its address is 98H. The 8-bit loaded into this register controls the operation of serial communication. C. Interrupt register: 8051 µC has 2 8-bit interrupt register. 1. Interrupt enable register (IE): it is 8-bit register. It is bit/byte addressable. Its address is A8H.it is used to enable and disable function of interrupt. 2. Interrupt priority register (IP): It is 8-bit register. It is bit/byte addressable. Its address is B8H. it is used to select low or high level priority of each individual interrupts
  • 25. D. Power control register (PCON): it is 8-bit register. It is byte addressable .Its address is 87H. its bits are used to control mode of power saving circuit, either idle or power down mode and also one bit is used to modify baud rate of Communication.
  • 26. Internal RAM organization  There are 128 bytes of RAM in the 8051  Assigned addresses 00 to 7FH  The 128 bytes are divided into three different groups as follows: 1) A total of 32 bytes from locations 00 to 1F hex are set aside for register banks and the stack 2) A total of 16 bytes from locations 20H to 2FH are set aside for bit-addressable read/write memory 3) A total of 80 bytes from locations 30H to 7FH are used for read and write storage, called scratch pad
  • 27.  These 32 bytes are divided into 4 banks of registers in which each bank has 8 registers, R0-R7  RAM location from 0 to 7 are set aside for bank 0 of R0- R7 where R0 is RAM location 0, R1 is RAM location 1, R2 is RAM location 2, and so on, until memory location 7 which belongs to R7 of bank 0  It is much easier to refer to these RAM locations with names such as R0, R1, and so on, than by their memory locations  Register bank 0 is the default when 8051 is powered up Scratch pad RAM Bit-Addressable RAM Register Bank 3 Register Bank 2 0F Register Bank 1 (stack) 08 07 Register Bank 0 00 10 18 17 20 1F 30 2F 7F RAM Allocation in 8051
  • 28. R7 R6 R5 R4 Bank 0 Bank 1 Bank 2 Bank 3 7 6 5 4 F E D C 17 16 15 14 R7 R6 R5 R4 R7 R6 R5 R4 R6 R5 1F R7 1E 1D 1C R4 3 R3 B R3 13 R3 1B R3 2 R2 A R2 12 R2 1A R2 1 R1 9 R1 11 R1 19 R1 0 R0 8 R0 10 R0 18 R0 Register banks and their RAM address Bank 0 0 0 Bank 1 0 1 Bank 2 1 0 Bank 3 1 1 RS1(PSW.4) RS0(PSW.3) PSW bank selection
  • 30. P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RS T (RXD)P3.0 (TXD)P3.1 (INT0)P3.2 (INT1)P3.3 (T0)P3.4 (T1)P3.5 (WR)P3.6 (RD)P3.7 XTAL2 XTAL1 GND Vcc P0.0(AD0) P0.1(AD1) P0.2(AD2) P0.3(AD3) P0.4(AD4) P0.5(AD5) P0.6(AD6) P0.7(AD7) -EA/VPP ALE/PROG -PSEN P2.7(A15) P2.6(A14) P2.5(A13) P2.4(A12) P2.3(A11) P2.2(A10) P2.1(A9) P2.0(A8) 1 2 3 4 5 6 7 8 8051/52 9 10(DS89C4x0 1 1 AT89C51 12 8031) 13 14 15 16 17 18 19 20 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 A total of 32 pins are set aside for the four ports P0, P1, P2, P3, where each port takes 8 pins Grond -PSEN and ALE are used mainly in 8031-baded systems Vcc, GND, XTAL1, XTAL2, RST, -EA are used by all members of 8051 and 8031 families P1 P3 P2 P0 Provides +5V supply voltage to the chip PIN DESCRIPTION (co’)
  • 31. PIN DESCRIPTION OF THE 8051  RST: RESET pin is an input and is active high(Normally High)  Upon applying a high pulse to this pin, the microcontroller will reset and terminate all activities  This is often referred to as a power-on reset  Activating a power-on reset will cause all values in the registers to be lost  EA : “External access’’, is an input pin and must be connected to Vcc or GND EA pin must be connected to GND to indicate that the code is stored externally  PSEN : “Program store enable’’, is an output pin This pin is connected to the OE pin of the ROM  ALE : “Address latch enable”, is an output pin and is active high  Port 0 provides both address and data  The 8031 multiplexes address and data through port 0 to save pins  ALE pin is used for demultiplexing the address and data by connecting to the G pin of the 74LS373 chip
  • 32. I/O Port Pins  The four 8-bit I/O ports P0, P1, P2 and P3 each uses 8 pins  All the ports upon RESET are configured as input, ready to be used as input ports  When the first 0 is written to a port, it becomes an output  To reconfigure it as an input, a 1 must be sent to the port  To use any of these ports as an input port, it must be programmed
  • 33. PORT 0  It can be used for input or output, each pin must be connected externally to a 10K ohm pull-up resistor  This is due to the fact that P0 is an open drain, unlike P1, P2, and P3  Open drain is a term used for MOS chips in the same way that open collector is used for TTL  Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data When connecting an 8051/31 to an external memory, port 0 provides both address and data P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 Vcc 10 K 8051 Port 0 P0.X P0.X P0.X
  • 34. PORT 1  Port 1 can be used as input or output  In contrast to port 0, this port does not need any pull-up resistors since it already has pull-up resistors internally  Upon reset, port 1 is configured as an input port  To make port 1 an input port, it must be programmed as such by writing 1 to all its bits Port 1 is configured first as an input port by writing 1s to it, then data is received from that port and saved in R7 and R5 MOV A,#0FFH ;A=FF hex MOV P1,A ;make P1 an input port MOV A,P1 ;by writing it all 1s ;get data from P1 MOV R7,A ;save it to in reg R7 ACALL DELAY ;wait MOV MOV A,P1 R5,A ;another data from P1 ;save it to in reg R5
  • 35. PORT 2  Port 2 can be used as input or output  Just like P1, port 2 does not need any pull- up resistors since it already has pull-up resistors internally  Upon reset, port 2 is configured as an input port  To make port 2 an input port, it must be programmed as such by writing 1 to all its bits  In many 8051-based system, P2 is used as simple I/O  In 8031-based systems, port 2 must be used along with P0 to provide the 16- bit address for the external memory  Port 2 is also designated as A8 – A15, indicating its dual function  Port 0 provides the lower 8 bits via A0 – A7
  • 36.  Port 3 can be used as input or output. PORT 3  Port 3 has the additional function of providing some extremely important signals P3 Bit Function Pin P3.0 RxD 10 P3.1 TxD 11 P3.2 INT0 12 P3.3 INT1 13 P3.4 T0 14 P3.5 T1 15 P3.6 WR 16 P3.7 RD 17 Serial communications External interrupts Timers Read/Write signals of external memories In systems based on 8751, 89C51 or DS89C4x0, pins 3.6 and 3.7 are used for I/O while the rest of the pins in port 3 are normally used in the alternate function role
  • 37. Block diagram of Interfacing of External Memory to 8051
  • 38. Step 1: Connect EA pin to ground Step 2: Connect the PSEN to the CE and OE. Step 3: Then, Port 2 (P2.0 – P2.7) to A8 – A12 pins of ext. ROM. Step 4: Connect ALE to G of 74LS373 latch to enable it. Step 5: Next, connect the OC of 74LS373 to GND. Step 6: Connect Port 0 (P0.0 – P0.7), which consists of both address and data multiplexed into Port 0 to 1D – 8D pins of 74LS373 latch to demultiplex it and 1Q – 8Q of the latch to A0 – A7 of ext. ROM. Step 7: Connect Port 0 (P0.0 – P0.7) to D0 – D7 of the ext. ROM. Step 8: VPP of ext. ROM to VCC. Interfacing of External Memory to 8051