88
CHAPTER 4 I/O Ports
MB89960 series
4.4 Port 3
4.4.2 Operation of Port 3
This section describes the operation of port 3.
s Operation of Port 3
q Operation as an output port
Setting the corresponding DDR3 register bit to “1” sets a pin as an output port.
When a pin is set as an output port, the output buffer is “ON” and the pin outputs the
data stored in the output latch.
Writing data to the PDR3 register stores the data in the output latch and outputs the
data directly to the pin.
Reading the PDR3 register returns the pin value (“0” or “1”, the same value as the
output latch).
If using P34 as an output port, be sure to disable both of the resources sharing this pin
(CLK output and timer/counter output).
Note: As the bit manipulation instructions (SETB and CLRB) read the output latch data rather
than the pin level, the instructions do not change the output latch values for bits other
than the bit being set or cleared.
q Operation as an input port
Setting the corresponding DDR3 register bit to “0” sets a pin as an input port.
When a pin is set as an input port, the output buffer is “OFF” and the pin goes to the
high impedance state.
Writing data to the PDR3 register stores the data in the output latch but does not
output the data to the pin.
Reading the PDR3 register returns the pin value (“0” or “1”).
q Operation as a resource output
Set the output enable bit of the resource to use a pin as a resource output. As the output enable
bit of the resource has priority when determining whether a pin is an input or output, the pin
functions as a resource output if the resource output is enabled, even if the DDR3 register bit is
set to “0”. As the pin value can be read even if the resource output is enabled, the resource
output value can be read.
To select P34 as clock output, set DDR3 bit 5 to “1”. To select P34 as 8/16 bit timer/count
output, set DDR3 bit 5 to “0” and set the appropriate value in T1DR, T2DR, T1CR and T2CR.
q Operation as a resource input
The pin value is continuously input for ports that share a pin with a resource input, regardless of
the DDR3 register setting and of whether or not the resource is using the input pin. When the
resource is using the external signal, set the DDR3 register bit to “0” to set the port as an input.