8051 programes -ppt.pptx  bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
Contents:
Introduction
8051 Architecture
Addressing
Modes Timers
⚫An example for CISC Processor.
⚫Harvard Architecture
⚫Collection of 8 and 16 bit
registers and 8 bit memory
locations.
⚫External Memory can be
interfaced.
Pin Description of the 8051
1
2
3
4
5
6
7
8
9
10
11
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
P1.0
P1.1
P1.2
P1.3
P1.4
P1.5
P1.6
P1.7
RST
(RX
D)P
3.0
(TXD)P3.1
(I
NT0)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)
8051

Pins of
8051 ( 1/4 )
⚫ Vcc ( pin 40 ):
⚫ Vcc provides supply voltage to the chip.
⚫ The voltage source is +5V.
⚫ GND ( pin 20 ): ground
⚫ XTAL1 and XTAL2 ( pins 19,18 ):
⚫ These 2 pins provide external clock.
P⚫inRsSoTf ( 8p0i5n
19 () 2 : /4r ) eset
⚫ It is an input pin and is active high ( normally low ) .
⚫ Upon applying a high pulse to RST, the microcontroller will
reset and all values in registers will be lost.
Pins of 8051 ( 3/4 )
⚫ /EA ( pin 31 ): external access
⚫ The /EA pin is connected to GND to indicate the code is
stored externally.
⚫ For 8051, /EA pin is connected to Vcc.
⚫ “/” means active low.
⚫ /PSEN ( pin 29 ): program store enable
⚫ This is an output pin and is connected to the OE pin of the
ROM
Pins of 8051 ( 4/4 )
⚫ ALE ( pin 30 ): address latch enable
⚫ It is an output pin and is active high.
⚫ 8051 port 0 provides both address and data.
⚫ The ALE pin is used for de-multiplexing the address and data
by connecting to the G pin of the 74LS373 latch.
⚫ I/O port pins
⚫ The four ports P0, P1, P2, and P3.
⚫ Each port uses 8 pins.
⚫ All I/O pins are bi-directional.
Block Diagram
⚫Internal ROM and RAM
⚫I/O Ports with
programmable Pins
⚫ALU
⚫Working Registers
⚫Clock Circuits
⚫Timers and Counters
⚫Serial Data
Communication.
8051 Programming Model
Specific Features
⚫8 bit cpu with registers A and B
⚫16 bit PC and DPTR(data pointer).
⚫8 bit program status word(PSW)
⚫8 bit Stack Pointer
⚫4K Internal ROM
⚫128bytes Internal RAM
- 4 register banks each having 8 registers
16 bytes,which may be addressed at the bit
level.
80 bytes of general purpose data memory
Specific Features
⚫32 i/o pins arranged as 4 8 bit ports:P0 to P3
⚫Two 16 bit timer/counters:T0 and T1
⚫Full duplex serial data receiver/transmitter
⚫Control registers:TCON,TMOD,SCON,PCON,IP and IE
⚫Two external and Three internal interrupt sources.
⚫Oscillator and Clock Circuits.
Pins of I/O Port
⚫ The 8051 has four I/O ports
⚫ Port 0 ( pins 32-39 ): P0 ( P0.0 ~ P0.7 )
⚫ Port 1 ( pins 1-8 ) : P1 ( P1.0 ~ P1.7 )
⚫ Port 2 ( pins 21-28 ): P2 ( P2.0 ~ P2.7 )
⚫ Port 3 ( pins 10-17 ): P3 ( P3.0 ~ P3.7 )
⚫ Each port has 8 pins.
⚫ Named P0.X ( X=0,1,...,7 ) , P1.X, P2.X, P3.X
⚫ Ex : P0.0 is the bit 0 ( LSB ) of P0
⚫ Ex : P0.7 is the bit 7 ( MSB ) of P0
⚫ These 8 bits form a byte.
⚫ Each port can be used as input or output (bi-direction).

