English
Language : 

H8S-2214 Datasheet, PDF (127/936 Pages) Renesas Technology Corp – Renesas 16-Bit Single-Chip Microcomputer H8S Family H8S-2100 Series
Section 2 CPU
Example: Using the BCLR instruction to clear only P14 in the port 1 P1DDR register.
The P1DDR register consists of 8 write-only bits and sets the I/O direction of the port 1 pins.
Reading this register is invalid. When read, the values returned are undefined.
Here we present an example in which P14 is specified to be an input port using the BCLR
instruction. Currently, P17 to 14 are set to be output pins and P13 to P10 are set to be input pins.
At this point, the value of P1DDR is H'F0.
I/O
P1DDR
P17
Output
1
P16
Output
1
P15
Output
1
P14
Output
1
P13
Input
0
P12
Input
0
P11
Input
0
P10
Input
0
To switch P14 from the Output pin to the input pin function, the value of P1DDR bit 4 must be
changed from 1 to 0 (H'F0 → H'E0). Here we assume that the BCLR instruction is used to clear
P1DDR bit 4.
BCLR #4, @P1DDR
However if a bit manipulation instruction of the type shown above is used on P1DDR, which is a
write-only register, the following problem may occur.
Although the first thing that happens is that data is read from P1DDR in byte units, the value read
at this time is undefined. An undefined value is a value that is either 0 or 1 in the register but reads
out as an arbitrary value whose relationship to the actual value is unknown. Since the P1DDR bits
are all write-only bits, every bit reads out as an undefined value. Although the actual value of
P1DDR at this point is H'F0, assume that bit 3 becomes a 1 here, and the value read out is H'F8.
I/O
P1DDR
Read value
P17
Output
1
1
P16
Output
1
1
P15
Output
1
1
P14
Output
1
1
P13
Input
0
1
P12
Input
0
0
P11
Input
0
0
P10
Input
0
0
Rev.4.00 Sep. 18, 2008 Page 67 of 872
REJ09B0189-0400