SlideShare a Scribd company logo
The 8051 MicroController
Important 8051 Features
• 4K bytes ROM
• 128 bytes RAM
• Four 8-bit I/O ports
• Two 16-bit timers
• Serial interface
• 64K external code memory space
• 64K data memory space
Pin Layout
• The 8051 is a 40 pin device, but out of these
40 pins, 32 are used for I/O.
• 24 of these are dual purpose, i.e. they can
operate as I/O or a control line or as part of
address or data bus.
8051 pinouts
Port 0 and Port 1
• Port 0 is a dual purpose port, it is located
from pin 32 to pin 39 (8 pins) and is labeled
as AD0 to AD7.
• Port 1 is a dedicated I/O port from pin 1 to
pin 8. It is generally used for interfacing to
external device thus if you need to connect
to switches or LEDs, you could make use of
these 8 pins.
Port 2 and Port 3
• Like port 0, port 2 is a dual-purpose port. It can be
used for general I/O or as the high byte of the
address bus for designs with external code
memory.
• Port 3 is also dual purpose but designers generally
avoid using this port unnecessarily for I/O because
the pins have alternate functions which are related
to special features of the 8051. Indiscriminate use
of these pins may interfere with the normal
operation of the 8051.
Oscillator ( clock) Input
• The 8051 is typically driven by a crystal
oscillator connected to pin 18 and 19.
• The words XTAL is short for crysTAL.
Driving the 8051 from a TTL oscillator
Machine Cycle and Clock Cycle
• 12 clock cycles make one machine cycle.
Relationship between oscillator clock cycles, states, and the machine cycle
Memory Structure
• While most microprocessors implement a shared
memory space for data and code (programs),
microcontrollers has limited memory and the
program is usually stored in ROM.
• In the 8051, both code and data may be internal
but they are stored in separate memories, namely
the internal ROM and RAM. Expandable to a
max of 64K using external memory.
• The next page shows the 8031 which has no
internal ROM.
Summary of the 8031 memory spaces
Summary of the 8051 on chip data memory
Register Banks
• 4 Register Banks — Bank0, Bank1, Bank2
and Bank3
• Each Bank consists of — R0, R1, R2, R3,
R4, R5, R6, R7
• Bank 0 is the default upon power up of the
microcontroller
• Other banks can be selected by
programming PSW register.
General Purpose RAM
• The general purpose RAM area is from
address 30H to 7FH. The locations from
address 20H to 2FH can also be used as
general purpose RAM although these
addresses have very specific role.
Bit-Addressable RAM
• The 8051 contains 210 bit-addressable
locations of which 128 are at byte address
20H through 2FH.
• This is the powerful feature of most
microcontroller because individual bits can
be set, cleared, ANDed, ORed etc. with a
single instruction instead of having to read a
byte and modify
• Example
– we could issue a simple instruction
SETB 67H
This would set the bit at address 67H to logic HIGH.
Bit 67H is bit 7(most significant bit) of byte location
2CH
In order to achieve the same result, a microprocessor
would need to do this:
MOV A, 2CH
ORL A,#10000000B
MOV 2CH,A
Special Function Registers
• Above 7FH, there is another block of
memory 80H to 0FFH in all the version of
MCS51 uP
• this 128 bytes of memory are reserved for
Special Function Register (SFR). There are
21 SFRs.
SFRs
• SFR are usually addressed by name
• Memory location 0F0H is given a name called
Register B, similarly 80H is called P0.
• Not all memory location has a name
– memory location 35H has no name
• Some locations between the SFRs have no names
as well e.g. 91H. Such locations should not be
used to store any data. If you do it then your data
may be lost.
Program Status Word (PSW)
• This is a very important register because it
contains status bits which indicates the current
state of the cpu.
• PSW.7 CarrY(CY)
• PSW.6 Aux Carry (AC)
• PSW.5 Flag 0 (F0)
• PSW.4 Register Bank Select 1
• PSW.3 Register Bank Select 0
• PSW.2 Overflow(OV)
• PSW.1 reserved
• PSW.0 Even Parity Flag (P)
Commonly used SFRs
• Accumulator, it has two names, A and
ACC. Many instruction make use of the
accumulator, eg: mov A,R0, push acc
• SP, always pointing to the top of the stack,
increasing by 1 before write to stack,
decreasing by 1 after read from stack
_____
• PSEN (Program Store Enable)
– This is a dedicated control line on pin 29 and is
used to enable external program (code)
memory. This pin usually connects to an
EPROM’s Output Enable (OE) pin.
– This is a logic low pin as represented by the bar
above the word PSEN, this means that during a
fetch stage involving an instruction stored in
external memory, the pin will be pulsed
‘LOW’.
• ALE ( Address Latch Enable)
– This pin is used to demultiplex the address and
data lines.
– Remember that port 0 has 2 functions. As the
low byte of the address bus and as the data bus.
In designs with external memory, port 0 is
connected to both the address and data lines of
the external RAM thus during the part of the
fetch cycle where the address is supplied, the
ALE is pulsed to enable the G (gate) control pin
of the latch IC thus the data goes to RAM and
is interpreted as an address.
___
• EA (External Access)
– If you need to connect to external ROM then
this pin must be tied LOW (0V).
– This pin must be tied high (+5V) if the
programs executes from internal ROM.
RST (Reset)
• This is pin 9 of the IC and is used as the
master reset for the 8051. In order for the
8051 to recognize that a reset has occurred,
this pin must be brought HIGH for at least
two machine cycles. During normal
operation, this pin must be at logic LOW.
• Power Connections
– The 8051 requires a +5V input on its Vcc input
(pin 40) and Vss connection is on page 20.
Accessing External Code Memory
• If the design involves external code
memory, both P0 and P2 should not be used
as general purpose I/O since P2 is now the
Higher address bus while P0 is the
multiplexed Lower address bus and the data
bus.
_____
• As stated earlier, the PSEN pin must be
used.
FIGURE 2–8 Multiplexing the address bus (low-byte) and data bus
FIGURE 2–9 Accessing external code memory
An opcode fetch for 2-byte instruction
• Fig.2-10 shows what happens during an
opcode fetch for a 2 byte instruction that
has a time of 1 machine cycle.
Accessing External RAM
• For designs with external RAM, a typical
connection is shown in fig.2-12. Note the
control lines that must be used.
• MOVX instruction is used to indicate that
the external RAM is involved.
• e.g. MOVX A, @dptr ( a read operation)
• e.g. MOVX @dptr, A (a write operation)
• The timing diagram for a read operation is
shown in fig 2-11.
FIGURE 2–12 Interface to 1K RAM

