Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
97 views
8 pages
IO Ports in 8051
Input and output ports of 8051 microcontroller
Uploaded by
Syed Ashmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF or read online on Scribd
Download
Save
Save IO Ports in 8051 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
97 views
8 pages
IO Ports in 8051
Input and output ports of 8051 microcontroller
Uploaded by
Syed Ashmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as DOCX, PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save IO Ports in 8051 For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save IO Ports in 8051 For Later
You are on page 1
/ 8
Search
Fullscreen
2.2 II] ARCHITECTURE OF 8051 Figure 22 shows a functional block of the intemal operations of an 8051 microcontroller, The 8051 includes an 8 bit CPU, memory, four 8 bit /O ports, two timers/counters and @ Universal Asynchronous Receiver Transmitter (UART). 2.2.1 PROCESSOR ‘The processor includes arithmetic and logic unit, instruction decoder and timing generation unit, Accumulator A or Ace), B register and status regis Arithmetic and Logie Unit The Arithmetic and Logic Unit (ALU) performs the computing functions. The accumulator is an 8 bit register. In arithmetic and logical operations, one of the operands is in ‘A’ register. After the arithmetic/logical operations, are performed, the result is stored in ‘A’ register and this affects various flags namely Carry (C), Auxiliary Carry (AC), Overflow (O), and Parity (P) of status register. Instruction Decoder and Control The instruction decoder and control ate parts of the timing and control unit, When an instruction is fetched from program memory, itis loaded in the instruction register. “The decoder decodes the instruction and establishes the sequence of events to follow. The instruction register iy not programmable and cannot be accessed through any instruction, The timing generation and ‘control unit synchronises all the microcontroller operations with the clock and generates control signals necessary for communication between the processor and peripherals. CPU Registers ‘A’ Register (EOH) Similar toany Intel microprocessor, the $051 hasan 8 bit A and in the instruction, itis referred as “A’. The accumulator is used in al arithmetic and logical operations and hes direct connection to ALU. One of the operands is stored in the accumulator. After the operation is performed, the result is stored in the A. In multiplication operation, one of the 8 bit operands is stored in “A’ register. After the operation, it stores the lower byte of the result in “A' register. In division operation, it holds an 8 bit dividend and after the operation, the quotient is stored in the accumulator. I is also used in indexed addressing mode to access information from program memory. ‘A’ is bit addressable register. ‘B’ Register (FOH) The 8 bit “B" register is used during multiply and divide operations. In multiplication ‘operation, one of the 8 bit operands is stored in “B’ register. After the operation, it stores the higher byte of the result in °B* register. In division operation, it holds 8 bit divisor and after the operation the remainder is stored in “B" register. For other instructions, it can be used as an & bit general purpose register. “B” is bit addressable register. Program Status Word (DOH) The & bit Program Siatus Word (PSW) register contains the arithmetic status of the ALU and the bank selects bits for the data memory. After the arithmetic and logic operations, the C, AC, P, and O flags of PSW register are set or reset according to the result. In subtraction, the C and AC bits operate as borrow and digit borrow flag respectively. PSW is bit addressable register cy | ac] ro [ esi] eso [ ow] — [? Bit7 BitOStack Pointer (81H) Stack Pointer is an 8 bit register It contains the address of the data item on the top of the steck. It is incremented before the data is stored. While the siack may reside anywhere in on-chip RAM, the Stack Pointer is initialised to 07H after a reset. The operation and instruction associated with the stack will be discussed in detail in Chapter 3. Data Pointer (DPH-83 H and DPL-82 H) ‘The Data Pointer (DPTR) consists of two 8 bit registers—a high byte (DPH) anda low byte (DPL). Its intended function is to hold a 16 bit address. It is used to fumish address information for internal and external program memory and for extemal data memory. Program Counter Program Counter (PC) is a 16 bit register. The 16 bit program counter specifies the address of the next instruction to be executed. Afier reset, the PC will be set to 0000H and the CPU will siart executing the first instruction stored at program memory location O0OOH, The 8051 fetches the instruction one byte ata time and afer fetching, it increments the PC by 1. One of the important fettars of a microcontroller isthe number of pins which ean be uscd for connection with the extemal world, These pin are refered as Inpu(uiput (VO) pinsand a group of sueh pins are refered as an 0 port. The VO ports ate used to transfer dat in and out of a mierocontoler. I the 805, each VO pin has built-in MO cirewits which allows a pin to diteetly interface with the external circuits. This feature is usually not evailale in the microprocessors, therefore, we noed additional chips with the microprocessors to interface it with the external word 13.1 | THE 8051 PORTS ‘The BUSI port structute is extremely versatile and flexible. The devies has 32 1/0 pins configured as four bit parallel ports named PQ, P1,P2 and P3. Each pin can be used as an inputor as an output under the sofiware contol. Tse LO pins can be accessed directly by instructions during the program exceution. The HO ports are memory mapped in the 8051. ic, they are treated as memory’ Toeations. vt of the 32 170 pins, 24 pins (PO, P2 and P3) may each be used for two diferent Fanctions (bu only one ata im), providing «total 66 pins (40 normal pins + 24 alternate Functions of ports + 2 for programming). “The fanetion performed by a pin at any time depends on whic connected o that pin: therefore these actors ean be iruction is used 10 access a pin and what signal is ceil controlled by a progtammer. The altenate Functions of pons ate given below. Table 13 Fort Jornal fonction Ps Ln ones ts (AD7- ADO nd Fs lighontr aes bs AIS AS Fi taht ns svola able 123, FADGAID | XD Steps Reset Even witin al po, VO cpr yt combine in ERR rin re Da sitecent ways. Dilfeent pins ean be configured as an input or P3200ia 12) | TRO (xtra inert cnt non fon ast pn canbe st SSS) aa nr SliseBle Al pnsof tc S31 phi ee nS inkctondautatrwcestctsDinhotwr3us fgg yaa bn ‘The SFR for each port is made of these eight Latches, which 2208 OY ie isi sans ve [TH CTimefCounts 1 external inp) js shown Table 13.2.Tobe 122 Fort Ss and ther addressee SL S00 Port ri om sont Poot 2 ‘NTL Ponts Ps B-Bon 12.1.1 Porta Port Tis. rue HO port bees thas no alternate function al therefore ithas the simplest structure, The basic opcratio of Por 1 is discussed first to develop the understanding of sore basic concepts like configuring the por as an put or ‘output, reading port pin and writing a prt pin, The base discussion of Pot is equally applicable all ther ports unless specified explicily. The simplified structure of Port | is given in igure 13.1 AAs mentioned eatie, each port pin as aIstch (D latch), inpur baffers (BL and 12) and output driver (TH). The daa from the intemal data us is writen into the D hatch whea the “tte w ate’ signal fs acivated asa resulcof appropriate instruction execution. The Q output ofthe latch scoped into the internal data bus when the “eal latch signal i activated and the level of a port pin is copied into the internal data bus when the ‘read pin signal is activated, The instructions whieh aetvate these signals ae discussed in the later section ofthis chapter. srou/output Ports nt Veo Interna Pul-Up Resistor Read Latch . of Pix \ Pia Iniernal Date Bus. t——p Pix JN > LATCH Wrte to Lateh Read Pin B21. Configuring the Portasen Input The por pin wll be configured san input when we wie “110 dhe caesponing bit (ath) ali The emon for this explaied below, Conse {) senor Fire 132. seas taten Whoa “1° is writen to port bi itis writen to Mt je |] the D fateh: therefore, 1 will appear at output ermal outa y | yy of the latch, ic. Q = 1 and Q Now O=0 Bus: i connected (0 gate ofthe tansior (FET) TI, stich wil um oT TI wll Beave a» an open Circuit nd sconnect he pa pin snd sou thereon. the input inal comested to the pin wil goo te buffer 2, When we rea the put Read Pr port ssing an imrucion tke MOY A, Pl. the Boffer 2 whe ena (by “ead pga ad we ae cally veadins a pr pin. Figure 132 shows the path fr ssn Mow, The sina evel on dhe pin wl be essed he atral da gh he her 2 Yee ire tate Fe.132. Reading port pin red! as an inpat afer eset because the S0S1 writes 1S 0 all pot latches afer ress. 13 0 is All the port pins are eon written by a program to the port late, it ean be reconfigured as an input by writing a °T* to it Remember that c shown in Figute 13.1 and 18. ave only for one pin. There will he 8 seh cirewts, one For each pin ofthe port Note: Ports 29, P2 and P3 have additional cieuitry hecause they have dual functions furthermore, tho pull-up resistor is internal for ports PI, P2 and P3. We have to connect the external pull-up resistor For PO. 2. Configuring the Portas an Output ‘Nothing ext has (o be done o configure a por as an output—whatever level (1 or 0) is written (oa port late, the same level will directly appear on the port pin. Logic I’ (high) can be written to the port pin by simply writing “I” tothe port latch, As showa in Figure. 13.3,when “1° is writen to the D latch, it will make Q = | and Q=0, which will tum off TL and, therefore, I” will appear on the pin and the pin will source the cartent; similarly, logic “O" can be written by writing ‘0"to port latch. When "Dis writen, Q = 0 and Q = 1 wich will ru on TI and the pin will be connected t the ground (© volt as show in Figure 134 and i will sink the current, During the execution ofan instruction that modifies the valve ina por latch, the new value is available 10 the latch during S6P2 of the last machine cycle of the insuuction,[Newer write 0) tothe por that was configu Alireetly 10 Vee (logic high inped. Writing ‘0° will um on TT and it grounds the input pin, This will shor Yoo ‘Whatever Writen to Latch Bit ‘Appear at Port Pin } pinternal Pullup Read Laich—— aR Pin Internal Data Bus write to Latch mene Fig. 29.3. Whiting 3 tothe port pin Whatever Wiritlon to Latch Bit ‘Appeer at Port Pin Internal Pul-up Resistor Road Latch: ‘Write to Latoh Read Pin Fig. 13.4 Writing Oto the por pin das am input port hecause may da age the port when the pi is connected ¢ high-level signal (Vcc ) Connected 10a pin, and a high current will low hough TH and may damage it, To avoid such problems, ‘ere a to be taken while the connee hetwoen the input signal and the port pin as shown in F 12 input signal toa port pin, One simple way is to use a curent-limiting resisor Fg. 19S. Portprotecton axing current iting resistor13.1.2 Porto Port O can be used as an inpuvoutput or os a esa onal data bus and low-order address mory. The sirctare of PO is at ‘shown in Figure 13.6. a When PO is sed as an oui weg “01 peat ach pin takes wil make Q= Oand Qe 1. The PIN he will connected to the get TI hough ga imalipleace When he pom is wpe sane yg as] i ‘output internal signal “Control” will be O and ues a ‘contacts tote out 2-0-1 muliplsn. 4 will wen on TH, thus grounding the port pin and logic willbe available the port Read Pn pin. The operation is summarized in Figure 1B. ead Lae. internal Data ue Wie to Latch Fig. 3.7 Writing 010 Port Opin While writing “1° to the fatehes, Q-= | and J = 0 this will tar off the TH, which Moats pin to high impedance state ‘Therefore, an extemal pup resistor is needed © proxige logic “I*, Note that T2 remains off when the pin is used as InpuvOutpur Port Oas an Address/Data Bus When PO is used as an address bus (function of the port is decided by instructions used to secess the port), the inte ‘control signal connects the address line (indicated as ADDR/DATA in Figure 13.6) to the gate of 71 (lower PET) using the multiplexer. The logic “I'on the address bit will ten on the T2 (upper FEET) sinee ‘contol is also “T'whon PO is used ‘san address bus and atthe same time, TI is tacned off, which in tuin provides logic *I" on the port pin as shown in Figure 13.8 ‘When aildress bit is ‘0°. 1 is turned on and T2 is umed off providing logic 0" at port pin. Once an address is issued and latched into external latch using ALE. the bus behaves as a data bus. Now if data isto be written tothe external memoryead Leteh Br Iomat Data Bus +p] ets yo eae — teh BO, 0 Lt ei 182 Read Pin Fig. 138 Port Os address (tte to por operation, he data willbe written to pins exactly in a way asthe address is written tothe pins as deseribed just above, Ifthe data isto be read irom the extsral memory; the contro Jogi will automatically write I's to laehes to ‘configure ports an inp control = 0 and, so both Tt and 12 will be off, “control” =O will connoet Q of the tteh to the gie of TH through the multiplexer) and the da athe port pin will he transferred the intemal data us through the buffer B2, Discussion Question Why do Por pins need external pull presisons? Answer PortOneedsa pull-up resistor because this port provides an open colleetoroutpat. With an open collector output, logic | cannot ne supplied to the in, when we write | o kate bit, the corresponding pin wil Hot (high impedance state) “Therefore, w provile logic 1 atthe por pin, we need to connect the external pull-up resistor 13.1.3 Port2 Port? can he used as Input/Output port exactly similar to Port 1."The other use of Port? provide high-order address byte w aveess extemal memory. The strcture of Port 2 is shown in Figure 139. ecriData Cento! a teal Dats ‘LN Bus +I) 7 Witte Leteh —/.— Rid itux a 2 Read Pin Fig. 39 Port 2steacture‘When itis supplying high-onder address signals (5-9), the internal control signals conncet ares Hine (indicated a¢ ADDR in Figure 13.9) to the gate of TT through the inverter. A 0" on de address bit will turn on TL and provide “O'on the port pin, Similarly, °I' on dhe adress bit will peovide “Ion the por pia, Port 2 latches are kept stable forthe duration ‘of the entire external memory teacivrite eyele 13.14 Pores Port 3 can also be used as InpaOutput por similar to Port | ad the sltemate funetions are controlled by various SFRS. Port 3 strucwre is shown in Figure 13.10 ‘The altemate functions can only be used ifthe bit Lach inthe corresponding port SFR contains 21, otherwise the port nis fined al “O". As shown in Figure 13.10, ifthe P3 bit lach contains 1 then output is controlled by the signal labled ‘aliemate output function’. The actual P3.X pin lovel is always available wo the pins alternate input function Diseussion Question What are the alternate functions of Port, |, 2 and Answer Port 0 also functions as the lower order 8 bits ofthe multiplexed addressdata bus fr external memory access. “There is no altemate function for Port 1, for Port 2 also aes as higher-order 8 bits ofthe address bus for extemal memory acess Port 3 pins have individual altemate fonctions. The pins on this port funetion as extemal imterrupeinpats, serial <éta input and output, timer/eounter inputs and control signals fr external memory access (Refer Table 13.1), Yoo ‘ternate Output | Invern Puta uneven Resistor oad Latch Aernate Input Funetion
You might also like
8051 PPT
PDF
No ratings yet
8051 PPT
51 pages
Unit Ippt 1
PDF
No ratings yet
Unit Ippt 1
73 pages
UNIT 3 Microcontrollers
PDF
No ratings yet
UNIT 3 Microcontrollers
46 pages
MPMC U4 Ece
PDF
No ratings yet
MPMC U4 Ece
38 pages
8051 Manual Draft2
PDF
No ratings yet
8051 Manual Draft2
43 pages
Et 3491
PDF
No ratings yet
Et 3491
22 pages
8051 Pin Configaration and Architecture
PDF
No ratings yet
8051 Pin Configaration and Architecture
59 pages
Module 4
PDF
No ratings yet
Module 4
22 pages
8051 Architecture
PDF
No ratings yet
8051 Architecture
9 pages
8051 Microcontroller Objectives: Understand The 8051 Architecture Use SFR in C Use I/O Ports in C
PDF
No ratings yet
8051 Microcontroller Objectives: Understand The 8051 Architecture Use SFR in C Use I/O Ports in C
59 pages
Microcontroller 1 J2 and 3 Module Notes
PDF
No ratings yet
Microcontroller 1 J2 and 3 Module Notes
38 pages
MPMC - UNIT - 2 - All Slides
PDF
No ratings yet
MPMC - UNIT - 2 - All Slides
117 pages
EC 6504 UNIT-IV Updated Notes
PDF
No ratings yet
EC 6504 UNIT-IV Updated Notes
84 pages
Chapter 4
PDF
No ratings yet
Chapter 4
25 pages
Topic 4 - 1 Ports
PDF
No ratings yet
Topic 4 - 1 Ports
20 pages
Micro Control 4th Sem Notes
PDF
No ratings yet
Micro Control 4th Sem Notes
21 pages
Microcontroller
PDF
No ratings yet
Microcontroller
40 pages
Ee312 Lab Manual 1634191279
PDF
No ratings yet
Ee312 Lab Manual 1634191279
99 pages
8051 Microcontroller-Day2
PDF
No ratings yet
8051 Microcontroller-Day2
66 pages
Microprocessor and Micro Controller
PDF
No ratings yet
Microprocessor and Micro Controller
118 pages
Friday, April 20, 2012
PDF
100% (1)
Friday, April 20, 2012
39 pages
IO Port Configuration 8051
PDF
No ratings yet
IO Port Configuration 8051
11 pages
8051 Microcontroller
PDF
No ratings yet
8051 Microcontroller
45 pages
0 - MPunit-6 & 7
PDF
No ratings yet
0 - MPunit-6 & 7
118 pages
8051 Microcontroller Objectives: Understand The 8051 Architecture Use SFR in C Use I/O Ports in C
PDF
No ratings yet
8051 Microcontroller Objectives: Understand The 8051 Architecture Use SFR in C Use I/O Ports in C
60 pages
8051 Microcontroller
PDF
No ratings yet
8051 Microcontroller
27 pages
Unit IV
PDF
No ratings yet
Unit IV
26 pages
Lesson 12: Introduction To 8051 Microcontroller Internal Architecture
PDF
No ratings yet
Lesson 12: Introduction To 8051 Microcontroller Internal Architecture
4 pages
Microcontrollers Notes
PDF
No ratings yet
Microcontrollers Notes
13 pages
FMM Unit-4 (8051 Microcontroller)
PDF
No ratings yet
FMM Unit-4 (8051 Microcontroller)
18 pages
8051 Architecture
PDF
No ratings yet
8051 Architecture
55 pages
8051
PDF
No ratings yet
8051
59 pages
Chapter 7M PDF
PDF
No ratings yet
Chapter 7M PDF
115 pages
Micro Controller
PDF
No ratings yet
Micro Controller
60 pages
Chapter Three
PDF
No ratings yet
Chapter Three
20 pages
The 8051 Microcontroller
PDF
No ratings yet
The 8051 Microcontroller
72 pages
CH 3
PDF
No ratings yet
CH 3
58 pages
Unit 1 E&IoT Notes
PDF
86% (7)
Unit 1 E&IoT Notes
13 pages
8051architecturesb 121025020524 Phpapp01
PDF
No ratings yet
8051architecturesb 121025020524 Phpapp01
50 pages
Microcontrollers: Created By: Sachin Bhalavat (Elect. & Comm. Engg.)
PDF
100% (1)
Microcontrollers: Created By: Sachin Bhalavat (Elect. & Comm. Engg.)
52 pages
Pin Diagram Ports
PDF
No ratings yet
Pin Diagram Ports
22 pages
III - I R09 Regular Dec 2013
PDF
No ratings yet
III - I R09 Regular Dec 2013
162 pages
III - I R09 Regular Dec 2013
PDF
No ratings yet
III - I R09 Regular Dec 2013
162 pages
X Ray
PDF
No ratings yet
X Ray
18 pages
Unit 1
PDF
No ratings yet
Unit 1
47 pages
Intel 8051mc Architecture & Intel 8085 Microprocessor Family.
PDF
No ratings yet
Intel 8051mc Architecture & Intel 8085 Microprocessor Family.
13 pages
16ECE315-Digital Design Through Verilog HDL
PDF
No ratings yet
16ECE315-Digital Design Through Verilog HDL
1 page
ERTOS Course Outcomes
PDF
No ratings yet
ERTOS Course Outcomes
2 pages
Digital Design Through Verilog HDL Course Outcomes For Lab
PDF
No ratings yet
Digital Design Through Verilog HDL Course Outcomes For Lab
1 page
III-I R09 DEC 2014 RESULT (12 Batch)
PDF
No ratings yet
III-I R09 DEC 2014 RESULT (12 Batch)
551 pages
Microcontroller 8051
PDF
No ratings yet
Microcontroller 8051
42 pages
Iii-I R09 Dec 2014 Result PDF
PDF
No ratings yet
Iii-I R09 Dec 2014 Result PDF
184 pages
Operators 140917230056 Phpapp01
PDF
No ratings yet
Operators 140917230056 Phpapp01
20 pages
CH 01
PDF
No ratings yet
CH 01
37 pages
Verilog HDL Basics
PDF
No ratings yet
Verilog HDL Basics
73 pages
Digital Design and Synthesis: Behavioral Verilog
PDF
No ratings yet
Digital Design and Synthesis: Behavioral Verilog
41 pages
01 MI Introduction
PDF
No ratings yet
01 MI Introduction
72 pages
DIP and Soft Computing Syllabus
PDF
No ratings yet
DIP and Soft Computing Syllabus
5 pages
Development of Timing and State Diagrams Refined The Block Diagram Cleaned Up and Added Better Names, Added Detail
PDF
No ratings yet
Development of Timing and State Diagrams Refined The Block Diagram Cleaned Up and Added Better Names, Added Detail
21 pages
Texture Analysis and Fracture Identificat
PDF
No ratings yet
Texture Analysis and Fracture Identificat
5 pages
Verilog Code For Basic Logic Gates
PDF
No ratings yet
Verilog Code For Basic Logic Gates
4 pages
The Look Up Table (LUT)
PDF
No ratings yet
The Look Up Table (LUT)
5 pages
WWW - Manaresults.co - In: Applications (Common To ECE, ETM)
PDF
No ratings yet
WWW - Manaresults.co - In: Applications (Common To ECE, ETM)
2 pages