SlideShare a Scribd company logo
EMBEDDED SYSTEM
I/O Programming
of
Microcontroller 8051
PRESENTED BY :
SHAWON ISLAM
What is I/O Operation ?
I/O operation defined as a set of collection of end users where
microprocessor or microcontroller read and write data and communicate
each other.
Every microcontroller I/O operation or programming are different. We will
see there 8051 microcontroller I/O programming.
This is actually figure of I/O programming.
There was various I/O commands go to I/O
devices and fetch data from memory either it
Is read operation either write operation.
8051 Microcontroller !
In 8051, I/O operations are done using four ports and 40 pins. The following pin diagram
shows the details of the 40 pins. I/O operation port reserves 32 pins where each port has 8
pins. The other 8 pins are designated as 𝑽𝒄𝒄
There are four port name as 𝑷𝟎, 𝑷𝟏, 𝑷𝟐 and 𝑷𝟑.
Each port has 8-pins so 4 port has 32-pins.
We know microprocessor has two buses.
Address Bus and Data Bus . It can be 8-bit, 16-bit
Or 32-bit. 8051 consisting with 16-bit
Address bus and 8-bit data bus.
𝑷𝟎
𝑷𝟐
𝑷𝟏
𝑷𝟑
Address Bus and Data Bus !
Address bus carries memory addresses from the processor to other
components such as primary storage and input/output devices. Address bus
is unidirectional.
Data bus carries the data between the processor and other components.
The data bus is bidirectional .
There is also control bus. Control bus is
Bi-directional it transmit command signals from
The CPU and response signals from the
Hardware.
I/O Ports !
In 8051 microcontroller the ports are act as data bus. They can send or
receive data between them.
They carry data from one port and transfer to another unit of
microcontroller. The data size must be 8-bit.
Microcontroller can communicate one port to another unit at a time. It can
not communicate parallel to multiple ports at a time, But microcontroller
8051 can communicate 4 units at a time because of it has 4 ports named as
𝑷𝟎, 𝑷𝟏, 𝑷𝟐 and 𝑷𝟑. That’s why this port are say as data bus. Technically they
are not data bus ,they are ports
When we turn on microcontroller 8051 then every ports was configured as
input port. They are ready for take input.
I/O Ports !
Every ports are able to use as input or output port of microcontroller 8051.
But we have to defined as the state by code.
When the first 0 is written to a port. It becomes an output.
When the first 1 is written to a port. It becomes an input.
To use any of these ports as an input or output port it must be
programmed. Because initial state it act as input port.
When all the ports as input port look like (This is initial state after ON):
𝑷𝟎 = 𝟏 𝑷𝟏 = 𝟏 𝑷𝟐 = 𝟏 𝑷𝟑 = 𝟏
When all the ports as output port look like:
𝑷𝟎 = 𝟎 𝑷𝟏 = 𝟎 𝑷𝟐 = 𝟎 𝑷𝟑 = 𝟎
𝑃0 Port of Microcontroller 8051 !
It can be used for input or output port. 𝑷𝟎 has 8-pins.
Each pins must be connected
to a 10K ohm pull-up resistor.
This is due to the fact that 𝑷𝟎 is an
Open drain unlike 𝑷𝟏 ,𝑷𝟐 𝒂𝒏𝒅 𝑷𝟑
Open drain is term used for MOS
chips in the same way that open
collector is used for TTL chips.
𝑃0 Port of Microcontroller 8051 !
Port 𝑷𝟎 also act as a address bus. Sometimes when we wanted to read data
from memory that why the memory address need to know ,by this time port
𝑷𝟎 act as a address bus.
Addresses are 16-bit but 𝑃0 has 8-bit only. How the address will know ?
For this another port also used as a address bus. 𝑷𝟎 and 𝑷𝟐 act as a address
bus those time. AD means there address. It was known as DUAL-Role
𝑷𝟎 port has 𝐴𝐷0 − 𝐴𝐷7
𝑷𝟐 port has 𝐴𝐷8 − 𝐴𝐷15
By combining these two ports it was act as address bus. By using two ports
it can know addresses of memory location and able to read data in memory.
𝑃1 Port of Microcontroller 8051 !
Port 𝑷𝟏 can be used as input or output. In contrast to port 𝑷𝟎 ,this need to
pull-up resistors for connecting with port pins. But port 𝑃1 does not need
any pull-up resistors since it was already has pull-up resistors internally.
𝑷𝟏 has 8-pins.
Upon reset ,port 𝑷𝟏 is configured as an input port. The port 𝑷𝟏 is only used
for exchanging the data between units. It has no more operations. It was only
used for data exchange.
𝑃2 Port of Microcontroller 8051 !
Port 𝑷𝟐 can be used as input and output also. Just like port 𝑷𝟏 ,port 𝑷𝟐
does not need any pull-up resistors since it was already has pull-up resistors
internally. 𝑷𝟐 has 8-pins.
Upon reset, port 𝑷𝟐 is configured as an input port.
By Combining with port 𝑷𝟎 it was act as a address bus.
When the 8051 is connected to an external memory, it provides path for
upper 8-bits of 16-bits address, and it cannot be used as I/O.
𝑃3 Port of Microcontroller 8051 !
Port 𝑷𝟑 can be used as input and output by considering its state.
Port 𝑷𝟑 does not need any pull-up resistors.
Port 𝑷𝟑 is configured as an input port upon reset.
Port 𝑷𝟑 has the additional function of providing some extremely important
signal’s.
Just like 𝑷𝟏 ,port 𝑷𝟑 also exchanging data between units but it has some
additional function’s also.
𝑃3 Port of Microcontroller 8051 !
Without exchanging data ,port
𝑷𝟑 also works with some
additional program’s.
In port 𝑷𝟑 the P3.0 and P3.1
are used for serial communica-
tion’s
P3.0 RxD is used for receiving
data from other units.
P3.1 TxD is used for transmitting
data to other units.
𝑃3 Port of Microcontroller 8051 !
In port 𝑷𝟑 the P3.2 and P3.3
are used for interrupt processes.
Interrupt defined as, when
microcontroller executes any
program and other programs are
interrupt it. Like a Hardware
Failure, Power failure.
To get the interrupts from other
unit microcontroller 8051 used these
two pins.
This two pins are active on low. 𝑰𝑵𝑻𝟎 is used for output
Interrupts on other units and 𝑰𝑵𝑻𝟏 is used for take input
Interrupts from other units.
𝑃3 Port of Microcontroller 8051 !
Microcontroller 8051 has two
timers for maintaining the
processing time.
P3.4 and P3.5 are used count
time of processes. This two are
counters. T0 is for timer 0 and T1
is for timer 1.
𝑃3 Port of Microcontroller 8051 !
P3.6 and P3.7 pins of port
𝑷𝟑 was used for read and write
operations of memory .
If it need to write in memory
then P3.6 𝑾𝑹 signal will be
generated and the particular
location of memory was written.
𝑃3 Port of Microcontroller 8051 !
If it need to read data in
memory then P3.7 𝑹𝑫 signal will
be generated and the particular
location of memory was read.
Both of pins are active on low.
𝑃3 Port of Microcontroller 8051 !
We know microcontroller 8051 has 128-bytes of RAM and 4-Kbytes of
ROM.
It has limited memory. If a greater memory size required for some
program for execute it then microcontroller 8051 must be add an external
memory with it. Like Hard Disk(HD), Solid State Drive (SSD).
How microcontroller 8051 read or write in external memory?
Sol: When it want to write in memory then low signal generates from 𝑾𝑹 , then it will be
active because it will active on low by this time 𝑹𝑫 pin will get the high signal because now it
is write operation that’s why it will standby. Then the memory address generated where the
data will be written. Then the microcontroller write the data using 8-bit data bus on particular
location. The read operation is the reverse of write operation.
Assembly Code For Port 𝑷𝟎
Assembly Code For Port 𝑷𝟏
Port 𝑷𝟏 as input

