Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
8XC196Kx,8XC196Jx,87C196CA microcontroller family user's manual.1995.pdf
Скачиваний:
68
Добавлен:
23.08.2013
Размер:
3.97 Mб
Скачать

CHAPTER 6

I/O PORTS

I/O ports provide a mechanism to transfer information between the device and the surrounding system circuitry. They can read system status, monitor system operation, output device status, configure system options, generate control signals, provide serial communication, and so on. Their usefulness in an application is limited only by the number of I/O pins available and the imagination of the engineer.

6.1I/O PORTS OVERVIEW

Standard I/O port registers are located in the SFR address space and they can be windowed. Mem- ory-mapped I/O port registers are located in memory-mapped address space. They are indirectly addressable only, and they cannot be windowed. All ports can provide low-speed input/output pins or serve alternate functions. Table 6-1 provides an overview of the device I/O ports. The remainder of this chapter describes the ports in more detail and explains how to configure the pins. The chapters that cover the associated peripherals discuss using the pins for their special functions.

 

 

 

Table 6-1.

Device I/O Ports

Port

 

Bits

Type

 

Direction

Associated Peripheral(s)

 

 

 

 

 

 

 

Port 0

8

(Kx)

Standard

 

Input-only

A/D converter

6

(CA, Jx)

 

 

 

 

 

 

 

 

 

 

 

 

 

Port 1

8

(Kx)

Standard

 

Bidirectional

EPA and timers

4

(CA, Jx)

 

 

 

 

 

 

 

 

 

 

 

 

 

Port 2

8

(Kx)

Standard

 

Bidirectional

SIO, interrupts, bus control, clock gen.

6

(CA, Jx)

 

 

 

 

 

 

 

 

 

 

 

 

 

Port 3

8

 

Memory-mapped

 

Bidirectional

Address/data bus

 

 

 

 

 

 

 

Port 4

8

 

Memory-mapped

 

Bidirectional

Address/data bus

 

 

 

 

 

 

 

Port 5

8

 

Memory-mapped

 

Bidirectional

Bus control, slave port

 

 

 

 

 

 

 

Port 6

8

 

Standard

 

Bidirectional

EPA, SSIO

 

 

 

 

 

 

 

6.2INPUT-ONLY PORT 0

Port 0 is an eight-bit, high-impedance, input-only port. Its pins can be read as digital inputs; they are also inputs to the A/D converter. Port 0 differs from the other ports in that its pins can be used only as inputs to the digital or analog circuitry.

6-1

8XC196Kx, Jx, CA USER’S MANUAL

Because port 0 is permanently configured as an input-only port, it has no configuration registers. Its single register, P0_PIN, can be read to determine the current state of the pin. The register is byte-addressable and can be windowed. (See Chapter 4, “Memory Partitions.”)

Table 6-2 lists the standard input-only port pins and Table 6-3 describes the P0_PIN status register.

Table 6-2. Standard Input-only Port Pins

Port Pin

Special-function

Special-function

Associated

Signal(s)

Signal Type

Peripheral

 

 

 

 

 

P0.7:0 (Kx),

ACH7:0 (Kx),

Input

A/D converter

P0.7:2 (CA, Jx)

ACH7:2 (CA, Jx)

 

 

 

 

 

 

Table 6-3. Input-only Port Registers

Mnemonic

Address

Description

 

 

 

P0_PIN

1FDAH

Port 0 Input

 

 

Each bit of P0_PIN reflects the current state of the corresponding

 

 

port 0 pin.

 

 

 

6.2.1Standard Input-only Port Operation

Figure 6-1 is a schematic of an input-only port pin. Transistors Q1 and Q2 serve as electrostatic discharge (ESD) protection devices; they are referenced to VREF and ANGND. Transistor Q3 is an additional ESD protection device; it is referenced to VSS (digital ground). Resistor R1 limits current flow through Q3 to acceptable levels. At this point, the input signal is sent to the analog multiplexer and to the digital level-translation buffer. The level-translation buffer converts the input signals to work with the VCC and VSS digital voltage levels used by the CPU core. This buffer is Schmitt-triggered for improved noise immunity. The signals are latched in the P0_PIN register and are output onto the internal bus when P0_PIN is read.

6-2

I/O PORTS

Internal Bus

 

Vcc

 

 

VREF

VREF

 

 

 

To Analog MUX

 

 

PORT 0

Level

 

 

Q1

 

Data Register

Translation

 

 

 

Buffer

P0_PIN

Buffer

 

150 to 200 Ohms

Input Pin

 

Q

D

 

 

 

 

 

 

LE

 

 

R1

 

 

 

 

 

 

 

Read Port

PH1 Clock

 

 

Q3

Q2

 

 

 

 

 

 

Vss

Vss

Vss

ANGND ANGND

 

 

 

 

 

 

A0236-01

Figure 6-1. Standard Input-only Port Structure

6.2.2Standard Input-only Port Considerations

Port 0 pins are unique in that they may individually be used as digital inputs and analog inputs at the same time. However, reading the port induces noise into the A/D converter, decreasing the accuracy of any conversion in progress. We strongly recommend that you not read the port while an A/D conversion is in progress. To reduce noise, the P0_PIN register is clocked only when the port is read.

These port pins are powered by the analog reference voltage (VREF) and analog ground (ANGND) pins. If the port pins are to function as either analog or digital inputs, the VREF and ANGND pins must provide power. If the voltage applied to the analog input exceeds VREF or ANGND by more than 0.5 volts, current will be driven through Q1 or Q2 into the reference circuitry, decreasing the accuracy of all analog conversions.

The port pin is sampled one state time before the read buffer is enabled. Sampling occurs during phase 1 (while CLKOUT is low) and resolves the value of the pin before it is presented to the internal bus. To ensure that the value is recognized, it must be valid 45 ns before the rising edge of CLKOUT and must remain valid until CLKOUT falls. If the pin value changes during the sample time, the new value may or may not be recorded.

As a digital input, a pin acts as a high-impedance input. However, as an analog input, a pin must provide current for a short time to charge the internal sample capacitor when a conversion begins. This means that if a conversion is taking place on a port pin, its input characteristics change momentarily.

6-3

Соседние файлы в предмете Электротехника