1. Hitachi neither warrants nor grants licenses of any rights of Hitachi’s or any third party’s
patent, copyright, trademark, or other intellectual property rights for information contained in
this document. Hitachi bears no responsibility for problems that may arise with third party’s
rights, including intellectual property rights, in connection with use of the information
contained in this document.
2. Products and product specifications may be subject to change without notice. Confirm that you
have received the latest product standards or specifications before final design, purchase or
use.
3. Hitachi makes every attempt to ensure that its products are of high quality and reliability.
However, contact Hitachi’s sales office before using the product in an application that
demands especially high quality and reliability or where its failure or malfunction may directly
threaten human life or cause risk of bodily injury, such as aerospace, aeronautics, nuclear
power, combustion control, transportation, traffic, safety equipment or medical equipment for
life support.
4. Design your application so that the product is used within the ranges guaranteed by Hitachi
particularly for maximum rating, operating supply voltage range, heat radiation characteristics,
installation conditions and other characteristics. Hitachi bears no responsibility for failure or
damage when used beyond the guaranteed ranges. Even within the guaranteed ranges,
consider normally foreseeable failure rates or failure modes in semiconductor devices and
employ systemic measures such as fail-safes, so that the equipment incorporating Hitachi
product does not cause bodily injury, fire or other consequential damage due to operation of
the Hitachi product.
5. This product is not designed to be radiation resistant.
6. No one is permitted to reproduce or duplicate, in any form, the whole or part of this document
without written approval from Hitachi.
7. Contact Hitachi’s sales office for any questions regarding this document or Hitachi
semiconductor products.
Page 3
Preface
The H8/3664 Series of single-chip microcomputers has the high-speed H8/300H CPU at its core,
with many necessary peripheral functions on-chip. The H8/300H CPU instruction set is
compatible with the H8/300 CPU.
The H8/3664 Series includes such peripheral functions as four timers, an I2C bus interface, a serial
communication interface, and a 10-bit A/D converter, so that they can be used as an embedded
microcomputer for a sophisticated control system.
This manual describes the hardware of the H8/3664 Series. For details on the H8/3664 Series
instruction set, refer to the H8/300H Series Programming Manual.
Notes:
When using an on-chip emulator (E10T) for H8/3664 program development and debugging, the
following restrictions must be noted.
1. The NMI pin is reserved for the E10T, and cannot be used.
2. Pins P85, P86, and P87 cannot be used. (In order to use these pins, additional hardware must
be provided on the user board.)
3. Area H'7000 to H'7FFF is used by the E10T, and is not available to the user.
4. Area H'F780 to H'FB7F must on no account be accessed.
5. When the E10T is used, address breaks can be set as available to the user, or for use by the
E10T. If address breaks are set as being used by the E10T, the address break control registers
must not be accessed.
6. When the E10T 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.
Page 4
Page 5
Main Revisions and Additions in this Edition
PageItemDescription
4Figure 1.1 Block DiagramTEST pin is amended to TEST pin
432.9.2 Notes on Bit ManipulationExample 1 description added
543.4.2 Interrupt Edge Select Register 2 (IEGR2)Bit 5 description amended
79Figure 5.9 Pin Connection when not Using
Subclock
88Table 6.3 Transition Mode after the SLEEP
Instruction Execution and Interrupt Handling
102Figure 7.4 User Program ModeFigure amended
1227.9 Flash Memory and Power-Down States
Table 7.10 Flash Memory Operating States
179Figure 11.2 Increment Timing with Internal ClockFigure amended
28114.5.1 Data Transfer Format1st line, reference figure No.
322Figure 15.5 I2C Bus TimingR/W is amended to R/W
322 to
324
324 to
326
15.3.2 Master Transmit Operation
Figure 15.6 Example of Master Transmit Mode
Operation Timing (MLS = WAIT = 0)
15.3.3 Master Receive Operation
Figure 15.7 Example of Master Receive Mode
Operation Timing (1) (NLS = ACKB = 0, WAIT = 1)
Figure amended
*1 description changed
Description amended
amended
Description changed
Figure amended
Description changed
Figure amended
Figure 15.7 Example of Master Receive Mode
Operation Timing (2) (NLS = ACKB = 0, WAIT = 1)
32615.3.4 Slave Receive OperationR/W is amended to R/W
327Figure 15.8 Example of Slave Receive Mode
Operation Timing (1) (MLS = ACKB = 0)
32815.3.5 Slave Transmit OperationDescription amended
329Figure 15.10 Example of Slave Transmit Mode
(Example)
333Figure 15.14 Flowchart for Master Receive Mode
(Example)
R/W is amended to R/W
R/W is amended to R/W
Flowchart changed
Flowchart changed
Page 6
PageItemDescription
339,
340
15.4 Usage Notes
• Notes on Start Condition Issuance for
Description added
Retransmission
Figure 15.17 Flowchart and Timing of Start
Condition Instruction Issuance for Retransmission
34816.2.3 A/D Control Register (ADCR)Bit 7 Note added
367Table 18.2 DC Characteristics (2)Conditions changed
370Table 18.4 I2C Bus Interface TimingSymbol in SCL and SDA output fall
time amended
372,
373
Table 18.6 A/D Converter CharacteristicsMin Value in AVcc amended
• Timer W: 16-bit timer
Counts any of four internal clock signals or external events
Maximum of four types of pulses can be input or output and processed
Output compare/input capture (4 output pins)
Output compare/input capture operation can be buffered
PWM mode can be set (maximum of three synchronous outputs)
• Watchdog timer: 8-bit timer
Reset signal generated by counter overflow
Operates independent from system clock by internal oscillation circuit
Serial
communication
interface
• Selectable between asynchronous mode or 8-bit clock synchronous mode
• Incorporate baud rate generator
• Multi-processor communication function (asynchronous)
2
Page 19
ItemDescription
2
C bus
I
interface
• Conforms to I
• Selectable between single master mode and slave mode
• Supports two slave addresses
2
C bus interface proposed by Philips Electronics
A/D converter
Package
• 10-bit resolution
• 8-channel analog input pins (selectable between single mode and scan mode)
• Conversion time: 7 µs
• Sample and hold function
CodeBody SizePin Pitch
QFP-64 (FP-64E)10.0 × 10.0 mm0.5 mm
QFP-64 (FP-64A)14.0 × 14.0 mm0.8 mm
SDIP-42 (DP-42S)14.0 × 37.3 mm1.78 mm
Note: DP-42S has no P11, P12, PB4/AN4, PB5/AN5, PB6/AN6, and PB7/AN7 pins.
Figure 1.3 Pin Arrangement (DP-42S)
6
Page 23
1.4Pin Functions
Table 1.2Pin Functions
TypeSymbol
Pin No.
FP-64E
FP-64ADP-42SI/OName and Functions
Power
source pins
V
CC
1214InputPower supply: All VCC pins should
be connected to the user system
V
.
CC
V
SS
911InputGround: All VSS pins should be
connected to the user system GND
(0 V).
AV
CC
35InputAnalog power supply: This is the
power supply pin for the A/D
converter. When the A/D converter
is not used, connect this pin to the
user system V
V
CL
68InputInternal step-down power supply:
CC
.
Connect a capacitor of around
0.1 µF between this pin and the V
SS
pin for stabilization.
Clock pinsOSC11113InputSystem clock: These pins connect
to a crystal or ceramic oscillator, or
can be used to input an external
clock.
OSC21012Output
See section 5, Clock Pulse
Generators, for a typical connection
diagram.
X157InputSubclock: These pins connect to a
X246Output
System
RES79InputReset: When this pin is driven low,
control
TEST810InputTest: This is a test pin, not for use
32.768-kHz crystal oscillator.
See section 5, Clock Pulse
Generators, for a typical connection
diagram.
the chip is reset.
in application systems. It should be
connected to V
SS
.
7
Page 24
TypeSymbol
Pin No.
FP-64E
FP-64ADP-42SI/OName and Functions
Interrupt
pins
NMI3527InputNon-maskable interrupt request
input pin
IRQ0 to
IRQ3
51 to 5439 to 42InputIRQ interrupt request 0 to 3:
These are input pins for edgesensitive external interrupts, with a
selection of rising or falling edge.
WKP0 to
WKP5
13, 14,
19 to 22
15 to 20InputWKP interrupt request 0 to 5:
These are input pins for edgesensitive external interrupts, with a
selection of rising or falling edge.
Timer ATMOW2321OutputClock output: This is an output pin
for waveforms generated by the
timer A output circuit.
Timer VTMOV3026OutputTimer V output: This is an output
pin for waveforms generated by the
timer V output compare function.
TMCIV2925InputTimer V event input: This is an
event input pin for input to the timer
V counter.
TMRIV2824InputTimer V counter reset: This is a
counter reset input pin for timer V.
TRGV5442InputTimer V counter trigger input:
This is a trigger input pin for the
timer V counter.
Timer WFTCI3628InputTimer W clock input: This is an
external clock input pin for input to
the timer X counter.
I2C bus
inerface
FTIOA to
FTIOD
SDA2622I/OI2C data I/O: Can directly drive a
37 to 4029 to 32I/OTimer W output compare A/input
capture/PWM output pin
bus by NMOS open-drain output.
SCL2723I/OI2C clock I/O: Can directly drive a
bus by NMOS open-drain output.
8
Page 25
TypeSymbol
Pin No.
FP-64E
FP-64ADP-42SI/OName and Functions
Serial communication
interface
(SCI)
TXD4638OutputSCI3 transmit data output: This is
the data output pin.
RXD4537InputSCI3 receive data input: This is
the data input pin.
SCK34436OutputSCI3 clock I/O: This is the clock
I/O pin.
A/D
converter
AN7 to AN055 to 621 to 4InputAnalog input channels 7 to 0:
These are analog data input
channels to the A/D converter.
ADTRG2220InputA/D converter trigger input: This
is the external trigger input pin to
the A/D converter.
I/O portsPB7 to PB055 to 621 to 4InputPort B: This is an 8-bit input port.
P17 to P14,
P12 to P10
51 to 54,
23 to 25
39 to 42,21I/OPort 1: This is a 7-bit I/O port.
P22 to P2044 to 4636 to 38I/OPort 2: This is a 3-bit I/O port.
P57 to P5013, 14,
19 to 22,
15 to 20,
22, 23
I/OPort 5: This is an 8-bit I/O port.
26, 27
P76 to P7428 to 3024 to 26I/OPort 7: This is a 3-bit I/O port.
P87 to P8036 to 4328 to 35I/OPort 8: This is an 8-bit I/O port.
OtherNCNon-connected pins: These pins
must be left unconnected.
9
Page 26
10
Page 27
Section 2 CPU
2.1Features
The H8/3664 Series has an H8/300H CPU with an internal 32-bit architecture that is upwardcompatible with the H8/300 CPU, and supports only normal mode, which has a 64-kbyte address
space.
The H8/300H CPU has the following features.
• Upward compatibility with H8/300 CPU
Can execute H8/300 Series 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 registers
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]
Register indirect 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, or @aa:24]
Immediate [#xx:8, #xx:16, or #xx:32]
Program-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 two to four states
Maximum clock frequency:16 MHz
8/16/32-bit register-register add/subtract:2 states
8 × 8-bit register-register multiply:14 states
16 ÷ 8-bit register-register divide:14 states
11
Page 28
16 × 16-bit register-register multiply:22 states
32 ÷ 16-bit register-register divide:22 states
• Low-power mode
Transition to low-power state by SLEEP instruction
2.2Address Space and Memory Map
The address space of the H8/3664 Series CPU is 64 kbytes, which includes the program area and
the data area.
Figures 2.1 and 2.2 show the memory map.
12
Page 29
H'0000
H'0033
H'0034
HD64F3664
(Flash memory version)
Interrupt vector
On-chip ROM
(32 kbytes)
H'0000
H'0033
H'0034
H'1FFF
HD6433660
(Mask ROM version)
Interrupt vector
On-chip ROM
(8 kbytes)
H'0000
H'0033
H'0034
H'2FFF
HD6433661
(Mask ROM version)
Interrupt vector
On-chip ROM
(12 kbytes)
H'7FFF
H'F780
H'FB7F
H'FB80
H'FF7F
H'FF80
H'FFFF
Not used
(1-kbyte work area
for flash memory
programming)
On-chip RAM
(2 kbytes)
(1-kbyte user area)
Internal I/O register
H'FD80
H'FF7F
H'FF80
H'FFFF
Not used
On-chip RAM
(512 bytes)
Internal I/O register
Not used
H'FD80
On-chip RAM
(512 bytes)
H'FF7F
H'FF80
Internal I/O register
H'FFFF
Figure 2.1 Memory Map (1)
13
Page 30
H'0000
H'0033
H'0034
HD6433662
(Mask ROM version)
Interrupt vector
On-chip ROM
(16 kbytes)
H'0000
H'0033
H'0034
HD6433663
(Mask ROM version)
Interrupt vector
On-chip ROM
(24 kbytes)
H'0000
H'0033
H'0034
HD6433664
(Mask ROM version)
Interrupt vector
H'3FFF
Not used
On-chip ROM
(32 kbytes)
H'5FFF
H'7FFF
Not used
Not used
H'FD80
On-chip RAM
(512 bytes)
H'FF7F
H'FF80
Internal I/O register
H'FFFF
14
H'FB80
On-chip RAM
(1 kbyte)
H'FF7F
H'FF80
Internal I/O register
H'FFFF
Figure 2.2 Memory Map (2)
H'FB80
On-chip RAM
(1 kbyte)
H'FF7F
H'FF80
Internal I/O register
H'FFFF
Page 31
2.3Register Configuration
The H8/300H CPU has the internal registers shown in figure 2.3. There are two types of registers:
general registers and control registers. Control registers are 24-bit program counter (PC) and 8-bit
condition code register (CCR).
General Registers (ERn)
0707015
ER0
ER1
ER2
ER3
ER4
ER5
ER6
ER7
Control Registers (CR)
Legend
SP:
PC:
CCR:
I:
UI:
H:
U:
N:
Z:
V:
C:
Stack pointer
Program counter
Condition code register
Interrupt mask bit
User bit or interrupt mask bit
Half-carry flag
User bit
Negative flag
Zero flag
Overflow flag
Carry flag
E0
E1
E2
E3
E4
E5
E6
E7
230
PC
(SP)
R0H
R1H
R2H
R3H
R4H
R5H
R6H
R7H
CCR
7
6543210
IUIHUNZVC
R0L
R1L
R2L
R3L
R4L
R5L
R6L
R7L
Figure 2.3 CPU Internal Registers
15
Page 32
2.3.1General Registers
The H8/300H CPU has eight 32-bit general registers. These general registers are all functionally
alike and can be used without distinction between data registers and address 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.
When the general registers are used as 32-bit registers or as 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 sixteen 16-bit
registers. The E registers (E0 to E7) are also referred to as extended registers.
The R registers divide into 8-bit general registers designated by the letters RH (R0H to R7H) and
RL (R0L to R7L). These registers are functionally equivalent, providing a maximum of sixteen 8bit registers.
Figure 2.4 illustrates the usage of the general registers. The usage of each register can be selected
independently.
• Address registers
• 32-bit registers• 16-bit registers• 8-bit registers
E registers
(extended registers)
E0 to E7
ER registers
ER0 to ER7
R registers
R0 to R7
RH registers
R0H to R7H
RL registers
R0L to R7L
Figure 2.4 Usage of General Registers
16
Page 33
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.5 shows the
stack.
Free area
SP (ER7)
Stack area
Figure 2.5 Relationship between Stack Pointer and Stack Area
2.3.2Program 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) or a multiple of 2 bytes, 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.3.3Condition Code Register (CCR)
This 8-bit register contains internal CPU status information, including the 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.
Bit 7—Interrupt Mask Bit (I): Masks interrupts other than NMI when set to 1. NMI is accepted
regardless of the I bit setting.
Bit 6—User Bit (UI): Can be written and read by software using the LDC, STC, ANDC, ORC,
and XORC instructions.
Bit 5—Half-Carry Flag (H): 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.
17
Page 34
Bit 4—User Bit (U): Can be written and read by software using the LDC, STC, ANDC, ORC, and
XORC instructions.
Bit 3—Negative Flag (N): Indicates the most significant bit (sign bit) of data.
Bit 2—Zero Flag (Z): Set to 1 to indicate zero data, and cleared to 0 to indicate non-zero data.
Bit 1—Overflow Flag (V): Set to 1 when an arithmetic overflow occurs, and cleared to 0 at other
times.
Bit 0—Carry Flag (C): 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 store the value shifted out of the end bit
The carry flag is also used as a bit accumulator by bit manipulation instructions.
Some instructions leave flag bits unchanged. Operations can be performed on CCR by the LDC,
STC, ANDC, ORC, and XORC instructions. The N, Z, V, and C flags are used by conditional
branch (Bcc) instructions.
For the action of each instruction on the flag bits, see appendix A.1, Instruction List.
18
Page 35
2.4Data 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 instructions treat byte data as two
digits of 4-bit BCD data.
2.4.1General Register Data Formats
Figures 2.6 and 2.7 show the data formats in general registers.
General
Data TypeData Format
1-bit data
1-bit data
Register
RnH
RnL
70
6543210
7
Don’t care
Don’t care
70
76543210
43
Lower digitUpper digit
Don’t care
Don’t care
Don’t care
7
70
MSBLSB
43
Lower digitUpper digit
Don’t care
0
4-bit BCD data
4-bit BCD data
Byte data
Byte data
70
RnH
RnL
70
RnH
MSBLSB
RnL
Figure 2.6 General Register Data Formats (1)
19
Page 36
Word data
General
RegisterData TypeData Format
150
Rn
MSBLSB
150
Word data
Longword data
Notation
ERn:
En:
Rn:
RnH:
RnL:
MSB:
LSB:
General register
General register E
General register R
General register RH
General register RL
Most significant bit
Least significant bit
En
ERn
MSBLSB
3116
MSB
150
Figure 2.7 General Register Data Formats (2)
LSB
20
Page 37
2.4.2Memory Data Formats
Figure 2.8 shows the data formats on memory. The H8/300H CPU can access word data and
longword data on memory, but 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, no address error occurs but the least
significant bit of the address is regarded as 0, so the access starts at the preceding address. This
also applies to instruction fetches.
When ER7 (SP) is used as an address register to access the stack, the operand size should be word
size or longword size.
AddressData TypeData Format
70
1-bit data
Byte data
Word data
Longword data
Address L
Address 2M
Address 2M + 1
Address 2N
Address 2N + 1
76543210Address L
MSBLSB
MSB
LSB
MSB
Address 2N + 2
Address 2N + 3
LSB
Figure 2.8 Memory Data Formats
21
Page 38
2.5Instruction Set
2.5.1Instruction Set Overview
The H8/300H CPU has 62 types of instructions. Tables 2.1 to 2.8 summarize the instructions in
each functional category. The operation notation used in these tables is defined next.
Operation Notation
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 of CCR
Z Z (zero) flag of CCR
V V (overflow) flag of CCR
C C (carry) flag of CCR
PC Program counter
SP Stack pointer
#IMM Immediate data
disp Displacement
+ Addition
– Subtraction
× Multiplication÷ Division
∧ AND logical
∨ OR logical
⊕ Exclusive OR logical
→ Move¬ NOT (logical complement)
:3/:8/:16/:24 3-, 8-, 16-, or 24-bit length
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 data or address registers (ER0 to ER7).
22
Page 39
Table 2.1Data 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 the H8/3664 Series.
MOVTPE B Rs → (EAs)
Cannot be used in the H8/3664 Series.
POP W/L @SP+ → Rn
Pops a general register from the stack. POP.W Rn is identical to
MOV.W @SP+, Rn. Similarly, 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. Similarly, PUSH.L ERn is identical to MOV.L
ERn, @–SP.
Note: *Size refers to the operand size.
B: Byte
W: Word
L:Longword
23
Page 40
Table 2.2Arithmetic Operation Instructions
Instruction Size* Function
ADD, SUB 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 data in a general register. Use the
SUBX or ADD instruction.)
ADDX, SUBX B Rd ± Rs ± C → Rd, Rd ± #IMM ± C → Rd
Performs addition or subtraction with carry or borrow on data in two
general registers, or on immediate data and data in a general
register.
INC, DEC 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.)
Adds or subtracts the value 1, 2, or 4 to or from data in a 32-bit
register.
DAA, DAS B Rd decimal adjust → Rd
Decimal-adjusts an addition or subtraction result in a general register
by referring to CCR to produce 4-bit BCD data.
MULXU B/W Rd × Rs → Rd
Performs unsigned multiplication on data in two general registers:
either 8 bits × 8 bits → 16 bits or 16 bits × 16 bits → 32 bits.
MULXS B/W Rd × Rs → Rd
Performs signed multiplication on data in two general registers:
either 8 bits × 8 bits → 16 bits or 16 bits × 16 bits → 32 bits.
DIVXU B/W Rd ÷ Rs → Rd
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.
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 according to the
result.
24
Page 41
Instruction Size* Function
NEG B/W/L 0 – Rd → Rd
Takes the two’s complement (arithmetic complement) of data in a
general register.
EXTS W/L Rd (sign extension) → Rd
Extends byte data in the lower 8 bits of a 16-bit register to word data,
or extends word data in the lower 16 bits of a 32-bit register to
longword data, by extending the sign bit.
EXTU W/L Rd (zero extension) → Rd
Extends byte data in the lower 8 bits of a 16-bit register to word data,
or extends word data in the lower 16 bits of a 32-bit register to
longword data, by padding with zeros.
Note: *Size refers to the operand size.
B: Byte
W: Word
L:Longword
25
Page 42
Table 2.3Logic Operation 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 of general register contents.
Note: *Size refers to the operand size.
B: Byte
W: Word
L:Longword
Table 2.4Shift Instructions
Instruction Size* Function
SHAL,
SHAR
SHLL,
SHLR
ROTL,
ROTR
ROTXL,
ROTXR
Note: *Size refers to the operand size.
B: Byte
W: Word
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 bit.
L:Longword
26
Page 43
Table 2.5Bit Manipulation Instructions
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 3
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 3
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 3 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 3 bits of a general register.
BAND 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.
BIAND B 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.
BOR B 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.
BIOR B 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.
27
Page 44
Instruction Size* Function
BXOR B C ⊕ (<bit-No.> of <EAd>) → C
Exclusive-ORs the carry flag with a specified bit in a general register
or memory operand and stores the result in the carry flag.
BIXOR B C ⊕ [¬ (<bit-No.> of <EAd>)] → C
Exclusive-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.
BLD B (<bit-No.> of <EAd>) → C
Transfers a specified bit in a general register or memory operand to
the carry flag.
BILD B ¬ (<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.
BST B C → (<bit-No.> of <EAd>)
Transfers the carry flag value to a specified bit in a general register
or memory operand.
BIST B 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.
Note: *Size refers to the operand size.
B: Byte
28
Page 45
Table 2.6Branching Instructions
Instruction Size Function
Bcc*— Branches to a specified address if a specified condition is true. The
branching conditions are listed below.
MnemonicDescriptionCondition
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) C = 0
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: *Conditional branch instructions are generally called the Bcc instructions.
29
Page 46
Table 2.7System Control Instructions
Instruction Size* Function
TRAPA— Starts trap-instruction exception handling
RTE— Returns from an exception-handling routine
SLEEP— Causes a transition to the power-down state
LDC B/W (EAs) → CCR
Moves the source operand contents to the condition code register.
The condition code register 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 condition code register with immediate data.
ORC B CCR ∨ #IMM → CCR
Logically ORs the condition code register with immediate data.
XORC B CCR ⊕ #IMM → CCR
Logically exclusive-ORs the condition code register with immediate
data.
NOP— PC + 2 → PC
Only increments the program counter.
Note: *Size refers to the operand size.
B: Byte
W: Word
30
Page 47
Table 2.8Block Transfer Instruction
Instruction Size Function
EEPMOV.B— if R4L ≠ 0 then
repeat@ER5+ → @ER6+, R4L – 1 → R4L
untilR4L = 0
else next;
EEPMOV.W— if R4 ≠ 0 then
repeat@ER5+ → @ER6+, R4 – 1 → R4
untilR4 = 0
else next;
Transfers a data block according to parameters set in general
registers R4L or R4, ER5, and ER6.
R4L or R4: Size of block (bytes)
Execution of the next instruction begins as soon as the transfer is
completed.
31
Page 48
2.5.2Basic Instruction Formats
The H8/300H instructions consist of 2-byte (1-word) units. An instruction consists of an operation
field (OP field), a register field (r field), an effective address extension (EA field), and a condition
field (cc field).
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 4 bits of the
instruction. Some instructions have two operation fields.
Register Field: Specifies a general register. Address registers are specified by 3 bits, data registers
by 3 bits or 4 bits. Some instructions have two register fields. Some have no register field.
Effective Address Extension: 8, 16, or 32 bits specifying immediate data, an absolute address, or
a displacement. A 24-bit address or displacement is treated as 32-bit data in which the first 8 bits
are 0 (H'00).
Condition Field: Specifies the branching condition of Bcc instructions.
Figure 2.9 shows examples of instruction formats.
Operation field only
op
Operation field and register fields
oprnrm
Operation field, register fields, and effective address extension
oprnrm
EA (disp)
Operation field, effective address extension, and condition field
opccEA (disp)
NOP, RTS, etc.
ADD.B Rn, Rm, etc.
MOV.B @(d:16, Rn), Rm
BRA d:8
32
Figure 2.9 Instruction Formats
Page 49
2.6Addressing Modes and Effective Address Calculation
The following describes the H8/300H CPU. In the H8/3664 Series, the upper eight bits are ignored
in the generated 24-bit address, so the effective address is 16 bits.
2.6.1Addressing Modes
The H8/300H CPU supports the eight addressing modes listed in table 2.9. Each instruction uses a
subset of these addressing modes. Addressing modes that can be used differ depending on the
instruction. For details, refer to appendix A, CPU Instruction Set. 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 absolute (@aa:8) addressing mode 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.9Addressing 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
1 Register Direct—Rn: The register field of the instruction code specifies an 8-, 16-, or 32-bit
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.
2 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.
3 Register Indirect with Displacement—@(d:16, ERn) or @(d:24, ERn): A 16-bit or 24-bit
displacement contained in the instruction code is added to the contents of an address register
(ERn) specified by the register field of the instruction, and the lower 24 bits of the sum specify the
address of a memory operand. A 16-bit displacement is sign-extended when added.
4 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 contain 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 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 become 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 word or longword access, the resulting
register value should be even.
5 Absolute Address—@aa:8, @aa:16, or @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), or 24 bits long (@aa:24). 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. Table 2.10 indicates the accessible
address ranges.
Table 2.10Absolute Address Access Ranges
Absolute AddressAccess 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
34
Page 51
6 Immediate—#xx:8, #xx:16, or #xx:32: The instruction code contains 8-bit (#xx:8), 16-bit
(#xx:16), or 32-bit (#xx:32) immediate data as an operand.
The instruction codes of the ADDS, SUBS, INC, and DEC instructions contain immediate data
implicitly. The instruction codes of some bit manipulation instructions contain 3-bit immediate
data specifying a bit number. The TRAPA instruction code contains 2-bit immediate data
specifying a vector address.
7 Program-Counter Relative—@(d:8, PC) or @(d:16, PC): This mode is used in the Bcc and
BSR instructions. An 8-bit or 16-bit displacement contained in the instruction code is signextended to 24 bits and added to the 24-bit PC contents to generate a 24-bit 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 instruction. The resulting value should be an
even number.
8 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. See figure 2.10. The
upper bits of the 8-bit absolute address are assumed to be 0 (H'0000), so the address range is 0 to
255 (H'0000 to H'00FF). Note that the first part of this range is also the exception vector area.
Table 2.11 explains how an effective address (EA) is calculated in each addressing mode. In the
H8/3664 Series, the upper 8 bits of the calculated address are ignored in order to generate a 16-bit
effective address.
35
Page 52
Table 2.11Effective Address Calculation
No.
Addressing Mode and
Instruction Format
Effective Address
CalculationEffective Address
1Register direct (Rn)
oprm rn
2Register indirect (@ERn)
rop
3Register indirect with displacement
@(d:16, ERn)/@(d:24, ERn)
opr
disp
310
General register contents
310
General register contents
Operand is general
register contents
23
230
0
Sign extensiondisp
4Register indirect with post-increment
or pre-decrement
Register indirect with post-increment
@ERn+
310
op
r
Register indirect with pre-decrement
@–ERn
310
General register contents
1, 2, or 4
General register contents
23
230
0
op
r
36
1, 2, or 4
1 for a byte operand, 2 for a word
operand, 4 for a longword operand
Page 53
Addressing Mode and
No.
Instruction Format
5Absolute address
@aa:8
Effective Address
CalculationEffective Address
@aa:8
opabs
@aa:16
op
@aa:24
op
6Immediate
#xx:8, #xx:16, or #xx:32
abs
abs
23
H'FFFF
23
Sign
exten-
sion
23
08 7
016 15
0
Operand is immediate
data
op
IMM
7Program-counter relative
@(d:8, PC) or @(d:16, PC)
opdisp
23
Sign
exten-
sion
PC contents
disp
0
23
0
37
Page 54
Addressing Mode and
No.
Instruction Format
8Memory indirect @@aa:8
opabs
Effective Address
CalculationEffective Address
238 7
H'0000
15
Memory
contents
abs
0
0
0
H'00
Legend:
r, rm, rn: Register field
op:Operation field
disp:Displacement
IMM:Immediate data
abs:Absolute address
Note:In the H8/3664 Series, the upper 8 bits of the calculation result are ignored.
016 1523
38
Page 55
2.7Basic Bus Cycle
CPU operation is synchronized by a system clock (ø) or a subclock (ø
clock signals see section 4, Clock Pulse Generators. The period from a rising edge of ø or ø
). For details on these
SUB
SUB
to
the next rising edge is called one state. A bus cycle consists of two states or three states. The cycle
differs depending on whether access is to on-chip memory or to on-chip peripheral modules.
2.7.1Access 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.11 shows the on-chip memory access cycle.
Bus cycle
ø or ø
T1 state
SUB
T2 state
Internal address bus
Internal read signal
Internal data bus
(read access)
Internal write signal
Internal data bus
(write access)
Figure 2.11 On-Chip Memory Access Cycle
Address
Read data
Write data
39
Page 56
2.7.2Access to 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 of each register, refer to
appendix B, Internal I/O Registers. Registers with 16-bit data bus width can be accessed by word
size only. Registers with 8-bit 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, access is completed in two cycles. In
two-state access, the operation timing is the same as that for on-chip memory.
Figure 2.12 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.
In the program halt state there are a sleep mode, standby mode, and sub-sleep mode. These states
are shown in figure 2.13. Figure 2.14 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
(high speed) mode
The CPU executes successive program
instructions at high speed,
synchronized by the system clock
Active
Subactive mode
The CPU executes
successive program
instructions at reduced
speed, synchronized
by the subclock
Program halt state
A state in which some
or all of the chip
functions are stopped
to conserve power
Exception-
handling state
A transient state in which the CPU changes
the processing flow due to a reset or an interrupt
Sleep mode
Standby mode
Subsleep mode
Power-down
modes
Note: See section 6, Power-Down Modes, for details on the modes and their transitions.
Figure 2.13 CPU Operation States
41
Page 58
Reset state
Reset cleared
Exception-handling state
Reset occurs
Reset
occurs
Program halt state
Reset
occurs
SLEEP instruction executed
Interrupt
source
Program execution state
Interrupt
source
Exceptionhandling
complete
Figure 2.14 State Transitions
2.9Application Notes
2.9.1Notes on Data Access to Empty Areas
The address space of the H8/3664 Series CPU includes empty areas in addition to the RAM,
registers, and ROM areas available to the user. If these empty areas are mistakenly accessed by an
application program, the following results will occur.
• Data transfer from CPU to empty area
The transferred data will be lost. This action may also cause the CPU to misoperate.
• Data transfer from empty area to CPU
Unpredictable data is transferred.
42
Page 59
2.9.2Notes on Bit Manipulation
The BSET, BCLR, BNOT, BST, and BIST instructions read one byte of data, modify the data,
then write the data byte again. Special care is required when using these instructions in cases
where two registers are assigned to the same address, in the case of registers that include writeonly bits, and when the instruction accesses an I/O port.
Order of OperationOperation
1ReadRead byte data at the designated address
2ModifyModify a designated bit in the read data
3WriteWrite the altered byte data to the designated address
Bit Manipulation in Two Registers Assigned to the Same Address
Example 1: Timer load register and timer counter (This applies to timers B and C. It does not
apply to the H8/3664 Series.)
Figure 2.15 shows an example in which two timer registers share 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 take place.
Order of OperationOperation
1ReadTimer counter data is read (one byte)
2ModifyThe CPU modifies (sets or resets) the designated bit in the instruction
3WriteThe altered byte data is written to the timer load register
The timer counter 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 load register may be
modified to the timer counter value.
R
Count clockTimer counter
Figure 2.15 Timer Configuration Example
Reload
Timer load register
R:W:Read
Write
W
Internal bus
43
Page 60
Example 2: BSET instruction executed designating port 5
P57 and P56 are designated as input pins, with a low-level signal input at P57 and a high-level
signal input at P56. The remaining pins, P55 to P50, are output pins and output low-level signals. In
this example, the BSET instruction is used to change pin P50 to high-level output.
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.
Next, the CPU sets bit 0 of the read data to 1, changing the PDR5 data to H'41. Finally, the CPU
writes this value (H'41) to PDR5, completing execution of BSET.
As a result of this operation, 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.
44
Page 61
To avoid 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.
[A: Prior to executing BSET]
MOV.B #80, R0L
MOV.B R0L, @RAM0
The PDR5 value (H'80) is written to a work area in
memory (RAM0) as well as to PDR5.
Bit Manipulation in a Register Containing a Write-Only Bit
Example 3: BCLR instruction executed designating port 5 control register PCR5
As in the examples above, P57 and P56 are input pins, with a low-level signal input at P57 and a
high-level signal input at P56. The remaining pins, P55 to P50, are output pins that output low-level
signals. In this example, the BCLR instruction is used to change pin P50 to an input port. It is
assumed that a high-level signal will be input to this input pin.
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 PCR5 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 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.
46
Page 63
To avoid this problem, store a copy of the PCR5 data in a work area in memory. Perform the bit
manipulation on the data in the work area, then write this data to PCR5.
[A: Prior to executing BCLR]
MOV.B #3F, R0L
MOV.B R0L, @RAM0
The PCR5 value (H'3F) is written to a work area in
memory (RAM0) as well as to PCR5.
• The EEPMOV instruction is a block data transfer instruction. It moves the number of bytes
specified by R4L from the address specified by R5 to the address specified by R6.
→
R5
←
R6
R5 + R4L
→
←
R6 + R4L
• When setting R4L and R6, make sure that the final destination address (R6 + R4L) does not
exceed H'FFFF. The value in R6 must not change from H'FFFF to H'0000 during execution of
the instruction.
→
R5
R5 + R4L
→
H'FFFF
Not allowed
←
R6
←
R6 + R4L
48
Page 65
Section 3 Exception Handling
3.1Overview
3.1.1Exception Handling Types
Exception handling is performed in the H8/3664 Series when a reset, interrupt, or trap instruction
occurs. Table 3.1 shows these three types of exception handling. A trap instruction can always be
accepted when the program is being executed.
Table 3.1Exception Handling Types
Exception SourceTime of Start of Exception Handling
ResetException handling starts as soon as the reset state is cleared
InterruptWhen an interrupt is requested, exception handling starts after the present
instruction or the exception handling in progress is completed
Trap instructionExecution handling starts up when a TRAP instruction is executed
3.2Reset
As soon as the RES pin is set to low, all processing is stopped and the chip enters the reset state.
The internal state of the CPU and the registers of the on-chip peripheral modules are initialized by
the reset. To make sure the chip is reset properly, when turning the power on, the RES pin should
be held at low until the clock pulse generator output stabilizes. When resetting during operation,
the RES pin should be held at low for at least 10 system clock cycles. Reset exception handling
begins when the RES pin is held at low for a given period, then returned to the high level.
3.2.1Reset Sequence
A reset is the highest-priority exception handling. The sequence of the reset exception handling
takes place as follows.
1. Set the I bit of the condition code register (CCR).
2. The CPU generates the reset exception handling vector address (H'0000 to H'0001), and
transfers the address to PC as a start address. Then a program starts executing from the
address indicated in PC. Figure 3.1 shows the reset sequence.
49
Page 66
3.2.2Reset by Watchdog Timer
When the watchdog timer overflows, the chip enters the reset state and reset exception handling
begins. The same reset exception handling is carried out as for input at the RES pin. For details on
the watchdog timer, see section 13, Watchdog Timer.
3.2.3Interrupt Immediately after Reset
After a reset, if the CPU was to accept an interrupt before the stack pointer (SP) was initialized,
PC and CCR would not be pushed onto the stack correctly, resulting in control over the program
being lost. To prevent this, immediately after reset exception handling all interrupts including
NMI are masked. For this reason, the initial program instruction is always executed immediately
after a reset. This instruction should initialize the stack pointer (e.g. MOV.W #xx: 16, SP).
Reset cleared
Initial program
Vector fetch
Internal
processing
instruction prefetch
RES
ø
Internal
address bus
Internal read
signal
Internal write
signal
Internal data
bus (16 bits)
(1)
(2)(3)
(2)
(1) Reset exception handling vector address (H'0000)
(2) Program start address
(3) Initial program instruction
50
Figure 3.1 Reset Sequence
Page 67
3.3Interrupts
3.3.1Interrupt and Vector Address
The interrupt sources that start the interrupt exception handling include 11 external interrupts and
20 internal interrupts. Table 3.2 shows the interrupts, their priorities, and their vector addresses.
When more than one interrupt is requested, handling is performed from the interrupt with the
highest priority.
NMI is the highest-priority interrupt, and cannot be masked by the I bit in CCR. All other external
interrupts excluding NMI and internal interrupts excluding address break are masked by the I bit
in CCR, and kept masked while the I bit is set to 1.
Table 3.2Interrupt Priorities and Their Vector Addresses
IEGR1 is an 8-bit read/write register used to designate whether pins NMI and IRQ3 to IRQ0 are
set to rising edge sensing or falling edge sensing. Upon reset, IEGR1 is initialized to H'70.
Bit 7—NMI Edge Select (NMIEG): Bit 7 selects the input sensing of pin NMI.
Bit 7: NMIEGDescription
0Falling edge of NMI pin input is detected(initial value)
1Rising edge of NMI pin input is detected
Bits 6 to 4—Reserved Bits: Bits 6 to 4 are reserved; they are always read as 1, and cannot be
modified.
Bit 3—IRQ3 Edge Select (IEG3): Bit 3 selects the input sensing of pin IRQ3.
Bit 3: IEG3Description
0Falling edge of IRQ3 pin input is detected(initial value)
1Rising edge of IRQ3 pin input is detected
53
Page 70
Bit 2—IRQ2 Edge Select (IEG2): Bit 2 selects the input sensing of pin IRQ2.
Bit 2: IEG2Description
0Falling edge of IRQ2 pin input is detected(initial value)
1Rising edge of IRQ2 pin input is detected
Bit 1—IRQ1 Edge Select (IEG1): Bit 1 selects the input sensing of pin IRQ1.
Bit 1: IEG1Description
0Falling edge of IRQ1 pin input is detected(initial value)
1Rising edge of IRQ1 pin input is detected
Bit 0—IRQ0 Edge Select (IEG0): Bit 0 selects the input sensing of pin IRQ0.
Bit 0: IEG0Description
0Falling edge of IRQ0 pin input is detected(initial value)
1Rising edge of IRQ0 pin input is detected
IEGR2 is an 8-bit read/write register used to designate whether pins WKP5 to WKP0 are set to
rising edge sensing or falling edge sensing. Upon reset, IEGR2 is initialized to H'C0.
Bits 7 and 6—Reserved Bits: Bits 7 and 6 are reserved; they are always read as 1, and cannot be
modified.
Bit 5—WKP5 Edge Select (WPEG5): Bit 5 selects the input sensing of pins WKP5 and ADTRG.
Bit 5: WPEG5Description
0Falling edge of WKP5 (ADTRG) pin input is detected(initial value)
1Rising edge of WKP5 (ADTRG) pin input is detected
54
Page 71
Bits 4 to 0—WKP4 to WKP0 Edge Select (WPEG4 to WPEG0): Bits 4 to 0 select the input
sensing of pins WKP4 to WKP0.
Bit n: WPEGnDescription
0Falling edge of WKPn pin input is detected(initial value)
1Rising edge of WKPn pin input is detected
IRR1 is an 8-bit read/write register, in which a corresponding flag is set to 1 when a direct
transfer, a timer A, or IRQ3 to IRQ0 interrupt is requested. The flags are not cleared automatically
when an interrupt is accepted. It is necessary to write 0 to clear each flag. Upon reset, IRR1 is
initialized to H'30.
Bit 7—Direct Transfer Interrupt Request Flag (IRRDT)
Bit 7: IRRDTDescription
0Clearing conditions:(initial value)
When IRRDT = 1, it is cleared by writing 0
1Setting conditions:
When a direct transfer is made by executing a SLEEP instruction while DTON
= 1 in SYSCR2
Bit 6—Timer A Interrupt Request Flag (IRRTA)
Bit 6: IRRTADescription
0Clearing conditions:(initial value)
When IRRTA = 1, it is cleared by writing 0
1Setting conditions:
When the timer A counter value overflows from H'FF to H'00
56
Page 73
Bits 5 and 4—Reserved Bits: Bits 5 and 4 are reserved: they are always read as 1 and cannot be
modified.
Bit 4—Reserved Bit: Bit 4 is reserved; it is always read as 1, and cannot be modified.
Bits 3 to 0—IRQ3 to IRQ0 Interrupt Request Flags (IRRI3 to IRRI0)
Bit n: IRRInDescription
0Clearing conditions:(initial value)
When IRRIn = 1, it is cleared by writing 0
1Setting conditions:
When pin IRQ
is input
is designated for interrupt input and the designated signal edge
IWPR is an 8-bit read/write register, in which a corresponding flag is set to 1 when the designated
signal edge is input at pin WKP5 to WKP0. The flags are not cleared automatically when an
interrupt is accepted. It is necessary to write 0 to clear each flag. Upon reset, IWPR is initialized to
H'C0.
Bits 7 and 6— Bits 7 and 6 are reserved; they are always read as 1, and cannot be modified.
Bits 5 to 0—WKP5 to WKP0 Interrupt Request Flags (IWPF5 to IWPF0)
Bit n: IWPFnDescription
0Clearing conditions:(initial value)
When IWPFn = 1, it is cleared by writing 0
1Setting conditions:
When pin WKPn is designated for interrupt input and the designated signal
edge is input
(n = 5 to 0)
57
Page 74
3.5Interrupt Sources
3.5.1External Interrupts
There are 11 external interrupts: NMI, IRQ3 to IRQ0, and WKP5 to WKP0.
• NMI Interrupt
NMI interrupt is requested by input signal 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. When NMI interrupt exception handling is accepted, the I bit is set to 1 in
CCR.
• 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.
When IRQ3 to IRQ0 interrupt is accepted, the I bit is set to 1 in CCR. These interrupts can be
masked by setting bits IEN3 to IEN0 in IENR1.
• 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. When a WKP5 to WKP0 interrupt is accepted, the I bit is set to 1 in CCR. These
interrupts can be masked by setting bit IENWP in IENR1.
3.5.2Internal Interrupts
There are 20 internal interrupts that can be requested by the on-chip peripheral modules. Each onchip peripheral module has a flag to show the interrupt request status and the enable bit to enable
or disable the interrupt. For timer A interrupt requests and direct transfer interrupt requests
generated by execution of a SLEEP instruction, this function is included in IRR1 and IENR1.
Table 3.2 shows the order of priority of interrupts and their vector addresses.
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. When this interrupt is accepted, the I bit
58
Page 75
is set to 1 in CCR. These interrupts can be masked by writing 0 to clear the corresponding enable
bit.
3.5.3Interrupt Operations
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. From among the interrupts with interrupt request flags set to 1, the interrupt controller selects
the interrupt request with the highest priority and holds the others pending. (Refer to
table 3.2 for a list of interrupt priorities.)
3. The CPU accepts the NMI and address break without depending on the I bit value. Other
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.
Notes: 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).
2. 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.
59
Page 76
SP – 4
SP (R7)
CCR
SP – 3
SP – 2
SP – 1
SP (R7)
Notation:
PC
:
H
PC
:
L
CCR:
SP:
Notes:
SP + 1
SP + 2
SP + 3
SP + 4
CCR
PC
PC
*3
H
L
Even address
Stack area
Prior to start of interrupt
exception handling
PC and CCR
After completion of interrupt
exception handling
saved to stack
Upper 8 bits of program counter (PC)
Lower 8 bits of program counter (PC)
Condition code register
Stack pointer
1.2.PC shows the address of the first instruction to be executed upon return from the interrupt
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.
Figure 3.2 Stack State after Completion of Interrupt Exception Handling
60
Page 77
Prefetch instruction of
interrupt-handling routine
Internal
processing
Vector fetch
Stack access
(9)
Instruction
Interrupt is
accepted
Interrupt level
decision and wait for
Internal
processing
prefetch
end of instruction
Interrupt
request signal
(3)(9)(8)(6)(5)
(4)(1)(7)(10)
(2)
(1)
ø
Internal
address bus
Internal read
signal
Internal write
signal
Internal data bus
Figure 3.3 Interrupt Sequence
(16 bits)
(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)
(10) First instruction of interrupt-handling routine
61
Page 78
3.5.4Interrupt Response Time
Table 3.4 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.4Interrupt Wait States
ItemStates
Waiting time for completion of executing instruction*1 to 13
Saving of PC and CCR to stack4
Vector fetch2
Instruction fetch4
Internal processing4
Total15 to 27
Note: * Not including EEPMOV instruction.
3.6Trap Instruction
When a TRAP instruction is executed, trap instruction exception handling starts up. A TRAP
instruction generates vector addresses corresponding to the vector numbers 0 to 3 designated in the
instruction code.
3.7Application Notes
3.7.1Notes on Stack Area Use
When word data is accessed in the H8/3664 Series, 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.
Setting an odd address in SP may cause a program to crash. An example is shown in figure 3.4.
62
Page 79
SP
→
SP
→
PC
H
PC
L
SP
→
R1L
PC
H'FEFC
L
H'FEFD
H'FEFF
BSR instruction
SP set to H'FEFFStack accessed beyond SP
MOV. B R1L, @–R7
Contents of PC are lost
H
Notation:
PC
:
Upper byte of program counter
H
PC
:
Lower byte of program counter
L
R1L:
SP:
General register R1L
Stack pointer
Figure 3.4 Operation when Odd Address is Set in SP
When CCR contents are saved to the stack during interrupt exception handling or restored when
RTE is executed, this also takes place in word size. Both the upper and lower bytes of word data
are saved to the stack; on return, the even address contents are restored to CCR while the odd
address contents are ignored.
3.7.2Notes on Rewriting Port Mode Registers
When a port mode register is rewritten to switch the functions of external interrupt pins, the
following points should be observed.
When an external interrupt pin function is switched by rewriting the port mode register that
controls pins IRQ3 to IRQ1, and WKP5 to WKP0, the interrupt request flag may be set to 1 at the
time the pin function is switched, even if no valid interrupt is input at the pin. Table 3.5 shows the
conditions under which interrupt request flags are set to 1 in this way.
63
Page 80
Table 3.5Conditions under which Interrupt Request Flag is Set to 1
Interrupt Request
Flags Set to 1Conditions
IRR1IRRI3When bit IRQ3 in PMR1 is changed from 0 to 1 while pin IRQ3 is low and bit IEG3 in
IEGR1 = 0.
When bit IRQ3 in PMR1 is changed from 1 to 0 while pin IRQ3 is low and bit IEG3 in
IEGR1 = 1.
IRRI2When bit IRQ2 in PMR1 is changed from 0 to 1 while pin IRQ2 is low and bit IEG2 in
IEGR1 = 0.
When bit IRQ2 in PMR1 is changed from 1 to 0 while pin IRQ2 is low and bit IEG2 in
IEGR1 = 1.
IRRI1When bit IRQ1 in PMR1 is changed from 0 to 1 while pin IRQ1 is low and bit IEG1 in
IEGR1 = 0.
When bit IRQ1 in PMR1 is changed from 1 to 0 while pin IRQ1 is low and bit IEG1 in
IEGR1 = 1.
IRRI0When bit IRQ0 in PMR1 is changed from 0 to 1 while pin IRQ0 is low and bit IEG0 in
IEGR1 = 0.
When bit IRQ0 in PMR1 is changed from 1 to 0 while pin IRQ0 is low and bit IEG0 in
IEGR1 = 1.
IWPRIWPF5When bit WKP5 in PMR5 is changed from 0 to 1 while pin WKP5 is low and bit
WPEG5 in IEGR2 = 0.
When bit WKP5 in PMR5 is changed from 1 to 0 while pin WKP5 is low and bit
WPEG5 in IEGR2 = 1.
IWPF4When bit WKP4 in PMR5 is changed from 0 to 1 while pin WKP4 is low and bit
WPEG4 in IEGR2 = 0.
When bit WKP4 in PMR5 is changed from 1 to 0 while pin WKP4 is low and bit
WPEG4 in IEGR2 = 1.
IWPF3When bit WKP3 in PMR5 is changed from 0 to 1 while pin WKP3 is low and bit
WPEG3 in IEGR2 = 0.
When bit WKP3 in PMR5 is changed from 1 to 0 while pin WKP3 is low and bit
WPEG3 in IEGR2 = 1.
IWPF2When bit WKP2 in PMR5 is changed from 0 to 1 while pin WKP2 is low and bit
WPEG2 in IEGR2 = 0.
When bit WKP2 in PMR5 is changed from 1 to 0 while pin WKP2 is low and bit
WPEG2 in IEGR2 = 1.
IWPF1When bit WKP1 in PMR5 is changed from 0 to 1 while pin WKP1 is low and bit
WPEG1 in IEGR2 = 0.
When bit WKP1 in PMR5 is changed from 1 to 0 while pin WKP1 is low and bit
WPEG1 in IEGR2 = 1.
IWPF0When bit WKP0 in PMR5 is changed from 0 to 1 while pin WKP0 is low and bit
WPEG0 in IEGR2 = 0.
When bit WKP0 in PMR5 is changed from 1 to 0 while pin WKP0 is low and bit
WPEG0 in IEGR2 = 1.
64
Page 81
Figure 3.5 shows the procedure for setting a bit in a port mode register and clearing the interrupt
request flag.
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. If the instruction to clear the flag is executed immediately after
the port mode register access without executing an intervening instruction, the flag will not be
cleared.
An alternative method to avoid the setting of interrupt request flags when pin functions are
switched is to keep the pins at the high level so that the conditions in table 3.5 do not occur.
Interrupts masked. (Another possibility
CCR I bit 1
Set port mode register bit
←
is to disable the relevant interrupt in
interrupt enable register 1.)
Execute NOP instruction
Clear interrupt request flag to 0
CCR I bit 0
←
Figure 3.5 Port Mode Register Setting and Interrupt Request Flag
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
Clearing Procedure
65
Page 82
66
Page 83
Section 4 Address Break
4.1Overview
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.
4.1.1Block Diagram
Figure 4.1 shows a block diagram of the address break.
Internal address bus
Interrupt
generation
control circuit
Notation:
BARH, BARL: Break address register
BDRH, BDRL: Break data register
ABRKCR:Address break control register
ABRKSR:Address break status register
Comparator
BARHBARL
ABRKCR
ABRKSR
Internal data bus
BDRHBDRL
Comparator
Interrupt
Figure 4.1 Block Diagram of an Address Break
67
Page 84
4.1.2Register Configuration
Table 4.1 shows the address break register configuration.
Table 4.1Address Break Registers
NameAbbrev.R/WInitial ValueAddress
Address break control registerABRKCRR/WH'80H'FFC8
Address break status registerABRKSRR/WH'3FH'FFC9
Break address register (H)BARHR/WH'FFH'FFCA
Break address register (L)BARLR/WH'FFH'FFCB
Break data register (H)BDRHR/WUndefinedH'FFCC
Break data register (L)BDRLR/WUndefinedH'FFCD
ABRKCR is an 8-bit read/write register that sets address break conditions.
Bit 7—RTE Interrupt Enable (RTINTE): Bit 7 enables or disables an interrupt after RTE
instruction execution.
Bit 7: RTINTEDescription
0Disables an interrupt after RTE instruction execution (one instruction is
executed)
1Enables an interrupt after RTE instruction execution (Initial value)
68
Page 85
Bits 6 and 5—Condition Select (CSEL1, CSEL0): Bits 6 and 5 set address break conditions.
When CSEL1=0 and CSEL0=0, data is not compared regardless of the values of DCMP1 and
DCMP0.
Bit 6: CSEL1Bit 5: CSEL0Description
00Instruction execution cycle(Initial value)
1CPU data read cycle
10CPU data write cycle
1CPU data read/write cycle
Bits 4 to 2—Address Compare Condition Select (ACMP2 to ACMP0): Bits 4 to 2 set
comparison condition between the address set in BAR and the internal address bus.
Bit 4:
ACMP2
000Compare 16-bit addresses(Initial value)
1**Reserved
Note: * Don’t care.
Bit 3:
ACMP1
10Compares upper 8-bit addresses
Bit 2:
ACMP0Description
1Compares upper 12-bit addresses
1Compares upper 4-bit addresses
Bits 1 and 0—Data Compare Condition Select (DCMP1, DCMP0): Bits 1 and 0 set the
comparison condition between the data set in BDR and the internal data bus.
Bit 1: DCMP1Bit 0: DCMP0Description
00No data comparison(Initial value)
1Compares lower 8-bit data between BDRL and data bus
10Compares upper 8-bit data between BDRH and data bus
1Compares 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.2 shows the access and
data bus used.
BAR (BARH, BARL) is a 16-bit read/write register that sets the address for generating an address
break interrupt. When setting the address break condition to the instruction execution cycle, set
the first byte address of the instruction.
BDR (BDRH, BDRL) is a 16-bit read/write register that sets the data for generating an address
break interrupt. BDRH is compared with the upper 8-bit data bus. BDRL is compared with the
lower 8-bit 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.2.1, Address Break Control Register, for details.
4.3Operation
When the ABIE bit in ABRKSR is set to 1, if 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,
the address break function generates an interrupt request to the CPU. When the interrupt request
is accepted, interrupt exception handling starts after the instruction being executed ends. The
address break interrupt is not masked because of the I bit in CCR of the CPU.
72
Page 89
Figures 4.2 to 4.4 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
Figure 4.2 Address Break Interrupt Operation Example (1)
Program
0258
025A
*
025C
0260
0262
:
NOP
instruc-
tion
prefetch
025A025C025ESP-2SP-4
NOP
NOP
MOV.W @H'025A,R0
NOP
NOP
:
MOV
instruc-
tion 1
prefetch
Interrupt acceptance
MOV
instruc-
tion 2
prefetch
Underline indicates the address
to be stacked.
Internal
processingStack save
When the address break is specified in the data read cycle
Register setting
• ABRKCR = H'A0
• BAR = H'025A
MOV
instruc-
tion 1
prefetch
φ
Address
bus
Interrupt
request
025C
Program
0258
025A
025C
*
0260
0262
:
MOV
instruc-
tion 2
prefetch
025E0260025A02620264SP-2
NOP
NOP
MOV.W @H'025A,R0
NOP
NOP
:
NOP
instruc-
tion
prefetch
MOV
instruc-
tion
execution
Underline indicates the address
to be stacked.
NOP
instruc-
tion
prefetch
Interrupt acceptance
Next
instru-
ction
prefetch
Internal
processing
Stack
save
Figure 4.3 Address Break Interrupt Operation Example (2)
73
Page 90
When the interrupt acceptance is prohibited after the RTE (RTB) instruction
Register setting
• ABRKCR = H'10
Interrupt
Interrupt
RTE
instruc-
tion
prefetch
φ
Address
bus
Interrupt
request
039C
MOV
instruc-
tion
execution
Program
0258
025A
025C
0260
0262
:
NOP
instruc-
tion
prefetch
039ESPSP+2025C025E
NOP
instruc-
tion
prefetch
NOP
NOP
MOV.W @H'025A,R0
NOP
NOP
:
Stack
resumption
Internal
processing
Internal
processing
:
039A
039C
039E
:
MOV
instruc-
tion 1
prefetch
Vector
fetch
Underline indicates the
address to be stacked.
:
NOP
RTE
NOP
:
instruc-
prefetch
Internal
processingStack restore
MOV
tion 2
Interrupt request
is prohibited
NOP
instruc-
tion
prefetch
0260
Continues
to the
lower
φ
Address
bus
Interrupt
request
025A
Interrupt acceptance
0262SP-2SP-4XXXX
Figure 4.4 Address Break Interrupt Operation Example (3)
74
Page 91
Section 5 Clock Pulse Generators
5.1Overview
Clock oscillator circuitry (CPG: clock pulse generator) is provided on-chip, including both a
system clock pulse generator and a subclock pulse generator. The system clock pulse generator
consists of a system clock oscillator and system clock dividers. The subclock pulse generator
consists of a subclock oscillator circuit and a subclock divider.
5.1.1Block Diagram
Figure 5.1 shows a block diagram of the clock pulse generators.
ø
OSC
ø
OSC
OSC
ø
ø
ø
OSC
OSC
OSC
OSC
/8
/16
/32
/64
)
System
clock
divider
1
2
System
clock
oscillator
System clock pulse generator
ø
(f
OSC
OSC
)
Duty
correction
circuit
ø
(f
OSC
OSC
ø
Prescaler S
(13 bits)
ø/2
to
ø/8192
ø
/2
X
1
X
2
Subclock
oscillator
Subclock pulse generator
ø
W
)
(f
W
Subclock
divider
W
ø
/4
W
/8
ø
W
ø
SUB
Prescaler W
(5 bits)
/8
ø
W
to
øW/128
Figure 5.1 Block Diagram of Clock Pulse Generators
5.1.2System Clock and Subclock
The basic clock signals that drive the CPU and on-chip peripheral modules are ø and ø
the clock signals have names: ø is the system clock, ø
is the subclock, ø
SUB
is the oscillator
OSC
. Four of
SUB
clock, and øW is the watch clock.
The clock signals available for use by peripheral modules are ø/2, ø/4, ø/8, ø/16, ø/32, ø/64, ø/128,
ø/256, ø/512, ø/1024, ø/2048, ø/4096, ø/8192, øW/8, øW/16, øW/32, øW/64, and øW/128. The clock
requirements differ from one module to another.
75
Page 92
5.2System Clock Generator
Clock pulses can be supplied to the system clock divider either by connecting a crystal or ceramic
oscillator, or by providing external clock input.
Connecting a Crystal Oscillator: Figure 5.2 shows a typical method of connecting a crystal
oscillator. An AT-cut parallel-resonance crystal resonator should be used.
C
1
OSC
1
OSC
2
C
2
Figure 5.2 Typical Connection to Crystal Oscillator
Figure 5.3 shows the equivalent circuit of a crystal oscillator. An oscillator having the
C = C = 12 pF ±20%
12
characteristics given in table 5.1 should be used.
C
S
OSC
L
S
1
C
0
R
S
OSC
2
Figure 5.3 Equivalent Circuit of Crystal Oscillator
Connecting a Ceramic Oscillator: Figure 5.4 shows a typical method of connecting a ceramic
oscillator.
C
1
OSC
1
C
2
OSC
2
C1 = 30 pF ±10%
C
= 30 pF ±10%
2
Figure 5.4 Typical Connection to Ceramic Oscillator
Notes on Board Design: When generating clock pulses by connecting a crystal or ceramic
oscillator, pay careful attention to the following points.
Avoid running signal lines close to the oscillator circuit, since the oscillator may be adversely
affected by induction currents. (See figure 5.5.)
The board should be designed so that the oscillator and load capacitors are located as close as
possible to pins OSC1 and OSC2.
To be avoided
C
C
2
1
Signal A
Signal B
OSC
OSC
1
2
Figure 5.5 Board Design of Oscillator Circuit
External Clock Input Method: Connect an external clock signal to pin OSC1, and leave pin
OSC2 open. Figure 5.6 shows a typical connection. The duty cycle of the external clock signal
must be 45 to 55%.
77
Page 94
OSC
1
External clock input
OSC
2
Open
Figure 5.6 Example of External Clock Input
5.3Subclock Generator
Connecting a 32.768-kHz Crystal Oscillator: Clock pulses can be supplied to the subclock
divider by connecting a 32.768-kHz crystal oscillator, as shown in figure 5.7. Follow the same
precautions as noted under 5.2 Notes on Board Design.
C
1
X
1
X
2
C
2
C = C = 15 pF (typ.)
12
Figure 5.7 Typical Connection to 32.768-kHz Crystal Oscillator
Figure 5.8 shows the equivalent circuit of the 32.768-kHz crystal oscillator.
L
S
X
1
CO = 1.5 pF (typ.)
R
= 14 kΩ (typ.)
S
f
= 32.768 kHz
W
Note: Constants are reference values.
C
S
C
O
R
S
Figure 5.8 Equivalent Circuit of 32.768-kHz Crystal Oscillator
X
2
78
Page 95
Pin Connection when Not Using Subclock: When the subclock is not used, connect pin X1 to
VCL or VSS and leave pin X2 open, as shown in figure 5.9.
V
or V
CL
X
1
SS
X
2
Open
Figure 5.9 Pin Connection when not Using Subclock
5.4Prescalers
This LSI is equipped with two on-chip prescalers having different input clocks (prescaler S and
prescaler W). Prescaler S is a 13-bit counter using the system clock (ø) as its input clock. Its
prescaled outputs provide internal clock signals for on-chip peripheral modules. Prescaler W is a
5-bit counter using a 32.768-kHz signal divided by 4 (øW/4) as its input clock. Its prescaled
outputs are used by timer A as a time base for timekeeping.
Prescaler S (PSS): Prescaler S is a 13-bit counter using the system clock (ø) as its input clock. It
is incremented once per clock period.
Prescaler S is initialized to H'0000 by a reset, and starts counting on exit from the reset state.
In standby mode, subactive mode, and subsleep mode, the system clock pulse generator stops.
Prescaler S also stops and is initialized to H'0000.
The CPU cannot read or write prescaler S.
The output from prescaler S is shared by the on-chip peripheral modules. The divider ratio can be
set separately for each on-chip peripheral function.
In active (medium-speed) mode the clock input to prescaler S is determined by the division factor
designated by MA1 and MA0 in SYSCR1.
Prescaler W (PSW): Prescaler W is a 5-bit counter using a 32.768 kHz signal divided by 4 (øW/4)
as its input clock.
Prescaler W is initialized to H'00 by a reset, and starts counting on exit from the reset state.
Even in standby mode, subactive mode, or subsleep mode, prescaler W continues functioning so
long as clock signals are supplied to pins X1 and X2.
79
Page 96
Prescaler W can be reset by setting 1s in bits TMA3 and TMA2 of timer mode register A (TMA).
Output from prescaler W can be used to drive timer A, in which case timer A functions as a time
base for timekeeping.
5.5Usage Notes
5.5.1Note on Oscillators
Oscillator characteristics are closely related to board design and should be carefully evaluated by
the user, referring to the examples shown in this section. Oscillator circuit constants will differ
depending on the oscillator element, stray capacitance in its interconnecting circuit, and other
factors. Suitable constants should be determined in consultation with the oscillator element
manufacturer. Design the circuit so that the oscillator element never receives voltages exceeding
its maximum rating.
5.5.2Notes on Board Design
When using a crystal resonator (ceramic resonator), place the resonator and its load capacitors as
close as possible to the OSC1 and OSC2 pins. Other signal lines should be routed away from the
oscillator circuit to prevent induction from interfering with correct oscillation (see figure 5.10).
Signal ASignal BAvoid
C
1
OSC
1
C
2
OSC
2
Figure 5.10 Example of Incorrect Board Design
80
Page 97
Section 6 Power-down Modes
6.1Overview
This LSI has six modes of operation after a reset. These include a normal active mode and four
power-down modes, in which power dissipation is significantly reduced. The module standby
mode reduces power dissipation by selectively halting on-chip module functions. Table 6.1
summarizes the six operating modes.
Table 6.1Operating Modes
Operating ModeDescription
Active modeThe CPU and all on-chip peripheral modules are operable on
the system clock. The system clock frequency can be selected
from øosc, øosc/8, øosc/16, øosc/32, and øosc/64. For details,
see 6.2.2, System Control Register 2.
Subactive modeThe CPU and all on-chip peripheral modules are operable on
the subclock. The subclock frequency can be selected from
øw/2, øw/4, and øw/8.
Sleep modeThe CPU halts. On-chip peripheral functions are operable on
the system clock.
Subsleep modeThe CPU halts. On-chip peripheral functions are operable on
the subclock.
Standby modeThe CPU and all on-chip peripheral modules halt. When the
clock time-base function is selcted, timer A is operable.
Module standby modeThe on-chip peripheral modules specified by software stop
operating. For details, see 6.2.3, Module Standby Control
Register 1.
6.1.1Register Configuration
Table 6.2 shows the power-down mode register configuration.
Table 6.2Power-down Mode Registers
NameAbbreviationR/WInitial ValueAddress
System control register 1SYSCR1R/WH'00H'FFF0
System control register 2SYSCR2R/WH'00H'FFF1
Module standby control
SYSCR1 is an 8-bit read/write register for control of the power-down modes.
Upon reset, SYSCR1 is initialized to H'00.
Bit 7—Software Standby (SSBY): This bit designates the transition to the sleep mode, subsleep
mode, or standby mode.
Bit 7: SSBYDescription
0When a SLEEP instruction is executed in the active mode, a transition is made
to the sleep mode or subsleep mode.(Initial value)
1When a SLEEP instruction is executed in the active mode, a transition is made
to the standby mode.
Bits 6 to 4—Standby Timer Select 2 to 0 (STS2 to STS0): These bits designate the time the
CPU and peripheral modules wait for stable clock operation after exiting from the standby mode,
subactive mode, or subsleep mode to the active mode or sleep mode due to an interrupt. The
designation should be made according to the clock frequency so that the waiting time is at least 10
ms.
Bit 6: STS2Bit 5: STS1Bit 4: STS0Description
000Wait time = 8,192 states(Initial value)
1Wait time = 16,384 states
10Wait time = 32,768 states
1Wait time = 65,536 states
100Wait time = 131,072 states
10Wait time = 128 states
82
1Wait time = 1,024 states
1Wait time = 16 states
Page 99
Bit 3—Noise Elimination Sampling Frequency Select (NESEL): This bit selects the frequency
at which the watch clock signal (øW) generated by the subclock pulse generator is sampled, in
relation to the oscillator clock (ø
) generated by the system clock pulse generator. When ø
OSC
OSC
= 2
to 10 MHz, clear NESEL to 0.
Bit 3: NESELDescription
0Sampling rate is ø
1Sampling rate is ø
/16(Initial value)
OSC
/4
OSC
Bits 2 to 0—Reserved Bits: Bits 2 to 0 are reserved: they are always read as 0 and cannot be
modified.
SYSCR2 is an 8-bit read/write register for power-down mode control.
Upon reset, SYSCR2 is initialized to H'00.
Bit 7—Sleep Mode Selection (SMSEL): This bit chooses the transition to the sleep mode or
subsleep mode when the SLEEP instruction is executed. The transition after the SLEEP instruction
is executed depends on a combination of this and other control bits.
Bit 7: SMSELDescription
0A transition is made to sleep mode.(Initial value)
1A transition is made to subsleep mode.
Bit 6—Low Speed on Flag (LSON): This bit chooses the system clock (ø) or subclock (ø
SUB
) as
the CPU operating clock. The resulting operation mode after the SLEEP instruction is executed
depends on the combination of other control bits.
Bit 6: LSONDescription
0The CPU operates on the system clock (ø)(Initial value)
1The CPU operates on the subclock (ø
SUB
)
83
Page 100
Bit 5—Direct Transfer on Flag (DTON): This bit designates whether to make direct transitions
between the active and subactive modes when a SLEEP instruction is executed. The mode to
which the transition is made after the SLEEP instruction is executed depends on a combination of
this and other control bits.
Bit 5: DTONDescription
0When a SLEEP instruction is executed, a transition is made to standby mode,
sleep mode, or subsleep mode.(Initial value)
1When a SLEEP instruction is executed, a direct transition is made to active
mode if LSON = 0, or to subactive mode if LSON = 1.
Bits 4 to 2—Active Mode Clock Select (MA2 to MA0): These bits select the operating clock
frequency in the active and sleep modes. The operating clock frequency changes to the set
frequency after the SLEEP instruction is executed.
Bit 4: MA2Bit 3: MA1Bit 2: MA0Description
0**ø
100ø
1ø
10ø
1ø
osc
osc
osc
osc
osc
/8
/16
/32
/64
(Initial value)
Note: * Don’t care
Bits 1 and 0— Subactive Mode Clock Select (SA1, SA0): These bits select the operating clock
frequency in the subactive and subsleep modes. The operating clock frequency changes to the set
frequency after the SLEEP instruction is executed.
Bit 1: SA1Bit 0: SA0Description
00ø
1ø
1*øW/2
Note: * Don’t care
/8(Initial value)
W
/4
W
84
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.