English
Language : 

H83627 Datasheet, PDF (64/381 Pages) Renesas Technology Corp – single-chip microcomputers
Bit Manipulation in a Register Containing a Write-only Bit
Example 3: In this example, the port 6 control register PCR6 is accessed by a BCLR instruction.
As in the examples above, P67 and P66 are input pins, with a low-level signal input at P67 and a
high-level signal at P66. The remaining pins, P65 to P60, are output pins that output low-level
signals. In this example, the BCLR instruction is used to change pin P60 to an input port. It is
assumed that a high-level signal will be input to this input pin.
[A: Prior to executing BCLR]
Input/output
Pin state
PCR6
PDR6
P67
Input
Low
level
0
1
P66
Input
High
level
0
0
P65
Output
Low
level
1
0
P64
Output
Low
level
1
0
P63
Output
Low
level
1
0
P62
Output
Low
level
1
0
P61
Output
Low
level
1
0
P60
Output
Low
level
1
0
[B: BCLR instruction executed]
BCLR #0, @PCR6
The BCLR instruction is executed designating PCR6.
[C: After executing BCLR]
Input/output
Pin state
PCR6
PDR6
P67
Output
Low
level
1
1
P66
Output
High
level
1
0
P65
Output
Low
level
1
0
P64
Output
Low
level
1
0
P63
Output
Low
level
1
0
P62
Output
Low
level
1
0
P61
Output
Low
level
1
0
P60
Input
High
level
0
0
[D: Explanation of how BCLR operates]
When the BCLR instruction is executed, first the CPU reads PCR6. Since PCR6 is a write-only
register, the CPU reads a value of H'FF, even though the PCR6 value is actually H'3F.
Next, the CPU clears bit 0 in the read data to 0, changing the data to H'FE. Finally, this value
(H'FE) is written to PCR6 and BCLR instruction execution ends.
As a result of this operation, bit 0 in PCR6 becomes 0, making P60 an input port. However, bits 7
and 6 in PCR6 change to 1, so that P67 and P66 change from input pins to output pins.
51