More Related Content

Similar to 8051.ppt

8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
nitugatkal
 
Micro controller
Micro controllerMicro controller
Micro controller
Dr. Ashok Kumar K
 
Microprocessor history1
Microprocessor history1Microprocessor history1
Microprocessor history1
HarshitParkar6677
 
Microprocessor history1
Microprocessor history1Microprocessor history1
Microprocessor history1
HarshitParkar6677
 
8051 architecture and pin configuration
8051 architecture and pin configuration8051 architecture and pin configuration
8051 architecture and pin configuration
NITHIN KALLE PALLY
 
8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx
ARYAKUMARNIRAV
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III  The 8051 MicrocontrollersSYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III  The 8051 Microcontrollers
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
Arti Parab Academics
 
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
Microcontroller Electronics Engineering Sem 4MODULE 1.pptxMicrocontroller Electronics Engineering Sem 4MODULE 1.pptx
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
itsmeaswin03
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller
918007165995
 
002079
002079002079
002079
irfantheraj
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf
Srikrishna Thota
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
Adarsh College, Hingoli
 
microcontroller.pptx
microcontroller.pptxmicrocontroller.pptx
microcontroller.pptx
Adarsh College, Hingoli
 
UNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxUNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptx
Gowrishankar C
 
assignment 1-MC.pdf
assignment 1-MC.pdfassignment 1-MC.pdf
assignment 1-MC.pdf
SANTHAKUMARP5
 
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxlec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
MadavanR1
 
The hardware of the Mcs 51 microcontroller
 The hardware of the Mcs 51 microcontroller The hardware of the Mcs 51 microcontroller
The hardware of the Mcs 51 microcontroller
Garba Geidam
 

Similar to 8051.ppt (20)

8051 microcontroller
8051 microcontroller 8051 microcontroller
8051 microcontroller
 
8051.pptx
8051.pptx8051.pptx
8051.pptx
 
Micro controller
Micro controllerMicro controller
Micro controller
 
Microprocessor history1
Microprocessor history1Microprocessor history1
Microprocessor history1
 
Microprocessor history1
Microprocessor history1Microprocessor history1
Microprocessor history1
 
