Hardware manual

Rev. 3.0, 09/98, page 81 of 361
Section 6 I/O Ports
6.1 Overview
The H8/338 Series has nine parallel I/O ports, including:
Six 8-bit input/output ports-ports 1, 2, 3, 4, 6, and 9
One 8-bit input port-port 7
One 7-bit input/output port-port 8
One 3-bit input/output port-port 5
Ports 1, 2, and 3 have programmable input pull-up transistors. Ports 1 to 6, 8, and 9 can drive a
Darlington pair. Ports 1 to 4, 6, and 9 can drive one TTL load and a 90pF capacitive load. Ports 5
and 8 can drive one TTL load and a 30pF capacitive load. Ports 1 and 2 can drive LEDs (10mA
current sink).
Input and output are memory-mapped. The CPU views each port as a data register (DR) located in
the register field at the high end of the address space. Each port (except port 7) also has a data
direction register (DDR) which determines which pins are used for input and which for output.
Output:
To send data to an output port, the CPU selects output in the data direction register and
writes the desired data in the data register, causing the data to be held in a latch. The latch output
drives the pin through a buffer amplifier. If the CPU reads the data register of an output port, it
obtains the data held in the latch rather than the actual level of the pin.
Input:
To read data from an I/O port, the CPU selects input in the data direction register and
reads the data register. This causes the input logic level at the pin to be placed directly on the
internal data bus. There is no intervening input latch.
The data direction registers are write-only registers; their contents are invisible to the CPU. If the
CPU reads a data direction register all bits are read as “1,” regardless of their true values. Care is
required if bit manipulation instructions are used to set and clear the data direction bits. See the
note on bit manipulation instructions in section 3.5.5, “Bit Manipulations.”
Auxiliary Functions:
In addition to their general-purpose input/output functions, all of the I/O
ports have auxiliary functions. Most of the auxiliary functions are software-selectable and must be
enabled by setting bits in control registers. When selected, an auxiliary function usually replaces
the general-purpose input/output function, but in some cases both functions can operate
simultaneously. Table 6.1 summarizes the functions of the ports.