When using this document, keep the following in mind:
1. This document may, wholly or partially, be subject to change without notice.
2. All rights are reserved: No one is permitted to reproduce or duplicate, in any form, the whole
or part of this document without Hitachi’s permission.
3. Hitachi will not be held responsible for any damage to the user that may result from accidents
or any other reasons during operation of the user’s unit according to this document.
4. Circuitry and other examples described herein are meant merely to indicate the characteristics
and performance of Hitachi’s semiconductor products. Hitachi assumes no responsibility for
any intellectual property claims or other problems that may result from applications based on
the examples described herein.
5. No license is granted by implication or otherwise under any patents or other rights of any third
party or Hitachi, Ltd.
6. MEDICAL APPLICATIONS: Hitachi’s products are not authorized for use in MEDICAL
APPLICATIONS without the written consent of the appropriate officer of Hitachi’s sales
company. Such use includes, but is not limited to, use in life support systems. Buyers of
Hitachi’s products are requested to notify the relevant Hitachi sales offices when planning to
use the products in MEDICAL APPLICATIONS.
Page 3
Preface
The H8/300L Series of single-chip microcomputers has a high-speed H8/300L CPU core, with
many necessary peripheral system functions on-chip. The H8/300L CPU instruction set is
compatible with the H8/300 CPU.
On-chip peripheral functions of the H8/3637 Series include a high-precision DTMF generator for
tone dialing, a 14-bit PWM, five types of timers, two serial communication interface channels, and
an A/D converter.
This manual describes the hardware of the H8/3637 Series. For details on the H8/3637 Series
instruction set, refer to the H8/300L Series Programming Manual.
The H8/300L Series is a series of single-chip microcomputers (MCU: microcomputer unit), built
around the high-speed H8/300L CPU and equipped with peripheral system functions on-chip.
Within the H8/300L Series, the H8/3637 Series of single-chip microcomputers features a highprecision DTMF generator for tone dialing. Other on-chip peripheral functions include five types
of timers, two serial communication interface channels, an A/D converter, and a 14-bit pulse width
modulator (PWM). The H8/3637 Series includes three models, the H8/3637, H8/3636, and
H8/3635, with different amounts of on-chip memory: the H8/3637 has 60 kbytes of ROM and 2
kbytes of RAM; the H8/3636 has 48 kbytes of ROM and 2 kbytes of RAM; and the H8/3635 has
40 kbytes of ROM and 2 kbytes of RAM.
The H8/3637 has a ZTAT version with user-programmable on-chip PROM.
Table 1.1 summarizes the features of the H8/3637 Series.
Note: * ZTATTM is a trademark of Hitachi, Ltd.
1
Page 13
Table 1.1Features
ItemDescription
CPUHigh-speed H8/300L CPU
• General-register architecture
General registers: Sixteen 8-bit registers (can be used as eight 16-bit
registers)
• Operating speed
Max. operating speed: 5 MHz
Add/subtract: 0.4 µs (operating at ø= 5 MHz)
Multiply/divide: 2.8 µs (operating at ø= 5 MHz)
Can run on 32.768 kHz subclock
• Instruction set compatible with H8/300 CPU
Instruction length of 2 bytes or 4 bytes
Basic arithmetic operations between registers
MOV instruction for data transfer between memory and registers
• Instruction features
Multiply (8 bits × 8 bits)
Divide (16 bits ÷ 8 bits)
Bit accumulator
Register-indirect designation of bit position
Interrupts30 interrupt sources
• 13 external interrupt sources: IRQ
• 17 internal interrupt sources
Clock pulse
generators
Power-down
modes
Two on-chip clock pulse generators
• System clock pulse generator: 1 MHz to 10 MHz
• Subclock pulse generator: 32.768 kHz
Six power-down modes
• Sleep mode
• Standby mode
• Watch mode
• Subsleep mode
• Subactive mode
• Active (medium-speed) mode
to IRQ0, WKP7 to WKP
4
0
2
Page 14
Table 1.1Features (cont)
ItemDescription
MemoryLarge on-chip memory
• H8/3637: 60-kbyte ROM, 2-kbyte RAM
• H8/3636: 48-kbyte ROM, 2-kbyte RAM
• H8/3635: 40-kbyte ROM, 2-kbyte RAM
I/O ports66 I/O ports
• I/O pins: 61
• Input pins: 5
TimersFive on-chip timers
• Timer A: 8-bit timer with built-in interval/watch clock time base function
Count-up timer with selection of eight internal clock signals divided from
the system clock (ø)* and four clock signals divided from the watch
clock (ø
• Timer F: 16-bit timer with built-in output compare function
Can be used as two independent 8-bit timers.
Count-up timer with selection of four internal clock signals or event
input from external pin
Compare-match function with toggle output
• Timer G: 8-bit timer with built-in input capture/interval functions
Count-up timer with selection of four internal clock signals
Input capture function with built-in noise canceller circuit
• Timer Y: 16-bit timer with built-in interval/auto-reload functions
Count-up timer with selection of seven internal clocks or event input
from external pin
Auto-reload function
• Watchdog timer
Reset signal generated on 8-bit timer overflow
Serial
communication
interface
Two serial communication interface channels on chip
• SCI1: synchronous serial interface
Choice of 8-bit or 16-bit data transfer
• SCI3: 8-bit synchronous or asynchronous serial interface
Built-in function for multiprocessor communication
Note: *ø and øw are defined in section 4, Clock Pulse Generators.
)*
w
3
Page 15
Table 1.1Features (cont)
ItemDescription
A/D converter8-bit successive-approximations A/D converter using a resistance ladder
• 4-channel analog input port
• Conversion time: 31/ø, 62/ø or 124/ø per channel
DTMF generatorBuilt-in tone dialer supporting OSC clock frequencies from 1.2 MHz to 10 MHz
in 400-kHz steps
14-bit PWMPulse-division PWM to reduce ripple
• Can be used as a 14-bit D/A converter by connecting a low-pass filter
externally
Product lineupProduct Code
Mask ROM
Version
HD6433637FHD6473637F80-pin QFP
HD6433637XHD6473637X80-pin TQFP
HD6433637WHD6473637W80-pin TQFP
HD6433636F—80-pin QFP
HD6433636X—80-pin TQFP
HD6433636W—80-pin TQFP
HD6433635F—80-pin QFP
HD6433635X—80-pin TQFP
HD6433635W—80-pin TQFP
ZTAT™
VersionPackageROM/RAM Size
ROM: 60 kbytes
(FP-80B)
(TFP-80F)
(TFP-80C)
(FP-80B)
(TFP-80F)
(TFP-80C)
(FP-80B)
(TFP-80F)
(TFP-80C)
RAM: 2 kbytes
ROM: 48 kbytes
RAM: 2 kbytes
ROM: 40 kbytes
RAM: 2 kbytes
4
Page 16
1.2Internal Block Diagram
Figure 1.1 shows a block diagram of the H8/3637 Series.
P10/TMOW
P1
/TMOFL
1
P1
/TMOFH
2
P1
/TMIG
3
P1
/PWM
4
P1
/IRQ1
5
P16/IRQ2/TMCIY
P1
/IRQ3/TMIF
7
/IRQ4/ADTRG
P2
0
P2
/SCK1
1
P2
/SI1
2
P2
/SO1
3
P2
/SCK3
4
P2
/RXD
5
P2
/TXD
6
P2
/IRQ0
7
/WKP0
P5
0
P5
/WKP1
1
P5
/WKP2
2
P5
/WKP3
3
P5
/WKP4
4
P5
/WKP5
5
P5
/WKP6
6
P5
/WKP7
7
VSSVSSVCCV
CC
RES
TEST
OSC2OSC1X1X
2
CPU (8-bit)
generator
System clock
Subclock pulse
pulse generator
Address bus
Data bus (upper)
Data bus (lower)
ROM
(40 k/48 k/
60 kbytes)
Timer A
RAM
(2 kbytes)
SCI1
Timer F
Timer G
P6
0
P6
1
P6
2
P6
3
P6
4
Port 6Port 5Port 2Port 1
P6
5
P6
6
P6
7
Timer Y
WDTDTMF
SCI3
PWM
A/D converter
Port EPort APort 9Port 8Port 7
PE
3
PE
2
PA
3
PA
2
PA
1
PA
0
P9
7
P9
6
P9
5
P9
4
P9
3
P9
2
P9
1
P9
0
P8
7
P8
6
P8
5
P8
4
P8
3
P8
2
P8
1
P8
0
P7
7
P7
6
P7
5
P7
4
P7
3
P7
2
P7
1
P7
0
Port B
4
5
6
AVCCAV
SS
/AN
4
PB
/AN
5
PB
/AN
6
PB
7
/AN
7
PB
Figure 1.1 Block Diagram
ref
VT
TONED
5
Page 17
1.3Pin Arrangement and Functions
1.3.1Pin Arrangement
The H8/3637 Series pin arrangement is shown in figure 1.2 and 1.3.
7, 269, 28InputPower supply: All VCC pins should be
3, 255, 27InputGround: All VSS pins should be
7577InputAnalog power supply: This is the power
802InputAnalog ground: This is the A/D
7476InputDTMF generator reference level: This
57InputSystem clock: These pins connect to a
1
46Output
2
connected to the system power supply
(+5 V)
connected to the system power supply
(0 V)
supply pin for the A/D converter. When
the A/D converter is not used, connect
this pin to the system power supply
(+5 V).
converter ground pin. It should be
connected to the system power supply
(0 V).
is a power supply pin for the reference
level for DTMF.
crystal or ceramic oscillator, or can be
used to input an external clock. See
section 4, Clock Pulse Generators, for a
typical connection diagram.
System
control
8
X
1
13InputSubclock: These pins connect to a
32.768-kHz crystal oscillator. See section
X
2
24Output
4, Clock Pulse Generators, for a typical
connection diagram.
RES810InputReset: When this pin is driven low, the
chip is reset
TEST68InputTest: This is a test pin, not for use in
applica-tion systems. It should be
connected to V
.
SS
Page 20
Table 1.2Pin Functions (cont)
Pin No.
TFP-80F
TypeSymbol
Interrupt
pins
IRQ
IRQ
IRQ
IRQ
IRQ
0
1
2
3
4
WKP
WKP
Timer pinsTMOW2426OutputClock output: This is an output pin for
TMIF1719InputTimer F event counter input: This is an
TMOFL2325OutputTimer FL output: This is an output pin
TMOFH2224OutputTimer FH output: This is an output pin
TMIG2123InputTimer G capture input: This is an input
TMCIY1820InputTimer Y clock input: This pin inputs an
14-bit PWM PWM2022Output14-bit PWM output: This pin outputs the
TFP-80C FP-80BI/OName and Functions
16
19
18
17
9
to
38 to 3140 to 33InputWakeup interrupt request 0 to 7:
7
0
18
21
20
19
11
InputExternal interrupt request 0 to 4:
These are input pins for external
interrupts for which there is a choice
between rising and falling edge sensing
These are input pins for external
interrupts that are detected at the falling
edge
wave-forms generated by the timer A
output circuit
event input pin for input to the timer F
counter
for waveforms generated by the timer FL
output compare function
for waveforms generated by the timer FH
output compare function
pin for the timer G input capture function
external clock to the timer Y counter.
waveform generated by the 14-bit PWM.
9
Page 21
Table 1.2Pin Functions (cont)
Pin No.
TFP-80F
TypeSymbol
I/O portsPB7 to
PB
4
PA3 to
PA
0
PE3, PE272, 7174, 73I/OPort E: This is a 2-bit I/O port. Input or
P17 to
P1
0
P2
7
P26 to
P2
0
P57 to
P5
0
P67 to
P6
0
P77 to
P7
0
P87 to
P8
0
P97 to
P9
0
TFP-80C FP-80BI/OName and Functions
76 to 7978 to 80,1InputPort B: This is a 4-bit input port
27 to 3029 to 32I/OPort A: This is a 4-bit I/O port. Input or
17 to 2419 to 26I/OPort 1: This is an 8-bit I/O port. Input or
1618InputPort 2 (bit 7): This is a 1-bit input port.
15 to 917 to 11I/OPort 2 (bits 6 to 0): This is a 7-bit I/O
38 to 3140 to 33I/OPort 5: This is an 8-bit I/O port. Input or
46 to 3948 to 41I/OPort 6: This is an 8-bit I/O port. Input or
54 to 4756 to 49I/OPort 7: This is an 8-bit I/O port. Input or
62 to 5564 to 57I/OPort 8: This is an 8-bit I/O port. Input or
70 to 6372 to 65I/OPort 9: This is an 8-bit I/O port. Input or
output can be designated for each bit by
means of port control register A (PCRA).
output can be designated for each bit by
means of port control register E (PCRE).
output can be designated for each bit be
means of port control register 1 (PCR1).
port. Input or output can be designated
for each bit by means of port control
register 2 (PCR2).
output can be designated for each bit by
means of port control register 5 (PCR5).
output can be designated for each bit by
means of port control register 6 (PCR6).
output can be designated for each bit by
means of port control register 7 (PCR7).
output can be designated for each bit by
means of port control register 8 (PCR8).
output can be designated for each bit by
means of port control register 9 (PCR9).
10
Page 22
Table 1.2Pin Functions (cont)
Pin No.
TFP-80F
TypeSymbol
Serial com-
SI
1
munication
interface
(SCI)
SO
1
SCK
RXD1416InputSCI3 receive data input: This is the
TXD1517OutputSCI3 send data output: This is the SCI3
SCK
A/D
c onv er ter
AN7 to
AN
4
ADTRG911InputA/D converter trigger input: This is the
DTMF
TONED7375OutputDTMF signal: This is the output pin for
generator
TFP-80C FP-80BI/OName and Functions
1113InputSCI1 receive data input: This is the
1214OutputSCI1 send data output: This is the SCI1
1012I/OSCI1 clock I/O :This is the SCI1 clock
1
1315I/OSCI3 clock I/O: This is the SCI3 clock
3
76 to 7978 to 80,1InputAnalog input channels 4 to 7: These
SCI1 data input pin
data output pin
I/O pin
SCI3 data input pin
data output pin
I/O pin
are analog data input channels to the
A/D converter
external trigger input pin to the A/D
converter
the DTMF signal
11
Page 23
Section 2 CPU
2.1Overview
The H8/300L CPU has sixteen 8-bit general registers, which can also be paired as eight 16-bit
registers. Its concise, optimized instruction set is designed for high-speed operation.
2.1.1Features
Features of the H8/300L CPU are listed below.
• General-register architecture
Sixteen 8-bit general registers, also usable as eight 16-bit general registers
• Instruction set with 55 basic instructions, including:
Multiply and divide instructions
Powerful bit-manipulation instructions
• Eight addressing modes
Register direct
Register indirect
Register indirect with displacement
Register indirect with post-increment or pre-decrement
Absolute address
Immediate
Program-counter relative
Memory indirect
• 64-kbyte address space
• High-speed operation
All frequently used instructions are executed in two to four states
High-speed arithmetic and logic operations
8- or 16-bit register-register add or subtract: 0.4 µs*
8 × 8-bit multiply:2.8 µs*
16 ÷ 8-bit divide:2.8 µs*
• Low-power operation modes
SLEEP instruction for transition to low-power operation
Note: * These values are at ø = 5 MHz.
13
Page 24
2.1.2Address Space
The H8/300L CPU supports an address space of up to 64 kbytes for storing program code and
data.
See 2.8, Memory Map, for details of the memory map.
2.1.3Register Configuration
Figure 2.1 shows the register structure of the H8/300L CPU. There are two groups of registers: the
general registers and control registers.
General registers (Rn)
7070
R0H
R1H
R2H
R3H
R4H
R5H
R6H
R7H
(SP)
R0L
R1L
R2L
R3L
R4L
R5L
R6L
R7L
SP: Stack Pointer
14
Control registers (CR)
150
PC
75321064
CCR I U H U N Z V C
Figure 2.1 CPU Registers
PC: Program Counter
CCR: Condition Code Register
Carry flag
Overflow flag
Zero flag
Negative flag
Half-carry flag
Interrupt mask bit
User bit
User bit
Page 25
2.2Register Descriptions
2.2.1General Registers
All the general registers have the same functions, and can be used as both data registers and
address registers.
When used as data registers, they can be accessed as 16-bit registers (R0 to R7), or the high bytes
(R0H to R7H) and low bytes (R0L to R7L) can be accessed separately as 8-bit registers.
When used as address registers, the general registers are accessed as 16-bit registers (R0 to R7).
R7 also functions as the stack pointer (SP), used implicitly by hardware in exception handling and
subroutine calls. When it functions as the stack pointer, as indicated in figure 2.2, SP (R7) points
to the top of the stack.
Lower address side [H'0000]
Unused area
SP (R7)
Stack area
Upper address side [H'FFFF]
Figure 2.2 Stack Pointer
2.2.2Control Registers
The CPU control registers include a 16-bit program counter (PC) and an 8-bit condition code
register (CCR).
(1) Program Counter (PC): This 16-bit register indicates the address of the next instruction the
CPU will execute. All instructions are fetched 16 bits (1 word) at a time, so the least significant bit
of the PC is ignored (always regarded as 0).
15
Page 26
(2) Condition Code Register (CCR): This 8-bit register contains internal status information,
including the interrupt mask bit (I) and half-carry (H), negative (N), zero (Z), overflow (V), and
carry (C) flags. These bits can be read and written by software (using the LDC, STC, ANDC,
ORC, and XORC instructions). The N, Z, V, and C flags are used as branching conditions for
conditional branching (Bcc) instructions.
Bit 7—Interrupt Mask Bit (I): When this bit is set to 1, interrupts are masked. This bit is set to 1
automatically at the start of exception handling. The interrupt mask bit may be read and written by
software. For further details, see 3.3, Interrupts.
Bit 6—User Bit (U): Can be used freely by the user.
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 is cleared to 0
otherwise.
The H flag is used implicitly by the DAA and DAS instructions.
When the ADD.W, SUB.W, or CMP.W instruction is executed, the H flag is set to 1 if there is a
carry or borrow at bit 11, and is cleared to 0 otherwise.
Bit 4—User Bit (U): Can be used freely by the user.
Bit 3—Negative Flag (N): Indicates the most significant bit (sign bit) of the result of an
instruction.
Bit 2—Zero Flag (Z): Set to 1 to indicate a zero result, and cleared to 0 to indicate a non-zero
result.
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/rotate carry
The carry flag is also used as a bit accumulator by bit manipulation instructions.
Some instructions leave some or all of the flag bits unchanged.
Refer to the H8/300L Series Programming Manual for the action of each instruction on the flag
bits.
16
Page 27
2.2.3Initial Register Values
When the CPU is reset, the program counter (PC) is initialized to the value stored at address
H'0000 in the vector table, and the I bit in the CCR is set to 1. The other CCR bits and the general
registers are not initialized. In particular, the stack pointer (R7) is not initialized. R7 initialization
should therefore be carried out immediately after a reset.
2.3Data Formats
The H8/300L CPU can process 1-bit data, 4-bit (BCD) data, 8-bit (byte) data, and 16-bit (word)
data.
Bit manipulation instructions operate on 1-bit data specified as bit n in a byte operand
(n = 0, 1, 2, ..., 7).
All arithmetic and logic instructions except ADDS and SUBS can operate on byte data.
The MOV.W, ADD.W, SUB.W, CMP.W, ADDS, SUBS, MULXU (8 bits × 8 bits), and DIVXU
(16 bits ÷ 8 bits) instructions operate on word data.
The DAA and DAS instructions perform decimal arithmetic adjustments on byte data in two-digit
4-bit BCD form.
17
Page 28
2.3.1Data Formats in General Registers
General register data formats are shown in figure 2.3.
Data TypeRegister No.Data Format
70
1-bit dataRnH
1-bit dataRnL
Byte dataRnH
Byte dataRnL
Word dataRn
4-bit BCD dataRnH
76543210Don’t care
70
MSBLSBDon’t care
150
MSBLSB
7034
Upper digitLower digit
70
76543210Don’t care
70
MSBLSBDon’t care
Don’t care
4-bit BCD dataRnL
Legend:
Upper byte of general register
RnH:
Lower byte of general register
RnL:
Most significant bit
MSB:
Least significant bit
LSB:
18
70
Don’t care
Figure 2.3 Register Data Formats
34
Upper digitLower digit
Page 29
2.3.2Memory Data Formats
Figure 2.4 indicates the data formats in memory. For access by the H8/300L CPU, word data
stored in memory must always begin at an even address. In word access the least significant bit of
the address is regarded as 0. If an odd address is specified, the access is performed at the preceding
even address. This rule affects the MOV.W instruction, and also applies to instruction fetching.
1-bit data
Byte data
Word data
Byte data (CCR) on stack
Word data on stack
CCR: Condition code register
Note: Ignored on return*
AddressData Type
Address n
Address n
Even address
Odd address
Even address
Odd address
Even address
Odd address
Data Format
70
76543210
MSBLSB
MSB
MSBLSBCCR
MSBLSB
MSB
Upper 8 bits
Lower 8 bits
CCR*
LSB
LSB
Figure 2.4 Memory Data Formats
When the stack is accessed using R7 as an address register, word access should always be
performed. When the CCR is pushed on the stack, two identical copies of the CCR are pushed to
make a complete word. When they are restored, the lower byte is ignored.
19
Page 30
2.4Addressing Modes
2.4.1Addressing Modes
The H8/300L CPU supports the eight addressing modes listed in table 2.1. Each instruction uses a
subset of these addressing modes.
Table 2.1Addressing Modes
No.Address ModesSymbol
1Register directRn
2Register indirect@Rn
3Register indirect with displacement@(d:16, Rn)
4Register indirect with post-increment
Register indirect with pre-decrement
5Absolute address@aa:8 or @aa:16
6Immediate#xx:8 or #xx:16
7Program-counter relative@(d:8, PC)
8Memory indirect@@aa:8
1. Register Direct—Rn: The register field of the instruction specifies an 8- or 16-bit general
register containing the operand.
@Rn+
@–Rn
Only the MOV.W, ADD.W, SUB.W, CMP.W, ADDS, SUBS, MULXU (8 bits × 8 bits), and
DIVXU (16 bits ÷ 8 bits) instructions have 16-bit operands.
2. Register Indirect—@Rn: The register field of the instruction specifies a 16-bit general
register containing the address of the operand in memory.
3. Register Indirect with Displacement—@(d:16, Rn): The instruction has a second word
(bytes 3 and 4) containing a displacement which is added to the contents of the specified general
register to obtain the operand address in memory.
This mode is used only in MOV instructions. For the MOV.W instruction, the resulting address
must be even.
20
Page 31
4. Register Indirect with Post-Increment or Pre-Decrement—@Rn+ or @–Rn:
• Register indirect with post-increment—@Rn+
The @Rn+ mode is used with MOV instructions that load registers from memory.
The register field of the instruction specifies a 16-bit general register containing the address of
the operand. After the operand is accessed, the register is incremented by 1 for MOV.B or 2 for
MOV.W. For MOV.W, the original contents of the 16-bit general register must be even.
• Register indirect with pre-decrement—@–Rn
The @–Rn mode is used with MOV instructions that store register contents to memory.
The register field of the instruction specifies a 16-bit general register which is decremented by
1 or 2 to obtain the address of the operand in memory. The register retains the decremented
value. The size of the decrement is 1 for MOV.B or 2 for MOV.W. For MOV.W, the original
contents of the register must be even.
5. Absolute Address—@aa:8 or @aa:16: The instruction specifies the absolute address of the
operand in memory.
The absolute address may be 8 bits long (@aa:8) or 16 bits long (@aa:16). The MOV.B and bit
manipulation instructions can use 8-bit absolute addresses. The MOV.B, MOV.W, JMP, and JSR
instructions can use 16-bit absolute addresses.
For an 8-bit absolute address, the upper 8 bits are assumed to be 1 (H'FF). The address range is
H'FF00 to H'FFFF (65280 to 65535).
6. Immediate—#xx:8 or #xx:16: The instruction contains an 8-bit operand (#xx:8) in its second
byte, or a 16-bit operand (#xx:16) in its third and fourth bytes. Only MOV.W instructions can
contain 16-bit immediate values.
The ADDS and SUBS instructions implicitly contain the value 1 or 2 as immediate data. Some bit
manipulation instructions contain 3-bit immediate data in the second or fourth byte of the
instruction, specifying a bit number.
7. Program-Counter Relative—@(d:8, PC): This mode is used in the Bcc and BSR
instructions. An 8-bit displacement in byte 2 of the instruction code is sign-extended to 16 bits and
added to the program counter contents to generate a branch destination address. The possible
branching range is –126 to +128 bytes (–63 to +64 words) from the current address. The result of
the addition should be an even number.
21
Page 32
8. Memory Indirect—@@aa:8: This mode can be used by the JMP and JSR instructions. The
second byte of the instruction code specifies an 8-bit absolute address. The word located at this
address contains the branch destination address.
The upper 8 bits of the absolute address are assumed to be 0 (H'00), so the address range is H'0000
to H'00FF (0 to 255). Note that with the H8/300L Series, the lower end of the address area is also
used as a vector area. See 3.3, Interrupts, for details on the vector area.
If an odd address is specified as a branch destination or as the operand address of a MOV.W
instruction, the least significant bit is regarded as 0, causing word access to be performed at the
address preceding the specified address. See 2.3.2, Memory Data Formats, for further information.
2.4.2Effective Address Calculation
Table 2.2 shows how effective addresses are calculated in each of the addressing modes.
Arithmetic and logic instructions use register direct addressing (1). The ADD.B, ADDX, SUBX,
CMP.B, AND, OR, and XOR instructions can also use immediate addressing (6).
Data transfer instructions can use all addressing modes except program-counter relative (7) and
memory indirect (8).
Bit manipulation instructions use register direct (1), register indirect (2), or 8-bit absolute
addressing (5) to specify a byte operand, and 3-bit immediate addressing (6) to specify a bit
position in that byte. The BSET, BCLR, BNOT, and BTST instructions can also use register direct
addressing (1) to specify the bit position.
Notes: 1. PUSH Rn is equivalent to MOV.W Rn, @–SP.
POP Rn is equivalent to MOV.W @SP+, Rn. The machine language is also the same.
2. Bcc is a conditional branch instruction in which cc represents a condition code.
, POP
1
14
8
14
Total: 55
The following sections give a concise summary of the instructions in each category, and indicate
the bit patterns of their object code. The notation used is defined next.
The functions of the instructions are shown in tables 2.4 to 2.11. The meaning of the operation
symbols used in the tables is as follows.
26
Page 37
Notation
RdGeneral register (destination)
RsGeneral register (source)
RnGeneral register
(EAd), <EAd>Destination operand
(EAs), <EAs>Source operand
CCRCondition code register
NN (negative) flag of CCR
ZZ (zero) flag of CCR
VV (overflow) flag of CCR
CC (carry) flag of CCR
PCProgram counter
SPStack pointer
#IMMImmediate data
dispDisplacement
+Addition
–Subtraction
×Multiplication
÷Division
∧AND logical
∨OR logical
⊕Exclusive OR logical
→Move
~Logical negation (logical complement)
:33-bit length
:88-bit length
:1616-bit length
( ), < >Contents of operand indicated by effective address
27
Page 38
2.5.1Data Transfer Instructions
Table 2.4 describes the data transfer instructions. Figure 2.5 shows their object code formats.
Table 2.4Data Transfer Instructions
InstructionSize*Function
MOVB/W(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.
The Rn, @Rn, @(d:16, Rn), @aa:16, #xx:16, @–Rn, and @Rn+
addressing modes are available for byte or word data. The @aa:8
addressing mode is available for byte data only.
The @–R7 and @R7+ modes require word operands. Do not specify
byte size for these two modes.
POPW@SP+ → Rn
Pops a 16-bit general register from the stack. Equivalent to MOV.W
@SP+, Rn.
PUSHWRn → @–SP
Pushes a 16-bit general register onto the stack. Equivalent to
MOV.W Rn, @–SP.
Note: *Size: Operand size
B: Byte
W: Word
Certain precautions are required in data access. See 2.9.1, Notes on Data Access, for details.
28
Page 39
15087
oprmrn
15087
oprmrn
15087
oprmrn
disp
MOV
Rm→Rn
@Rm←→Rn
@(d:16, Rm)←→Rn
15087
oprmrn
15087
oprnabs
15087
oprn
abs
15087
oprnIMM
15087
oprn
IMM
15087
oprn
Legend:
op:
rm, rn:
disp:
abs:
IMM:
Operation field
Register field
Displacement
Absolute address
Immediate data
111
@Rm+→Rn, or
Rn →@–Rm
@aa:8←→Rn
@aa:16←→Rn
#xx:8→Rn
#xx:16→Rn
PUSH, POP
@SP+ Rn, or
→
Rn @–SP
→
Figure 2.5 Data Transfer Instruction Codes
29
Page 40
2.5.2Arithmetic Operations
Table 2.5 describes the arithmetic instructions.
Table 2.5Arithmetic Instructions
InstructionSize*Function
ADD
SUB
ADDX
SUBX
INC
DEC
ADDS
SUBS
DAA
DAS
MULXUBRd × Rs → Rd
DIVXUBRd ÷ Rs → Rd
CMPB/WRd – Rs, Rd – #IMM
NEGB0 – Rd → Rd
Note: *Size: Operand size
B: Byte
W: Word
B/WRd ± Rs → Rd, Rd + #IMM → Rd
Performs addition or subtraction on data in two general registers, or
addition on immediate data and data in a general register. Immediate
data cannot be subtracted from data in a general register. Word data
can be added or subtracted only when both words are in general
registers.
BRd ± Rs ± C → Rd, Rd ± #IMM ± C → Rd
Performs addition or subtraction with carry or borrow on byte data in
two general registers, or addition or subtraction on immediate data
and data in a general register.
BRd ± 1 → Rd
Increments or decrements a general register
WRd ± 1 → Rd, Rd ± 2 → Rd
Adds or subtracts immediate data to or from data in a general
register. The immediate data must be 1 or 2.
BRd decimal adjust → Rd
Decimal-adjusts (adjusts to packed 4-bit BCD) an addition or
subtraction result in a general register by referring to the CCR
Performs 8-bit × 8-bit unsigned multiplication on data in two general
registers, providing a 16-bit result
Performs 16-bit ÷ 8-bit unsigned division on data in two general
registers, providing an 8-bit quotient and 8-bit remainder
Compares data in a general register with data in another general
register or with immediate data, and the result is stored in the CCR.
Word data can be compared only between two general registers.
Obtains the two’s complement (arithmetic complement) of data in a
general register
30
Page 41
2.5.3Logic Operations
Table 2.6 describes the four instructions that perform logic operations.
Table 2.6Logic Operation Instructions
InstructionSize*Function
ANDBRd ∧ Rs → Rd, Rd ∧ #IMM → Rd
Performs a logical AND operation on a general register and another
general register or immediate data
ORBRd ∨ Rs → Rd, Rd ∨ #IMM → Rd
Performs a logical OR operation on a general register and another
general register or immediate data
XORBRd ⊕ Rs → Rd, Rd ⊕ #IMM → Rd
Performs a logical exclusive OR operation on a general register and
another general register or immediate data
NOTB~ Rd → Rd
Obtains the one’s complement (logical complement) of general
register contents
Note: *Size: Operand size
B: Byte
2.5.4Shift Operations
Table 2.7 describes the eight shift instructions.
Table 2.7Shift Instructions
InstructionSize*Function
SHAL
SHAR
SHLL
SHLR
ROTL
ROTR
ROTXL
ROTXR
Note: *Size: Operand size
B: Byte
BRd shift → Rd
Performs an arithmetic shift operation on general register contents
BRd shift → Rd
Performs a logical shift operation on general register contents
BRd rotate → Rd
Rotates general register contents
BRd rotate through carry → Rd
Rotates general register contents through the C (carry) bit
31
Page 42
Figure 2.6 shows the instruction code format of arithmetic, logic, and shift instructions.
15087
oprmrn
15087
oprn
15087
oprn
15087
op
15087
rnIMM
oprn
15087
op
15087
rnIMM
op
Legend:
op:
rm, rn:
IMM:
Operation field
Register field
Immediate data
rm
rm
ADD, SUB, CMP,
ADDX, SUBX (Rm)
ADDS, SUBS, INC, DEC,
DAA, DAS, NEG, NOT
MULXU, DIVXU
ADD, ADDX, SUBX,
CMP (#XX:8)
AND, OR, XOR (Rm)
AND, OR, XOR (#xx:8)
rn
SHAL, SHAR, SHLL, SHLR,
ROTL, ROTR, ROTXL, ROTXR
32
Figure 2.6 Arithmetic, Logic, and Shift Instruction Codes
Page 43
2.5.5Bit Manipulations
Table 2.8 describes the bit-manipulation instructions. Figure 2.7 shows their object code formats.
Table 2.8Bit-Manipulation Instructions
InstructionSize*Function
BSETB1 → (<bit-No.> of <EAd>)
Sets a specified bit in a general register or memory to 1. The bit
number is specified by 3-bit immediate data or the lower three bits of
a general register.
BCLRB0 → (<bit-No.> of <EAd>)
Clears a specified bit in a general register or memory to 0. The bit
number is specified by 3-bit immediate data or the lower three bits of
a general register.
BNOTB~ (<bit-No.> of <EAd>) → (<bit-No.> of <EAd>)
Inverts a specified bit in a general register or memory. The bit
number is specified by 3-bit immediate data or the lower three bits of
a general register.
BTSTB~ (<bit-No.> of <EAd>) → Z
Tests a specified bit in a general register or memory 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.
BANDBC ∧ (<bit-No.> of <EAd>) → C
ANDs the C flag with a specified bit in a general register or memory,
and stores the result in the C flag.
BIANDBC ∧ [~ (<bit-No.> of <EAd>)] → C
ANDs the C flag with the inverse of a specified bit in a general
register or memory, and stores the result in the C flag.
The bit number is specified by 3-bit immediate data.
BORBC ∨ (<bit-No.> of <EAd>) → C
ORs the C flag with a specified bit in a general register or memory,
and stores the result in the C flag.
BIORBC ∨ [~ (<bit-No.> of <EAd>)] → C
ORs the C flag with the inverse of a specified bit in a general register
or memory, and stores the result in the C flag.
The bit number is specified by 3-bit immediate data.
Note: *Size: Operand size
B: Byte
33
Page 44
Table 2.8Bit-Manipulation Instructions (cont)
InstructionSize*Function
BXORBC ⊕ (<bit-No.> of <EAd>) → C
XORs the C flag with a specified bit in a general register or memory,
and stores the result in the C flag.
BIXORBC ⊕ [~(<bit-No.> of <EAd>)] → C
XORs the C flag with the inverse of a specified bit in a general
register or memory, and stores the result in the C flag.
The bit number is specified by 3-bit immediate data.
BLDB(<bit-No.> of <EAd>) → C
Copies a specified bit in a general register or memory to the C flag.
BILDB~ (<bit-No.> of <EAd>) → C
Copies the inverse of a specified bit in a general register or memory
to the C flag.
The bit number is specified by 3-bit immediate data.
BSTBC → (<bit-No.> of <EAd>)
Copies the C flag to a specified bit in a general register or memory.
BISTB~ C → (<bit-No.> of <EAd>)
Copies the inverse of the C flag to a specified bit in a general
register or memory.
The bit number is specified by 3-bit immediate data.
Note: *Size: Operand size
B: Byte
Certain precautions are required in bit manipulation. See 2.9.2, Notes on Bit Manipulation, for
details.
34
Page 45
15087
opIMMrn
BSET, BCLR, BNOT, BTST
Operand:
Bit No.:
register direct (Rn)
immediate (#xx:3)
15087
oprn
15087
op0
op
15087
op0
15087
op
op
15087
op
15087
opIMMrn
rm
rn
rn
abs
abs
Operand:
Bit No.:
Operand:
0000000IMM
Bit No.:
Operand:
0000000rmop
Bit No.:
Operand:
0000IMM
Bit No.:
Operand:
0000rmop
Bit No.:
register direct (Rn)
register direct (Rm)
register indirect (@Rn)
immediate (#xx:3)
register indirect (@Rn)
register direct (Rm)
absolute (@aa:8)
immediate (#xx:3)
absolute (@aa:8)
register direct (Rm)
BAND, BOR, BXOR, BLD, BST
Operand:
Bit No.:
register direct (Rn)
immediate (#xx:3)
15087
op0
15087
op
Legend:
op:
rm, rn:
abs:
IMM:
Operation field
Register field
Absolute address
Immediate data
Figure 2.7 Bit Manipulation Instruction Codes
rn
0000000IMMop
abs
0000IMMop
Operand:
Bit No.:
Operand:
Bit No.:
register indirect (@Rn)
immediate (#xx:3)
absolute (@aa:8)
immediate (#xx:3)
35
Page 46
15087
opIMMrn
15087
op0
15087
op
Legend:
op:
rm, rn:
abs:
IMM:
Operation field
Register field
Absolute address
Immediate data
Figure 2.7 Bit Manipulation Instruction Codes (cont)
BIAND, BIOR, BIXOR, BILD, BIST
Operand:
Bit No.:
rn
0000000IMMop
abs
0000IMMop
Operand:
Bit No.:
Operand:
Bit No.:
register direct (Rn)
immediate (#xx:3)
register indirect (@Rn)
immediate (#xx:3)
absolute (@aa:8)
immediate (#xx:3)
36
Page 47
2.5.6Branching Instructions
Table 2.9 describes the branching instructions. Figure 2.8 shows their object code formats.
Table 2.9Branching Instructions
InstructionSizeFunction
Bcc—Branches to the designated address if the specified condition is true.
The branching conditions are given below.
MnemonicDescriptionCondition
BRA (BT)Always (true)Always
BRN (BF)Never (false)Never
BHIHighC ∨ Z = 0
BLSLow or sameC ∨ Z = 1
BCC (BHS)Carry clear (high or same)C = 0
BCS (BLO)Carry set (low)C = 1
BNENot equalZ = 0
BEQEqualZ = 1
BVCOverflow clearV = 0
BVSOverflow setV = 1
BPLPlusN = 0
BMIMinusN = 1
BGEGreater or equalN ⊕ V = 0
BLTLess thanN ⊕ V = 1
BGTGreater thanZ ∨ (N ⊕ V) = 0
BLELess or equalZ ∨ (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
37
Page 48
15087
opccdisp
15087
oprm0
15087
op
abs
15087
opabs
15087
opdisp
15087
oprm0
15087
op
abs
000
000
Bcc
JMP (@Rm)
JMP (@aa:16)
JMP (@@aa:8)
BSR
JSR (@Rm)
JSR (@aa:16)
38
15087
opabs
15087
op
Legend:
op:
Operation field
cc:
Condition field
rm:
Register field
disp:
Displacement
abs:
Absolute address
Figure 2.8 Branching Instruction Codes
JSR (@@aa:8)
RTS
Page 49
2.5.7System Control Instructions
Table 2.10 describes the system control instructions. Figure 2.9 shows their object code formats.
Table 2.10System Control Instructions
InstructionSize*Function
RTE—Returns from an exception-handling routine
SLEEP—Causes a transition from active mode to a power-down mode. See
section 5, Power-Down Modes, for details
LDCBRs → CCR, #IMM → CCR
Moves immediate data or general register contents to the condition
code register
STCBCCR → Rd
Copies the condition code register to a specified general register
ANDCBCCR ∧ #IMM → CCR
Logically ANDs the condition code register with immediate data
ORCBCCR ∨ #IMM → CCR
Logically ORs the condition code register with immediate data
XORCBCCR ⊕ #IMM → CCR
Logically exclusive-ORs the condition code register with immediate
data
NOP—PC + 2 → PC
Only increments the program counter
Note: *Size: Operand size
B: Byte
39
Page 50
15087
op
15087
oprn
RTE, SLEEP, NOP
LDC, STC (Rn)
15087
opIMM
Legend:
op:
Operation field
rn:
Register field
IMM:
Immediate data
ANDC, ORC,
XORC, LDC (#xx:8)
Figure 2.9 System Control Instruction Codes
2.5.8Block Data Transfer Instruction
Table 2.11 describes the block data transfer instruction. Figure 2.10 shows its object code format.
Table 2.11 Block Data Transfer Instruction
InstructionSizeFunction
EEPMOV—If R4L ≠ 0 then
repeat @R5+ → @R6+, R4L – 1 → R4L
untilR4L = 0
else next;
Block transfer instruction. Transfers the number of bytes specified by
R4L, from locations starting at the address specified by R5, to
locations starting at the address specified by R6. On completion of
the transfer, the next instruction is executed.
Certain precautions are required in using the EEPMOV instruction. See 2.9.3, Notes on Use of the
EEPMOV Instruction, for details.
40
Page 51
15087
op
op
Legend:
op:Operation field
Figure 2.10 Block Data Transfer Instruction Code
41
Page 52
2.6Basic Operational Timing
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.6.1Access to On-Chip Memory (RAM, ROM)
Acess 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 ø
SUB
Internal address bus
Internal read signal
Internal data bus
(read access)
T1 state
Address
T2 state
Read data
42
Internal write signal
Internal data bus
(write access)
Figure 2.11 On-Chip Memory Access Cycle
Write data
Page 53
2.6.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,
so access is by byte size only. This means that for accessing word data, two instructions must be
used.
Two-state access to on-chip peripheral modules
Figure 2.12 shows operation timings for accessing on-chip peripheral modules in 2 states.
There are four CPU states: the reset state, program execution state, program halt state, and
exception-handling state. The program execution state includes active (high-speed or mediumspeed) mode and subactive mode. In the program halt state there are a sleep mode, standby mode,
watch mode, and sub-sleep mode. These states are shown in figure 2.14.
Figure 2.15 shows the state transitions.
44
Page 55
CPU stateReset state
The CPU is initialized.
Program
execution state
Active
(high speed) mode
The CPU executes successive program
instructions at high speed,
synchronized by the system clock
(medium speed) mode
The CPU executes successive
program instructions at
reduced speed, synchronized
by the system clock
The CPU executes
successive program
instructions at reduced
speed, synchronized
by the subclock
Active
Subactive mode
Low-power
modes
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 exception handling source.
Note: See section 5, Power-Down Modes, for details on the modes and their transitions.
Sleep mode
Standby mode
Watch mode
Subsleep mode
Figure 2.14 CPU Operation States
45
Page 56
Reset state
Reset cleared
Exception-handling state
Reset occurs
Reset
occurs
Program halt state
Reset
occurs
SLEEP instruction executed
Interrupt
source
Exceptionhandling
request
Program execution state
Exceptionhandling
complete
Figure 2.15 State Transitions
2.7.2Program Execution State
In the program execution state the CPU executes program instructions in sequence.
There are three modes in this state, two active modes (high speed and medium speed) and one
subactive mode. Operation is synchronized with the system clock in active mode (high speed and
medium speed), and with the subclock in subactive mode. See section 5, Power-Down Modes for
details on these modes.
2.7.3Program Halt State
In the program halt state there are four modes: sleep mode, standby mode, watch mode, and
subsleep mode. See section 5, Power-Down Modes for details on these modes.
2.7.4Exception-Handling State
The exception-handling state is a transient state occurring when exception handling is started by a
reset or interrupt and the CPU changes its normal processing flow. In exception handling caused
by an interrupt, SP (R7) is referenced and the PC and CCR values are saved on the stack.
For details on interrupt handling, see 3.3, Interrupts.
46
Page 57
2.8Memory Map
Figure 2.16 shows a memory map for the H8/3637 Series.
H'0000
H'0029
H'002A
H'9FFF
H'BFFF
H'EDFF
H'F77F
H'F780
Interrupt vectors
(42 bytes)
On-chip ROM
Reserved
H8/3635
40 kbytes
H8/3637H8/3636
48 kbytes
60 kbytes
H'FF7F
H'FF80
H'FF8F
H'FF90
H'FFFF
On-chip RAM
Reserved
Internal I/O registers
(112 bytes)
2 kbytes
Figure 2.16 H8/3637 Series Memory Map
47
Page 58
2.9Application Notes
2.9.1Notes on Data Access
Access to Empty Area: The address space of the H8/300L 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.
Access to the Internal I/O Register: Internal data transfer to or from on-chip modules other than
the ROM and RAM areas makes use of an 8-bit data width. If word access is attempted to these
areas, the following results will occur.
• Word access from CPU to I/O register area:
Upper byte: Will be written to I/O register.
Lower byte: Transferred data will be lost.
• Word access from I/O register to CPU:
Upper byte: Will be written to upper part of CPU register.
Lower byte: Unpredictable data will be written to lower part of CPU register.
Byte size instructions should therefore be used when transferring data to or from I/O registers
other than the on-chip ROM and RAM areas.
Figure 2.17 shows the data size and number of states in which on-chip peripheral modules can be
accessed.
48
Page 59
H'0000
H'0029
H'002A
Interrupt vectors
(42 bytes)
H8/3635H8/3637H8/3636
Access
Word Byte
States
H'9FFF
H'BFFF
H'EDFF
H'F77F
H'F780
H'FF7F
H'FF80
H'FF8F
H'FF90
H'FFFF
On-chip ROM
Reserved
On-chip RAM
Reserved
Internal I/O registers
(112 bytes)
40 kbytes
2 kbytes
48 kbytes
60 kbytes
———
—
×
: Access possible
×
: Not possible
2
2
——
2 or 3
Figure 2.17 Data Size and Number of States for Access to and from
On-Chip Peripheral Modules
49
Page 60
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.
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: Bit manipulation to the timer load register and the timer counter
Figure 2.18 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 bit designated 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.
Count clockTimer counter
Reload
Timer load register
R
R:W:Read
Write
W
Internal bus
Figure 2.18 Timer Configuration Example
50
Page 61
Example 2: Here a BSET instruction is executed designating port 6.
P67 and P66 are designated as input pins, with a low-level signal input at P67 and a high-level
signal at P66. The remaining pins, P65 to P60, are output pins and output low-level signals. In this
example, the BSET instruction is used to change pin P60 to high-level output.
When the BSET instruction is executed, first the CPU reads port 6.
Since P67 and P66 are input pins, the CPU reads the pin states (low-level and high-level input).
P65 to P60 are output pins, so the CPU reads the value in PDR6. In this example PDR6 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 PDR6 data to H'41. Finally, the CPU
writes this value (H'41) to PDR6, completing execution of BSET.
As a result of this operation, bit 0 in PDR6 becomes 1, and P60 outputs a high-level signal.
However, bits 7 and 6 of PDR6 end up with different values.
51
Page 62
To avoid this problem, store a copy of the PDR6 data in a work area in memory. Perform the bit
manipulation on the data in the work area, then write this data to PDR6.
[A: Prior to executing BSET]
MOV. B #80, R0L
MOV. B R0L, @RAM0
MOV. B R0L, @PDR6
P6
P6
7
6
The PDR6 value (H'80) is written to a work area in
memory (RAM0) as well as to PDR6.
Bit Manipulation in a Register Containing a Write-only Bit
Example 3: In this example, the port 6 control register PCR6 is accessed by a BCLR instruction.
As in the examples above, P67 and P66 are input pins, with a low-level signal input at P67 and a
high-level signal at P66. The remaining pins, P65 to P60, are output pins that output low-level
signals. In this example, the BCLR instruction is used to change pin P60 to an input port. It is
assumed that a high-level signal will be input to this input pin.
When the BCLR instruction is executed, first the CPU reads PCR6. Since PCR6 is a write-only
register, the CPU reads a value of H'FF, even though the PCR6 value is actually H'3F.
Next, the CPU clears bit 0 in the read data to 0, changing the data to H'FE. Finally, this value
(H'FE) is written to PCR6 and BCLR instruction execution ends.
As a result of this operation, bit 0 in PCR6 becomes 0, making P60 an input port. However, bits 7
and 6 in PCR6 change to 1, so that P67 and P66 change from input pins to output pins.
53
Page 64
To avoid this problem, store a copy of the PCR6 data in a work area in memory. Perform the bit
manipulation on the data in the work area, then write this data to PCR6.
[A: Prior to executing BCLR]
MOV. B #3F, R0L
MOV. B R0L, @RAM0
MOV. B R0L, @PCR6
P6
P6
7
6
The PCR6 value (H'3F) is written to a work area in
memory (RAM0) as well as to PCR6.
Table 2.12 lists the registers with shared addresses. Table 2.13 lists the registers that contain writeonly bits.
Table 2.12 Registers with Shared Addresses
Register NameAbbreviationAddress
Timer counter YH / timer load register YHTCYH/TLYHH'FFCE
Timer counter YL / timer load register YLTCYL/TLYLH'FFCF
Port data register 1*PDR1H'FFD4
Port data register 2*PDR2H'FFD5
Port data register 5*PDR5H'FFD8
Port data register 6*PDR6H'FFD9
Port data register 7*PDR7H'FFDA
Port data register 8*PDR8H'FFDB
Port data register 9*PDR9H'FFDC
Port data register A*PDRAH'FFDD
Port data register E*PDREH'FFD3
Note: *The port data register addresses are also assigned directly to input pins.
Table 2.13 Registers with Write-Only Bits
Register NameAbbreviationAddress
Port control register 1PCR1H'FFE4
Port control register 2PCR2H'FFE5
Port control register 5PCR5H'FFE8
Port control register 6PCR6H'FFE9
Port control register 7PCR7H'FFEA
Port control register 8PCR8H'FFEB
Port control register 9PCR9H'FFEC
Port control register APCRAH'FFED
Port control register EPCREH'FFE3
Timer control register FTCRFH'FFB6
PWM control registerPWCRH'FFA4
PWM data register UPWDRUH'FFA5
PWM data register LPWDRLH'FFA6
55
Page 66
2.9.3Notes on Use of the EEPMOV Instruction
• 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
←
R6
R5 + R4L
→
Not allowed
H'FFFF
←
R6 + R4L
56
Page 67
Section 3 Exception Handling
3.1Overview
Exception handling is performed in the H8/3637 Series when a reset or interrupt occurs.
Table 3.1 shows the priorities of these two types of exception handling.
Table 3.1Exception Handling Types and Priorities
PriorityException SourceTime of Start of Exception Handling
HighResetException handling starts as soon as the reset state is cleared
InterruptWhen an interrupt is requested, exception handling starts after
execution of the present instruction or the exception handling
Low
3.2Reset
3.2.1Overview
A reset is the highest-priority exception. The internal state of the CPU and the registers of the onchip peripheral modules are initialized.
in progress is completed
3.2.2Reset Sequence
As soon as the RES pin goes low, all processing is stopped and the H8/3637 Series enters the reset
state.
To make sure the chip is reset properly, observe the following precautions.
• At power on: Hold the RES pin low until the clock pulse generator output stabilizes.
• When an external clock or ceramic oscillator is used, also, at power on the RES pin must be
held low for the crystal oscillator oscillation stabilization time shown in table 14.3 in section
14, Electrical Characteristics.
• Resetting during operation: Hold the RES pin low for at least 18 system clock cycles.
Reset exception handling begins when the RES pin is held low for a given period, then returned to
the high level. Reset exception handling takes place as follows.
• The CPU internal state and the registers of on-chip peripheral modules are initialized, with the
I bit of the condition code register (CCR) set to 1.
57
Page 68
• The PC is loaded from the reset exception handling vector address (H'0000 to H'0001), after
which the program starts executing from the address indicated in PC.
When system power is turned on or off, the RES pin should be held low.
Figure 3.1 shows the reset sequence.
Reset cleared
Program initial
instruction prefetch
RES
ø
Vector fetch
Internal
processing
Internal
address bus
Internal read
signal
Internal write
signal
Internal data
bus (16-bit)
(1)
(2)(3)
(1) Reset exception handling vector address (H'0000)
(2) Program start address
(3) First instruction of program
(2)
Figure 3.1 Reset Sequence
3.2.3Interrupt Immediately after Reset
After a reset, if an interrupt were to be accepted before the stack pointer (SP: R7) was initialized,
PC and CCR would not be pushed onto the stack correctly, resulting in program runaway. To
prevent this, immediately after reset exception handling all interrupts 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).
58
Page 69
3.3Interrupts
3.3.1Overview
The interrupt sources include 13 external interrupts (WKP0 to WKP7, IRQ0 to IRQ4), and 17
internal interrupts from on-chip peripheral modules. Table 3.2 shows the interrupt sources, their
priorities, and their vector addresses. When more than one interrupt is requested, the interrupt with
the highest priority is processed.
The interrupts have the following features:
• Internal and external interrupts can be masked by the I bit of CCR. When this bit is set to 1,
interrupt request flags are set but interrupts are not accepted.
• IRQ0 to IRQ4 can each be set independently to either rising edge sensing or falling edge
sensing.
59
Page 70
Table 3.2Interrupt Sources and Priorities
Interrupt SourceInterruptVector Number Vector AddressPriority
RESReset0H'0000 to H'0001 High
IRQ
0
IRQ
1
IRQ
2
IRQ
3
IRQ
4
WKP
0
WKP
1
WKP
2
WKP
3
WKP
4
WKP
5
WKP
6
WKP
7
SCI1SCI1 transfer complete10H'0014 to H'0015
Timer ATimer A overflow11H'0016 to H'0017
Timer YTimer Y overflow12H'0018 to H'0019
Timer FLTimer FL compare match
Timer FHTimer FH compare match
Timer GTimer G input capture
SCI3SCI3 receive data full
A/D converterA/D conversion end19H'0026 to H'0027
(SLEEP instruction
executed)
Note: Vector addresses H'0002 to H'0007, H'001A to H'001B, and H'0022 to H'0023 are reserved
and cannot be used.
IRQ
IRQ
IRQ
IRQ
IRQ
WKP
WKP
WKP
WKP
WKP
WKP
WKP
WKP
0
1
2
3
4
0
1
2
3
4
5
6
7
4H'0008 to H'0009
5H'000A to H'000B
6H'000C to H'000D
7H'000E to H'000F
8H'0010 to H'0011
9H'0012 to H'0013
14H'001C to H'001D
Timer FL overflow
15H'001E to H'001F
Timer FH overflow
16H'0020 to H'0021
Timer G overflow
18H'0024 to H'0025
SCI3 transmit data empty
SCI3 transmit end
SCI3 overrun error
SCI3 framing error
SCI3 parity error
Direct transfer20H'0028 to H'0029
Low
60
Page 71
3.3.2Interrupt Control Registers
Table 3.3 lists the registers that control interrupts.
Note: *Only a write of 0 for flag clearing is possible.
IRR1 is an 8-bit read/write register, in which the corresponding bit is set to 1 when a timer A,
SCI1, or IRQ4 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.
Bit 7—Timer A Interrupt Request Flag (IRRTA)
Bit 7: IRRTADescription
0[Clearing conditions](initial value)
When IRRTA = 1, it is cleared by writing 0
1[Setting conditions]
When the timer A counter value overflows (goes from H'FF to H'00)
65
Page 76
Bit 6—SCI1 Interrupt Request Flag (IRRS1)
Bit 6: IRRS1Description
0[Clearing conditions](initial value)
When IRRS1 = 1, it is cleared by writing 0
1[Setting conditions]
When an SCI1 transfer is completed
Bit 5—Reserved Bit: Bit 5 is reserved; it is always read as 1, and cannot be modified.
Bits 4 to 0—IRQ4 to IRQ0 Interrupt Request Flags (IRRI4 to IRRI0)
Bits 4 to 0:
IRRI4 to IRRI0Description
0[Clearing conditions](initial value)
When IRRIn = 1, it is cleared by writing 0 to IRRIn.
1[Setting conditions]
IRRIn is set when pin IRQ
edge is detected.
is set to interrupt input, and the designated signal
Note: *Only a write of 0 for flag clearing is possible.
IRR2 is an 8-bit register containing direct transfer, A/D converter, timer G, timer FH, timer FL,
and timer Y interrupt flags. When a direct transfer, A/D converter, timer G, timer FH, timer FL, or
timer Y interrupt is requested, the corresponding flag is set to 1. The flags are not cleared
automatically when an interrupt is accepted. It is necessary to write 0 to clear each flag. However,
the timer Y interrupt request flag (IRRTY) is cleared by writing 0 to bit 0 (IRRTYC).
66
Page 77
Bit 7—Direct Transfer Interrupt Request Flag (IRRDT)
Bit 7: IRRDTDescription
0[Clearing conditions](initial value)
When IRRDT = 1, it is cleared by writing 0
1[Setting conditions]
When DTON = 1 and a direct transfer is made immediately after a SLEEP
instruction is executed
Bit 6—A/D Converter Interrupt Request Flag (IRRAD)
Bit 6: IRRADDescription
0[Clearing conditions](initial value)
When IRRAD = 1, it is cleared by writing 0
1[Setting conditions]
When A/D conversion is completed and ADSF is reset
Bit 5—Reserved Bit: Bit 5 is reserved: it is always read as 0, and should be used cleared to 0.
Bit 4—Timer G Interrupt Request Flag (IRRTG)
Bit 4: IRRTGDescription
0[Clearing conditions](initial value)
When IRRTG = 1, it is cleared by writing 0
1[Setting conditions]
When pin TMIG is set to TMIG input and the designated signal edge is
detected, or when TCG overflows (from H’FF to H’00) while TMG OVIE is set
to 1
Bit 3—Timer FH Interrupt Request Flag (IRRTFH)
Bit 3: IRRTFHDescription
0[Clearing conditions](initial value)
When IRRTFH = 1, it is cleared by writing 0
1[Setting conditions]
When counter FH matches output compare register FH in 8-bit timer mode, or
when 16-bit counter F (TCFL, TCFH) matches output compare register F
(OCRFL, OCRFH) in 16-bit timer mode
67
Page 78
Bit 2—Timer FL Interrupt Request Flag (IRRTFL)
Bit 2: IRRTFLDescription
0[Clearing conditions](initial value)
When IRRTFL = 1, it is cleared by writing 0
1[Setting conditions]
When counter FL matches output compare register FL in 8-bit timer mode
Bit 1—Timer Y Interrupt Request Flag (IRRTY)
Bit 1: IRRTYDescription
0[Clearing conditions](initial value)
When IRRTY is 1, it is cleared by writing 0 to IRRTYC
1[Setting conditions]
When the timer Y counter value overflows (from H’FFFF to H’0000)
Note: This bit is read-only. It is cleared by writing 0 to bit 0 (IRRTYC).
Bit 0—Timer Y Interrupt Request Clear Flag (IRRTYC): Bit 0 is a special bit for clearing
the IRRTY interrupt request flag. Writing 0 to this bit clears bit 1 (IRRTY) to 0. Note that
writing 0 to this bit does not give the bit itself a value of 0.
Bit 0 is always read as 1, and only a write of 0 to this bit is valid.
Note: *Only a write of 0 for flag clearing is possible.
IWPR is an 8-bit read/write register, in which the corresponding bit is set to 1 when pins WKP7 to
WKP0 are set to wakeup input and a pin receives a falling edge input. The flags are not cleared
automatically when an interrupt is accepted. It is necessary to write 0 to clear each flag.
68
Page 79
Bits 7 to 0—Wakeup Interrupt Request Flags (IWPF7 to IWPF0)
Bits 7 to 0:
IWPF7 to IWPF0Description
0[Clearing conditions](initial value)
When IWPFn = 1, it is cleared by writing 0 to IWPFn.
1[Setting conditions]
IWPFn is set when pin WKP
edge input is detected at the pin.
is set to wakeup interrupt input, and a falling
n
(n = 7 to 0)
3.3.3External Interrupts
There are 13 external interrupts, WKP0 to WKP7 and IRQ0 to IRQ4.
Interrupts WKP0 to WKP7: Interrupts WKP0 to WKP7 are requested by falling edge inputs at
pins WKP0 to WKP7. When these pins are designated as WKP0 to WKP7 pins in port mode register
5 (PMR5) and falling edge input is detected, the corresponding bit in the wakeup interrupt request
register (IWPR) is set to 1, requesting an interrupt. Wakeup interrupt requests can be disabled by
clearing the IENWP bit in IENR1 to 0. It is also possible to mask all interrupts by setting the CCR
I bit to 1.
When an interrupt exception handling request is received for interrupts WKP0 to WKP7, the CCR I
bit is set to 1. The vector number for interrupts WKP0 to WKP7 is 9. Since all eight interrupts are
assigned the same vector number, the interrupt source must be determined by the exception
handling routine.
Interrupts IRQ0 to IRQ4: Interrupts IRQ0 to IRQ4 are requested by inputs into pins IRQ0 to IRQ4.
These interrupts are detected by either rising edge sensing or falling edge sensing, depending on
the settings of bits IEG0 to IEG4 in the edge select register (IEGR).
When these pins are designated as pins IRQ0 to IRQ4 in port mode registers 1 and 2 (PMR1 and
PMR2) and the designated edge is input, the corresponding bit in IRR1 is set to 1, requesting an
interrupt. Interrupts IRQ0 to IRQ4 can be disabled by clearing bits IEN0 to IEN4 in IENR1 to 0.
All interrupts can be masked by setting the I bit in CCR to 1.
When IRQ0 to IRQ4 interrupt exception handling is initiated, the I bit in CCR is set to 1. Vector
numbers 4 to 8 are assigned to interrupts IRQ0 to IRQ4. The order of priority is from IRQ0 (high)
to IRQ4 (low). Table 3.2 gives details.
69
Page 80
3.3.4Internal Interrupts
There are 17 internal interrupts that can be requested by the on-chip peripheral modules. When a
peripheral module requests an interrupt, the corresponding bit in IRR1 or IRR2 is set to 1.
Individual interrupt requests can be disabled by clearing the corresponding bit in IENR1 or IENR2
to 0. All interrupts can be masked by setting the I bit in CCR to 1. When an internal interrupt
request is accepted, the I bit in CCR is set to 1. Vector numbers 10 to 20 are assigned to these
interrupts. Table 3.2 shows the order of priority of interrupts from on-chip peripheral modules.
3.3.5Interrupt Operations
Interrupts are controlled by an interrupt controller. Figure 3.2 shows a block diagram of the
interrupt controller. Figure 3.3 shows the flow up to interrupt acceptance.
Interrupt controller
External or
internal
interrupts
Interrupt
request
Priority decision logic
External
interrupts or
internal
interrupt
enable
signals
CCR (CPU)I
Figure 3.2 Block Diagram of Interrupt Controller
Interrupt operation is described as follows.
1. When an interrupt condition is met while the interrupt enable register bit is set to 1, an
interrupt request signal is sent to the interrupt controller.
2. When the interrupt controller receives an interrupt request, it sets the interrupt request flag.
70
Page 81
3. 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.)
4. The interrupt controller checks the I bit of CCR. If the I bit is 0, the selected interrupt request is
accepted; if the I bit is 1, the interrupt request is held pending.
5. If the interrupt is accepted, after processing of the current instruction is completed, both PC
and CCR are pushed onto the stack. The state of the stack at this time is shown in figure 3.4.
The PC value pushed onto the stack is the address of the first instruction to be executed upon
return from interrupt handling.
6. The I bit of CCR is set to 1, masking all further interrupts.
7. The vector address corresponding to the accepted interrupt is generated, and the interrupt
handling routine located at the address indicated by the contents of the vector address is
executed.
Notes: 1. When disabling interrupts by clearing bits in an interrupt enable register, or when
clearing bits in an interrupt request 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 processing for the
interrupt will be executed after the clear instruction has been executed.
71
Page 82
Program execution state
IRRI0 = 1
Yes
IEN0 = 1
Yes
I = 0
No
No
No
IRRI1 = 1
Yes
IEN1 = 1
Yes
No
No
IRRI2 = 1
Yes
IEN2 = 1
Yes
No
No
IRRDT = 1
IENDT = 1
No
Yes
No
Yes
72
PC contents saved
CCR contents saved
Branch to interrupt
handling routine
Legend:
PC:
Program counter
CCR:
Condition code register
I:
I bit of CCR
Yes
I ← 1
Figure 3.3 Flow up to Interrupt Acceptance
Page 83
SP – 4
SP – 3
SP – 2
SP – 1
SP (R7)
Stack area
SP (R7)
SP + 1
SP + 2
SP + 3
SP + 4
CCR
CCR*
PC
H
PC
L
Even address
Prior to start of interrupt
exception handling
Legend:
PC
Upper 8 bits of program counter (PC)
:
H
Lower 8 bits of program counter (PC)
PC
:
L
Condition code register
CCR:
Stack pointer
SP:
1.2.PC shows the address of the first instruction to be executed upon
Notes:
PC and CCR
saved to stack
After completion of interrupt
exception handling
return from the interrupt handling routine.
Register contents must always be saved and restored by word access,
starting from an even-numbered address.
* Ignored on return from interrupt.
Figure 3.4 Stack State after Completion of Interrupt Exception Handling
Figure 3.5 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.
73
Page 84
Prefetch instruction of
interrupt-handling routine
Internal
processing
Vector fetch
Stack access
Internal
processing
Instruction
prefetch
(9)
(3)(9)(8)(6)(5)
(4)(1)(7)(10)
74
Interrupt is
accepted
Interrupt level
decision and wait for
end of instruction
Interrupt
request signal
(1)
ø
Internal
address bus
Internal read
signal
Internal write
signal
Figure 3.5 Interrupt Sequence
(2)
(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
Internal data bus
(16 bits)
Page 85
3.3.6Interrupt 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 handler is executed.
Table 3.4Interrupt Wait States
ItemStatesTotal
Waiting time for completion of executing instruction*1 to 1315 to 27
Saving of PC and CCR to stack4
Vector fetch2
Instruction fetch4
Internal processing4
Note: *Not including EEPMOV instruction.
75
Page 86
3.4Application Notes
3.4.1Notes on Stack Area Use
When word data is accessed in the H8/3637 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.6.
PC
→
SP
→
SP
BSR instruction
SP set to H'FEFFStack accessed beyond SP
Legend:
PC
:
Upper byte of program counter
H
PC
:
Lower byte of program counter
L
R1L:
General register R1L
SP:
Stack pointer
PC
H
L
MOV. B R1L, @–R7
→
SP
Contents of PC are lost
R1L
PC
L
H'FEFC
H'FEFD
H'FEFF
H
Figure 3.6 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.4.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.
76
Page 87
When an external interrupt pin function is switched by rewriting the port mode register that
controls these pins (IRQ4 to IRQ0, and WKP7 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. Be sure to
clear the interrupt request flag to 0 after switching pin functions. Table 3.5 shows the conditions
under which interrupt request flags are set to 1 in this way.
Table 3.5Conditions under which Interrupt Request Flag is Set to 1
Interrupt Request
Flags Set to 1Conditions
IRR1IRRI4
IRRI3
IRRI2
IRRI1
IRRI0
IWPRIWPF7When PMR5 bit WKP7 is changed from 0 to 1 while pin WKP7 is low
IWPF6When PMR5 bit WKP6 is changed from 0 to 1 while pin WKP6 is low
IWPF5When PMR5 bit WKP5 is changed from 0 to 1 while pin WKP5 is low
IWPF4When PMR5 bit WKP4 is changed from 0 to 1 while pin WKP4 is low
IWPF3When PMR5 bit WKP3 is changed from 0 to 1 while pin WKP3 is low
IWPF2When PMR5 bit WKP2 is changed from 0 to 1 while pin WKP2 is low
IWPF1When PMR5 bit WKP1 is changed from 0 to 1 while pin WKP1 is low
IWPF0When PMR5 bit WKP0 is changed from 0 to 1 while pin WKP0 is low
• When PMR2 bit IRQ4 is changed from 0 to 1 while pin IRQ
IEGR bit IEG4 = 0.
• When PMR2 bit IRQ4 is changed from 1 to 0 while pin IRQ
IEGR bit IEG4 = 1.
• When PMR1 bit IRQ3 is changed from 0 to 1 while pin IRQ
IEGR bit IEG3 = 0.
• When PMR1 bit IRQ3 is changed from 1 to 0 while pin IRQ
IEGR bit IEG3 = 1.
• When PMR1 bit IRQ2 is changed from 0 to 1 while pin IRQ
IEGR bit IEG2 = 0.
• When PMR1 bit IRQ2 is changed from 1 to 0 while pin IRQ
IEGR bit IEG2 = 1.
• When PMR1 bit IRQ1 is changed from 0 to 1 while pin IRQ
IEGR bit IEG1 = 0.
• When PMR1 bit IRQ1 is changed from 1 to 0 while pin IRQ
IEGR bit IEG1 = 1.
• When PMR2 bit IRQ0 is changed from 0 to 1 while pin IRQ
IEGR bit IEG0 = 0.
• When PMR2 bit IRQ0 is changed from 1 to 0 while pin IRQ
IEGR bit IEG0 = 1.
is low and
4
is low and
4
is low and
3
is low and
3
is low and
2
is low and
2
is low and
1
is low and
1
is low and
0
is low and
0
77
Page 88
Figure 3.7 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 is to avoid the setting of interrupt request flags when pin functions are
switched by keeping 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
Execute NOP instruction
Clear interrupt request flag to 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
78
CCR I bit 0
←
Interrupt mask cleared
Figure 3.7 Port Mode Register Setting and Interrupt Request Flag
Clearing Procedure
Page 89
Section 4 Clock Pulse Generators
4.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.
4.1.1Block Diagram
Figure 4.1 shows a block diagram of the clock pulse generators.
ø
OSC
ø/2
to
ø/8192
ø
W
ø /2
W
ø /4
W
ø /8
W
to
ø /128
W
OSC
OSC
1
System clock
2
X
1
X
2
oscillator
System clock pulse generator
Subclock
oscillator
Subclock pulse generator
ø
OSC
(f )
ø
(f )
OSC
W
W
System clock
divider (1/2)
Subclock
divider
(1/2, 1/4, 1/8)
ø /2
OSC
System clock
divider (1/8)
ø /2
W
ø /4
W
ø /8
W
ø /16
OSC
ø
Prescaler S
(13 bits)
ø
SUB
Prescaler W
(5 bits)
Figure 4.1 Block Diagram of Clock Pulse Generators
4.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,
OSC
ø/128, ø/256, ø/512, ø/1024, ø/2048, ø/4096, ø/8192, øW, øW/2, øW/4, øW/8, øW/16, øW/32, øW/64,
and øW/128. The clock requirements differ from one module to another.
4.2System Clock Generator
Clock pulse can be supplied to the system clock divider either by connecting a crystal or ceramic
oscillator, or by providing external clock input.
79
Page 90
Connecting a Crystal Oscillator: Figure 4.2 shows a typical method of connecting a crystal
oscillator.
C
OSC
OSC
1
R
f
2
1
R = 1 M ±20%
C = C = 12 pF ±20%
C
2
12
Ω
f
Figure 4.2 Typical Connection to Crystal Oscillator
Figure 4.3 shows the equivalent circuit of a crystal oscillator. An oscillator having the
characteristics given in table 4.1 should be used.
C
S
OSC
L
S
1
C
0
R
S
OSC
2
Figure 4.3 Equivalent Circuit of Crystal Oscillator
Connecting a Ceramic Oscillator: Figure 4.4 shows a typical method of connecting a ceramic
oscillator.
C
OSC
OSC
1
R
f
2
1
Rf = 1 MΩ± 20%
C
= 30 pF ± 10%
C
2
1
C
= 30 pF ± 10%
2
Ceramic oscillator: Murata
Figure 4.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 4.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
1
C
2
Figure 4.5 Board Design of Oscillator Circuit
Signal A Signal B
OSC
OSC
1
2
81
Page 92
External Clock Input Method: Connect an external clock signal to pin OSC1, and leave pin
OSC2 open. Figure 4.6 shows a typical connection.
OSC
1
OSC
2
Open
Figure 4.6 External Clock Input (Example)
FrequencyOscillator Clock (ø
Duty cycle45% to 55%
OSC
External clock input
)
82
Page 93
4.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 4.7. Follow the same
precautions as noted in 4.2, Notes on Board Design.
C
X
1
R
f
X
2
Figure 4.7 Typical Connection to 32.768-kHz Crystal Oscillator
Figure 4.8 shows the equivalent circuit of the 32.768-kHz crystal oscillator.
C
S
1
C = C = 15 pF (typ.)
C
2
12
R
= 10 MΩ (typ.)
f
LR
X
1
S
C
0
S
C = 1.5 pF typ
0
R = 14 k typ
S
f = 32.768 kHz
W
Ω
X
2
Crystal oscillator: MX38T
(Nihon Denpa Kogyo)
Figure 4.8 Equivalent Circuit of 32.768-kHz Crystal Oscillator
Pin Connection when Not Using Subclock: When the subclock is not used, connect pin X1 to
VCC and leave pin X2 open, as shown in figure 4.9.
V
CC
X
1
X
2
Open
Figure 4.9 Pin Connection when not Using Subclock
83
Page 94
4.4Prescalers
The H8/3637 Series 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, watch 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 ø
OSC
/16.
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, watch mode, subactive mode, or subsleep mode, prescaler W continues
functioning so long as clock signals are supplied to pins X1 and X2.
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.
4.5Note on Oscillators
Oscillator characteristics of both the masked ROM and ZTATTM versions are closely related to
board design and should be carefully evaluated by the user, referring to the examples shown in this
section and figure 4.10, Example of Crystal and Ceramic Oscillator Layout. 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.
84
Page 95
AV
X
X
V
OSC
OSC
SS
1
2
SS
2
1
TEST
(VSS)
Figure 4.10 Example of Crystal and Ceramic Oscillator Layout.
85
Page 96
Section 5 Power-Down Modes
5.1Overview
The H8/3637 Series has seven modes of operation after a reset. These include six power-down
modes, in which power dissipation is significantly reduced.
Table 5.1 gives a summary of the seven operation modes.
Table 5.1Operation Modes
Operating ModeDescription
Active (high-speed) modeThe CPU runs on the system clock, executing program
instructions at high speed
Active (medium-speed) modeThe CPU runs on the system clock, executing program
instructions at reduced speed
Subactive modeThe CPU runs on the subclock, executing program instructions
at reduced speed
Sleep modeThe CPU halts. On-chip peripheral modules continue to operate
on the system clock.
Subsleep modeThe CPU halts. Timer A, and timer G, continue to operate on
the subclock.
Watch modeThe CPU halts. The time-base function of Timer A continues to
operate on the subclock.
Standby modeThe CPU and all on-chip peripheral modules stop operating
All but the active (high-speed) mode are power-down modes.
In this section the two active modes (high-speed and medium-speed) are referred to collectively as
active mode.
Figure 5.1 shows the transitions among these operation modes. Table 5.2 indicates the internal
states in each mode.
87
Page 97
Reset state
Program executingProgram execution stopped
LSON = 0, MSON = 0
Program execution stopped
SSBY = 1,
TMA3 = 0,
LSON = 0
Standby mode
SLEEP instruction
SLEEP instruction
SSBY = 1,
TMA3 = 1
Watch mode
DTON = 1
SLEEP instruction
SLEEP instruction
Active (high-speed)
*
4
SLEEP instruction
LSON = 0,
MSON = 1
*
4
*
1
(medium-speed)
DTON = 1
*
1
LSON = 1,
TMA3 = 1
mode
*
1
DTON = 1
Active
mode
SLEEP
instruction
*
3
SLEEP instruction
*
3
SLEEP
instruction
*
2
SSBY = 0,
LSON = 0
Sleep mode
SSBY = 0,
LSON = 1,
TMA3 = 1
Subsleep modeSubactive mode
: Transition caused by exception handling→
Power-down mode
A transition between different modes cannot be made to occur simply because an interrupt request is
generated. Make sure that the interrupt is accepted and interrupt handling is performed.
Details on the mode transition conditions are given in the explanations of each mode, in sections 5.2
through 5.8.
Notes:Timer A interrupt, IRQ interrupt, WKP to WKP interrupts
1.
Timer A interrupt, timer G interrupt, IRQ0 to IRQ4 interrupts, WKP0 to WKP7
2.
007
interrupts
All interrupts
3.
4.
IRQ interrupt, IRQ interrupt, WKP to WKP interrupts
SYSCR1 is an 8-bit read/write register for control of the power-down modes.
Upon reset, SYSCR1 is initialized to H'07.
Bit 7—Software Standby (SSBY): This bit designates transition to standby mode or watch mode.
Bit 7: SSBYDescription
0
1
• When a SLEEP instruction is executed in active mode, a transition is
made to sleep mode.
• When a SLEEP instruction is executed in subactive mode, a transition is
made to subsleep mode. (initial value)
• When a SLEEP instruction is executed in active mode, a transition is
made to standby mode or watch mode.
• When a SLEEP instruction is executed in subactive mode, a transition is
made to watch 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 standby mode or
watch mode to active 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.
90
Page 100
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
1**Wait time = 131,072 states
Note: *Don’t care
Bit 3—Low Speed on Flag (LSON): This bit chooses the system clock (ø) or subclock (ø
SUB
) as
the CPU operating clock when watch mode is cleared. The resulting operation mode depends on
the combination of other control bits and interrupt input.
Bit 3: LSONDescription
0The CPU operates on the system clock (ø)(initial value)
1The CPU operates on the subclock (ø
SUB
)
Bits 2 to 0—Reserved Bits: These bits are reserved; they are always read as 1, and cannot be
modified.