Program Counter & Data Pointer
⚫They are both 16 bit registers.
⚫Each is to hold the address of a byte in memory
⚫PC contains the address of the next instruction to
be executed.
⚫DPTR is made up of two 8 bit register DPH and DPL;
⚫DPTR contains the address of internal & external
code and data that has to be accessed.
A and B CPU registers
⚫Totally 34 general purpose registers or working registers.
⚫Two of these A and B hold results of many
instructions, particularly math and logical operations
of 8051 cpu.
⚫The other 32 are in four banks,B0 – B3 of eight
registers each.
⚫A(accumulator) is used for
addition,subtraction,mul,div,boolean bit manipulation and
for data transfers.
⚫But B register can only be used for mul and div operations.
8051 Flag bits and the PSW register
⚫PSW Register
CY AC F0 RS1 RS0 OV -- P
Carry flag PSW.7 CY
Auxiliary carry flag PSW.6 AC
Available to the user for general purpose PSW.5 --
Register Bank selector bit 1 PSW.4 RS1
Register Bank selector bit 0 PSW.3 RS0
Overflow flag PSW.2 OV
User define bit PSW.1 --
Parity flag Set/Reset odd/even parity PSW.0 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
• Two flag bits are stored in
PCON(Power control) registers also.
•They are the GF1 (3RD) and GF0(2nd) bits
• They are general purpose user flag
bit 1 and 0 respectively
•They can be set or cleared by the
program
•For more details of PCON, refer fig
⚫RAM memory space allocation in the
8051
7FH
30H
2FH
20H
1FH
10H
0FH
08H
07H
18H
17H
00H
Register Bank 0
(Stack) Register Bank 1
Register Bank 2
Register Bank 3
Bit-Addressable RAM
Scratch pad RAM
Memory Organization
Stack in the 8051
⚫ The register used to access
the stack is called SP (stack
pointer) register.
⚫ The stack pointer in the 8051
is only 8 bits wide, which
means that it can take value
00 to FFH. When 8051
powered up, the SP register
contains value 07.
7FH
30H
2FH
20H
1FH
10H
0FH
08H
07H
18H
17H
00H
Register Bank 0
(Stack) Register Bank 1
Register Bank 2
Register Bank 3
Bit-Addressable RAM
Scratch pad RAM
Special Function Registers
Name Function Name Function
A Accumulator SBUF Serial Port data
buffer
B Arithmetic SP Stack Pointer
DPH Addressing Ext
Memory
TMOD Timer/Counter
mode cntrl
DPL Addressing Ext
Memory
TCON Timer/Counter cntrl
IE Interrupt enable TL0 Timer0 lower byte
IP Interrupt Priority TH0 Timer0 higher byte
P0 I/O Port Latch TL1 Timer1 lower byte
P1 I/O Port Latch TH1 Timer1 higher byte
P2 I/O Port Latch
P3 I/O Port Latch
PCON Power Control
PSW Pgm Status Word
SCON Serial PortCntrl
Port 0 ( pins 32-39 )
⚫When connecting an 8051 to an external
memory, the 8051 uses ports to send
addresses and read instructions.
⚫16-bit address : P0 provides both address A0-
A7, P2 provides address A8-A15.
⚫Also, P0 provides data lines D0-D7.
⚫When P0 is used for address/data
multiplexing, it is connected to the
74LS373 to latch the address.
I/O Port Programming

Port 1 ( pins 1-
8 )
⚫ Port 1 is denoted by P1.
⚫ P1.0 ~ P1.7
⚫ P1 as an output port (i.e., write CPU data to the external pin)
⚫ P1 as an input port (i.e., read pin data into CPU bus)
ALE Pin
⚫The ALE pin is used for de-multiplexing the address
and data by connecting to the G pin of the 74LS373
latch.
⚫When ALE=0, P0 provides data D0-D7.
⚫When ALE=1, P0 provides address A0-A7.
⚫The reason is to allow P0 to multiplex address and data.
P⚫oArltth3ou ( gh ppoirnt 3sis1c0on-
f1ig7ur ) ed as an output port upon reset, this is not
the way it is most commonly used.
⚫Port 3 has the additional function of providing signals.
⚫Serial communications signal : RxD, TxD
⚫External interrupt : /INT0, /INT1
⚫Timer/counter : T0, T1
⚫External memory accesses : /WR, /RD
8051 programes -ppt.pptx  bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn
⚫Immediate
⚫Register
⚫Direct
⚫Register Indirect
⚫Indexed
AdThderweasysininwghicMh thoe
dinestsruction is specified.
Immediate Addressing Mode
⚫Immediate Data is specified in the instruction
itself
⚫Egs:
MOV A,#65H
MOV A,#’A’
MOV R6,#65H
MOV DPTR,#2343H
MOV P1,#65H
Register Addressing Mode
MOV Rn, A ;n=0,..,7
ADD A, Rn
MOV DPL, R6
MOV DPTR,
A MOV
Rm, Rn
Direct Addressing Mode
Although the entire of 128 bytes of RAM can be accessed
using direct addressing mode, it is most often used to
access RAM loc. 30 – 7FH.
MOV R0, 40H
MOV 56H, A
MOV A, 4
MOV 6, 2
; ≡ MOV A, R4
; copy R2 to R6
; MOV R6,R2 is
invalid !
Register Indirect Addressing Mode
⚫In this mode, register is used as a pointer to the data.
MOV A,@Ri
; move content of RAM loc. Where address is held by Ri into
A
( i=0 or 1 )
MOV @R1,B
In other word, the content of register R0 or R1 is sources
or target in MOV, ADD and SUBB insructions.
 jump