More Related Content

PPTX
Microcontroller (1).pptx
DOCX
Study of 8051 microcontroller
PPTX
Micro 8051
PPT
Ch3 ppt
PPT
Micro controller
PPTX
MICROCONTROLLER 8051- Architecture and registers
DOC
4th yr dmumicrocontroller1
PPTX
8051 microcontroller
Microcontroller (1).pptx
Study of 8051 microcontroller
Micro 8051
Ch3 ppt
Micro controller
MICROCONTROLLER 8051- Architecture and registers
4th yr dmumicrocontroller1
8051 microcontroller

Similar to Embedded System Microcontroller 8051 (20)

PPT
Microcontroller 8051
PPTX
8051 microcontroller
PPTX
Hardware View of Intel 8051
PDF
Microprocessor and Microcontroller Notes
PPTX
8051 Microcontroller -1.pptx
PPTX
8051 Microcontroller_module_4.1.pptx
PPTX
8051 Microcontroller By Er. Swapnil Kaware
PPTX
8051 Microcontroller PPT's By Er. Swapnil Kaware
PPTX
Advanced Microprocessor 6.pptx
PPTX
Microcontroller 8051 features and applications
DOC
8051 dev board guide
PDF
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
PPTX
Unit 4.pptx
DOCX
PDF
8051 Architecture and PIN Configuration.pdf
PPTX
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
PPT
janakiraman I msc 4 unit
PPT
janakiraman egsp collage I msc 4 unit
PPT
Microcontroller 8051
8051 microcontroller
Hardware View of Intel 8051
Microprocessor and Microcontroller Notes
8051 Microcontroller -1.pptx
8051 Microcontroller_module_4.1.pptx
8051 Microcontroller By Er. Swapnil Kaware
8051 Microcontroller PPT's By Er. Swapnil Kaware
Advanced Microprocessor 6.pptx
Microcontroller 8051 features and applications
8051 dev board guide
EMBEDDED SYSTEMS AND IOT lab manual for enginnering students
Unit 4.pptx
8051 Architecture and PIN Configuration.pdf
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT III The 8051 Microcontrollers
janakiraman I msc 4 unit
janakiraman egsp collage I msc 4 unit
Ad

