You are on page 1of 19

Microprocessor System

Lecture 4 : IO Port Programming

PIN Diagram .

Pins XTAL1 and XTAL2 .

Pin RST .

and port 3 has a D Flip-Flop. port 2.D Flip-Flop  Edge-Trigger  Each pin of port 0. . port 1.

Push-Pull Output .

Open Source .

Open Drain .

Port 0  Open Drain .

.Port 0 (1)  Each pin of port 0 must be connected externally to a 10K ohm pull-up register.

Port 0 is configured as an input port by writing 1 to all bits. Port 0.x is configured as an input bit by writing 1 to bit x of port 0. .   It provides data D0-D7 when ALE=0.   Port 0 is configured as an output port upon reset.  It provides both address and data in 8031based systems. It provides address A0-A7 when ALE=1.Port 0 (2)  It can be used for input or output.

Port 0 (3)  Example:   Back:    MOV A. A ACALL DELAY CPL A SJMP BACK . #55H MOV P0.

A MOV A.Port 0 (4)  Example:    Back:   MOV A. #0FFH MOV P0. A SJMP BACK . P0 MOV P1.

Port 1 is configured as an input port by writing 1 to all the bits.  Port 1 is configured as an output port upon reset.Port 1  It can be used for input or output.x is configured as an input bit by writing 1 to bit x of port 1. .  Port 1.

Port 1 (2)  Example:         MOV A. #0FFH MOV P1. A ACALL DELAY . A MOV A. P1 MOV R6. A ACALL DELAY MOV A. P1 MOV R7.

  .  It provides address in 8031-based systems. Port 2 is configured as an input port by writing 1 to all the bits.Port 2  It can be used for input or output. Port 2 provides bits A8-A15 of the address. Port 2 is used along with port 0 provide the 16-bit address for the external memory (64K).   Port 2 is configured as an output port upon reset.x is configured as an input bit by writing 1 to bit x of port 2. Port 2.

 Port 3 is configured as an output port upon reset.  Port .Port 3  It can be used for input or output.  It provides alternate functions. 3.x is configured as an input bit by writing 1 to bit x of port 3. Port 3 is configured as an input port by writing 1 to all the bits.

PSEN. and ALE  EA (external access):   EA is connected to VCC if code is stored in onchip ROM such as 8051 family.   PSEN (program store enable):  ALE (address latch enable):  ALE is used to de-multiplexing the address and data.Pins EA. EA is connected to Ground if code is stored in external ROM such as 8031. . PSEN is connected to OE of external ROM.

Single-Bit Address of Ports .