Datasheet

78K0/Ix2 CHAPTER 4 PORT FUNCTIONS
R01UH0010EJ0500 Rev.5.00 154
Feb 28, 2012
4.6 Cautions on 1-Bit Manipulation Instruction for Port Register n (Pn)
When a 1-bit manipulation instruction is executed on a port that provides both input and output functions, the output
latch value of an input port that is not subject to manipulation may be written in addition to the targeted bit.
Therefore, it is recommended to rewrite the output latch when switching a port from input mode to output mode.
<Example> When P20 is an output port, P21 to P27 are input ports (all pin statuses are high level), and the port
latch value of port 2 is 00H, if the output of output port P20 is changed from low level to high level via a
1-bit manipulation instruction, the output latch value of port 2 is FFH.
Explanation: The targets of writing to and reading from the Pn register of a port whose PMnm bit is 1 are the output
latch and pin status, respectively.
A 1-bit manipulation instruction is executed in the following order in the 78K0/Ix2 microcontrollers.
<1> The Pn register is read in 8-bit units.
<2> The targeted one bit is manipulated.
<3> The Pn register is written in 8-bit units.
In step <1>, the output latch value (0) of P20, which is an output port, is read, while the pin statuses of
P21 to P27, which are input ports, are read. If the pin statuses of P21 to P27 are high level at this time,
the read value is FEH.
The value is changed to FFH by the manipulation in <2>.
FFH is written to the output latch by the manipulation in <3>.
Figure 4-40. 1-Bit Manipulation Instruction (P20)
Low-level output
1-bit manipulation
instruction
(set1 P2.0)
is executed for P20
bit.
Pin status: High level
P20
P21 to P27
Port 2 output latch
00000000
High-level output
Pin status: High level
P20
P21 to P27
Port 2 output latch
11111111
1-bit manipulation instruction for P20 bit
<1> Port register 1 (P2) is read in 8-bit units.
In the case of P20, an output port, the value of the port output latch (0) is read.
In the case of P21 to P27, input ports, the pin status (1) is read.
<2> Set the P20 bit to 1.
<3> Write the results of <2> to the output latch of port register 2 (P2)
in 8-bit units.
Remark The following instructions are 1-bit manipulation instructions.
MOV1, AND1, OR1, XOR1, SET1, CLR1, NOT11, NOT1