8051 architecture and pin configuration
8051 architecture and pin configuration8051 architecture and pin configuration
8051 architecture and pin configuration
 
8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx8051 Microcontroller_module_4.1.pptx
8051 Microcontroller_module_4.1.pptx
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III  The 8051 MicrocontrollersSYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III  The 8051 Microcontrollers
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
 
Unit 5
Unit 5Unit 5
Unit 5
 
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
Microcontroller Electronics Engineering Sem 4MODULE 1.pptxMicrocontroller Electronics Engineering Sem 4MODULE 1.pptx
Microcontroller Electronics Engineering Sem 4MODULE 1.pptx
 
Study of 8051 microcontroller
Study of 8051 microcontrollerStudy of 8051 microcontroller
Study of 8051 microcontroller
 
002079
002079002079
002079
 
8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf8051 Architecture and PIN Configuration.pdf
8051 Architecture and PIN Configuration.pdf
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
microcontroller.pptx
microcontroller.pptxmicrocontroller.pptx
microcontroller.pptx
 
UNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptxUNIT 4 8051Microcontroller.pptx
UNIT 4 8051Microcontroller.pptx
 
assignment 1-MC.pdf
assignment 1-MC.pdfassignment 1-MC.pdf
assignment 1-MC.pdf
 
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptxlec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
lec3-8051microcontrollerarchitecture-230130044236-5c11a082.pptx
 
The hardware of the Mcs 51 microcontroller
 The hardware of the Mcs 51 microcontroller The hardware of the Mcs 51 microcontroller
The hardware of the Mcs 51 microcontroller
 
MICROCONTROLLER 8051
MICROCONTROLLER 8051MICROCONTROLLER 8051
MICROCONTROLLER 8051
 

Recently uploaded

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation & Control
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
Kerry Sado
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
AmarGB2
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 

Recently uploaded (20)

Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Water Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdfWater Industry Process Automation and Control Monthly - May 2024.pdf
Water Industry Process Automation and Control Monthly - May 2024.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Hierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power SystemHierarchical Digital Twin of a Naval Power System
Hierarchical Digital Twin of a Naval Power System
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Investor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptxInvestor-Presentation-Q1FY2024 investor presentation document.pptx
Investor-Presentation-Q1FY2024 investor presentation document.pptx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 

