![](http://datasheet.mmic.net.cn/330000/MB90F562_datasheet_16437954/MB90F562_210.png)
186
CHAPTER 8 I/O PORTS
MB90560 series
8.4
8.4.2 Operation of Port 1
Port 1
This section describes the operation of port 1.
I
Operation of Port 1
G
Port operation in output mode
Setting a bit of the DDR1 register to “1” places the corresponding port pin in output mode.
Data written to the PDR1 register in output mode is stored in the output latch of the PDR and
output to the port pins as is.
The PDR1 register can be accessed in read mode to read the value at the port pins (the
same value as in the output latch of the PDR).
<Check>
If a read-modify-write instruction (such as an instruction that sets bits) is used with the port
data register, the target bits of the register are set to the specified value. The bits that have
been specified for output using the DDR register are not affected, but for the bits that have
been specified for input, a value input from the pins is written to the output latch and output
as it is. Before switching the mode for the bits from input to output, therefore, write the output
data to the PDR register, then specify output mode in the DDR register.
G
Port operation in input mode
Writing a bit of the DDR1 register to “0” places the corresponding port pin in input mode.
In input mode, the output buffer is turned off, and the pins are placed in a high impedance
state.
However, when the RDR1 register is set to “1” to select a pull-up resistor, the pins are held at
the high level.
Data written to the PDR1 register in input mode is stored in the output latch of the PDR but
not output to the port pins.
The PDR1 register can be accessed in read mode to read the level value (“0” or “1”) at the
port pins.
G
Port operation for peripheral function input
When the port is also used for peripheral function input, the value at the pins is always supplied
as peripheral function inputs. To use an external signal for the peripheral function, reset the
DDR1 register to “0” to place the port in input mode.
G
Port operation after a reset
When the CPU is reset, the DDR1 and PDR registers are initialized to “0”. As a result, the
output buffer is turned off (I/O mode changes to input), the pull-up resistor is cut, and the pins
are placed in a high impedance state.
The PDR1 register is not initialized when the CPU is reset. To use the port in output mode,
therefore, output mode must be specified in the DDR1 register after the output data is set in
the PDR1 register.