2. CPU
Rev.3.00 Jul. 19, 2007 page 67 of 532
REJ09B0397-0300
Bit Manipulation in a Register Containing a Write-Only Bit
Example 3:
When a BCLR instruction is executed on PCR3 of port 3
As in the examples above, P3
7
and P3
6
are input pins, with a low-level signal input at P3
7
and a
high-level signal at P3
6
. The remaining pins, P3
5
to P3
0
, are output pins that output low-level
signals. In this example, the BCLR instruction is used to change pin P3
0
to an input port. It is
assumed that a high-level signal will be input to this input pin.
[A: Prior to executing BCLR]
P3
7
P3
6
P3
5
P3
4
P3
3
P3
2
P3
1
P3
0
Input/output Input Input
Output Output Output Output Output Output
Pin state
Low
level
High
level
Low
level
Low
level
Low
level
Low
level
Low
level
Low
level
PCR3
0 0 1 1 1 1 1 1
PDR3
1 0 0 0 0 0 0 0
[B: BCLR instruction executed]
BCLR #0 , @PCR3
The BCLR instruction is executed designating PCR3.
[C: After executing BCLR]
P3
7
P3
6
P3
5
P3
4
P3
3
P3
2
P3
1
P3
0
Input/output Output
Output
Output
Output Output Output Output Input
Pin state
Low
level
High
level
Low
level
Low
level
Low
level
Low
level
Low
level
High
level
PCR3
1 1 1 1 1 1 1 0
PDR3
1 0 0 0 0 0 0 0
[D: Explanation of how BCLR operates]
When the BCLR instruction is executed, first the CPU reads PCR3. Since PCR3 is a write-only
register, the CPU reads a value of H'FF, even though the PCR3 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 PCR3 and BCLR instruction execution ends.
Summary of Contents for F-ZTAT H8 Series
Page 6: ...Rev 3 00 Jul 19 2007 page iv of xxiv REJ09B0397 0300...
Page 194: ...7 RAM Rev 3 00 Jul 19 2007 page 168 of 532 REJ09B0397 0300...
Page 234: ...8 I O Ports Rev 3 00 Jul 19 2007 page 208 of 532 REJ09B0397 0300...
Page 274: ...9 Timers Rev 3 00 Jul 19 2007 page 248 of 532 REJ09B0397 0300...
Page 352: ...12 A D Converter Rev 3 00 Jul 19 2007 page 326 of 532 REJ09B0397 0300...
Page 561: ......