English
Language : 

H8S-2214 Datasheet, PDF (128/936 Pages) Renesas Technology Corp – Renesas 16-Bit Single-Chip Microcomputer H8S Family H8S-2100 Series
Section 2 CPU
The bit manipulation operation is performed on this value that was read. In this example, bit 4 will
be cleared for H'F8.
I/O
P1DDR
After bit
manipulation
P17
Output
1
1
P16
Output
1
1
P15
Output
1
1
P14
Output
1
0
P13
Input
0
1
P12
Input
0
0
P11
Input
0
0
P10
Input
0
0
After the bit manipulation operation, this data will be written to P1DDR, and the BCLR
instruction completes.
I/O
P1DDR
Write value
P17
Output
1
1
P16
Output
1
1
P15
Output
1
1
P14
Input
0
0
P13
Output
1
1
P12
Input
0
0
P11
Input
0
0
P10
Input
0
0
Although the instruction was expected to write H'E0 back to P1DDR, it actually wrote H'E8, and
P13, which was expected to be an input pin, is changed to function as an output pin. While this
section described the case where P13 was read out as a 1, since the values read are undefined
when P17 to P10 are read, when this bit manipulation instruction completes, bits that were 0 may
be changed to 1, and bits that were 1 may be changed to 0. To avoid this sort of problem, see
section 2.10.4, Access Methods for Registers with Write-Only Bits for methods for modifying
registers that include write-only bits.
Also note that it is possible to use the BCLR instruction to clear to 0 flags in internal I/O registers.
In this case, if it is clear from the interrupt handler or other information that the corresponding flag
is set to 1, then there is no need to read the value of the corresponding flag in advance.
2.10.4 Access Methods for Registers with Write-Only Bits
Undefined values will be read out if a data transfer instruction is executed for a register that
includes write-only bits, or if a bit manipulation instruction is executed for a register that includes
write-only bits. To avoid reading undefined values, use methods such as those shown below to
access registers that include write-only bits.
The basic method for writing to a register that includes write-only bits is to create a work area in
internal RAM or other memory area and first write the data to that area. Then, perform the desired
access operation for that memory and finally write that data to the register that includes write-only
bits.
Rev.4.00 Sep. 18, 2008 Page 68 of 872
REJ09B0189-0400