TC1796
System Units (Vol. 1 of 2)
General Purpose I/O Ports and Peripheral I/O Lines
User’s Manual 10-3 V2.0, 2007-07
Ports, V2.0
Each port line has a number of control and data bits, enabling very flexible usage of the
line. Each port pin (except Port 10) can be configured for input or output operation. In
input mode (default after reset), the output driver is switched off (high-impedance). The
actual voltage level present at the port pin is translated into a logical 0 or 1 via a Schmitt-
Trigger device and can be read via the read-only register Pn_IN. An input signal can also
be connected directly to the various inputs of the peripheral units (AltDataIn). The
function of the input line from the pin to the input register Pn_IN and to AltDataIn is
independent of whether the port pin operates as input or output. This means that when
the port is in output mode, the level of the pin can be read by software via Pn_IN or a
peripheral can use the pin level as an input.
In output mode, the output driver is activated and drives the value supplied through the
multiplexer to the port pin. Switching between input and output mode is accomplished
through the Pn_IOCR register, which enables or disables the output driver. If a
peripheral unit uses a GPIO port line as a bi-directional I/O line, register Pn_IOCR has
to be written for input or output selection. The Pn_IOCR register further controls the
driver type of the output driver, and determines whether an internal weak pull-up or pull-
down device is alternatively connected to the pin when used as an input. This offers
additional advantages in an application.
The output multiplexer in front of the output driver selects the signal source for the GPIO
line when used as output. If the pin is used as general-purpose output, the multiplexer is
switched by software (Pn_IOCR register) to the Output Data Register Pn_OUT. Software
can set or clear the bit in Pn_OUT, and therefore it can directly influence the state of the
port pin. If the on-chip peripheral units use the pin for output signals, the alternate output
lines ALT1 to ALT3 can be switched via the multiplexer to the output driver. The data
written into the output register Pn_OUT by software can be used as input data to an on-
chip peripheral. This enables, for example, peripheral tests via software without external
circuitry.
When selected as general-purpose output line, the logic state of each port pin can be
changed individually by programming the pin-related bits in the Output Modification
Register Pn_OMR. The bits in Pn_OMR make it possible to set, clear, toggle, or leave
the bits in the Pn_OUT register unchanged.
When selected as general-purpose output line, the actual logic level at the pin can be
examined through reading latch Pn_IN and compared against the applied output level
(either applied through software via the output register Pn_OUT, or via an alternate
output function of a peripheral unit). This can be used to detect some electrical failures
at the pin caused through external circuitry. In addition, software-supported arbitration
schemes can be implemented in this way using the open-drain configuration and an
external wired-And circuitry. Collisions on the external communication lines can be
detected when a high level (1) is output, but a low level (0) is seen when reading the pin
value via the input register Pn_IN.