Recently uploaded (20)

PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PPTX
Artificial Intelligence
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PDF
PPT on Performance Review to get promotions
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPTX
UNIT 4 Total Quality Management .pptx
PDF
III.4.1.2_The_Space_Environment.p pdffdf
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPTX
Fundamentals of Mechanical Engineering.pptx
PPT
introduction to datamining and warehousing
PDF
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
PDF
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Artificial Intelligence
Exploratory_Data_Analysis_Fundamentals.pdf
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Automation-in-Manufacturing-Chapter-Introduction.pdf
Fundamentals of safety and accident prevention -final (1).pptx
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPT on Performance Review to get promotions
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
UNIT 4 Total Quality Management .pptx
III.4.1.2_The_Space_Environment.p pdffdf
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Fundamentals of Mechanical Engineering.pptx
introduction to datamining and warehousing
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
BIO-INSPIRED ARCHITECTURE FOR PARSIMONIOUS CONVERSATIONAL INTELLIGENCE : THE ...
Visual Aids for Exploratory Data Analysis.pdf
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Ad

Embedded System Microcontroller 8051

  • 1. EMBEDDED SYSTEM I/O Programming of Microcontroller 8051 PRESENTED BY : SHAWON ISLAM
  • 2. What is I/O Operation ? I/O operation defined as a set of collection of end users where microprocessor or microcontroller read and write data and communicate each other. Every microcontroller I/O operation or programming are different. We will see there 8051 microcontroller I/O programming. This is actually figure of I/O programming. There was various I/O commands go to I/O devices and fetch data from memory either it Is read operation either write operation.
  • 3. 8051 Microcontroller ! In 8051, I/O operations are done using four ports and 40 pins. The following pin diagram shows the details of the 40 pins. I/O operation port reserves 32 pins where each port has 8 pins. The other 8 pins are designated as 𝑽𝒄𝒄 There are four port name as 𝑷𝟎, 𝑷𝟏, 𝑷𝟐 and 𝑷𝟑. Each port has 8-pins so 4 port has 32-pins. We know microprocessor has two buses. Address Bus and Data Bus . It can be 8-bit, 16-bit Or 32-bit. 8051 consisting with 16-bit Address bus and 8-bit data bus. 𝑷𝟎 𝑷𝟐 𝑷𝟏 𝑷𝟑
  • 4. Address Bus and Data Bus ! Address bus carries memory addresses from the processor to other components such as primary storage and input/output devices. Address bus is unidirectional. Data bus carries the data between the processor and other components. The data bus is bidirectional . There is also control bus. Control bus is Bi-directional it transmit command signals from The CPU and response signals from the Hardware.
  • 5. I/O Ports ! In 8051 microcontroller the ports are act as data bus. They can send or receive data between them. They carry data from one port and transfer to another unit of microcontroller. The data size must be 8-bit. Microcontroller can communicate one port to another unit at a time. It can not communicate parallel to multiple ports at a time, But microcontroller 8051 can communicate 4 units at a time because of it has 4 ports named as 𝑷𝟎, 𝑷𝟏, 𝑷𝟐 and 𝑷𝟑. That’s why this port are say as data bus. Technically they are not data bus ,they are ports When we turn on microcontroller 8051 then every ports was configured as input port. They are ready for take input.
  • 6. I/O Ports ! Every ports are able to use as input or output port of microcontroller 8051. But we have to defined as the state by code. When the first 0 is written to a port. It becomes an output. When the first 1 is written to a port. It becomes an input. To use any of these ports as an input or output port it must be programmed. Because initial state it act as input port. When all the ports as input port look like (This is initial state after ON): 𝑷𝟎 = 𝟏 𝑷𝟏 = 𝟏 𝑷𝟐 = 𝟏 𝑷𝟑 = 𝟏 When all the ports as output port look like: 𝑷𝟎 = 𝟎 𝑷𝟏 = 𝟎 𝑷𝟐 = 𝟎 𝑷𝟑 = 𝟎
  • 7. 𝑃0 Port of Microcontroller 8051 ! It can be used for input or output port. 𝑷𝟎 has 8-pins. Each pins must be connected to a 10K ohm pull-up resistor. This is due to the fact that 𝑷𝟎 is an Open drain unlike 𝑷𝟏 ,𝑷𝟐 𝒂𝒏𝒅 𝑷𝟑 Open drain is term used for MOS chips in the same way that open collector is used for TTL chips.
  • 8. 𝑃0 Port of Microcontroller 8051 ! Port 𝑷𝟎 also act as a address bus. Sometimes when we wanted to read data from memory that why the memory address need to know ,by this time port 𝑷𝟎 act as a address bus. Addresses are 16-bit but 𝑃0 has 8-bit only. How the address will know ? For this another port also used as a address bus. 𝑷𝟎 and 𝑷𝟐 act as a address bus those time. AD means there address. It was known as DUAL-Role 𝑷𝟎 port has 𝐴𝐷0 − 𝐴𝐷7 𝑷𝟐 port has 𝐴𝐷8 − 𝐴𝐷15 By combining these two ports it was act as address bus. By using two ports it can know addresses of memory location and able to read data in memory.
  • 9. 𝑃1 Port of Microcontroller 8051 ! Port 𝑷𝟏 can be used as input or output. In contrast to port 𝑷𝟎 ,this need to pull-up resistors for connecting with port pins. But port 𝑃1 does not need any pull-up resistors since it was already has pull-up resistors internally. 𝑷𝟏 has 8-pins. Upon reset ,port 𝑷𝟏 is configured as an input port. The port 𝑷𝟏 is only used for exchanging the data between units. It has no more operations. It was only used for data exchange.
  • 10. 𝑃2 Port of Microcontroller 8051 ! Port 𝑷𝟐 can be used as input and output also. Just like port 𝑷𝟏 ,port 𝑷𝟐 does not need any pull-up resistors since it was already has pull-up resistors internally. 𝑷𝟐 has 8-pins. Upon reset, port 𝑷𝟐 is configured as an input port. By Combining with port 𝑷𝟎 it was act as a address bus. When the 8051 is connected to an external memory, it provides path for upper 8-bits of 16-bits address, and it cannot be used as I/O.
  • 11. 𝑃3 Port of Microcontroller 8051 ! Port 𝑷𝟑 can be used as input and output by considering its state. Port 𝑷𝟑 does not need any pull-up resistors. Port 𝑷𝟑 is configured as an input port upon reset. Port 𝑷𝟑 has the additional function of providing some extremely important signal’s. Just like 𝑷𝟏 ,port 𝑷𝟑 also exchanging data between units but it has some additional function’s also.
  • 12. 𝑃3 Port of Microcontroller 8051 ! Without exchanging data ,port 𝑷𝟑 also works with some additional program’s. In port 𝑷𝟑 the P3.0 and P3.1 are used for serial communica- tion’s P3.0 RxD is used for receiving data from other units. P3.1 TxD is used for transmitting data to other units.
  • 13. 𝑃3 Port of Microcontroller 8051 ! In port 𝑷𝟑 the P3.2 and P3.3 are used for interrupt processes. Interrupt defined as, when microcontroller executes any program and other programs are interrupt it. Like a Hardware Failure, Power failure. To get the interrupts from other unit microcontroller 8051 used these two pins. This two pins are active on low. 𝑰𝑵𝑻𝟎 is used for output Interrupts on other units and 𝑰𝑵𝑻𝟏 is used for take input Interrupts from other units.
  • 14. 𝑃3 Port of Microcontroller 8051 ! Microcontroller 8051 has two timers for maintaining the processing time. P3.4 and P3.5 are used count time of processes. This two are counters. T0 is for timer 0 and T1 is for timer 1.
  • 15. 𝑃3 Port of Microcontroller 8051 ! P3.6 and P3.7 pins of port 𝑷𝟑 was used for read and write operations of memory . If it need to write in memory then P3.6 𝑾𝑹 signal will be generated and the particular location of memory was written.
  • 16. 𝑃3 Port of Microcontroller 8051 ! If it need to read data in memory then P3.7 𝑹𝑫 signal will be generated and the particular location of memory was read. Both of pins are active on low.
  • 17. 𝑃3 Port of Microcontroller 8051 ! We know microcontroller 8051 has 128-bytes of RAM and 4-Kbytes of ROM. It has limited memory. If a greater memory size required for some program for execute it then microcontroller 8051 must be add an external memory with it. Like Hard Disk(HD), Solid State Drive (SSD). How microcontroller 8051 read or write in external memory? Sol: When it want to write in memory then low signal generates from 𝑾𝑹 , then it will be active because it will active on low by this time 𝑹𝑫 pin will get the high signal because now it is write operation that’s why it will standby. Then the memory address generated where the data will be written. Then the microcontroller write the data using 8-bit data bus on particular location. The read operation is the reverse of write operation.
  • 18. Assembly Code For Port 𝑷𝟎
  • 19. Assembly Code For Port 𝑷𝟏 Port 𝑷𝟏 as input