Indexed Addressing Mode And On-Chip
ROM Access
⚫This mode is widely used in accessing data elements
of look-up table entries located in the program
(code)
space ROM at the 8051
MOVC A,@A+DPTR
A= content of address A +DPTR from ROM
Note:
Because the data elements are stored in the program
(code ) space ROM of the 8051, it uses the instruction
MOVC instead of MOV. The “C” means code.

More Related Content

PPTX
8051- Microcontrollers Architecture & Addressing modes
PDF
Basics and Working of 8051 Microprocontroller
PDF
Microprocessor Techniques and Computer Organisation
PDF
Working and Internals of 8051 Microcontroller
PDF
Microcontroller Basics and Architecture of 8051
PDF
Introduction to 8051 Microcontroller and its Architecture
PDF
Hardware Structures, Addressing Modes, Interrupt Control : 8051
PDF
8051 Hardware Architecture, Addressing Modes, Interfacing
8051- Microcontrollers Architecture & Addressing modes
Basics and Working of 8051 Microprocontroller
Microprocessor Techniques and Computer Organisation
Working and Internals of 8051 Microcontroller
Microcontroller Basics and Architecture of 8051
Introduction to 8051 Microcontroller and its Architecture
Hardware Structures, Addressing Modes, Interrupt Control : 8051
8051 Hardware Architecture, Addressing Modes, Interfacing

Similar to 8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn (20)

PDF
Pin Description of the 8051 along with I/O Interfacing
PDF
Introduction Architecture Addressing Modes
PDF
microcontroller intel 8051 pin description
PDF
Instruction Set Architecture and Design of Hardware
PPT
Unit_4 8051_PPT_Architecture_pin_Addressing mode.ppt
PPTX
MICROCONTROLLER 8051- Architecture and registers
PPTX
8051 Microcontroller
PPTX
Microcontroller 8051 features and applications
PPTX
8051 basics register organization and its advantages
PPT
The hardware of the Mcs 51 microcontroller
PPTX
Unit 4 Introduction to Microcontrollers.pptxUnit-3 IO Interfacing-1.pptximpor...
PDF
8051_microcontroller_unit4 Presentation.pdf
PPTX
8051 microcontroller lecture EEE 3209.pptx
PPT
Microcontroller 8051
PPTX
8051 Microcontroller_module_4.1.pptx
PPTX
MCUnit 4and 5_New.pptx
PPT
janakiraman egsp collage I msc 4 unit
PPT
8051 Microcontroller architecture and operation
PPT
Microcontroller 8051
PDF
8051 microcontroller
Pin Description of the 8051 along with I/O Interfacing
Introduction Architecture Addressing Modes
microcontroller intel 8051 pin description
Instruction Set Architecture and Design of Hardware
Unit_4 8051_PPT_Architecture_pin_Addressing mode.ppt
MICROCONTROLLER 8051- Architecture and registers
8051 Microcontroller
Microcontroller 8051 features and applications
8051 basics register organization and its advantages
The hardware of the Mcs 51 microcontroller
Unit 4 Introduction to Microcontrollers.pptxUnit-3 IO Interfacing-1.pptximpor...
8051_microcontroller_unit4 Presentation.pdf
8051 microcontroller lecture EEE 3209.pptx
Microcontroller 8051
8051 Microcontroller_module_4.1.pptx
MCUnit 4and 5_New.pptx
janakiraman egsp collage I msc 4 unit
8051 Microcontroller architecture and operation
Microcontroller 8051
8051 microcontroller
Ad

More from NagarathnaRajur2 (20)