8051.ppt

  • 2. Important 8051 Features • 4K bytes ROM • 128 bytes RAM • Four 8-bit I/O ports • Two 16-bit timers • Serial interface • 64K external code memory space • 64K data memory space
  • 3. Pin Layout • The 8051 is a 40 pin device, but out of these 40 pins, 32 are used for I/O. • 24 of these are dual purpose, i.e. they can operate as I/O or a control line or as part of address or data bus.
  • 5. Port 0 and Port 1 • Port 0 is a dual purpose port, it is located from pin 32 to pin 39 (8 pins) and is labeled as AD0 to AD7. • Port 1 is a dedicated I/O port from pin 1 to pin 8. It is generally used for interfacing to external device thus if you need to connect to switches or LEDs, you could make use of these 8 pins.
  • 6. Port 2 and Port 3 • Like port 0, port 2 is a dual-purpose port. It can be used for general I/O or as the high byte of the address bus for designs with external code memory. • Port 3 is also dual purpose but designers generally avoid using this port unnecessarily for I/O because the pins have alternate functions which are related to special features of the 8051. Indiscriminate use of these pins may interfere with the normal operation of the 8051.
  • 7. Oscillator ( clock) Input • The 8051 is typically driven by a crystal oscillator connected to pin 18 and 19. • The words XTAL is short for crysTAL.
  • 8. Driving the 8051 from a TTL oscillator
  • 9. Machine Cycle and Clock Cycle • 12 clock cycles make one machine cycle.
  • 10. Relationship between oscillator clock cycles, states, and the machine cycle
  • 11. Memory Structure • While most microprocessors implement a shared memory space for data and code (programs), microcontrollers has limited memory and the program is usually stored in ROM. • In the 8051, both code and data may be internal but they are stored in separate memories, namely the internal ROM and RAM. Expandable to a max of 64K using external memory. • The next page shows the 8031 which has no internal ROM.
  • 12. Summary of the 8031 memory spaces
  • 13. Summary of the 8051 on chip data memory
  • 14. Register Banks • 4 Register Banks — Bank0, Bank1, Bank2 and Bank3 • Each Bank consists of — R0, R1, R2, R3, R4, R5, R6, R7 • Bank 0 is the default upon power up of the microcontroller • Other banks can be selected by programming PSW register.
  • 15. General Purpose RAM • The general purpose RAM area is from address 30H to 7FH. The locations from address 20H to 2FH can also be used as general purpose RAM although these addresses have very specific role.
  • 16. Bit-Addressable RAM • The 8051 contains 210 bit-addressable locations of which 128 are at byte address 20H through 2FH. • This is the powerful feature of most microcontroller because individual bits can be set, cleared, ANDed, ORed etc. with a single instruction instead of having to read a byte and modify
  • 17. • Example – we could issue a simple instruction SETB 67H This would set the bit at address 67H to logic HIGH. Bit 67H is bit 7(most significant bit) of byte location 2CH In order to achieve the same result, a microprocessor would need to do this: MOV A, 2CH ORL A,#10000000B MOV 2CH,A
  • 18. Special Function Registers • Above 7FH, there is another block of memory 80H to 0FFH in all the version of MCS51 uP • this 128 bytes of memory are reserved for Special Function Register (SFR). There are 21 SFRs.
  • 19. SFRs • SFR are usually addressed by name • Memory location 0F0H is given a name called Register B, similarly 80H is called P0. • Not all memory location has a name – memory location 35H has no name • Some locations between the SFRs have no names as well e.g. 91H. Such locations should not be used to store any data. If you do it then your data may be lost.
  • 20. Program Status Word (PSW) • This is a very important register because it contains status bits which indicates the current state of the cpu. • PSW.7 CarrY(CY) • PSW.6 Aux Carry (AC) • PSW.5 Flag 0 (F0) • PSW.4 Register Bank Select 1 • PSW.3 Register Bank Select 0 • PSW.2 Overflow(OV) • PSW.1 reserved • PSW.0 Even Parity Flag (P)
  • 21. Commonly used SFRs • Accumulator, it has two names, A and ACC. Many instruction make use of the accumulator, eg: mov A,R0, push acc • SP, always pointing to the top of the stack, increasing by 1 before write to stack, decreasing by 1 after read from stack
  • 22. _____ • PSEN (Program Store Enable) – This is a dedicated control line on pin 29 and is used to enable external program (code) memory. This pin usually connects to an EPROM’s Output Enable (OE) pin. – This is a logic low pin as represented by the bar above the word PSEN, this means that during a fetch stage involving an instruction stored in external memory, the pin will be pulsed ‘LOW’.
  • 23. • ALE ( Address Latch Enable) – This pin is used to demultiplex the address and data lines. – Remember that port 0 has 2 functions. As the low byte of the address bus and as the data bus. In designs with external memory, port 0 is connected to both the address and data lines of the external RAM thus during the part of the fetch cycle where the address is supplied, the ALE is pulsed to enable the G (gate) control pin of the latch IC thus the data goes to RAM and is interpreted as an address.
  • 24. ___ • EA (External Access) – If you need to connect to external ROM then this pin must be tied LOW (0V). – This pin must be tied high (+5V) if the programs executes from internal ROM.
  • 25. RST (Reset) • This is pin 9 of the IC and is used as the master reset for the 8051. In order for the 8051 to recognize that a reset has occurred, this pin must be brought HIGH for at least two machine cycles. During normal operation, this pin must be at logic LOW.
  • 26. • Power Connections – The 8051 requires a +5V input on its Vcc input (pin 40) and Vss connection is on page 20.
  • 27. Accessing External Code Memory • If the design involves external code memory, both P0 and P2 should not be used as general purpose I/O since P2 is now the Higher address bus while P0 is the multiplexed Lower address bus and the data bus. _____ • As stated earlier, the PSEN pin must be used.
  • 28. FIGURE 2–8 Multiplexing the address bus (low-byte) and data bus
  • 29. FIGURE 2–9 Accessing external code memory
  • 30. An opcode fetch for 2-byte instruction • Fig.2-10 shows what happens during an opcode fetch for a 2 byte instruction that has a time of 1 machine cycle.
  • 31. Accessing External RAM • For designs with external RAM, a typical connection is shown in fig.2-12. Note the control lines that must be used. • MOVX instruction is used to indicate that the external RAM is involved. • e.g. MOVX A, @dptr ( a read operation) • e.g. MOVX @dptr, A (a write operation)
  • 32. • The timing diagram for a read operation is shown in fig 2-11.