Page 218 DS008-1.1-JUN03 ©2003 Cygnal Integrated Products, Inc.
Preliminary
C8051F120/1/2/3
C8051F124/5/6/7
ble at the Port pins of the device. Also note that the Crossbar assigns pins to all associated functions when a serial
communication peripheral is selected (i.e. SMBus, SPI, UART). It would be impossible, for example, to assign TX0
to a Port pin without assigning RX0 as well. Each combination of enabled peripherals results in a unique device
pinout.
All Port pins on Ports 0 through 3 that are not allocated by the Crossbar can be accessed as General-Purpose I/O
(GPIO) pins by reading and writing the associated Port Data registers (See Figure 19.10, Figure 19.12, Figure 19.15,
and Figure 19.17), a set of SFR’s which are both byte- and bit-addressable. The output states of Port pins that are allo-
cated by the Crossbar are controlled by the digital peripheral that is mapped to those pins. Writes to the Port Data reg-
isters (or associated Port bits) will have no effect on the states of these pins.
A Read of a Port Data register (or Port bit) will always return the logic state present at the pin itself, regardless of
whether the Crossbar has allocated the pin for peripheral use or not. An exception to this occurs during the execution
of a read-modify-write instruction (ANL, ORL, XRL, CPL, INC, DEC, DJNZ, JBC, CLR, SETB, and the bitwise
MOV write operation). During the read cycle of the read-modify-write instruction, it is the contents of the Port Data
register, not the state of the Port pins themselves, which is read.
Because the Crossbar registers affect the pinout of the peripherals of the device, they are typically configured in the
initialization code of the system before the peripherals themselves are configured. Once configured, the Crossbar reg-
isters are typically left alone.
Once the Crossbar registers have been properly configured, the Crossbar is enabled by setting XBARE (XBR2.4) to a
logic 1. Until XBARE is set to a logic 1, the output drivers on Ports 0 through 3 are explicitly disabled in order
to prevent possible contention on the Port pins while the Crossbar registers and other registers which can
affect the device pinout are being written.
The output drivers on Crossbar-assigned input signals (like RX0, for example) are explicitly disabled; thus the values
of the Port Data registers and the PnMDOUT registers have no effect on the states of these pins.
19.1.2. Configuring the Output Modes of the Port Pins
The output drivers on Ports 0 through 3 remain disabled until the Crossbar is enabled by setting XBARE (XBR2.4) to
alogic1.
The output mode of each port pin can be configured to be either Open-Drain or Push-Pull. In the Push-Pull configura-
tion, writing a logic 0 to the associated bit in the Port Data register will cause the Port pin to be driven to GND, and
writing a logic 1 will cause the Port pin to be driven to VDD. In the Open-Drain configuration, writing a logic 0 to the
associated bit in the Port Data register will cause the Port pin to be driven to GND, and a logic 1 will cause the Port
pin to assume a high-impedance state. The Open-Drain configuration is useful to prevent contention between devices
in systems where the Port pin participates in a shared interconnection in which multiple outputs are connected to the
same physical wire (like the SDA signal on an SMBus connection).
The output modes of the Port pins on Ports 0 through 3 are determined by the bits in the associated PnMDOUT regis-
ters (See Figure 19.11, Figure 19.14, Figure 19.16, and Figure 19.18). For example, a logic 1 in P3MDOUT.7 will
configure the output mode of P3.7 to Push-Pull; a logic 0 in P3MDOUT.7 will configure the output mode of P3.7 to
Open-Drain. All Port pins default to Open-Drain output.
The PnMDOUT registers control the output modes of the port pins regardless of whether the Crossbar has allocated
the Port pin for a digital peripheral or not. The exceptions to this rule are: the Port pins connected to SDA, SCL, RX0
(if UART0 is in Mode 0), and RX1 (if UART1 is in Mode 0) are always configured as Open-Drain outputs, regardless
of the settings of the associated bits in the PnMDOUT registers.