PPT
Basics of C (2).ppt bbbbbbbbbbbbbbbbbbbbb
PPT
C-Programming Chapter 1 Fundamentals of C.ppt
PPT
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
PPT
C-Programming Chapter 1 Fundamentals of C.ppt
PPT
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
PPTX
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
PPTX
EXCEPTIONS-PYTHON.pptx RUNTIME ERRORS HANDLING
PPTX
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
PPTX
ppt on arm memory.pptx yjjghjghjjjjjjjj
PPTX
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
PPT
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
PPTX
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
PPT
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
PPTX
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
PPTX
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
PPTX
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
PPTX
IOT introduction with applications ffffffffffffffffffffff
PPTX
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
PPTX
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
PPTX
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
Basics of C (2).ppt bbbbbbbbbbbbbbbbbbbbb
C-Programming Chapter 1 Fundamentals of C.ppt
Basics of C.ppt VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
C-Programming Chapter 1 Fundamentals of C.ppt
lecture-ON-C.ppt BASIC WITH DEPTH CONTENT
OPERATORS-PYTHON.pptx ALL OPERATORS ARITHMATIC AND LOGICAL
EXCEPTIONS-PYTHON.pptx RUNTIME ERRORS HANDLING
OOPS-PYTHON.pptx OOPS IN PYTHON APPLIED PROGRAMMING
ppt on arm memory.pptx yjjghjghjjjjjjjj
05_Thumb (15).pptx ARM MICROCONTROLLERS THUMB INSTRUCTIONS WORKING PRINCIPLE
PM.ppt DATA STRUCTURE USING C WITH EXAMPLE PROGRAMES
Chapter_04_ARM_Assembly.pptx ARM ASSEMBLY CODE
MEMORY.ppt 8051/8052 MEMORY MANEGEMENT MEMORY DESCRIPTION
CHAPTER1.pptx ON 8051 MICROCONTROLLER INTRODUCTION CHAPTER
Core-Java-by-Mahika-Tutor.9459891.powerpoint.pptx
review.pptx mnbmnbm,nb,n,nm,mn,mn,n,nm,
IOT introduction with applications ffffffffffffffffffffff
CORE JAVA PPT FOR ENGINEERS BBBBBBBBBBBBBBBBBBB
JAVA CLASS PPT FOR ENGINEERING STUDENTS BBBBBBBBBBBBBBBBBBB
JavaSteps. PPT NBNBVNBNVBNNNNNNNNNNNNNN
Ad

Recently uploaded (20)

PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
PDF
My India Quiz Book_20210205121199924.pdf
PPTX
Virtual and Augmented Reality in Current Scenario
PDF
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
HVAC Specification 2024 according to central public works department
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
English Textual Question & Ans (12th Class).pdf
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
Journal of Dental Science - UDMY (2021).pdf
PDF
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
PPTX
Computer Architecture Input Output Memory.pptx
PDF
Hazard Identification & Risk Assessment .pdf
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 1).pdf
My India Quiz Book_20210205121199924.pdf
Virtual and Augmented Reality in Current Scenario
Skin Care and Cosmetic Ingredients Dictionary ( PDFDrive ).pdf
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
HVAC Specification 2024 according to central public works department
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
FOISHS ANNUAL IMPLEMENTATION PLAN 2025.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
English Textual Question & Ans (12th Class).pdf
Uderstanding digital marketing and marketing stratergie for engaging the digi...
Journal of Dental Science - UDMY (2021).pdf
LEARNERS WITH ADDITIONAL NEEDS ProfEd Topic
Unit 4 Computer Architecture Multicore Processor.pptx
What if we spent less time fighting change, and more time building what’s rig...
LIFE & LIVING TRILOGY- PART (1) WHO ARE WE.pdf
Computer Architecture Input Output Memory.pptx
Hazard Identification & Risk Assessment .pdf

