79
CHAPTER 5 PERIPHERAL HARDWARE FUNCTIONS
5.1.4 Digital I/O Port Operation
When a data memory manipulation instruction is executed for a digital I/O port, the operation of the port
and pins depends on the I/O mode setting (Table 5-3). This is because data taken in on the internal bus is
the data input from the pins in the input mode, or the output latch data in the output mode, as obvious from
the configurations of I/O ports.
(1) Operation when the input mode is set
Data from each pin is manipulated when a test instruction such as the SKT instruction ,a bit input instruction
such as MOV1,or an instruction for taking in port data on the internal bus in units of four or eight bits (such
as an IN, OUT, arithmetic/logical or comparison instruction) is executed.
When an instruction (the OUT or MOV instruction) is executed to transfer the contents of the accumulator
to a port in units of four or eight bits, the data of the accumulator is latched in the output latch, with the
output buffers kept off.
When the XCH instruction is executed, the data on each pin is loaded into the accumulator, and the data
in the accumulator is latched in the output latch, with the output buffers kept off.
When the INCS instruction is executed, the 4-bit data existing on the pins plus 1 is latched in the output
latch, with the output buffers kept off.
When an instruction such as the SET1, CLR1, or SKTCLR instruction is executed to rewrite a data memory
bit, the output latch data of the specified bit can be rewritten according to the instruction, but the states
of the other output latch bits are undefined.
(2) Operation when the output mode is set
When a test instruction or instruction for taking in port data on the internal bus in units of four or eight
bits is executed, output latch data is manipulated.
When an instruction is executed to transfer the contents of the accumulator in units of four or eight bits,
the output latch data is rewritten, and is output on the pins.
When the XCH instruction is executed, the output latch data is transferred to the accumulator. The
contents of the accumulator are latched in the output latches, and are output on the pins.
When the INCS instruction is executed, the contents of the output latch incremented by 1 are latched in
the output latch, and are output on the pins.
When a bit output instruction is executed, the specified bit of the output latch is rewritten, and is output
on the pin.
*