130
CHAPTER 4 I/O PORTS
4.2.2
Operation of Port 0 and Port 1
This section describes the operations of the port 0 and port 1.
s Operation of Port 0 and Port 1
r Operation as an output port
Setting the corresponding DDR0 or DDR1 register bit to "1" sets a pin as an output port.
When a pin is set as an output port, its output transistor is enabled and the pin outputs the
data stored in the output latch.
Writing data to the PDR0 and PDR1 registers stores the data in the output latch and outputs
the data directly to the pin.
Reading the PDR0 or PDR1 register returns the pin value.
r Operation as an input port
Setting the corresponding DDR0 or DDR1 register bit to "0" sets a pin as an input port.
When a pin is set as an input port, the output transistor is "OFF" and the pin goes to the
high-impedance state.
Writing data to the PDR0 and PDR1 registers stores the data in the output latch but does not
output the data to the pin.
Reading the PDR0 or PDR1 register returns the pin value.
r Operation as an external interrupt input
When a port is an external interrupt input, the port is made an input by setting the
corresponding DDR0 or DDR1 register bits to "0".
Reading the PDRO or PDR1 register returns the pin value, regardless of whether external
interrupt inputs or interrupt request outputs are enabled/disabled.
r Operation at reset
Resetting the CPU initializes the DDR0 and DDR1 register values to "0".
This sets the
output transistors "OFF" (all pins become input ports) and sets the pins to the high-
impedance state.
The PDR0 and PDR1 registers are not initialized by a reset. Therefore, to use as output
ports, the output data must be set in the PDR0 and PDR1 registers before setting the
corresponding DDR0 or DDR1 register bits to output mode.
r Operation in stop and watch modes
The pins go to the high-impedance state if the pin state specification bit in the standby control
register (STBC: SPL) is "1" when the device changes to stop or watch mode. This is achieved
by forcibly setting the output transistor "OFF" regardless of the DDR0 and DDR1 register
values.
To avoid current leakage, it is recommended to remain a known logic level of the input port pins
during the standby mode.