Sie sind auf Seite 1von 19

Microprocessor System

Lecture 4 : IO Port Programming

PIN Diagram

Pins XTAL1 and XTAL2

Pin RST

D Flip-Flop
Edge-Trigger Each

pin of port 0, port 1, port 2, and port 3 has a D Flip-Flop.

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 (2)

It can be used for input or output.


Port 0 is configured as an output port upon reset. Port 0.x is configured as an input bit by writing 1 to bit x of port 0. Port 0 is configured as an input port by writing 1 to all bits.

It provides both address and data in 8031based systems.


It provides data D0-D7 when ALE=0. It provides address A0-A7 when ALE=1.

Port 0 (3)
Example:
Back:

MOV A, #55H MOV P0, A ACALL DELAY CPL A SJMP BACK

Port 0 (4)
Example:
Back:

MOV A, #0FFH MOV P0, A MOV A, P0 MOV P1, A SJMP BACK

Port 1
It

can be used for input or output.

Port

1 is configured as an output port upon reset. Port 1.x is configured as an input bit by writing 1 to bit x of port 1. Port 1 is configured as an input port by writing 1 to all the bits.

Port 1 (2)

Example:

MOV A, #0FFH MOV P1, A MOV A, P1 MOV R7, A ACALL DELAY MOV A, P1 MOV R6, A ACALL DELAY

Port 2

It can be used for input or output.


Port 2 is configured as an output port upon reset. Port 2.x is configured as an input bit by writing 1 to bit x of port 2. Port 2 is configured as an input port by writing 1 to all the bits. 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).

It provides address in 8031-based systems.


Port 3

It can be used for input or output.

Port 3 is configured as an output port upon reset.

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. It provides alternate functions.

Port

Pins EA, PSEN, and ALE

EA (external access):

EA is connected to VCC if code is stored in onchip ROM such as 8051 family. EA is connected to Ground if code is stored in external ROM such as 8031.
PSEN is connected to OE of external ROM.

PSEN (program store enable):

ALE (address latch enable):

ALE is used to de-multiplexing the address and data.

Single-Bit Address of Ports

Das könnte Ihnen auch gefallen