98
μ
PD17068
10.2.4 Using an I/O Port as an Input Port
Select the pin to be set to input mode, using the I/O select register of each port.
The pins of port 1C can be set to input mode only in units of four bits.
The specified input pin enters the floating (Hi-Z) status and waits for the input of an external signal.
To read the input data, execute a read instruction (such as SKT) for the port register corresponding to the
pin.
If the signal input to the pin is high, 1 is read from the corresponding port register. If the input signal is
low, 0 is read from the port register.
If a write instruction (such as MOV) is executed for the port register corresponding to an input port, the
contents of the output latch are rewritten.
10.2.5 Using an I/O Port as an Output Port
Select the pin to be set to output mode, using the I/O select register of each port.
The pins of port 1C can be set in the output mode only in units of four bits.
The specified output pin outputs the contents of the output latch.
To set the output data, execute a write instruction (such as MOV) for the port register corresponding to the
pin.
To output a high signal to a pin, write 1. To output a low signal, write 0.
To set a port to the floating state, set the port to input mode.
If a read instruction (such as SKT) is executed for the port register corresponding to an output port, the
contents of the output latch are read.
For the P0A
0
and P0A
1
pins, the status of the pin is read as is. The contents of the output latch and the read
data may differ (see
Section 10.2.6
).
10.2.6 Notes on Using the I/O Port
If the P0A
0
and P0A
1
pins are used for output as described below, the contents of the output latches may
be rewritten.
Example
Setting the P0A
0
and P0A
1
pins as output ports
INITFLG NOT P0ABIO3, NOT P0ABIO2, P0ABIO1, P0ABIO0
; Sets the P0A
1
and P0A
0
pins to output mode.
INITFLG NOT P0A3, NOT P0A2, POA1, POA0
; Outputs a high signal to the P0A
1
and P0A
0
pins.
;
#
CLR1
P0A1
; Outputs a low signal to the P0A
1
pin.
Macro expansion
AND
. MF. P0A1 SHR 4, #. DF. (NOT P0A1 AND 0FH)
If the signal on pin P0A
0
is driven low by the execution of instruction
#
above, the CLR1 instruction rewrites
the contents of the output latch of pin P0A
0
to 0.
If an instruction to read, the contents of port register P0A are executed when the P0A
0
or P0A
1
pin is set
to output mode, the contents of the output latch are rewritten to the current signal level of the pin, even though
the actual contents of the output latch are not changed.