1. Renesas Technology Corp. puts the maximum effort into making semiconductor products better and
more reliable, but there is always the possibility that trouble may occur with them. Trouble with
semiconductors may lead to personal injury, fire or property damage.
Remember to give due consideration to safety when making your circuit designs, with appropriate
measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of nonflammable material or
(iii) prevention against any malfunction or mishap.
Notes regarding these materials
1. These materials are intended as a reference to assist our customers in the selection of the Renesas
Technology Corp. product best suited to the customer's application; they do not convey any license
under any intellectual property rights, or any other rights, belonging to Renesas Technology Corp. or
a third party.
2. Renesas Technology Corp. assumes no responsibility for any damage, or infringement of any thirdparty's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or
circuit application examples contained in these materials.
3. All information contained in these materials, including product data, diagrams, charts, programs and
algorithms represents information on products at the time of publication of these materials, and are
subject to change by Renesas Technology Corp. without notice due to product improvements or
other reasons. It is therefore recommended that customers contact Renesas Technology Corp. or
an authorized Renesas Technology Corp. product distributor for the latest product information
before purchasing a product listed herein.
The information described here may contain technical inaccuracies or typographical errors.
Renesas Technology Corp. assumes no responsibility for any damage, liability, or other loss rising
from these inaccuracies or errors.
Please also pay attention to information published by Renesas Technology Corp. by various means,
including the Renesas Technology Corp. Semiconductor home page (http://www.renesas.com).
4. When using any or all of the information contained in these materials, including product data,
diagrams, charts, programs, and algorithms, please be sure to evaluate all information as a total
system before making a final decision on the applicability of the information and products. Renesas
Technology Corp. assumes no responsibility for any damage, liability or other loss resulting from the
information contained herein.
5. Renesas Technology Corp. semiconductors are not designed or manufactured for use in a device or
system that is used under circumstances in which human life is potentially at stake. Please contact
Renesas Technology Corp. or an authorized Renesas Technology Corp. product distributor when
considering the use of a product contained herein for any specific purposes, such as apparatus or
systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use.
6. The prior written approval of Renesas Technology Corp. is necessary to reprint or reproduce in
whole or in part these materials.
7. If these products or technologies are subject to the Japanese export control restrictions, they must
be exported under a license from the Japanese government and cannot be imported into a country
other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the
country of destination is prohibited.
8. Please contact Renesas Technology Corp. for further details on these materials or the products
contained therein.
Rev. 1.00 Sep. 16, 2005 Page iii of xxx
General Precautions on Handling of Product
1. Treatment of NC Pins
Note: Do not connect anything to the NC pins.
The NC (not connected) pins are either not connected to any of the internal circuitry or are
used as test pins or to reduce noise. If something is connected to the NC pins, the
operation of the LSI is not guaranteed.
2. Treatment of Unused Input Pins
Note: Fix all unused input pins to high or low level.
Generally, the input pins of CMOS products are hi g h-impedance input pins. If unused pins
are in their open states, intermediate levels are induced by noise in the vicinity, a passthrough current flows internally, and a malfunction may occur.
3. Processing before Initialization
Note: When power is first supplied, the product's state is undefined.
The states of internal circuits are undefined until full power is supplied throughout the
chip and a low level is input on the reset pin. During the period where the states are
undefined, the register settings and the output state of each pin are also undefined. Design
your system so that it does not malfunction because of processing while it is in this
undefined state. For those products which have a reset function, reset the LSI immediately
after the power supply has been turned on.
4. Prohibition of Access to Undefined or Rese r ved Ad dresses
Note: Access to undefined or reserved addresses is prohibited.
The undefined or reserved addresses may be used to expand functions, or test registers
may have been be allocated to these addresses. Do not access these registers; the system's
operation is not guaranteed if they are accessed.
Rev. 1.00 Sep. 16, 2005 Page iv of xxx
Configuration of This Manual
This manual comprises the following items:
1. General Precautions on Handling of Product
2. Configuration of This Manual
3. Preface
4. Contents
5. Overview
6. Description of Functional Modules
• CPU and System-Control Modules
• On-Chip Peripheral Modules
The configuration of the functional description of each module differs according to the
module. However, the generic style includes the following items:
When designing an application system that includes this LSI, take notes into account. Each section
includes notes in relation to the descriptions given, and usage notes are given, as required, as the
final part of each section.
7. List of Registers
8. Electrical Characteristics
9. Appendix
10. Main Revisions and Additions in this Edition (only for revised versions)
The list of revisions is a summary of points that have been revised or added to earlier versions.
This does not include all of the revised contents. For details, see the actual locations in this
manual.
11. Index
Rev. 1.00 Sep. 16, 2005 Page v of xxx
Preface
The H8/36077 Group are single-chip microcom put ers made up of the high-speed H8/300H CPU
employing Renesas Technology original architecture as their cores, and the peripheral functions
required to configure a system. The H8/300H CPU has an instruction set that is compatible with
the H8/300 CPU.
Target Users: This manual was written for users who will be using the H8/36077 Group in the
design of application systems. Target users are expected to understand the
fundamentals of electrical circuits, logical circuits, and microcomputers.
Objective: This manual was written to explain the hardware functions and electrical
characteristics of the H8/36077 Group to the target users.
Refer to the H8/300H Series Programming Manual for a detailed description of the
instruction set.
Notes on reading this manual:
• In order to understand the overall functions of the chip
Read the manual according to the contents. This manual can be roughl y categorized into parts
on the CPU, system control functions, peripheral functions and electrical characteristics.
• In order to understand the details of the CPU's functions
Read the H8/300H Series Programming Manual.
• In order to understand the details of a register when its name is known
Read the index that is the final part of the manual to find the page number of the entry on the
register. The addresses, bits, and initial values of the registers are summarized in section 21,
List of Registers.
Example: Register name: The follo wi n g notat i on is used for cases when the same or a
similar function, e.g. serial communication interface, is
implemented on more than one channel:
XXX_N (XXX is the register name and N is the channel
number)
Bit order: The MSB is on the left and the LSB is on the right.
Rev. 1.00 Sep. 16, 2005 Page vi of xxx
Notes:
When using an on-chip emulator (E7, E8) for H8/36077 program development and debugging, the
following restrictions must be noted.
1. The NMI pin is reserved for the E7 or E8, and cannot be used.
2. Pins P85, P86, and P87 cannot be used. In order to use these pins, additional ha rdware must be
provided on the user board.
3. Area H’D000 to H’DFFF is used by the E7 or E8, and is not available to the user.
4. Area H’F780 to H’FB7F must on no account be accessed.
5. When the E7or E8 is used, address breaks can be set as either available to the user or for use
by the E7 or E8. If address breaks are set as being used by the E7, the address break control
registers must not be accessed.
6. When the E7 or E8 is used, NMI is an input/output pin (open-drain in output mode), P85 and
P87 are input pins, and P86 is an output pin.
7. Use channel 1 of the SCI3 (P21/RXD, P22/TXD) in on-board programming mode by boot
mode.
Related Manuals: The latest versions of all related manuals are available from our web site.
Please ensure you have the latest versions of all documents you require.
http://www.renesas.com/
• High-speed H8/300H CPU with an in ternal 16-bit architecture
Upward-compatible with H8/300 CPU at the object level
Si xteen 1 6- bi t gene ral re gi st ers
62 basic instructions
• Various peripheral functions
RTC (can be used as a free running counter)
Timer B1 (8-bit timer)
Timer V (8-bit timer)
Timer Z (16-bit timer)
14-bit PWM
Watchdog timer
SCI (asynchronous or clock synchronous serial communication interface) × 2 channels
2
I
C bus interface (conforms to the I2C bus interface format that is advocated by Philips
AVCC 3 Input Analog power supply pin for the A/D converter.
V
Clock pins OSC1 11 Input
OSC2/
X1 5 Input
X2 4 Output
System
control
TEST 8 Input Test pin. Connect this pin to Vss.
Interrupt
pins
IRQ0 to
WKP0 to
RTC TMOW 23 Output This is an output pin for a divided clock.
Timer B1 TMIB1 52 Input External event input pin
Symbol
FP-64K
FP-64A
I/O
Functions
VCC 12 Input Power supply pin. Connect this pin to the
system power supply.
9 Input Ground pin. Connect this pin to the system
SS
power supply (0V).
When the A/D converter is not used, connect
this pin to the system power supply.
6 Input Internal step-down power supply pin. Connect a
CL
capacitor of around 0.1 µF between this pin and
the Vss pin for stabilization.
These pins connect with crystal or ceramic
10 Output
CLKOUT
resonator for the system clock, or can be used
to input an external clock. When the on-chip
oscillator is used, the system clock can be
output on OSC2 pin.
See section 5, Clock Pulse Generator, for a
typical connection.
These pins connect with a 32.768 kHz crystal
resonator for the subclock. See section 5, Clock
Pulse Generator, for a typical connection.
RES7 Input Reset pin. The pull-up resistor (typ. 150 kΩ) is
incorporated. When driven low, this LSI is reset.
NMI35 Input Non-maskable interrupt request input pin. Be
sure to pull up by a resistor.
51 to 54 Input External interrupt request input pins. Can select
IRQ3
WKP5
13, 14,
19 to 22
Input External interrupt request input pins. Can select
the rising or falling edge.
the rising or falling edge.
Rev. 1.00 Sep. 16, 2005 Page 5 of 490
REJ09B0216-0100
Section 1 Overview
Pin No.
Type
Symbol
FP-64K
FP-64A I/O
Functions
Timer V TMOV 30 Output This is an output pin for a waveform generated
by the output compare function.
TMCIV 29 Input External event input pin
TMRIV 28 Input Counter reset input pin
TRGV 54 Input Counter start trigger input pin
Timer Z FTIOA0 36 I/O Output compare output/input capture
input/external clock input pin
FTIOB0 34 I/O Output compare output/input capture
input/PWM output pin
FTIOC0 33 I/O Output compare output/input capture
input/PWM sync output pin (at a reset,
complementary PWM mode)
FTIOD0 32 I/O Output compare output/input capture
input/PWM output pin
FTIOA1 37 I/O Output compare output/input capture
input/PWM output pin (at a reset,
complementary PWM mode)
detection voltage for the low-voltage detection
circuit.
Rev. 1.00 Sep. 16, 2005 Page 7 of 490
REJ09B0216-0100
Section 1 Overview
Rev. 1.00 Sep. 16, 2005 Page 8 of 490
REJ09B0216-0100
Section 2 CPU
Section 2 CPU
This LSI has an H8/300H CPU with an internal 32-bit architecture that is upw ard -compatible with
the H8/300CPU, and supports only normal mode, which has a 64-kbyte address space.
• Upward-compatible with H8/300 CPUs
Can execute H8/300 CPUs object programs
Additional eight 16-bit extended registers
32-bit transfer and arithmetic and logic instructions are added
Signed multiply and divide instructions are added.
• General-register architecture
Sixteen 16-bit general registers also usable as sixteen 8-bit registers and eight 16-bit
registers, or eight 32-bit registers
• Sixty-two basic instructions
8/16/32-bit data transfer and arithmetic and logic instructions
Multiply and divide instructions
Powerful bit-manipulation instructions
• Eight addressing modes
Register direct [Rn]
Register indirect [@ERn]
R egi st er in di rect with displacement [@(d:16,ERn) or @( d:24,ERn)]
Register indirect with post-increment or pre-decrement [@ERn+ or @–ERn]
Absolute address [@aa:8, @aa:16, @aa:24]
Immediate [#xx:8, #xx:16, or #xx:32]
Pr ogram-counter relative [@(d:8,PC) or @(d:16,PC)]
Memory indirect [@@aa:8]
• 64-kbyte address space
• High-speed operation
All frequently-used instructions execute in one or two states
8/16/32-bit register-register add/subtract : 2 state
8 × 8-bit register-register multiply : 14 states
16 ÷ 8-bit register-register divide : 14 states
16 × 16-bit register-register multiply : 22 states
32 ÷ 16-bit register-register divide : 22 states
CPU30H2C_000120030300Rev. 1.00 Sep. 16, 2005 Page 9 of 490
REJ09B0216-0100
Section 2 CPU
• Power-down state
Transition to power-down state by SLEEP instruction
2.1 Address Space and Memory Map
The address space of this LSI is 64 kbytes, which includes the program area and the data area.
Figures 2.1 show the memory map.
HD64F36077G
(Flash memory version)
H'0000
H'0041
H'0042
H'DFFF
H'E800
H'EFFF
H'F700
Internal I/O register
H'F77F
H'F780
(1 kbyte work area
for flash memory
H'FB7F
H'FB80
(1 kbyte user area)
H'FF7F
H'FF80
Internal I/O register
H'FFFF
Interrupt vector
On-chip ROM
(56 kbytes)
Not used
On-chip RAM
(2 kbytes)
Not used
programming)
On-chip RAM
(2 kbytes)
HD64F36074G
(Flash memory version)
H'0000
H'0041
H'0042
H'7FFF
H'E800
H'EFFF
H'F700
H'F77F
H'F780
H'FB7F
H'FB80
H'FF7F
H'FF80
H'FFFF
Interrupt vector
Internal I/O register
(1 kbyte work area
for flash memory
(1 kbyte user area)
Internal I/O register
On-chip ROM
(32 kbytes)
Not used
On-chip RAM
(2 kbytes)
Not used
programming)
On-chip RAM
(2 kbytes)
Figure 2.1 Memory Map
Rev. 1.00 Sep. 16, 2005 Page 10 of 490
REJ09B0216-0100
Section 2 CPU
2.2 Register Configuration
The H8/300H CPU has the internal registers shown in figure 2.2. There are two types of registers;
general registers and control registers. The control registers are a 24-bit program counter (PC), and
an 8-bit condition-code register (CCR).
General Registers (ERn)
150 70 70
ER0
ER1
ER2
ER3
ER4
ER5
ER6
ER7
E0
E1
E2
E3
E4
E5
E6
E7
(SP)
R0H
R1H
R2H
R3H
R4H
R5H
R6H
R7H
R0L
R1L
R2L
R3L
R4L
R5L
R6L
R7L
Control Registers (CR)
[Legend]
SP:
Stack pointer
PC:
Program counter
CCR:
Condition-code register
I:
Interrupt mask bit
UI:
User bit
230
PC
76543210
CCR
IUIHUNZVC
Half-carry flag
H:
User bit
U:
Negative flag
N:
Zero flag
Z:
Overflow flag
V:
Carry flag
C:
Figure 2.2 CPU Registers
Rev. 1.00 Sep. 16, 2005 Page 11 of 490
REJ09B0216-0100
Section 2 CPU
2.2.1 General Registers
The H8/300H CPU has eight 32-bit general registers. These general registers are all functionally
identical and can be used as both address registers and data registers. When a general register is
used as a data register, it can be accessed as a 32-bit, 16-bit, or 8-bit register. Figure 2.3 illustrates
the usage of the general registers. When the general registers are used as 32-bit registers or address
registers, they are designated by the letters ER (ER0 to ER7).
The ER registers divide into 16-bit general registers designated by the letters E (E0 to E7) and R
(R0 to R7). These registers are functionally equivalent, providing a maximum of sixteen 16-bit
registers. The E registers (E0 to E7) are also referred to as extended registers.
The R registers divide into 8-bit registers designated by the letters RH (R0H to R7H) and RL (R0L
to R7L). These registers are functionally equivalent, providing a maximum of sixteen 8-bit
registers.
The usage of each register can be selected independently.
• Address registers
• 32-bit registers
ER registers
(ER0 to ER7)
• 16-bit registers• 8-bit registers
E registers (extended registers)
(E0 to E7)
R registers
(R0 to R7)
RH registers
(R0H to R7H)
RL registers
(R0L to R7L)
Figure 2.3 Usage of General Registers
General register ER7 has the function of stack pointer (SP) in addition to its general-register
function, and is used implicitly in exception handling and subroutine calls. Figure 2.4 shows the
relationship between the stack pointer and the stack area.
Rev. 1.00 Sep. 16, 2005 Page 12 of 490
REJ09B0216-0100
Section 2 CPU
Empty area
SP (ER7)
Stack area
Figure 2.4 Relationship between Stack Pointer and Stack Area
2.2.2 Program Counter (PC)
This 24-bit counter indicates the address of the next instruction the CPU will execute. The length
of all CPU instructions is 2 bytes (one word), so the least significant PC bit is ignored. (When an
instruction is fetched, the least significant PC bit is regarded as 0). The PC is initialized when the
start address is loaded by the vector address generated during reset exception-handling sequence.
2.2.3 Condition-Code Register (CCR)
This 8-bit register contains internal CPU status information, including an interrupt mask bit (I) and
half-carry (H), negative (N), zero (Z), overflow (V), and carry (C) flags. The I bit is initialized to 1
by reset exception-handling sequence, but other bits are not initialized.
Some instructions leave flag bits unchanged. Operations can be performed on the CCR bits by the
LDC, STC, ANDC, ORC, and XORC instructions. The N, Z, V, and C flags are used as branching
conditions for conditional branch (Bcc) instructions.
For the action of each instruction on the flag bits, see appendix A.1, Instruction List.
Rev. 1.00 Sep. 16, 2005 Page 13 of 490
REJ09B0216-0100
Section 2 CPU
Initial
Bit Bit Name
Value R/W Description
7 I 1 R/W Interrupt Mask Bit
Masks interrupts other than NMI when set to 1. NMI is
accepted regardless of the I bit setting. The I bit is set
to 1 at the start of an exception-handling sequence.
6 UI Undefined R/W User Bit
Can be written and read by software using the LDC,
STC, ANDC, ORC, and XORC instructions.
5 H Undefined R/W Half-Carry Flag
When the ADD.B, ADDX.B, SUB.B, SUBX.B, CMP.B,
or NEG.B instruction is executed, this flag is set to 1 if
there is a carry or borrow at bit 3, and cleared to 0
otherwise. When the ADD.W, SUB.W, CMP.W, or
NEG.W instruction is executed, the H flag is set to 1 if
there is a carry or borrow at bit 11, and cleared to 0
otherwise. When the ADD.L, SUB.L, CMP.L, or NEG.L
instruction is executed, the H flag is set to 1 if there is a
carry or borrow at bit 27, and cleared to 0 otherwise.
4 U Undefined R/W User Bit
Can be written and read by software using the LDC,
STC, ANDC, ORC, and XORC instructions.
3 N Undefined R/W Negative Flag
Stores the value of the most significant bit of data as a
sign bit.
2 Z Undefined R/W Zero Flag
Set to 1 to indicate zero data, and cleared to 0 to
indicate non-zero data.
1 V Undefined R/W Overflow Flag
Set to 1 when an arithmetic overflow occurs, and
cleared to 0 at other times.
0 C Undefined R/W Carry Flag
Set to 1 when a carry occurs, and cleared to 0
otherwise. Used by:
• Add instructions, to indicate a carry
• Subtract instructions, to indicate a borrow
• Shift and rotate instructions, to indicate a carry
The carry flag is also used as a bit accumulator by bit
manipulation instructions.
Rev. 1.00 Sep. 16, 2005 Page 14 of 490
REJ09B0216-0100
Section 2 CPU
2.3 Data Formats
The H8/300H CPU can process 1-bit, 4-bit (BCD), 8-bit (byte), 16-bit (word), and 32-bit
(longword) data. Bit-manipulation instructions operate on 1-bit data by accessing bit n (n = 0, 1, 2,
…, 7) of byte operand data. The DAA and DAS decimal-adjust instruct i o ns treat byte dat a as two
digits of 4-bit BCD data.
2.3.1 General Register Data Formats
Figure 2.5 shows the data formats in general registers.
Data TypeGeneral RegisterData Format
70
6543271
Don't care
0
1-bit data
RnH
1-bit data
4-bit BCD data
4-bit BCD data
Byte data
Byte data
7
RnL
RnH
RnL
RnH
RnL
Don't care
704 3
UpperLower
Don't care
70
MSBLSB
Don't care
65432710
Don't care
704 3
UpperLower
7
MSBLSB
Figure 2.5 General Register Data Formats (1)
0
Don't care
0
Rev. 1.00 Sep. 16, 2005 Page 15 of 490
REJ09B0216-0100
Section 2 CPU
Data TypeData FormatGeneral
Register
Word data
Word dataRnEn
Longword
ERn
data
[Legend]
ERn:
General register ER
En:
General register E
Rn:
General register R
RnH:
General register RH
RnL:
General register RL
MSB:
Most significant bit
LSB:
Least significant bit
150
MSBLSB
150
MSBLSB
3116
MSB
150
Figure 2.5 General Register Data Formats (2)
LSB
Rev. 1.00 Sep. 16, 2005 Page 16 of 490
REJ09B0216-0100
Section 2 CPU
2.3.2 Memory Data Formats
Figure 2.6 shows the data formats in memory. The H8/300H CPU can access word data and
longword data in memory, however word or longword data must begin at an even address. If an
attempt is made to access word or longword data at an odd address, an address error does not
occur, however the least significant bit of the address is regarded as 0, so access begins the
preceding address. This also applies to instruction fetches.
When ER7 (SP) is used as an address register to access the stack area, the operand size should be
word or longword.
Data TypeAddress
1-bit data
Byte data
Word data
Longword dataAddress 2N
Address L
Address L
Address 2M
Address 2M+1
Address 2N+1
Address 2N+2
Address 2N+3
Figure 2.6 Memory Data Formats
Data Format
70
76 543210
MSB
MSB
MSB
LSB
LSB
LSB
Rev. 1.00 Sep. 16, 2005 Page 17 of 490
REJ09B0216-0100
Section 2 CPU
2.4 Instruction Set
2.4.1 Table of Instructions Classified by Function
The H8/300H CPU has 62 instructions. Tables 2.2 to 2.9 summarize the instructions in each
functional category. The notation used in tables 2.2 to 2.9 is defined below.
Table 2.1 Operation Notation
Symbol Description
Rd General register (destination)*
Rs General register (source)*
Rn General register*
ERn General register (32-bit register or address register)
(EAd) Destination operand
(EAs) Source operand
CCR Condition-code register
N N (negative) flag in CCR
Z Z (zero) flag in CCR
V V (overflow) flag in CCR
C C (carry) flag in CCR
PC Program counter
SP Stack pointer
#IMM Immediate data
disp Displacement
+ Addition
– Subtraction
× Multiplication
÷ Division
∧ Logical AND
∨ Logical OR
⊕ Logical XOR
→ Move
∼ NOT (logical complement)
:3/:8/:16/:24 3-, 8-, 16-, or 24-bit length
Rev. 1.00 Sep. 16, 2005 Page 18 of 490
REJ09B0216-0100
Section 2 CPU
Note: * General registers include 8-bit registers (R0H to R7H, R0L to R7L), 16-bit registers (R0
to R7, E0 to E7), and 32-bit registers/address register (ER0 to ER7).
Table 2.2 Data Transfer Instructions
Instruction Size* Function
MOV B/W/L (EAs) → Rd, Rs → (EAd)
Moves data between two general registers or between a general register
and memory, or moves immediate data to a general register.
MOVFPE B (EAs) → Rd
Cannot be used in this LSI.
MOVTPE B Rs → (EAs)
Cannot be used in this LSI.
POP W/L @SP+ → Rn
Pops a general register from the stack. POP.W Rn is identical to
MOV.W @SP+, Rn. POP.L ERn is identical to MOV.L @SP+, ERn.
PUSH W/L Rn → @–SP
Pushes a general register onto the stack. PUSH.W Rn is identical to
MOV.W Rn, @–SP. PUSH.L ERn is identical to MOV.L ERn, @–SP.
Note: * Refers to the operand size.
B: Byte
W: Word
L: Longword
Rev. 1.00 Sep. 16, 2005 Page 19 of 490
REJ09B0216-0100
Section 2 CPU
Table 2.3 Arithmetic Operations Instructions (1)
Instruction Size* Function
ADD
SUB
ADDX
SUBX
INC
DEC
ADDS
SUBS
DAA
DAS
MULXU B/W Rd × Rs → Rd
MULXS B/W Rd × Rs → Rd
DIVXU B/W Rd ÷ Rs → Rd
Note: * Refers to the operand size.
B: Byte
W: Word
L: Longword
B/W/L Rd ± Rs → Rd, Rd ± #IMM → Rd
Performs addition or subtraction on data in two general registers, or on
immediate data and data in a general register (immediate byte data
cannot be subtracted from byte data in a general register. Use the
SUBX or ADD instruction.)
B Rd ± Rs ± C → Rd, Rd ± #IMM ± C → Rd
Performs addition or subtraction with carry on byte data in two general
registers, or on immediate data and data in a general register.
B/W/L Rd ± 1 → Rd, Rd ± 2 → Rd
Increments or decrements a general register by 1 or 2. (Byte operands
can be incremented or decremented by 1 only.)
L Rd ± 1 → Rd, Rd ± 2 → Rd, Rd ± 4 → Rd
Adds or subtracts the value 1, 2, or 4 to or from data in a 32-bit register.
B Rd (decimal adjust) → Rd
Decimal-adjusts an addition or subtraction result in a general register by
referring to the CCR to produce 4-bit BCD data.
Performs unsigned multiplication on data in two general registers: either
8 bits × 8 bits → 16 bits or 16 bits × 16 bits → 32 bits.
Performs signed multiplication on data in two general registers: either 8
bits × 8 bits → 16 bits or 16 bits × 16 bits → 32 bits.
Performs unsigned division on data in two general registers: either 16
bits ÷ 8 bits → 8-bit quotient and 8-bit remainder or 32 bits ÷ 16 bits →
16-bit quotient and 16-bit remainder.
Rev. 1.00 Sep. 16, 2005 Page 20 of 490
REJ09B0216-0100
Table 2.3 Arithmetic Operations Instructions (2)
Instruction Size* Function
DIVXS B/W Rd ÷ Rs → Rd
Performs signed division on data in two general registers: either 16 bits
÷ 8 bits → 8-bit quotient and 8-bit remainder or 32 bits ÷ 16 bits → 16-bit
quotient and 16-bit remainder.
CMP B/W/L Rd – Rs, Rd – #IMM
Compares data in a general register with data in another general
register or with immediate data, and sets CCR bits according to the
result.
NEG B/W/L 0 – Rd → Rd
Takes the two's complement (arithmetic complement) of data in a
general register.
EXTU W/L Rd (zero extension) → Rd
Extends the lower 8 bits of a 16-bit register to word size, or the lower 16
bits of a 32-bit register to longword size, by padding with zeros on the
left.
EXTS W/L Rd (sign extension) → Rd
Extends the lower 8 bits of a 16-bit register to word size, or the lower 16
bits of a 32-bit register to longword size, by extending the sign bit.
Note: * Refers to the operand size.
B: Byte
W: Word
L: Longword
Section 2 CPU
Rev. 1.00 Sep. 16, 2005 Page 21 of 490
REJ09B0216-0100
Section 2 CPU
Table 2.4 Logic Operations Instructions
Instruction Size* Function
AND B/W/L Rd ∧ Rs → Rd, Rd ∧ #IMM → Rd
Performs a logical AND operation on a general register and another
general register or immediate data.
OR B/W/L Rd ∨ Rs → Rd, Rd ∨ #IMM → Rd
Performs a logical OR operation on a general register and another
general register or immediate data.
XOR B/W/L Rd ⊕ Rs → Rd, Rd ⊕ #IMM → Rd
Performs a logical exclusive OR operation on a general register and
another general register or immediate data.
NOT B/W/L ∼(Rd) → (Rd)
Takes the one's complement (logical complement) of general register
contents.
Note: * Refers to the operand size.
B: Byte
W: Word
L: Longword
Table 2.5 Shift Instructions
Instruction Size* Function
SHAL
SHAR
SHLL
SHLR
ROTL
ROTR
ROTXL
ROTXR
B/W/L Rd (shift) → Rd
Performs an arithmetic shift on general register contents.
B/W/L Rd (shift) → Rd
Performs a logical shift on general register contents.
B/W/L Rd (rotate) → Rd
Rotates general register contents.
B/W/L Rd (rotate) → Rd
Rotates general register contents through the carry flag.
Note: * Refers to the operand size.
B: Byte
W: Word
L: Longword
Rev. 1.00 Sep. 16, 2005 Page 22 of 490
REJ09B0216-0100
Table 2.6 Bit Manipulation Instructions (1)
Instruction Size* Function
BSET B 1 → (<bit-No.> of <EAd>)
Sets a specified bit in a general register or memory operand to 1. The bit
number is specified by 3-bit immediate data or the lower three bits of a
general register.
BCLR B 0 → (<bit-No.> of <EAd>)
Clears a specified bit in a general register or memory operand to 0. The
bit number is specified by 3-bit immediate data or the lower three bits of
a general register.
BNOT B ∼(<bit-No.> of <EAd>) → (<bit-No.> of <EAd>)
Inverts a specified bit in a general register or memory operand. The bit
number is specified by 3-bit immediate data or the lower three bits of a
general register.
BTST B ∼(<bit-No.> of <EAd>) → Z
Tests a specified bit in a general register or memory operand and sets
or clears the Z flag accordingly. The bit number is specified by 3-bit
immediate data or the lower three bits of a general register.
BAND
BIAND
BOR
BIOR
Note: * Refers to the operand size.
B: Byte
B
B
B
B
C ∧ (<bit-No.> of <EAd>) → C
ANDs the carry flag with a specified bit in a general register or memory
operand and stores the result in the carry flag.
C ∧ ¬ (<bit-No.> of <EAd>) → C
ANDs the carry flag with the inverse of a specified bit in a general
register or memory operand and stores the result in the carry flag.
The bit number is specified by 3-bit immediate data.
C ∨ (<bit-No.> of <EAd>) → C
ORs the carry flag with a specified bit in a general register or memory
operand and stores the result in the carry flag.
C ∨∼(<bit-No.> of <EAd>) → C
ORs the carry flag with the inverse of a specified bit in a general register
or memory operand and stores the result in the carry flag.
The bit number is specified by 3-bit immediate data.
Section 2 CPU
Rev. 1.00 Sep. 16, 2005 Page 23 of 490
REJ09B0216-0100
Section 2 CPU
Table 2.6 Bit Manipulation Instructions (2)
Instruction Size* Function
BXOR
BIXOR
BLD
BILD
BST
BIST
Note: * Refers to the operand size.
B: Byte
B
B
B
B
B
B
C ⊕ (<bit-No.> of <EAd>) → C
XORs the carry flag with a specified bit in a general register or memory
operand and stores the result in the carry flag.
C ⊕ ∼(<bit-No.> of <EAd>) → C
XORs the carry flag with the inverse of a specified bit in a general
register or memory operand and stores the result in the carry flag.
The bit number is specified by 3-bit immediate data.
(<bit-No.> of <EAd>) → C
Transfers a specified bit in a general register or memory operand to the
carry flag.
∼(<bit-No.> of <EAd>) → C
Transfers the inverse of a specified bit in a general register or memory
operand to the carry flag.
The bit number is specified by 3-bit immediate data.
C → (<bit-No.> of <EAd>)
Transfers the carry flag value to a specified bit in a general register or
memory operand.
∼C → (<bit-No.> of <EAd>)
Transfers the inverse of the carry flag value to a specified bit in a
general register or memory operand.
The bit number is specified by 3-bit immediate data.
Rev. 1.00 Sep. 16, 2005 Page 24 of 490
REJ09B0216-0100
Section 2 CPU
Table 2.7 Branch Instructions
Instruction Size Function
Bcc* Branches to a specified address if a specified condition is true. The
branching conditions are listed below.
Mnemonic Description Condition
BRA(BT) Always (true) Always
BRN(BF) Never (false) Never
BHI High C ∨ Z = 0
BLS Low or same C ∨ Z = 1
BCC(BHS) Carry clear
(high or same)
BCS(BLO) Carry set (low) C = 1
BNE Not equal Z = 0
BEQ Equal Z = 1
BVC Overflow clear V = 0
BVS Overflow set V = 1
BPL Plus N = 0
BMI Minus N = 1
BGE Greater or equal N ⊕ V = 0
BLT Less than N ⊕ V = 1
BGT Greater than Z∨(N ⊕ V) = 0
BLE Less or equal Z∨(N ⊕ V) = 1
JMP Branches unconditionally to a specified address.
BSR Branches to a subroutine at a specified address.
JSR Branches to a subroutine at a specified address.
RTS Returns from a subroutine
Note: * Bcc is the general name for conditional branch instructions.
C = 0
Rev. 1.00 Sep. 16, 2005 Page 25 of 490
REJ09B0216-0100
Section 2 CPU
Table 2.8 System Control Instructions
Instruction Size* Function
TRAPA Starts trap-instruction exception handling.
RTE Returns from an exception-handling routine.
SLEEP Causes a transition to a power-down state.
LDC B/W (EAs) → CCR
Moves the source operand contents to the CCR. The CCR size is one
byte, but in transfer from memory, data is read by word access.
STC B/W CCR → (EAd)
Transfers the CCR contents to a destination location. The condition
code register size is one byte, but in transfer to memory, data is written
by word access.
ANDC B CCR ∧ #IMM → CCR
Logically ANDs the CCR with immediate data.
ORC B CCR ∨ #IMM → CCR
Logically ORs the CCR with immediate data.
XORC B CCR ⊕ #IMM → CCR
Logically XORs the CCR with immediate data.
NOP PC + 2 → PC
Only increments the program counter.
Note: * Refers to the operand size.
B: Byte
W: Word
Transfers a data block. Starting from the address set in ER5, transfers
data for the number of bytes set in R4L or R4 to the address location set
in ER6.
Execution of the next instruction begins as soon as the transfer is
completed.
Section 2 CPU
Rev. 1.00 Sep. 16, 2005 Page 27 of 490
REJ09B0216-0100
Section 2 CPU
2.4.2 Basic Instruction Formats
H8/300H CPU instructions consist of 2-byte (1-word) units. An instruction consists of an
operation field (op), a register field (r), an effective address extension (EA), and a condition field
(cc).
Figure 2.7 shows examples of instruction formats.
• Operation Field
Indicates the function of the instruction, the addressing mode, and the operation to be carried
out on the operand. The operation field always includes the first four bits of the instruction.
Some instructions have two operation fields.
• Register Field
Specifies a general register. Address registers are specified by 3 bits, and data registers by 3
bits or 4 bits. Some instructions have two regist er fiel ds. Some have no register field.
• Effective Address Extension
8, 16, or 32 bits specifying immediate data, an absolute address, or a displacement. A24-bit
address or displacement is treated as a 32-bit data in which the first 8 bits are 0 (H'00).
• Condition Field
Specifies the branching condition of Bcc instructions.
(1) Operation field only
op
(2) Operation field and register fields
op
(3) Operation field, register fields, and effective address extension
op
EA(disp)
(4) Operation field, effective address extension, and condition field
opccEA(disp)BRA d:8
rn
rnrm
rm
Figure 2.7 Instruction Formats
Rev. 1.00 Sep. 16, 2005 Page 28 of 490
REJ09B0216-0100
NOP, RTS, etc.
ADD.B Rn, Rm, etc.
MOV.B @(d:16, Rn), Rm
Section 2 CPU
2.5 Addressing Modes and Effective Address Calculation
The following describes the H8/300H CPU. In this LSI, the upper eight bits are ignored in the
generated 24-bit address, so the effective address is 16 bits.
2.5.1 Addressing Modes
The H8/300H CPU supports the eight addressing modes listed in table 2.10. Each instruction uses
a subset of these addressing modes. Addressing modes that can be used dif fer de pen din g on the
instruction. For details, refer to appendix A.4, Combinations of Instructions and Addressing
Modes.
Arithmetic and logic instructions can use the register direct and immediate modes. Data transfer
instructions can use all addressing modes except program-counter relative and memory indirect.
Bit-manipulation instructions use register direct, register indirect, or the absolute addressing mode
(@aa:8) to specify an operand, and register direct (BSET, BCLR, BNOT, and BTST instructions)
or immediate (3-bit) addressing mode to specify a bit number in the operand.
Table 2.10 Addressing Modes
No. Addressing Mode Symbol
1 Register direct Rn
2 Register indirect @ERn
3 Register indirect with displacement @(d:16,ERn)/@(d:24,ERn)
4 Register indirect with post-increment
Register indirect with pre-decrement
5 Absolute address @aa:8/@aa:16/@aa:24
6 Immediate #xx:8/#xx:16/#xx:32
7 Program-counter relative @(d:8,PC)/@(d:16,PC)
8 Memory indirect @@aa:8
Register DirectRn
@ERn+
@–ERn
The register field of the instruction specifies an 8-, 16-, or 32-bit general register containing the
operand. R0H to R7H and R0L to R7L can be specified as 8-bit registers. R0 to R7 and E0 to E7
can be specified as 16-bit registers. ER0 to ER7 can be specified as 32-bit registers.
Rev. 1.00 Sep. 16, 2005 Page 29 of 490
REJ09B0216-0100
Section 2 CPU
Register Indirect@ERn
The register field of the instruction code specifies an address register (ERn), the lower 24 bits of
which contain the address of the operand on memory.
Register Indirect with Displacement@(d:16, ERn) or @(d:24, ERn)
A 16-bit or 24-bit displacement contained in the instruction is added to an address register (ERn)
specified by the register field of the instruction, and the lower 24 bits of the sum the address of a
memory operand. A 16-bit displacement is sign-extended when added.
Register Indirect with Post-Increment or Pre-Decrement@ERn+ or @-ERn
• Register indirect with post-increment@ERn+
The register field of the instruction code specifies an address register (ERn) the lower 24 bits
of which contains the address of a memory operand. After the operand is accessed, 1, 2, or 4 is
added to the address register contents (32 bits) and the sum is stored in the address register.
The value added is 1 for byte access, 2 for word access, or 4 for longword access. For the word
or longword access, the register value should be even.
• Register indirect with pre-decrement@-ERn
The value 1, 2, or 4 is subtracted from an address register (ERn) specified by the register field
in the instruction code, and the lower 24 bits of the result is the address of a memory operand.
The result is also stored in the address register. The value subtracted is 1 for byte access, 2 for
word access, or 4 for longword access. For the word or longword access, the register value
should be even.
Absolute Address@aa:8, @aa:16, @aa:24
The instruction code contains the absolute address of a memory operand. The absolute address
may be 8 bits long (@aa:8), 16 bits long (@aa:16), 24 bi t s long (@aa: 2 4 )
For an 8-bit absolute address, the upper 16 bits are all assumed to be 1 (H'FFFF). For a 16-bit
absolute address the upper 8 bits are a sign extension. A 24-bit absolute address can access the
entire address space.
The access ranges of absolute addresses for the group of this LSI are those shown in table 2.11,
because the upper 8 bits are ignored.
Rev. 1.00 Sep. 16, 2005 Page 30 of 490
REJ09B0216-0100
Section 2 CPU
Table 2.11 Absolute Address Access Ranges
Absolute Address Access Range
8 bits (@aa:8) H'FF00 to H'FFFF
16 bits (@aa:16) H'0000 to H'FFFF
24 bits (@aa:24) H'0000 to H'FFFF
Immediate#xx:8, #xx:16, or #xx:32
The instruction contains 8-bit (#xx:8), 16-bit (#xx:16), or 32-bit (#xx:32) immediate data as an
operand.
The ADDS, SUBS, INC, and DEC instructions contain immediate data implicitly. Some bit
manipulation instructions contain 3-bit immediate data in the instruction code, specifying a bit
number. The TRAPA instruction contains 2-bit immediate data in its instruction code, specifying a
vector address.
Program-Counter Relative@(d:8, PC) or @(d:16, PC)
This mode is used in the BSR instruction. An 8-bit or 16-bit displacement contained in the
instruction is sign-extended and added to the 24-bit PC contents to generate a branch address. The
PC value to which the displacement is added is the address of the first byte of the next instruction,
so the possible branching range is –126 to +128 bytes (–63 to +64 words) or –32766 to +32768
bytes (–16383 to +16384 words) from the branch in struction. The resulting value should be an
even number.
Memory Indirect@@aa:8
This mode can be used by the JMP and JSR instructions. The instruction code contains an 8-bit
absolute address specifying a memory operand. This memory operand contains a branch address.
The memory operand is accessed by longword access. The first byte of the memory operand is
ignored, generating a 24-bit branch address. Figure 2.8 shows how to specify branch address for in
memory indirect mode. The upper bits of the absolute address are all assumed to be 0, so the
address range is 0 to 255 (H'0000 to H'00FF).
Note that the first part of the address range is also the exception vector area.
Rev. 1.00 Sep. 16, 2005 Page 31 of 490
REJ09B0216-0100
Section 2 CPU
Specified
Dummy
by @aa:8
Branch address
Figure 2.8 Branch Address Specification in Memory Indirect Mode
2.5.2 Effective Address Calculation
Table 2.12 indicates how effective addresses are calculated in each addressing mode. In this LSI
the upper 8 bits of the effective address are ignored in order to generate a 16-bit effective address.
Table 2.12 Effective Address Calculation (1)
No
Addressing Mode and Instruction FormatEffective Address CalculationEffective Address (EA)
1
Register direct(Rn)
op
2
Register indirect(@ERn)
op
Register indirect with displacement
3
@(d:16,ERn) or @(d:24,ERn)
p
o
rn
rm
r
r
disp
31
General register contents
31
General register contents
31
Sign extension
p
dis
Operand is general register contents.
0
0
0
23
23
0
0
Register indirect with post-increment or
4
pre-decrement
•Register indirect with post-increment @ERn+
p
o
r
•Register indirect with pre-decrement @-ERn
p
o
r
1
3
General register contents
1, 2, or 4
31
General register contents
1, 2, or 4
The value to be added or subtracted is 1 when the
operand is byte size, 2 for word size, and 4 for
longword size.
Register field
Operation field
Displacement
Immediate data
Absolute address
abs
abs
IMM
dis
23
Sign extension
23
Operand is immediate data.
23
PC contents
p
23
Sign
extension
23
H'0000
dis
5
1
Memory contents
0
0
p
7
8
0
abs
0
23
23
H'00
15
16
5
1
16
0
0
0
0
Rev. 1.00 Sep. 16, 2005 Page 33 of 490
REJ09B0216-0100
Section 2 CPU
2.6 Basic Bus Cycle
CPU operation is synchronized by a system clock (φ) or a subclock (φ
edge of φ or φ
to the next rising edge is called one state. A bus cycle consists of two states or
SUB
). The period from a rising
SUB
three states. The cycle differs depending on whether access is to on-chip memory or to on-chip
peripheral modules.
2.6.1 Access to On-Chip Memory (RAM, ROM)
Access to on-chip memory takes place in two states. The data bus width is 16 bits, allowing access
in byte or word size. Figure 2.9 shows the on-chip memory access cycle.
Bus cycle
T
state
2
Read data
ø or ø
SUB
Internal address bus
Internal read signal
Internal data bus
(read access)
Internal write signal
T1 state
Address
Internal data bus
(write access)
Figure 2.9 On-Chip Memory Access Cycle
Rev. 1.00 Sep. 16, 2005 Page 34 of 490
REJ09B0216-0100
Write data
Section 2 CPU
2.6.2 On-Chip Peripheral Modules
On-chip peripheral modules are accessed in two states or three states. The data bus width is 8 bits
or 16 bits depending on the register. For description on the data bus width and number of
accessing states of each register, refer to section 21.1, Register Addresses (Address Order).
Registers with 16-bit data bus width can be accessed by wor d size onl y. Regist ers wi t h 8- bi t data
bus width can be accessed by byte or word size. When a register with 8-bit data bus width is
accessed by word size, a bus cycle occurs twice. In two-state access, the operation timing is the
same as that for on-chip memory.
Figure 2.10 shows the operation timing in the case of three-state access to an on-chip peripheral
module.
There are four CPU states: the reset state, program execution state, program halt state, and
exception-handling state. The program execution state includes active mode and subactive mode.
For the program halt state, there are a sleep mode, standby mode, and sub-sleep mode. These
states are shown in figure 2.11. Figure 2.12 shows the state transitions. For details on program
execution state and program halt state, refer to section 6, Power-Down Modes. For details on
exception processing, refer to section 3, Exception Handling.
CPU stateReset state
The CPU is initialized
Program
execution state
Program halt state
A state in which some
or all of the chip
functions are stopped
to conserve power
The CPU executes successive program
instructions at high speed,
synchronized by the system clock
The CPU executes
successive program
instructions at reduced
speed, synchronized
by the subclock
Active
(high speed) mode
Subactive mode
Sleep mode
Standby mode
Subsleep mode
Power-down
modes
Exception-
handling state
A transient state in which the CPU changes
the processing flow due to a reset or an interrupt
Figure 2.11 CPU Operation States
Rev. 1.00 Sep. 16, 2005 Page 36 of 490
REJ09B0216-0100
Section 2 CPU
Reset state
Reset
occurs
Program halt state
Reset cleared
Reset occurs
Reset
occurs
SLEEP instruction executed
Exception-handling state
Interrupt
source
Interrupt
source
Program execution state
Exceptionhandling
complete
Figure 2.12 State Transitions
2.8 Usage Notes
2.8.1 Notes on Data Access to Empty Areas
The address space of this LSI includes empty areas in addition to the ROM, RAM, and on-chip
I/O registers areas available to the user. When data is transferred from CPU to empty areas, the
transferred data will be lost. This action may also cause the CPU to malfunction. When data is
transferred from an empty area to CPU, the contents of the data cannot be guaranteed.
2.8.2 EEPMOV Instruction
EEPMOV is a block-transfer instruction and transfers the byte size of data indicated by R4L,
which starts from the address indicated by R5, to the address indicated by R6. Set R4L and R6 so
that the end address of the destination address (value of R6 + R4L) does not exceed H'FFFF (the
value of R6 must not change from H'FFFF to H'0000 during execution).
2.8.3 Bit-Manipulation Instruction
The BSET, BCLR, BNOT, BST, and BIST instructions read data from the specified address in
byte units, manipulate the data of the target bit, and write data to the same address again in byte
units. Special care is required when using these instructions in cases where two registers are
assigned to the same address, or when a bit is directly manipulated for a port or a register
containing a write-only bit, because this may rewrite data of a bit other than the bit to be
manipulated.
Rev. 1.00 Sep. 16, 2005 Page 37 of 490
REJ09B0216-0100
Section 2 CPU
(1) Bit Manipulation for Two Registers Assigned to the Same Address
Example 1: Bit manipulation for the timer load register and timer counter
(Applicable for timer B1 in the H8/36077 Group.)
Figure 2.13 shows an example of a timer in which two timer registers are assigned to the same
address. When a bit-manipulation instruction accesses the timer load register and timer counter of
a reloadable timer, since these two registers share the same address, the following operations takes
place.
1. Data is read in byte units.
2. The CPU sets or resets the bit to be manipulated with the bit-manipulation instruction.
3. The written data is written again in byte units to the timer load register.
The timer is counting, so the value read is not necessarily the same as the value in the timer load
register. As a result, bits other than the intended bit in the timer counter may be modified and the
modified value may be written to the timer load register.
Count clockTimer counter
Reload
Timer load register
Read
Write
Internal data bus
Figure 2.13 Example of Timer Configuration with Two Registers Allocated to Same
Address
Example 2: The BSET instruction is executed for port 5.
P57 and P56 are input pins, with a low-level signal input at P57 and a high-level signal input at
P56. P55 to P50 are output pins and output low-level signals. An example to output a high-level
signal at P50 with a BSET instruction is shown below.
1. When the BSET instruction is executed, first the CPU reads port 5.
Since P57 and P56 are input pins, the CPU reads the pin states (low-level and high-level
input).
P55 to P50 are output pins, so the CPU reads the value in PDR5. In this example PDR5 has a
value of H'80, but the value read by the CPU is H'40.
2. Next, the CPU sets bit 0 of the read data to 1, changing the PDR5 data to H'41.
3. Finally, the CPU writes H'41 to PDR5, completing execution of BSET instruction.
As a result of the BSET instruction, bit 0 in PDR5 becomes 1, and P50 outputs a high-level
signal. However, bits 7 and 6 of PDR5 end up with different values. To prevent this problem,
store a copy of the PDR5 data in a work area in memory. Perform the bit manipulation on the
data in the work area, then write this data to PDR5.
(2) Bit manipulation in a register containing a write-only bit
Example 3: BCLR instruction executed designating port 5 control register PCR5
P57 and P56 are input pins, with a low-level signal input at P57 and a high-level signal input at
P56. P55 to P50 are output pins that output low-level signals. An example of setting the P50 pin as
an input pin by the BCLR instruction is shown below. It is assumed that a high-level signal will be
input to this input pin.
1. When the BCLR instruction is executed, first the CPU reads PCR5. Since PCR5 is a write-only
register, the CPU reads a value of H'FF, even though the PC R 5 value is act ual ly H' 3F .
2. Next, the CPU clears bit 0 in the read data to 0, changing the data to H'FE.
3. Finally, H'FE is written to PCR5 and BCLR instruction execution ends.
As a result of this operation, bit 0 in PCR5 becomes 0, making P50 an input port. However,
bits 7 and 6 in PCR5 change to 1, so that P57 and P56 change from input pins to output pins.
To prevent this problem, store a copy of the PDR5 data in a work area in memory and
manipulate data of the bit in the work area, then write this data to PDR5.
Exception handling may be caused by a reset, a trap instruction (TRAPA), or interrupts.
• Reset
A reset has the highest exception priority. Exception handling starts as soon as the reset is
cleared by the RES pin. The chip is also reset when the watchdog timer overf lows, and
exception handling starts. Exception handling is the same as exception handling by the RES
pin.
• Trap Instruction
Exception handling starts when a trap instruction (TRAPA) is executed. The TRAPA
instruction generates a vector address corresponding to a vector number from 0 to 3, as
specified in the instruction code. Exception handling can be executed at all times in the
program execution state, regardless of the setting of the I bit in CCR.
• Interrupts
External interrupts other than NMI and internal interrupts other than address break are masked
by the I bit in CCR, and kept masked while the I bit is set to 1. Exception handling starts when
the current instruction or exception handling ends, if an interrupt request has been issued.
Rev. 1.00 Sep. 16, 2005 Page 43 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.1 Exception Sources and Vector Address
Table 3.1 shows the vector addresses and priority of each exception handling. When more than
one interrupt is requested, handling is performed from the interrupt with the highest priority.
Table 3.1 Exception Sources and Vector Address
Relative Module Exception Sources
RES pin
Watchdog timer
Reserved for system use 1 to 6 H'0002 to H'000D
External interrupt
pin
CPU Trap instruction (#0) 8 H'0010 to H'0011
(#1) 9 H'0012 to H'0013
(#2) 10 H'0014 to H'0015
(#3) 11 H'0016 to H'0017
Address break Break conditions satisfied 12 H'0018 to H'0019
CPU Direct transition by executing
External interrupt
pin
IRQ1 15 H'001E to H'001F
IRQ2 16 H'0020 to H'0021
IRQ3 17 H'0022 to H'0023
WKP 18 H'0024 to H'0025
RTC Overflow 19 H'0026 to H'0027
Reserved for system use 20 H'0028 to H'0029
Timer V Timer V compare match A
SCI3 SCI3 receive data full
Reset 0 H'0000 to H'0001 High
NMI 7 H'000E to H'000F
the SLEEP instruction
IRQ0
Low-voltage detection interrupt
Timer V compare match B
Timer V overflow
SCI3 transmit data empty
SCI3 transmit end
SCI3 receive error
Vector
Number Vector Address Priority
13 H'001A to H'001B
14 H'001C to H'001D
22 H'002C to H'002D
23 H'002E to H'002F
Low
Rev. 1.00 Sep. 16, 2005 Page 44 of 490
REJ09B0216-0100
Section 3 Exception Handling
Relative Module Exception Sources
IIC2 Transmit data empty
Vector
Number Vector Address Priority
24 H'0030 to H'0031 High
Transmit end
Receive data full
Arbitration lost/Overrun error
NACK detection
Stop conditions detected
A/D converter A/D conversion end 25 H'0032 to H'0033
Timer Z Compare match/input capture
26 H'0034 to H'0035
A0 to D0
Timer Z overflow
Compare match/input capture
27 H'0036 to H'0037
A1 to D1
Timer Z overflow
Timer Z underflow
Timer B1 Timer B1 overflow 29 H'003A to H'003B
SCI3_2 Receive data full
32 H'0040 to H'0041
Transmit data empty
Transmit end
Receive error
Reserved for system use 33 H'0042 to H'0043
Clock source
switching
Clock source switching (from
external clock to on-chip
oscillator)
34 H'0044 to H'0045
Low
Note: * A low-voltage detection interrupt is enabled only in the product with an on-chip power-
on reset and low-voltage detection circuit.
Rev. 1.00 Sep. 16, 2005 Page 45 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.2 Register Descriptions
Interrupts are controlled by the following registers.
• Interrupt edge select register 1 (IEGR1)
• Interrupt edge select register 2 (IEGR2)
• Interrupt enable register 1 (IENR1)
• Interrupt enable register 2 (IENR2)
• Interrupt flag register 1 (IRR1)
• Interrupt flag register 2 (IRR2)
• Wakeup interrupt flag register (IWPR)
3.2.1 Interrupt Edge Select Register 1 (IEGR1)
IEGR1 selects the direction of an edge that generates interrupt requests of pins NMI and IRQ3 to
IRQ0.
Initial
Bit Bit Name
7 NMIEG 0 R/W NMI Edge Select
6 to 4 All 1 Reserved
3 IEG3 0 R/W IRQ3 Edge Select
2 IEG2 0 R/W IRQ2 Edge Select
1 IEG1 0 R/W IRQ1 Edge Select
0 IEG0 0 R/W IRQ0 Edge Select
Value R/W Description
0: Falling edge of NMI pin input is detected
1: Rising edge of NMI pin input is detected
These bits are always read as 1.
0: Falling edge of IRQ3 pin input is detected
1: Rising edge of IRQ3 pin input is detected
0: Falling edge of IRQ2 pin input is detected
1: Rising edge of IRQ2 pin input is detected
0: Falling edge of IRQ1 pin input is detected
1: Rising edge of IRQ1 pin input is detected
0: Falling edge of IRQ0 pin input is detected
1: Rising edge of IRQ0 pin input is detected
Rev. 1.00 Sep. 16, 2005 Page 46 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.2.2 Interrupt Edge Select Register 2 (IEGR2)
IEGR2 selects the direction of an edge that generates interrupt requests of the pins ADTRG and
WKP5 to WKP0.
Initial
Bit Bit Name
7, 6 All 1 Reserved
5 WPEG5 0 R/W WKP5 Edge Select
4 WPEG4 0 R/W WKP4 Edge Select
3 WPEG3 0 R/W WKP3 Edge Select
2 WPEG2 0 R/W WKP2 Edge Select
1 WPEG1 0 R/W WKP1Edge Select
0 WPEG0 0 R/W WKP0 Edge Select
Value R/W Description
These bits are always read as 1.
0: Falling edge of WKP5(ADTRG) pin input is detected
1: Rising edge of WKP5(ADTRG) pin input is detected
0: Falling edge of WKP4 pin input is detected
1: Rising edge of WKP4 pin input is detected
0: Falling edge of WKP3 pin input is detected
1: Rising edge of WKP3 pin input is detected
0: Falling edge of WKP2 pin input is detected
1: Rising edge of WKP2 pin input is detected
0: Falling edge of WKP1 pin input is detected
1: Rising edge of WKP1 pin input is detected
0: Falling edge of WKP0 pin input is detected
1: Rising edge of WKP0 pin input is detected
Rev. 1.00 Sep. 16, 2005 Page 47 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.2.3 Interrupt Enable Register 1 (IENR1)
IENR1 enables direct transition interrupts, RTC interrupts, and external pin interrupts.
Initial
Bit Bit Name
7 IENDT 0 R/W Direct Transfer Interrupt Enable
6 IENTA 0 R/W RTC Interrupt Enable
5 IENWP 0 R/W Wakeup Interrupt Enable
4 1 Reserved
3 IEN3 0 R/W IRQ3 Interrupt Enable
2 IEN2 0 R/W IRQ2 Interrupt Enable
1 IEN1 0 R/W IRQ1 Interrupt Enable
0 IEN0 0 R/W IRQ0 Interrupt Enable
Value R/W Description
When this bit is set to 1, direct transition interrupt
requests are enabled.
When this bit is set to 1, RTC interrupt requests are
enabled.
This bit is an enable bit, which is common to the pins
WKP5 to WKP0. When the bit is set to 1, interrupt
requests are enabled.
This bit is always read as 1.
When this bit is set to 1, interrupt requests of the IRQ3 pin
are enabled.
When this bit is set to 1, interrupt requests of the IRQ2 pin
are enabled.
When this bit is set to 1, interrupt requests of the IRQ1 pin
are enabled.
When this bit is set to 1, interrupt requests of the IRQ0 pin
are enabled.
When disabling interrupts by clearing bits in an interrupt enable register, or when clearing bits in
an interrupt flag register, always do so while interrupts are masked (I = 1). If the above clear
operations are performed while I = 0, and as a result a conflict arises between the clear instruction
and an interrupt request, exception handling for the interrupt will be executed after the clear
instruction has been executed.
Rev. 1.00 Sep. 16, 2005 Page 48 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.2.4 Interrupt Enable Register 2 (IENR2)
IENR2 enables, timer B1 overflow interrupts.
Initial
Bit Bit Name
7, 6 All 0 Reserved
5 IENTB1 0 R/W Timer B1 Interrupt Enable
4 to 0 All 1 Reserved
Value R/W Description
These bits are always read as 0.
When this bit is set to 1, timer B1 overflow interrupt
requests are enabled.
These bits are always read as 1.
When disabling interrupts by clearing bits in an interrupt enable register, or when clearing bits in
an interrupt flag register, always do so while interrupts are masked (I = 1). If the above clear
operations are performed while I = 0, and as a result a conflict arises between the clear instruction
and an interrupt request, exception handling for the interrupt will be executed after the clear
instruction has been executed.
3.2.5 Interrupt Flag Register 1 (IRR1)
IRR1 is a status flag register for direct transition interrupts, RTC interrupts, and IRQ3 to IRQ0
interrupt requests.
Initial
Bit Bit Name
7 IRRDT 0 R/W Direct Transfer Interrupt Request Flag
Rev. 1.00 Sep. 16, 2005 Page 49 of 490
REJ09B0216-0100
Value R/W Description
[Setting condition]
When a direct transfer is made by executing a SLEEP
instruction while DTON in SYSCR2 is set to 1.
[Clearing condition]
When IRRDT is cleared by writing 0
Section 3 Exception Handling
Initial
Bit Bit Name
Value R/W Description
6 IRRTA 0 R/W RTC Interrupt Request Flag
[Setting condition]
When the RTC counter value overflows
[Clearing condition]
When IRRTA is cleared by writing 0
5, 4 All 1 Reserved
These bits are always read as 1.
3 IRRI3 0 R/W IRQ3 Interrupt Request Flag
[Setting condition]
When IRQ3 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IRRI3 is cleared by writing 0
2 IRRI2 0 R/W IRQ2 Interrupt Request Flag
[Setting condition]
When IRQ2 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IRRI2 is cleared by writing 0
1 IRRI1 0 R/W IRQ1 Interrupt Request Flag
[Setting condition]
When IRQ1 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IRRI1 is cleared by writing 0
0 IRRl0 0 R/W IRQ0 Interrupt Request Flag
[Setting condition]
When IRQ0 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IRRI0 is cleared by writing 0
Rev. 1.00 Sep. 16, 2005 Page 50 of 490
REJ09B0216-0100
3.2.6 Interrupt Flag Register 2 (IRR2)
IRR2 is a status flag register for timer B1 overflow interrupts.
Initial
Bit Bit Name
7, 6 All 0 Reserved
5 IRRTB1 0 R/W Timer B1 Interrupt Request flag
4 to 0 All 1 Reserved
Value R/W Description
These bits are always read as 0.
[Setting condition]
When the timer B1 counter value overflows
[Clearing condition]
When IRRTB1 is cleared by writing 0
These bits are always read as 1.
3.2.7 Wakeup Interrupt Flag Register (IWPR)
IWPR is a status flag register for WKP5 to WKP0 interrupt requests.
Initial
Bit Bit Name
7, 6 All 1 Reserved
5 IWPF5 0 R/W WKP5 Interrupt Request Flag
4 IWPF4 0 R/W WKP4 Interrupt Request Flag
Value R/W Description
These bits are always read as 1.
[Setting condition]
When WKP5 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IWPF5 is cleared by writing 0.
[Setting condition]
When WKP4 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IWPF4 is cleared by writing 0.
Section 3 Exception Handling
Rev. 1.00 Sep. 16, 2005 Page 51 of 490
REJ09B0216-0100
Section 3 Exception Handling
Initial
Bit Bit Name
Value R/W Description
3 IWPF3 0 R/W WKP3 Interrupt Request Flag
[Setting condition]
When WKP3 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IWPF3 is cleared by writing 0.
2 IWPF2 0 R/W WKP2 Interrupt Request Flag
[Setting condition]
When WKP2 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IWPF2 is cleared by writing 0.
1 IWPF1 0 R/W WKP1 Interrupt Request Flag
[Setting condition]
When WKP1 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IWPF1 is cleared by writing 0.
0 IWPF0 0 R/W WKP0 Interrupt Request Flag
[Setting condition]
When WKP0 pin is designated for interrupt input and the
designated signal edge is detected.
[Clearing condition]
When IWPF0 is cleared by writing 0.
Rev. 1.00 Sep. 16, 2005 Page 52 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.3 Reset Exception Handling
When the RES pin goes low, all processing halts and this LSI enters the reset. The internal state of
the CPU and the registers of the on-chip peripheral modules are initialized by the reset. To ensure
that this LSI is reset at power-up, hold the RES pin low until the clock pulse generator output
stabilizes. To reset the chip during operation, hold the RES pin low for at least 10 system clock
cycles. When the RES pin goes high after being held low for the necessary time, this LSI starts
reset exception handling. The reset exception handling sequence is shown in figure 3.1. However,
for the reset exception handling sequence of the product with on-chip power-on reset circuit, refer
to section 19, Band-Gap Circuit, Power-On Reset, and Low-Voltage Detection Circuits.
The reset exception handling sequence is as follows:
1. Set the I bit in the condition code register (CCR) to 1.
2. The CPU generates a reset exception handling vector address (from H'0000 to H'0001), the
data in that address is sent to the program counter (PC) as the start address, and program
execution starts from that address.
Rev. 1.00 Sep. 16, 2005 Page 53 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.4 Interrupt Exception Handling
3.4.1 External Interrupts
As the external interrupts, there are NMI, IRQ3 to IRQ0, and WKP5 to WKP0 interrupts.
(1) NMI Interrupt
NMI interrupt is requested by input signal edge to pin NMI. This interrupt is detected by either
rising edge sensing or falling edge sensing, depending on the setting of bit NMIEG in IEGR1.
NMI is the highest-priority interrupt, and can always be accepted without depending on the I
bit value in CCR.
(2) IRQ3 to IRQ0 Interrupts
IRQ3 to IRQ0 interrupts are requested by input signals to pins IRQ3 to IRQ0. These four
interrupts are given different vector addresses, and are detected individually by either rising
edge sensing or falling edge sensing, depending on the settings of bits IEG3 to IEG0 in IEGR1.
When pins IRQ3 to IRQ0 are designated for interrupt input in PMR1 and the designated signal
edge is input, the corresponding bit in IRR1 is set to 1, requesting the CPU of an interrupt.
These interrupts can be masked by setting bits IEN3 to IEN0 in IENR1.
(3) WKP5 to WKP0 Interrupts
WKP5 to WKP0 interrupts are requested by input signals to pins WKP5 to WKP0. These six
interrupts have the same vector addresses, and are detected individually by either rising edge
sensing or falling edge sensing, depending on the settings of bits WPEG5 to WPEG0 in
IEGR2.
When pins WKP5 to WKP0 are designated for interrupt input in PMR5 and the designated
signal edge is input, the corresponding bit in IWPR is set to 1, requesting the CPU of an
interrupt. These interrupts can be masked by setting bit IENWP in IENR1.
Rev. 1.00 Sep. 16, 2005 Page 54 of 490
REJ09B0216-0100
RES
ø
Reset cleared
Vector fetch
Internal
processing
Section 3 Exception Handling
Initial program
instruction prefetch
Internal
address bus
Internal read
signal
Internal write
signal
Internal data
bus (16 bits)
(1) Reset exception handling vector address (H'0000)
(2) Program start address
(3) Initial program instruction
Figure 3.1 Reset Sequence
(2)(1)
(2)(3)
Rev. 1.00 Sep. 16, 2005 Page 55 of 490
REJ09B0216-0100
Section 3 Exception Handling
3.4.2 Internal Interrupts
Each on-chip peripheral module has a flag to show the interrupt request status and the enable bit to
enable or disable the interrupt. For RTC interrupt requests and direct transfer interrupt requests
generated by execution of a SLEEP instruction, this function is included in IRR1, IRR2, IENR1,
and IENR2.
When an on-chip peripheral module requests an interrupt, the corresponding interrupt request
status flag is set to 1, requesting the CPU of an interrupt. These interrupts can be masked by
writing 0 to clear the corresponding enable bit.
3.4.3 Interrupt Handling Sequence
Interrupts are controlled by an interrupt controller.
Interrupt operation is described as follows.
1. If an interrupt occurs while the NMI or interrupt enable bit is set to 1, an interrupt request
signal is sent to the interrupt controller.
2. When multiple interrupt requests are generated, the interrupt controller requests to the CPU for
the interrupt handling with the highest priority at that time according to table 3.1. Other
interrupt requests are held pending.
3. The CPU accepts the NMI and address break without dependi ng on the I bit value. Othe r
interrupt requests are accepted, if the I bit is cleared to 0 in CCR; if the I bit is set to 1, the
interrupt request is held pending.
4. If the CPU accepts the interrupt after processing of the current instruction is completed,
interrupt exception handling will begin. First, both PC and CCR are pushed onto the stack. The
state of the stack at this time is shown in figure 3.2. The PC value pushed onto the stack is the
address of the first instruction to be executed upon return from interrupt handling.
5. Then, the I bit of CCR is set to 1, masking further interrupts excluding the NMI and address
break. Upon return from interrupt handling, the values of I bit and other bits in CCR will be
restored and returned to the values prior to the start of interrupt exception handling.
6. Next, the CPU generates the vector address corresponding to the accepted interrupt, and
transfers the address to PC as a start address of the interrupt handling-routine. Then a program
starts executing from the address indicated in PC.
Figure 3.3 shows a typical interrupt sequence where the program area is in the on-chip ROM and
the stack area is in the on-chip RAM.
Rev. 1.00 Sep. 16, 2005 Page 56 of 490
REJ09B0216-0100
Section 3 Exception Handling
SP – 4
SP – 3
SP – 2
SP – 1
SP (R7)
[Legend]
:
Upper 8 bits of program counter (PC)
PC
H
PC
:
Lower 8 bits of program counter (PC)
L
CCR:
Condition code register
SP:
Stack pointer
1.2.PC shows the address of the first instruction to be executed upon return from the interrupt
Notes:
handling routine.
Register contents must always be saved and restored by word length, starting from
an even-numbered address.
3. Ignored when returning from the interrupt handling routine.
Stack area
Prior to start of interrupt
exception handling
SP (R7)
SP + 1
SP + 2
SP + 3
SP + 4
PC and CCR
saved to stack
CCR
*3
CCR
PCH
PCL
After completion of interrupt
exception handling
Even address
Figure 3.2 Stack Status after Exception Handling
3.4.4 Interrupt Response Time
Table 3.2 shows the number of wait states after an interrupt request flag is set until the first
instruction of the interrupt handling-routine is executed.
Table 3.2 Interrupt Wait States
Item States Total
Waiting time for completion of executing instruction*1 to 23 15 to 37
Saving of PC and CCR to stack 4
Vector fetch 2
Instruction fetch 4
Internal processing 4
Note: * Not including EEPMOV instruction.
Rev. 1.00 Sep. 16, 2005 Page 57 of 490
REJ09B0216-0100
Section 3 Exception Handling
Prefetch instruction of
interrupt-handling routine
Internal
processing
Vector fetch
Stack access
(9)
Internal
processing
(3)(9)(8)(6)(5)
Instruction
prefetch
Interrupt is
accepted
Interrupt level
decision and wait for
end of instruction
Interrupt
request signal
ø
(1)
Internal
address bus
Internal read
signal
Internal write
Figure 3.3 Interrupt Sequence
Rev. 1.00 Sep. 16, 2005 Page 58 of 490
REJ09B0216-0100
(4)(1)(7)(10)
(2)
signal
Internal data bus
(1) Instruction prefetch address (Instruction is not executed. Address is saved as PC contents, becoming return address.)
(2)(4) Instruction code (not executed)
(3) Instruction prefetch address (Instruction is not executed.)
(5) SP – 2
(6) SP – 4
(7) CCR
(8) Vector address
(9) Starting address of interrupt-handling routine (contents of vector)
(16 bits)
(10) First instruction of interrupt-handling routine
Section 3 Exception Handling
3.5 Usage Notes
3.5.1 Interrupts after Reset
If an interrupt is accepted after a reset and before the stack pointer (SP) is initialized, the PC and
CCR will not be saved correctly, leading to a program crash. To prevent this, all interrupt requests,
including NMI, are disabled immediately after a reset. Since the first instruction of a program is
always executed immediately after the reset state ends, make sure that this instruction initializes
the stack pointer (example: MOV.W #xx: 16, SP).
3.5.2 Notes on Stack Area Use
When word data is accessed, the least significant bit of the address is regarded as 0. Access to the
stack always takes place in word size, so the stack pointer (SP: R7) should never indicate an odd
address. Use PUSH Rn (MOV.W Rn, @–SP) or POP Rn (MOV.W @SP+, Rn) to save or restore
register values.
3.5.3 Notes on Rewriting Port Mode Registers
When a port mode register is rewritten to switch the functions of external interrupt pins, IRQ3 to
IRQ0, and WKP5 to WKP0, the interrupt request flag may be set to 1.
When switching a pin function, mask the interrupt before setting the bit in the port mode register.
After accessing the port mode register, execute at least one instruction (e.g., NOP), then clear the
interrupt request flag from 1 to 0.
Figure 3.4 shows a port mode register setting and interrupt request flag clearing procedure.
Interrupts masked. (Another possibility
CCR I bit 1
Set port mode register bit
Execute NOP instruction
Clear interrupt request flag to 0
CCR I bit 0
←
←
is to disable the relevant interrupt in
interrupt enable register 1.)
After setting the port mode register bit,
first execute at least one instruction
(e.g., NOP), then clear the interrupt
request flag to 0.
Interrupt mask cleared
Figure 3.4 Port Mode Register Setting and Interrupt Request Flag Clearing Procedure
Rev. 1.00 Sep. 16, 2005 Page 59 of 490
REJ09B0216-0100
Section 3 Exception Handling
Rev. 1.00 Sep. 16, 2005 Page 60 of 490
REJ09B0216-0100
Section 4 Address Break
Section 4 Address Break
The address break simplifies on-board program debugging. It requests an address break interrupt
when the set break condition is satisfied. The interrupt request is not affected by the I bit of CCR.
Break conditions that can be set include instruction execution at a specific address and a
combination of access and data at a specific address. With the address break function, the
execution start point of a program containing a bug is detected and execution is branched to the
correcting program. Figure 4.1 shows a block diagram of the address break.
Internal address bus
Comparator
BARHBARL
Interrupt
generation
control circuit
BDRHBDRL
Comparator
[Legend]
BARH, BARL: Break address registers
BDRH, BDRL: Break data registers
ABRKCR: Address break control register
ABRKSR: Address break status register
ABRKCR
ABRKSR
Figure 4.1 Block Diagram of Address Break
Internal data bus
Interrupt
ABK0001A_000020020200Rev. 1.00 Sep. 16, 2005 Page 61 of 490
REJ09B0216-0100
Section 4 Address Break
4.1 Register Descriptions
Address break has the following registers.
• Address break control register (ABRKCR)
• Address break status register (ABRKSR)
• Break address register (BARH, BARL)
• Break data register (BDRH, BDRL)
4.1.1 Address Break Control Register (ABRKCR)
ABRKCR sets address break conditions.
Initial
Bit Bit Name
7 RTINTE 1 R/W RTE Interrupt Enable
6
5
4
3
2
CSEL1
CSEL0 0 0
ACMP2
ACMP1
ACMP0
Value R/W Description
When this bit is 0, the interrupt immediately after
executing RTE is masked and then one instruction must
be executed. When this bit is 1, the interrupt is not
masked.
R/W
R/W
0
0
0
R/W
R/W
R/W
Condition Select 1 and 0
These bits set address break conditions.
00: Instruction execution cycle
01: CPU data read cycle
10: CPU data write cycle
11: CPU data read/write cycle
Address Compare Condition Select 2 to 0
These bits set the comparison condition between the
address set in BAR and the internal address bus.
000: Compares 16-bit addresses
001: Compares upper 12-bit addresses
010: Compares upper 8-bit addresses
011: Compares upper 4-bit addresses
1XX: Reserved (setting prohibited)
Rev. 1.00 Sep. 16, 2005 Page 62 of 490
REJ09B0216-0100
Section 4 Address Break
Initial
Bit Bit Name
1
0
[Legend] X: Don't care.
DCMP1
DCMP0 0 0
Value R/W Description
R/W
R/W
Data Compare Condition Select 1 and 0
These bits set the comparison condition between the data
set in BDR and the internal data bus.
00: No data comparison
01: Compares lower 8-bit data between BDRL and data
bus
10: Compares upper 8-bit data between BDRH and data
bus
11: Compares 16-bit data between BDR and data bus
When an address break is set in the data read cycle or data write cycle, the data bus used will
depend on the combination of the byte/word access and address. Table 4.1 shows the access and
data bus used. When an I/O register space with an 8-bit data bus width is accessed in word size, a
byte access is generated twice. For details on data widths of each register, see section 21.1,
Register Addresses (Address Order).
Table 4.1 Access and Data Bus Used
Word Access Byte Access
Even Address Odd Address Even Address Odd Address
ROM space Upper 8 bits Lower 8 bits Upper 8 bits Upper 8 bits
ABRKSR consists of the address break interrupt flag and the address break interrupt enable bit.
Initial
Bit Bit Name
7 ABIF 0 R/W Address Break Interrupt Flag
6 ABIE 0 R/W Address Break Interrupt Enable
5 to 0 All 1 Reserved
Value R/W Description
[Setting condition]
When the condition set in ABRKCR is satisfied
[Clearing condition]
When 0 is written after ABIF=1 is read
When this bit is 1, an address break interrupt request is
enabled.
These bits are always read as 1.
4.1.3 Break Address Registers (BARH, BARL)
BARH and BARL are 16-bit read/write registers that set the address for generating an address
break interrupt. When setting the address break condition to the instru ction execution cycle, set the
first byte address of the instruction. The initial value of this register is H'FFFF.
4.1.4 Break Data Registers (BDRH, BDRL)
BDRH and BDRL are 16-bit read/write registers that set the data for generating an address break
interrupt. BDRH is compared with the upper 8-bit data bus. BDRL is compared with the lower 8bit data bus. When memory or registers are accessed by byte, the upper 8-bit data bus is used for
even and odd addresses in the data transmission. Therefore, comparison data must be set in BDRH
for byte access. For word access, the data bus used depends on the address. See section 4.1.1,
Address Break Control Register (ABRKCR), for details. The initial value of this register is
undefined.
Rev. 1.00 Sep. 16, 2005 Page 64 of 490
REJ09B0216-0100
Section 4 Address Break
4.2 Operation
When the ABIF and ABIE bits in ABRKSR are set to 1, the address break function generates an
interrupt request to the CPU. The ABIF bit in ABRKSR is set to 1 by the combination of the
address set in BAR, the data set in BDR, and the conditions set in ABRKCR. When the interrupt
request is accepted, interrupt exception handling starts after the instruction being executed ends.
The address break interrupt is not masked by the I bit in CCR of the CPU.
Figures 4.2 show the operation examples of the address break interrupt setting.
When the address break is specified in instruction execution cycle
Register setting
• ABRKCR = H'80
• BAR = H'025A
NOP
instruc-
tion
prefetch
φ
Address
bus
Interrupt
request
0258
Program
0258
NOP
025A
*
NOP
025C
MOV.W @H'025A,R0
0260
NOP
0262
NOP
:
:
NOP
instruc-
prefetch
MOV
instruc-
tion
tion 1
prefetch
025A025C025ESP-2SP-4
Interrupt acceptance
MOV
instruc-
tion 2
prefetch
Underline indicates the address
to be stacked.
Internal
processing
Stack save
Figure 4.2 Address Break Interrupt Operation Example (1)
Rev. 1.00 Sep. 16, 2005 Page 65 of 490
REJ09B0216-0100
Section 4 Address Break
When the address break is specified in the data read cycle
Register setting
• ABRKCR = H'A0
• BAR = H'025A
Program
0258
025A
025C
*
0260
0262
:
NOP
NOP
MOV.W @H'025A,R0
NOP
NOP
:
Underline indicates the address
to be stacked.
φ
Address
bus
Interrupt
request
MOV
instruc-
tion 1
prefetch
025C
MOV
instruc-
tion 2
prefetch
NOP
instruc-
tion
prefetch
025E0260025A02620264SP-2
MOV
instruc-
tion
execution
tion
Next
instru-
ction
prefetch
NOP
instruc-
prefetch
Interrupt acceptance
Internal
processing
Figure 4.2 Address Break Interrupt Operation Example (2)
Stack
save
Rev. 1.00 Sep. 16, 2005 Page 66 of 490
REJ09B0216-0100
Section 5 Clock Pulse Generator
Section 5 Clock Pulse Generator
The clock pulse generator (CPG) consists of a system clock generating circuitry, a subclock
generating circuitry, and two prescalers. The system clock generating circuitry includes an
external clock oscillator, a duty correction circuit, an on-chip oscillator, an RC clock divider, a
clock select circuit, and a system clock divider. The subclock generating circuitry includes a
subclock oscillator, and a subclock divider. The CPG can function as a clock generating circuitry
itself or in combination with an external oscillator. Figure 5.1 shows a block diagram of the clock
pulse generator.
OSC1
OSC2
X
1
X
2
External
clock
oscillator
On-chip
oscillator
Subclock
oscillator
φ
φ
RC
System clock generating circuitry
Subclock generating circuitry
OSC
Duty
correction
circuit
RC clock
divider
φ
(fW)
φ
OSC
Clock
φ
RC
φ
/2
RC
φ
/4
RC
W
select
circuit
φ
RC
φ
Subclock
divider
System
clock
divider
φ
W
φ
W
φW/8
φ
φ/8
φ
φ/16
φ/32
SUB
φ/2
to
φ/8192
/8
φ
W
to
φ
/128
W
φ/64
/2
/4
Prescaler S
(13 bits)
φ
Prescaler W
(5 bits)
Figure 5.1 Block Diagram of Clock Pulse Generator
The system clock (φ) and subclock (φ
) are basic clocks on which the CPU and on-chip
SUB
peripheral modules operate. The system clock is divided into from φ/2 to φ/8192 by prescaler S.
The subclock is divided into from φ
/8 to φW/128 by prescaler W. These divided clocks are
W
supplied to respective peripheral modules.
CPG0200A_000020020200Rev. 1.00 Sep. 16, 2005 Page 67 of 490
REJ09B0216-0100
Section 5 Clock Pulse Generator
5.1 Features
• Choice of two clock sources
On-chip oscillator clock
Clock by an external oscillator output
• Choice of two types of RC oscillation frequency by the user software
16 MHz
20 MHz
• Frequency trimming
Since the initial frequency of the on-chip oscillator in the flash memory version is within the
range of two frequencies shown above, it is normally unnecessary to trim the frequency. It is,
however, still possible to adjust it by rewriting the trimming registers.
• Backup of the external oscillation halt
This system detects the external oscillator halt. If detected, the system clock source is
automatically switched to the on-chip oscillator clock.
• Interrupt can be requested to the CPU when the system clock is switched from the external
clock to the on-chip oscillator clock.
5.2 Register Descriptions
The CPG has the following registers.
• RC control register (RCCR)
• RC trimming data protect register (RCTRMDPR)
• RC trimming data register (RCTRMDR)
• Clock control/status register (CKCSR)
Rev. 1.00 Sep. 16, 2005 Page 68 of 490
REJ09B0216-0100
Section 5 Clock Pulse Generator
5.2.1 RC Control Register (RCCR)
RCCR controls the on-chip oscillator.
Initial
Bit Bit Name
7 RCSTP 0 R/W On-Chip Oscillator Standby
6 FSEL 1 R/W Frequency Select for On-chip Oscillator
5 VCLSEL 0 R/W Power Supply Select for On-chip Oscillator
4 to 2 All 0 Reserved
1
0
RCPSC1
RCPSC0 1 0
Value R/W Description
The on-chip oscillator standby state is entered by setting
this bit to 1.
0: 16 MHz
1: 20 MHz
0: Selects VBGR
1: Selects VCL
When the VCL power is selected, the accuracy of the onchip oscillator frequency cannot be guaranteed.
These bits are always read as 0.
R/W
R/W
Division Ratio Select for On-chip Oscillator
The division ratio of φ
bit.
These bits can be written to only when the CKSTA bit in
CKCSR is 0.
(not divided)
0X: φ
RC
/2
10: φ
RC
/4
11: φ
RC
changes right after rewriting this
RC
Rev. 1.00 Sep. 16, 2005 Page 69 of 490
REJ09B0216-0100
Section 5 Clock Pulse Generator
5.2.2 RC Trimming Data Protect Register (RCTRMDPR)
RCTRMDPR controls RCTRMDPR itself and writing to RCTRMDR. Use the MOV instruction to
rewrite this register. Bit manipulation instruction cannot change the settings.
Initial
Bit Bit Name
7 WRI 1 W Write Inhibit
6 PRWE 0 R/W Protect Information Write Enable
5 LOCKDW 0 R/W Trimming Data Register Lock Down
Value R/W Description
Only when writing 0 to this bit, this register can be written
to. This bit is always read as 1.
Bits 5 and 4 can be written to when this bit is set to 1.
[Setting condition]
• When writing 0 to the WRI bit and writing 1 to the
PRWE bit
[Clearing conditions]
• Reset
• When writing 0 to the WRI bit and writing 0 to the
PRWE bit
The RC trimming data register (RCTRMDR) cannot be
written to when this bit is set to 1. Once this bit is set to 1,
this register cannot be written to until a reset is input even
if 0 is written to this bit.
[Setting condition]
• When writing 0 to the WRI bit and writing 1 to the
LOCKDW bit while the PRWE bit is 1
[Clearing condition]
• Reset
Rev. 1.00 Sep. 16, 2005 Page 70 of 490
REJ09B0216-0100
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.