Section 5. I/O Ports
5.1 Overview
The H8/330 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
All ports except port 7 have programmable MOS input pull-ups. Ports 1 and 2 can drive LEDs.
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.
MOS Pull-Up:
The MOS pull-ups for input pins are controlled as follows. To turn on the pull-up
transistor for a pin, software must first clear its data direction bit to “0” to make the pin an input
pin, then write a “1” in the data bit for that pin. The pull-up can be turned off by writing a “0” in
the data bit, or a “1” in the data direction bit. The pull-ups are also turned off by a reset and by
entry to the hardware standby mode.
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
77