8051 programes -ppt.pptx bnvmmmmmmmmmmmmmmmmmmmmmmmmmmhn

  • 3. ⚫An example for CISC Processor. ⚫Harvard Architecture ⚫Collection of 8 and 16 bit registers and 8 bit memory locations. ⚫External Memory can be interfaced.
  • 4. Pin Description of the 8051 1 2 3 4 5 6 7 8 9 10 11 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 P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 RST (RX D)P 3.0 (TXD)P3.1 (I NT0)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) 8051 
  • 5. Pins of 8051 ( 1/4 ) ⚫ Vcc ( pin 40 ): ⚫ Vcc provides supply voltage to the chip. ⚫ The voltage source is +5V. ⚫ GND ( pin 20 ): ground ⚫ XTAL1 and XTAL2 ( pins 19,18 ): ⚫ These 2 pins provide external clock.
  • 6. P⚫inRsSoTf ( 8p0i5n 19 () 2 : /4r ) eset ⚫ It is an input pin and is active high ( normally low ) . ⚫ Upon applying a high pulse to RST, the microcontroller will reset and all values in registers will be lost.
  • 7. Pins of 8051 ( 3/4 ) ⚫ /EA ( pin 31 ): external access ⚫ The /EA pin is connected to GND to indicate the code is stored externally. ⚫ For 8051, /EA pin is connected to Vcc. ⚫ “/” means active low. ⚫ /PSEN ( pin 29 ): program store enable ⚫ This is an output pin and is connected to the OE pin of the ROM
  • 8. Pins of 8051 ( 4/4 ) ⚫ ALE ( pin 30 ): address latch enable ⚫ It is an output pin and is active high. ⚫ 8051 port 0 provides both address and data. ⚫ The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch. ⚫ I/O port pins ⚫ The four ports P0, P1, P2, and P3. ⚫ Each port uses 8 pins. ⚫ All I/O pins are bi-directional.
  • 10. ⚫Internal ROM and RAM ⚫I/O Ports with programmable Pins ⚫ALU ⚫Working Registers ⚫Clock Circuits ⚫Timers and Counters ⚫Serial Data Communication.
  • 12. Specific Features ⚫8 bit cpu with registers A and B ⚫16 bit PC and DPTR(data pointer). ⚫8 bit program status word(PSW) ⚫8 bit Stack Pointer ⚫4K Internal ROM ⚫128bytes Internal RAM - 4 register banks each having 8 registers 16 bytes,which may be addressed at the bit level. 80 bytes of general purpose data memory
  • 13. Specific Features ⚫32 i/o pins arranged as 4 8 bit ports:P0 to P3 ⚫Two 16 bit timer/counters:T0 and T1 ⚫Full duplex serial data receiver/transmitter ⚫Control registers:TCON,TMOD,SCON,PCON,IP and IE ⚫Two external and Three internal interrupt sources. ⚫Oscillator and Clock Circuits.
  • 14. Pins of I/O Port ⚫ The 8051 has four I/O ports ⚫ Port 0 ( pins 32-39 ): P0 ( P0.0 ~ P0.7 ) ⚫ Port 1 ( pins 1-8 ) : P1 ( P1.0 ~ P1.7 ) ⚫ Port 2 ( pins 21-28 ): P2 ( P2.0 ~ P2.7 ) ⚫ Port 3 ( pins 10-17 ): P3 ( P3.0 ~ P3.7 ) ⚫ Each port has 8 pins. ⚫ Named P0.X ( X=0,1,...,7 ) , P1.X, P2.X, P3.X ⚫ Ex : P0.0 is the bit 0 ( LSB ) of P0 ⚫ Ex : P0.7 is the bit 7 ( MSB ) of P0 ⚫ These 8 bits form a byte. ⚫ Each port can be used as input or output (bi-direction). 
  • 15. Program Counter & Data Pointer ⚫They are both 16 bit registers. ⚫Each is to hold the address of a byte in memory ⚫PC contains the address of the next instruction to be executed. ⚫DPTR is made up of two 8 bit register DPH and DPL; ⚫DPTR contains the address of internal & external code and data that has to be accessed.
  • 16. A and B CPU registers ⚫Totally 34 general purpose registers or working registers. ⚫Two of these A and B hold results of many instructions, particularly math and logical operations of 8051 cpu. ⚫The other 32 are in four banks,B0 – B3 of eight registers each. ⚫A(accumulator) is used for addition,subtraction,mul,div,boolean bit manipulation and for data transfers. ⚫But B register can only be used for mul and div operations.
  • 17. 8051 Flag bits and the PSW register ⚫PSW Register CY AC F0 RS1 RS0 OV -- P Carry flag PSW.7 CY Auxiliary carry flag PSW.6 AC Available to the user for general purpose PSW.5 -- Register Bank selector bit 1 PSW.4 RS1 Register Bank selector bit 0 PSW.3 RS0 Overflow flag PSW.2 OV User define bit PSW.1 -- Parity flag Set/Reset odd/even parity PSW.0 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
  • 18. • Two flag bits are stored in PCON(Power control) registers also. •They are the GF1 (3RD) and GF0(2nd) bits • They are general purpose user flag bit 1 and 0 respectively •They can be set or cleared by the program •For more details of PCON, refer fig
  • 19. ⚫RAM memory space allocation in the 8051 7FH 30H 2FH 20H 1FH 10H 0FH 08H 07H 18H 17H 00H Register Bank 0 (Stack) Register Bank 1 Register Bank 2 Register Bank 3 Bit-Addressable RAM Scratch pad RAM Memory Organization
  • 20. Stack in the 8051 ⚫ The register used to access the stack is called SP (stack pointer) register. ⚫ The stack pointer in the 8051 is only 8 bits wide, which means that it can take value 00 to FFH. When 8051 powered up, the SP register contains value 07. 7FH 30H 2FH 20H 1FH 10H 0FH 08H 07H 18H 17H 00H Register Bank 0 (Stack) Register Bank 1 Register Bank 2 Register Bank 3 Bit-Addressable RAM Scratch pad RAM
  • 21. Special Function Registers Name Function Name Function A Accumulator SBUF Serial Port data buffer B Arithmetic SP Stack Pointer DPH Addressing Ext Memory TMOD Timer/Counter mode cntrl DPL Addressing Ext Memory TCON Timer/Counter cntrl IE Interrupt enable TL0 Timer0 lower byte IP Interrupt Priority TH0 Timer0 higher byte P0 I/O Port Latch TL1 Timer1 lower byte P1 I/O Port Latch TH1 Timer1 higher byte P2 I/O Port Latch P3 I/O Port Latch PCON Power Control PSW Pgm Status Word SCON Serial PortCntrl
  • 22. Port 0 ( pins 32-39 ) ⚫When connecting an 8051 to an external memory, the 8051 uses ports to send addresses and read instructions. ⚫16-bit address : P0 provides both address A0- A7, P2 provides address A8-A15. ⚫Also, P0 provides data lines D0-D7. ⚫When P0 is used for address/data multiplexing, it is connected to the 74LS373 to latch the address. I/O Port Programming
  • 23.  Port 1 ( pins 1- 8 ) ⚫ Port 1 is denoted by P1. ⚫ P1.0 ~ P1.7 ⚫ P1 as an output port (i.e., write CPU data to the external pin) ⚫ P1 as an input port (i.e., read pin data into CPU bus)
  • 24. ALE Pin ⚫The ALE pin is used for de-multiplexing the address and data by connecting to the G pin of the 74LS373 latch. ⚫When ALE=0, P0 provides data D0-D7. ⚫When ALE=1, P0 provides address A0-A7. ⚫The reason is to allow P0 to multiplex address and data.
  • 25. P⚫oArltth3ou ( gh ppoirnt 3sis1c0on- f1ig7ur ) ed as an output port upon reset, this is not the way it is most commonly used. ⚫Port 3 has the additional function of providing signals. ⚫Serial communications signal : RxD, TxD ⚫External interrupt : /INT0, /INT1 ⚫Timer/counter : T0, T1 ⚫External memory accesses : /WR, /RD
  • 28. Immediate Addressing Mode ⚫Immediate Data is specified in the instruction itself ⚫Egs: MOV A,#65H MOV A,#’A’ MOV R6,#65H MOV DPTR,#2343H MOV P1,#65H
  • 29. Register Addressing Mode MOV Rn, A ;n=0,..,7 ADD A, Rn MOV DPL, R6 MOV DPTR, A MOV Rm, Rn
  • 30. Direct Addressing Mode Although the entire of 128 bytes of RAM can be accessed using direct addressing mode, it is most often used to access RAM loc. 30 – 7FH. MOV R0, 40H MOV 56H, A MOV A, 4 MOV 6, 2 ; ≡ MOV A, R4 ; copy R2 to R6 ; MOV R6,R2 is invalid !
  • 31. Register Indirect Addressing Mode ⚫In this mode, register is used as a pointer to the data. MOV A,@Ri ; move content of RAM loc. Where address is held by Ri into A ( i=0 or 1 ) MOV @R1,B In other word, the content of register R0 or R1 is sources or target in MOV, ADD and SUBB insructions.  jump
  • 32. Indexed Addressing Mode And On-Chip ROM Access ⚫This mode is widely used in accessing data elements of look-up table entries located in the program (code) space ROM at the 8051 MOVC A,@A+DPTR A= content of address A +DPTR from ROM Note: Because the data elements are stored in the program (code ) space ROM of the 8051, it uses the instruction MOVC instead of MOV. The “C” means code.