H8 539 Extended
H8 539 Extended
H8 539 Extended
The semiconductor operations of Mitsubishi Electric and Hitachi were transferred to Renesas
Technology Corporation on April 1st 2003. These operations include microcomputer, logic, analog
and discrete devices, and memory chips other than DRAMs (flash memory, SRAMs etc.)
Accordingly, although Hitachi, Hitachi, Ltd., Hitachi Semiconductors, and other Hitachi brand
names are mentioned in the document, these names have in fact all been changed to Renesas
Technology Corp. Thank you for your understanding. Except for our corporate trademark, logo and
corporate statement, no changes whatsoever have been made to the contents of the document, and
these changes do not constitute any alteration to the contents of the document itself.
H8/539F-ZTAT™
HD64F5398
HD64F5398S
HD64F5398A
Hardware Manual
ADE-602-108B
Rev 3.0
2/18/1999
Hitachi, Ltd.
Cautions
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.
Preface
1
The H8/539F is an F-ZTAT* microcontroller with on-chip flash memory that can be
2
reprogrammed onboard, offering even better field-programmability than ZTAT*
microcontrollers with user-programmable on-chip ROM.
The general-register architecture and highly orthogonal, optimized instruction set of the H8/500
CPU enable even programs coded in the high-level C language to be compiled into efficient object
code.
Many of the peripheral functions needed in microcontroller application systems are provided on-
chip, including large RAM and ROM, a powerful set of timers, a serial interface, a high-precision
A/D converter, and I/O ports. Compact, high-performance systems can thus be implemented
easily.
Additionally, the on-chip flash memory makes this microcontroller suitable for high-speed data
transfer and fast arithmetic/logic operations.
This document describes the H8/539F hardware. For further details about the H8/500 CPU
instruction set, refer to the H8/500 Series Programming Manual.
1.1 Features
The H8/539F is a CMOS microcomputer unit (MCU) with an original Hitachi architecture. It
consists of an H8/500 CPU core plus supporting functions required in system configurations.
The H8/500 CPU features a highly orthogonal instruction set that permits addressing modes and
data sizes to be specified independently in each instruction. An internal 16-bit architecture and
16-bit, two-state access to both on-chip memory and external memory enhance the CPU's data-
processing capability and provide the speed needed for realtime control applications.
The on-chip supporting functions include RAM, ROM, timers, a serial communication interface
(SCI), A/D converter, and I/O ports. An on-chip data transfer controller (DTC) provides an
efficient way to transfer data in either direction between memory and I/O without using the CPU.
A ZTAT™* (Zero Turn-Around Time) version of the H8/539 is already available, with on-chip
ROM that can be freely programmed by the user. However, the PROM in the ZTAT version can
be programmed once only. Flash memory, on the other hand, is electrically programmable and
erasable, so that it can be reprogrammed while mounted on the circuit board. Moreover, the
single-transistor structure of flash memory-in contrast to the two-transistor structure of EEPROM-
makes it suitable for large-capacity applications.
Use of the H8/539F with on-chip flash memory allows the program and data to be modified even
after embedding in the application system, offering QTAT capability for small-lot, multiple-model
production, and the possibility of optimization tuning on an individual product basis, as well as
version upgrading and maintenance affer shipment.
Feature Description
H8/500 CPU General-register machine
• Eight 16-bit general registers
• Five 8-bit and two 16-bit control registers
High-speed operation
• Maximum clock rate : 16 MHz (oscillator frequency: 16 MHz)
• ROM:
128-kbyte flash memory
8 block divisions
(32 kB × 3, 28 kB × 1, 1 kB × 4)
S-mask and A-mask models single power source
Feature Description
16-bit integrated- Pulse unit with seven 16-bit timer channels
timer pulse unit Compare/Capture
(IPU) Channel Compare Registers Registers
Channel 1 4 4
Channels 2 to 5 2 each 2 each
Channels 6 & 7 2 each
Synchronization function
• Counters on different channels can be synchronized
Feature Description
I/O ports • 74 input/output pins
• 12 input-only pins
Data transfer • Can transfer data in both directions between memory and I/O without using
controller (DTC) the CPU
Wait-state • Can insert wait states (TW) in access to external I/O or memory
controller (WSC)
Bus controller • Address space can be partitioned into 16-bit-bus and 8-bit-bus areas
(BSC) • Address space can be partitioned into two-state-access and three-state-
access areas
• I/O ports can be expanded and reconfigured
Feature Description
Multiplier • 16 bit × 16 bit signed or unsigned multiplication
(MULT) • Multiply-accumulate: 32 bits (saturating); 42 bits (non-saturating)
Product lineup
Model Package ROM
Dual power HD64F5398F 112-pin Flash memory
source system plastic QFP (VPP = 12 V)
(FP-112)
Single power HD64F5398SF 112-pin Flash memory
source system plastic QFP (single power
(S-mask model) (FP-112) source)
Single power HD64F5398AF
source system
Noise reduction
(A-mask model)
P17/D15
P16/D14
P15/D13
P14/D12
P13/D11
P12/D10
PB7/A15
PB6/A14
PB5/A13
PB4/A12
PB3/A11
PB2/A10
PC7/A7
PC6/A6
PC5/A5
PC4/A4
PC3/A3
PC2/A2
PC1/A1
PC0/A0
P27/D7
P26/D6
P25/D5
P24/D4
P23/D3
P22/D2
P21/D1
P20/D0
P11/D9
P10/D8
PB1/A9
PB0/A8
Port 2 Port 1 Port C Port B
PA6/BACK/T3OC2/TXD3
PA5/BREQ/T3OC1/RXD3
PA4/WAIT
Port A
PA3/A19/T5OC2/SCK3
PA2/A18/T5OC1/PW3
Port 9
STBY Data
transfer P93/AN3
Address bus
MD0 controller
MD1 P92/AN2
MD2 P91/AN1
PWM timer 10-bit A/D P90/AN0
HWR converter
(3 channels)
LWR (12 channels)
RD
AS P83/AN11
Watchdog
Port 8
φ timer P82/AN10
*2 VCC Bus controller
Address bus
P81/AN9
VCC P80/AN8
VCC
Data bus (upper)
VSS 16-bit
VSS integrated- Serial
VSS timer pulse communication P77/SCK2/PW2
Data bus (lower)
AVCC P74/TXD2
AVSS P73/RXD1
VREF P72/TXD1
P71/IRQ1/ADTRG
P70/IRQ0
P47/T7IOC2
P46/T7IOC1
P45/T6IOC2
P44/T6IOC1
P43/T5IOC2
P42/T5IOC1
P41/T4IOC2
P40/T4IOC1
P57/T3IOC2
P56/T3IOC1
P55/T2IOC2
P54/T2IOC1
P53/T1IOC4
P52/T1IOC3
P51/T1IOC2
P50/T1IOC1
P61/IRQ3
P64/TCLK3
P63/TCLK2
P62/TCLK1
Note: *1 In the dual power source model (VPP = 12 V), this is the RESO (output)/VPP (input) pin.
In the S-mask and A-mask models (single power source), it is the FWE (input) pin.
*2 In the A-mask model (single power source), pin 1 (FP-112) is the VCL pin, not the VCC pin.
Figure 1-2 (a) shows the pin arrangement of the H8/539F (FP-112 package).
PA3/A19/T5OC2/SCK3
PA2/A18/T5OC1/PW3
PA1/A17/T4OC2/PW2
PA0/A16/T4OC1/PW1
PA4/WAIT
PB7/A15
PB6/A14
PB5/A13
PB4/A12
PB3/A11
EXTAL
STBY
XTAL
HWR
AVCC
LWR
RES
MD2
MD1
MD0
NMI
VCC
VSS
RD
AS
φ
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
VREF 85 56 PB2/A10
P90/AN0 86 55 PB1/A9
P91/AN1 87 54 PB0/A8
P92/AN2 88 53 VSS
P93/AN3 89 52 PC7/A7
P94/AN4 90 51 PC6/A6
P95/AN5 91 50 PC5/A5
P96/AN6 92 49 PC4/A4
P97/AN7 93 48 PC3/A3
P80/AN8 94 47 PC2/A2
P81/AN9 95 46 PC1/A1
P82/AN10 96 45 PC0/A0
P83/AN11 97 44 VCC
AVSS 98 Top view 43 P17/D15
VSS 99 (FP-112) 42 P16/D14
P70/IRQ0 100 41 P15/D13
P71/IRQ1/ADTRG 101 40 P14/D12
P72/TXD1 102 39 P13/D11
P73/RXD1 103 38 P12/D10
P74/TXD2 104 37 P11/D9
P75/RXD2 105 36 P10/D8
P76/SCK1/PW1 106 35 VSS
P77/SCK2/PW2 107 34 P27/D7
P60/IRQ2/PW3 108 33 P26/D6
P61/IRQ3 109 32 P25/D5
P62/TCLK1 110 31 P24/D4
P63/TCLK2 111 30 P23/D3
P64/TCLK3 112 29 P22/D2
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
RESO*/VPP
VSS
P20/D0
P21/D1
VSS
P30/T1OC1
P31/T1OC2
P32/T1OC3
P33/T1OC4
P34/T2OC1
P35/T2OC2
P50/T1IOC1
P51/T1IOC2
P52/T1IOC3
P53/T1IOC4
P54/T2IOC1
P55/T2IOC2
P56/T3IOC1
P57/T3IOC2
P40/T4IOC1
P41/T4IOC2
P42/T5IOC1
P43/T5IOC2
P44/T6IOC1
P45/T6IOC2
P46/T7IOC1
P47/T7IOC2
VCC
Pin 1
PA5/BREQ/T3OC1/RXD3
PA6/BACK/T3OC2/TXD3
PA3/A19/T5OC2/SCK3
PA2/A18/T5OC1/PW3
PA1/A17/T4OC2/PW2
PA0/A16/T4OC1/PW1
PA4/WAIT
PB7/A15
PB6/A14
PB5/A13
PB4/A12
PB3/A11
EXTAL
STBY
MD2 *
XTAL
HWR
AVCC
LWR
RES
MD1
MD0
NMI
VCC
VSS
RD
AS
φ
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
VREF 85 56 PB2/A10
P90/AN0 86 55 PB1/A9
P91/AN1 87 54 PB0/A8
P92/AN2 88 53 VSS
P93/AN3 89 52 PC7/A7
P94/AN4 90 51 PC6/A6
P95/AN5 91 50 PC5/A5
P96/AN6 92 49 PC4/A4
P97/AN7 93 48 PC3/A3
P80/AN8 94 47 PC2/A2
P81/AN9 95 46 PC1/A1
P82/AN10 96 45 PC0/A0
P83/AN11 97 44 VCC
AVSS 98 Top view 43 P17/D15
VSS 99 (FP-112) 42 P16/D14
P70/IRQ0 100 41 P15/D13
P71/IRQ1/ADTRG 101 40 P14/D12
P72/TXD1 102 39 P13/D11
P73/RXD1 103 38 P12/D10
P74/TXD2 104 37 P11/D9
P75/RXD2 105 36 P10/D8
P76/SCK1/PW1 106 35 VSS
P77/SCK2/PW2 107 34 P27/D7
P60/IRQ2/PW3 108 33 P26/D6
P61/IRQ3 109 32 P25/D5
P62/TCLK1 110 31 P24/D4
P63/TCLK2 111 30 P23/D3
P64/TCLK3 112 29 P22/D2
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
VSS
P20/D0
P21/D1
P30/T1OC1
P31/T1OC2
P32/T1OC3
P33/T1OC4
P34/T2OC1
P35/T2OC2
P50/T1IOC1
P51/T1IOC2
P52/T1IOC3
P53/T1IOC4
P54/T2IOC1
P55/T2IOC2
P56/T3IOC1
P57/T3IOC2
P40/T4IOC1
P41/T4IOC2
P42/T5IOC1
P43/T5IOC2
P44/T6IOC1
P45/T6IOC2
P46/T7IOC1
P47/T7IOC2
VSS
*FWE
VCC
Notes: * (1) Pin 19 is the /VPP pin in the dual power source
model (VPP = 12 V), and the FWE pin* in the S-mask
model (single power source). (* The S-mask model H8/539
does not have a output.) S
HD64F5398F
(2) Under no circumstances apply 12 V to the JAPAN
S-mask model (single power source), as this
may cause permanent damage to the chip. Pin 1
Figure 1-2 (b) H8/539F S-Mask Model Pin Arrangement (FP-112, Top View)
PA3/A19/T5OC2/SCK3
PA2/A18/T5OC1/PW3
PA1/A17/T4OC2/PW2
PA0/A16/T4OC1/PW1
PA4/WAIT
PB7/A15
PB6/A14
PB5/A13
PB4/A12
PB3/A11
EXTAL
MD2*1
STBY
XTAL
HWR
AVCC
LWR
RES
MD1
MD0
NMI
VCC
VSS
RD
AS
φ
84
83
82
81
80
79
78
77
76
75
74
73
72
71
70
69
68
67
66
65
64
63
62
61
60
59
58
57
VREF 85 56 PB2/A10
P90/AN0 86 55 PB1/A9
P91/AN1 87 54 PB0/A8
P92/AN2 88 53 VSS
P93/AN3 89 52 PC7/A7
P94/AN4 90 51 PC6/A6
P95/AN5 91 50 PC5/A5
P96/AN6 92 49 PC4/A4
P97/AN7 93 48 PC3/A3
P80/AN8 94 47 PC2/A2
P81/AN9 95 46 PC1/A1
P82/AN10 96 45 PC0/A0
P83/AN11 97 44 VCC
AVSS 98 Top view 43 P17/D15
VSS 99 (FP-112) 42 P16/D14
P70/IRQ0 100 41 P15/D13
P71/IRQ1/ADTRG 101 40 P14/D12
P72/TXD1 102 39 P13/D11
P73/RXD1 103 38 P12/D10
P74/TXD2 104 37 P11/D9
P75/RXD2 105 36 P10/D8
P76/SCK1/PW1 106 35 VSS
P77/SCK2/PW2 107 34 P27/D7
P60/IRQ2/PW3 108 33 P26/D6
P61/IRQ3 109 32 P25/D5
P62/TCLK1 110 31 P24/D4
P63/TCLK2 111 30 P23/D3
P64/TCLK3 112 29 P22/D2
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
1
2
3
4
5
6
7
8
9
VSS
P20/D0
P21/D1
P30/T1OC1
P31/T1OC2
P32/T1OC3
P33/T1OC4
P34/T2OC1
P35/T2OC2
P50/T1IOC1
P51/T1IOC2
P52/T1IOC3
P53/T1IOC4
P54/T2IOC1
P55/T2IOC2
P56/T3IOC1
P57/T3IOC2
P40/T4IOC1
P41/T4IOC2
P42/T5IOC1
P43/T5IOC2
P44/T6IOC1
P45/T6IOC2
P46/T7IOC1
P47/T7IOC2
*1FWE
VSS
VCL
*2 0.1µF
Note: 1. (1) Pin19 is the RESO/VPP pin in the dual power source H8/539
model (VPP = 12 V), and the FWE pin* in the A-mask A
model. (*The A-mask model does not have a RESO HD64F5398F
output.) JAPAN
Figure 1-2 (c) H8/539F A-Mask Model Pin Arrangement (FP-112, Top View)
(1) Pin Assignments in Each Operating Mode: Table 1-2 lists the assignments of the pins of the
FP-112 package in each operating mode.
Serial TXD1 102 Output Transmit data 1, 2, and 3: Serial transmit data
commu- TXD2 104 output pins for SCI1, SCI2, and SCI3.
nication TXD3 68
interface RXD1 103 Input Receive data 1, 2, and 3: Serial receive data
(SCI)
RXD2 105 input pins for SCI1, SCI2, and SCI3.
RXD3 67
SCK1 106 Input/ Serial clock 1, 2, and 3: Serial clock input/output
SCK2 107 Output pins for SCI1, SCI2, and SCI3. Used for input and
SCK3 65 output of the serial clock in clocked synchronous
mode, and of the SCI operating clock in
asynchronous mode.
PWM PW1 62 Output PWM1, PWM2, and PWM3 output: Output pins
timer 106 for PWM1, PWM2, and PWM3.
PW2 63 Output
107
PW3 64 Output
108
12 V must not be applied to the S-mask or A-mask model (single power source), as this will
permanently damage the device.
The flash memory programming power source for the S-mask and A-mask models (single power
source) is VCC.
The programming power source for the dual power source model was the VPP pin (12 V), but
there is no VPP pin in the single power source models. In the S-mask and A-mask models the
FWE pin is provided at the same pin position as the VPP pin in the dual power source model, but
FWE is not a power source pin-it is used to control flash memory write enabling.
Also, in boot mode, 12 V must be applied to the MD2 pin in the dual power source model, but this
is not necessary in the S-mask and A-mask models (single power source).
The maximum rating of the FWE and MD2 pins in the S-mask and A-mask models (single power
source) is VCC +0.3 V. Applying a voltage in excess of the maximum rating will permanently
damage the device.
Do not select the HN28F101 programmer setting for the S-mask or A-mask model (single power
source). If this setting is made by mistake, 12.0 V may be applied to the FWE pin, causing
permanent damage to the device.
When using a PROM programmer to program the on-chip flash memory in the S-mask or A-mask
model (single power source), use a PROM programmer that supports Hitachi microcomputer
device types with 128-kbyte on-chip flash memory.
Table 1-4 shows examples of product type names and markings for the H8/539F (dual power
source model), H8/539F S-mask model (single power source), and the H8/539F A-mask model
(single power source), and the differences in flash memory programming power source.
Table 1-4 Differences in H8/539F and H8/539F S-Mask and A-Mask Models Markings
Table 1-5 shows the differences between the H8/539F (dual power source model) and H8/539F S-
mask and A-mask models (single power source model).
12 V 5V
MD2 FWE
min 0 µs
12 V
VPP
tMDS: 4tcyc (min.) tMDS: 4tcyc (min.)
EB0 (1 kbyte)
LB7 (12 kbytes)
EB1 (1 kbyte)
SB0 (512 bytes) EB2 (1 kbyte)
SB1 (512 bytes) EB3 (1 kbyte)
SB2 (512 bytes)
SB3 (512 bytes)
EB4 (28 kbytes)
SB4 (512 bytes)
SB5 (512 bytes)
SB6 (512 bytes)
SB7 (512 bytes)
Reset during Drive 5(6 pin low for at least Drive 5(6 pin low for at least 20
operation 6 system clock cycles (6φ) system clock cycles (20φ)
(5(6 pulse width tRESW = (5(6 pulse width tRESW =
min. 6.0 tcyc) min. 20 tcyc)
(See section 19 for bit functions) (See section 20 for bit functions)
RAM emulation On-chip RAM Flash memory On-chip RAM Flash memory
block configuration EE80 0000 EE80 0000
////////Shading
F000 F000
shows areas for EB0
which ROM/RAM F200 2FFF 03FF
overlapping is 3000 F3FF 0400
SB0 F400
permitted during F400 3200 EB1
F600 F67F
RAM emulation SB1 F7FF F67F
F680 3400 F800 F680 07FF
SB2 0800
F800
3600 EB2
FA00 SB3
3800 0BFF
SB4 FBFF 0C00
FC00
3A00 EB3
FDFF
SB5
FE7F FE7F 0FFF
3C00
SB6 1000
3D00
SB7
3FFF 3FFF
FLMER register 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
OVLPE − − − A11E A10E A9E − OVLPE − − − A11E A10E − −
Table 1.7 lists the points of difference with the S-mask model.
For the most effective noise reduction, it is recommended that the A-mask model be used in the
singe-chip mode (mode 7).
1.5.1 Features
The features of the H8/539F A-mask model with on-chip step-down circuit are as follows.
• EMI Noise
EMI noise has been reduced approximately 10 to 20 dB compared with the H8/539F S-mask
model.
• Current Consumption
Current consumption during normal operation has been reduced approximately 30% compared
with the H8/539F S-mask model.
• Compatibility with S-Mask Version
The H8/539F A-mask model is functionally compatible with the S-mask model. With the
exception of the VCL pin, it is also completely pin compatible. In the single-chip mode, its
electrical characteristics are compatible* as well. The bus timing AC characteristics differ in
the externally expanded modes due to the slower bus interface.
Note: * The (φ clock output AC characteristics (tCL, tCH, tCr, tCf) differ from those of the S-mask
model.
The on-chip step-down circuit automatically lowers the microcomputer's internal power source
voltage to the optimum level. The H8/539F A-mask model is equipped with a VCL (internal step-
down pin) which must be connected to a 0.1 µF capacitor to stabilize the internal voltage.
Table 1.6 lists pin functions and Figure 1.3 shows the method for connecting the external
capacitor.
VCC power
External source
capacitor
VCL VCC
0.1µF
H8/539F A-mask model H8/539F S-mask model
Note: Do not connect the VCC power source to the Note: The S-mask model has a VCC pin in the
VCL pin of the A-mask model. (As before, same position as the VCL output pin of the
connect the VCC power source to the other A-mask model.
VCC pins.)
Position the capacitor near the pin.
Figure 1.3 Method of Connecting A-Mask VCL Capacitor and Differences with S-Mask Model
Table 1.7 lists the points of difference between the S-mask and A-mask models.
H8/539 H8/539
S A
HD64F5398F16 HD64F5398F16
JAPAN JAPAN
2.1 Overview
The H8/539F has the H8/500 CPU, which is common to all chips in the H8/500 Family. The
H8/500 CPU is a high-speed central processing unit that is designed for realtime control and
supports a large address space. Its architecture features eight general registers, 16-bit internal data
paths, and an optimized instruction set.
The H8/500 CPU is suitable for control of a wide range of medium-scale office and industrial
equipment.
2.1.1 Features
• General-register machine
Eight 16-bit general registers
Seven control registers (two 16-bit registers, five 8-bit registers)
• High-speed operation: 16 MHz maximum clock rate
At 16 MHz a register-register add operation takes only 125 ns.
• Maximum address space: 1 Mbyte
Managed in 64-kbyte pages
Four pages available simultaneously: code page, stack page, data page, and extended
page.
The CPU architecture supports up to 16 Mbytes, but the chip has only enough pins to address 1
Mbyte.
The H8/500 CPU has different address spaces in its two operating modes, the minimum mode and
maximum mode. The CPU operating mode is selected by the input at the mode pins (MD2 to
MD0) at a reset. Table 2-1 summarizes the CPU operating modes. Figure 2-1 shows a memory
map for the minimum mode. Figure 2-2 shows a memory map for the maximum mode.
H'0000
64 kbytes
H'FFFF
H'0FFFF
H'10000
Page 1
(64 kbytes)
H'1FFFF
1 Mbyte
H'20000
H'F0000
Page 15
(64 kbytes)
H'FFFFF
15 0
R0
R1
R2
R3
R4
R5
R6 (FP)
R7 (SP)
FP: Frame pointer
SP: Stack pointer
15 0
PC
PC: Program counter
SR
CCR
15 8 7 0
T − − − − I2 I1 I0 − − − − N Z V C
SR: Status register
CCR: Condition code register
CP
CP: Code page register
DP
DP: Data page register
EP
EP: Extended page register
TP
TP: Stack page register
BR
BR: Base register
2.2.1 Overview
All eight of the general registers are functionally alike; there is no distinction between data
registers and address registers. When these registers are accessed as data registers, either byte or
word size can be selected.
When these registers are accessed as address registers, word size is implicitly assumed.
15 0
R0
R1
R2
R3
R4
R5
R6 (FP)
R7 (SP)
FP: Frame pointer
SP: Stack pointer
R7 functions as the stack pointer (SP), and is used implicitly in exception handling and subroutine
calls. It is also used implicitly in pre-decrement or post-increment mode by the LDM and STM
instructions, which load and store multiple registers on the stack.
R6 functions as a frame pointer (FP). The LINK and UNLK instructions use R6 implicitly to
reserve or release a stack frame.
2.3.1 Overview
The control registers include a 16-bit program counter and a 16-bit status register.
15 0
PC
PC: Program counter
SR
CCR
15 8 7 0
T − − − − I2 I1 I0 − − − − N Z V C
SR: Status register
CCR: Condition code register
The 16-bit program counter (PC) indicates the address of the next instruction the CPU will
execute.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
PC
The 16-bit status register (SR) contains status flags that indicate the internal state of the CPU.
CCR
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
SR T − − − − I2 I1 I0 − − − − N Z V C
Carry flag
Overflow flag
Zero flag
Negative flag
Reserved bits
Interrupt mask bits
Reserved bits
Trace bit
The lower eight bits of the status register are referred to as the condition code register (CCR).
Byte access to the CCR is possible.
Bit 15
T Description
0 Instructions are executed in succession (initial mode after reset)
1 Trace exception handling starts after each instruction (trace mode)
For information about trace exception handling, see section 4.4, "Trace."
Interrupt Mask
I2 I1 I0 Level Priority Acceptable Interrupts
1 1 1 7 High NMI
1 1 0 6 Level 7 and NMI
1 0 1 5 Levels 6, 7 and NMI
1 0 0 4 Levels 5 to 7 and NMI
0 1 1 3 Levels 4 to 7 and NMI
0 1 0 2 Levels 3 to 7 and NMI
0 0 1 1 Levels 2 to 7 and NMI
0 0 0 0 Low Levels 1 to 7 and NMI
The CPU accepts only interrupts higher than the interrupt mask level. NMI (level 8) is accepted at
any interrupt mask level*. After accepting an interrupt, the H8/500 CPU updates I 2, I1, and I0 to
the level of the interrupt. Table 2-3 indicates the values of the interrupt mask bits after an
interrupt is accepted. A reset sets all three interrupt mask bits to 1.
Note: * The exception is when programming or erasing flash memory, in which case NMI input is
disabled. See section 19.4.9, "NMI Input Masking" and section 20.4.8, "NMI Input
Masking" for details.
Table 2-3 Interrupt Mask Bits (I2, I1, I0) after an Interrupt is Accepted
Interrupt Mask
Level of Interrupt Accepted I2 I1 I0
NMI (8) 1 1 1
7 1 1 1
6 1 1 0
5 1 0 1
4 1 0 0
3 0 1 1
2 0 1 0
1 0 0 1
(6) Bit 2—Zero (Z): Set to 1 to indicate zero data and cleared to 0 at other times.
(7) Bit 1—Overflow (V): Set to 1 when an arithmetic overflow occurs and cleared to 0 at other
times.
(8) Bit 0—Carry (C): Set to 1 when a carry or borrow occurs at the most significant data bit and
cleared to 0 at other times.
The specific changes that occur in the condition code bits when each instruction is executed are
listed in Appendix A.1 "Instruction Tables." See the H8/500 Series Programming Manual for
further details.
2.4.1 Overview
The four page registers are the code page register (CP), data page register (DP), extended page
register (EP), and stack page register (TP).
The page registers are not used to calculate effective addresses in minimum mode. In maximum
mode, the page registers combine with the program counter and general registers to generate 24-
bit effective addresses as shown in figure 2-6, thereby expanding the program area, data area, and
stack area.
8 bits 16 bits
CP PC
R0
R1
DP R2
R3
@aa:16
R4
EP
R5
R6
TP
R7
7 0
CP
CP: Code page register
DP
EP
TP
The code page register (CP) combines with the program counter to generate a 24-bit program code
address. CP contains the upper eight bits of the address.
Bit 7 6 5 4 3 2 1 0
CP
In maximum mode, CP is initialized at a reset to a value loaded from the vector table, and CP and
PC are both saved and restored in exception handling.
The data page register (DP) combines with general registers R0 to R3 to generate a 24-bit
effective address. DP contains the upper eight bits of the address.
Bit 7 6 5 4 3 2 1 0
DP
DP is used to calculate effective addresses in register indirect addressing mode using R0 to R3,
and in absolute addressing mode (but not short absolute addressing mode).
The extended page register (EP) combines with general register R4 or R5 to generate a 24-bit
operand address. EP contains the upper eight bits of the address.
Bit 7 6 5 4 3 2 1 0
EP
EP is used to calculate effective addresses in register indirect addressing mode using R4 or R5.
The stack page register (TP) combines with R6 (SP) or R7 (FP) to generate a 24-bit stack address.
TP contains the upper eight bits of the address.
Bit 7 6 5 4 3 2 1 0
TP
TP is used to calculate effective addresses in the register indirect addressing mode using R6 or R7,
in exception handling, and in subroutine calls.
2.5.1 Overview
The eight-bit base register (BR) stores the base address used in short absolute addressing mode
(representing the upper eight bits of an address in page 0). Figure 2-8 illustrates the base register
and short absolute addressing mode. In this addressing mode a 16-bit effective address is
generated by using the BR contents as the upper eight bits and an address given in the instruction
code as the lower eight bits. The short absolute addressing mode always addresses page 0.
8 bits 8 bits
BR @aa:8
7 0
BR
Table 2-4 indicates the data formats in general registers. All sizes of data can be stored: one-bit
data, four-bit BCD data, eight-bit (byte) data, 16-bit (word) data, and 32-bit (longword) data.
In addressing of one-bit data, bit 15 is the most significant bit and bit 0 is the least significant bit.
BCD and byte data are stored in the lower eight bits of a general register. All 16 bits of a general
register are used to store word data. Two general registers are used for longword data: the upper
16 bits are stored in Rn (n must be an even number); the lower 16 bits are stored in Rn+1.
Operations performed on BCD data or byte data do not alter the upper eight bits of the register.
BCD Rn
7 43 0
Don't care Upper digit Lower digit
Byte Rn 7 0
Don't care MSB LSB
Word Rn 15 0
MSB LSB
Longword* Rn 31 16
Rn+1 MSB Upper 16 bits
Lower 16 bits LSB
15 0
Instructions that access bit data in memory have byte or word operands. The instruction specifies
a bit number to indicate a specific bit in the operand.
Access to word data in memory must always begin at an even address. Access to word data
starting at an odd address causes an address error. The upper eight bits of word data are stored in
address n (where n is an even number); the lower eight bits are stored in address n + 1.
Word
Even address MSB Upper 8 bits
Odd address Lower 8 bits LSB
When the stack is accessed in exception processing (to save or restore the program counter, code
page register, or status register), word access is always performed, regardless of the actual data
size. Similarly, when the stack is accessed by an instruction using the pre-decrement or post-
increment register indirect addressing mode specifying R7 (@-R7 or @R7+), which is the stack
pointer, word access is performed regardless of the operand size specified in the instruction.
Programs should be coded so that the stack pointer always indicates an even address. An address
error will occur if the stack pointer indicates an odd address.
These modes and the corresponding effective address calculations are described next.
1. Register direct
2. Register indirect
3. Register indirect with displacement
4. Register indirect with pre-decrement or post-increment
5. Immediate
6. Absolute
7. PC-relative
Due to the highly orthogonal nature of the instruction set, most instructions having operands can
use any applicable addressing mode from 1 through 6. The PC-relative mode 7 is used by
branching instructions.
In most instructions, the addressing mode is specified in the effective address (EA) field and
effective address extension (if present).
Table 2-7 indicates how the addressing mode is specified in the effective address field.
(1) Register Direct Addressing Mode: The contents of a general register Rn are used directly as
operand data. This addressing mode is specified by giving the general register name.
Rn
@Rn
(3) Register Indirect Addressing Mode with Displacement: A displacement value is added to
the contents of a general register Rn, the sum is used as a memory address, and data access is
performed at that memory address. This addressing mode is specified by giving the general
register name with the address qualifier (@) and an 8-bit or 16-bit displacement value.
@−Rn or @Rn+
#xx:8 or #xx:16
(6) Absolute Addressing Mode: Data access is performed at a memory address given as a 16-bit
absolute address in the instruction, or given as an eight-bit absolute address in the instruction and
combined with the base register (BR) value. This addressing mode is specified by giving the
absolute address with an address qualifier.
@aa:16 or @aa:8
(7) PC-Relative Addressing Mode: An eight-bit or 16-bit displacement value given in the
instruction is added to the program counter value, the sum is used as a memory address, and this
memory address is moved into the program counter. This addressing mode is specified by giving
the displacement value.
disp
Displacement
Table 2-8 explains how an effective address is calculated in each addressing mode.
Rev. 3.0, 02/99, page 52 of 904
The page registers are not used to calculate effective addresses in minimum mode.
Addressing
Mode Mnemonic
No. EA Field Effective Address Calculation Effective Address
1 Register direct − Operand is contents of Rn.
Rn
1 0 1 0 Sz r r r
2 Register indirect − 23 15 0
@Rn DP *2 Rn
1 1 0 1 Sz r r r
Or TP or EP
3 Register indirect 23 15 0
with displacement 15 0 DP *2 Result
@(d:8,Rn) Rn
1 1 1 0 Sz r r r Or TP or EP
+
15 0
Displacement
16 bits
(8 bits with sign-bit extension)
@(d:16,Rn) 23 15 0
15 0 DP *2 Result
1 1 1 1 Sz r r r
Rn
Or TP or EP
+
15 0
Displacement
4 Register indirect 23 15 0
with pre- 15 0 DP *2 Result
decrement Rn
@-Rn Or TP or EP
1 0 1 1 Sz r r r −
*1
1 or 2
Rn is decremented by 1 or 2 before
instruction execution.
Register indirect − 23 15 0
with post-
DP *2 Rn
increment Rn is incremented by 1 or 2 after
@Rn+ instruction execution.
Or TP or EP
1 1 0 0 Sz r r r
Notes: 1. 1 for a byte operand, 2 for a word operand, and always 2 for R7 in register indirect mode with
pre-decrement or post-increment, even if byte size is specified.
2. Register Indirect Page Register
R7, R6 TP
R5, R4 EP
R3-R0 DP
Addressing
Mode Mnemonic
No. EA Field Effective Address Calculation Effective Address
5 Absolute −
@aa:8 23 15 0
H'00 BR EA extension data
0 0 0 0 Sz 1 0 1
@aa:16 −
23 15 0
0 0 0 1 Sz 1 0 1 DP EA extension data
7 PC-relative 23 15 0
d:8 15 0 CP Result
No EA field. PC
Specified in
op-code. +
15 0
Displacement
16 bits
(8 bits with sign extension)
d:16 23 15 0
No EA field. 15 0 CP Result
Specified in PC
op-code.
+
15 0
Displacement
Minimum mode supports an address space of up to 64 kbytes. The page registers are ignored.
Instructions that branch across page boundaries (PJMP, PJSR, PRTS, PRTD) are invalid.
In maximum mode the page registers are valid, expanding the maximum address space to 1
Mbyte. It is possible to move from one page to another with branching instructions (PJMP, PJSR,
PRTS, PRTD) and when branching to interrupt-handling routines.
When data access crosses a page boundary, the program must rewrite the page register before it
can access the data in the next page.
For further information on the operating modes, see section 3, "MCU Operating Modes."
CPG
φ φ/2- φ/4096
The system clock (φ) produced by duty adjustment of the clock (fOSC) supplied from the clock
oscillator is the H8/500 CPU's time base. One cycle of the system clock is referred to as a "state."
The H8/500 CPU's bus cycle consists of two or three states. The CPU uses different methods to
access on-chip memory, on-chip supporting modules, and external devices.
On-chip memory is accessed in two states using a 16-bit bus. Figure 2-11 shows the on-chip
memory access cycle. Figure 2-12 shows the pin states during on-chip memory access.
Bus cycle
T1 state T2 state
φ
A19-A0 Address
High
AS, RD, HWR, LWR
High impedance
D15-D0
Two-state access permits high-speed processing. No wait states (TW) can be inserted in access to
the two-state-access address space. The external two-state-access address space is accessed via a
16-bit bus. Figure 2-13 shows the access cycle for the external two-state-access address space.
Bus cycle
T1 state T2 state
φ
A19-A 0 Address
AS, RD
HWR, LWR
The on-chip supporting modules are always accessed in three states. The data bus is eight bits
wide, except that some of the registers in the 16-bit integrated-timer pulse unit (IPU) are accessed
via a 16-bit data bus.
Figure 2-14 shows the on-chip supporting module access cycle. Figure 2-15 indicates the pin
states during access to an on-chip supporting module.
Bus cycle
T1 state T2 state T3 state
φ
Internal
Address
address bus
Internal read
signal
A19-A 0 Address
The wait-state controller (WSC) can insert wait states (TW) in access to the three-state-access
address space.
Figure 2-16 shows the three-state read access cycle. Figure 2-17 shows the three-state write
access cycle.
Read cycle
T1 state T2 state T3 state
A19-A 0 Address
AS
RD
HWR, LWR
High
D15-D 0
Read data
(read access)
A19-A 0 Address
AS
RD High
HWR, LWR
D15-D 0
Write data
(write access)
2.10.1 Overview
The five processing states of the H8/500 CPU are the program execution state, exception-handling
state, bus-released state, reset state, and power-down state.
The power-down state is further divided into a sleep mode, software standby mode, and hardware
standby mode. Table 2-9 summarizes these states. Figure 2-18 shows a map of the state
transitions.
State Description
Program execution state The H8/500 CPU executes program instructions in sequence.
Exception-handling state A transient state in which the H8/500 CPU executes a
hardware sequence (saving the program counter and status
register, fetching a vector, etc.) triggered by a reset, interrupt,
or other exception.
Bus-released state The H8/500 CPU has released the external bus in response to
an external bus request signal.
Reset state The H8/500 CPU and all on-chip supporting modules have
been initialized and are stopped.
Power- Sleep mode Some or all clock signals are stopped to conserve power.
down
Software
state
standby mode
Hardware
standby mode
=1
state
=0
EQ
BR
EQ
SLEEP
=1
tion
instruc-
=0
BR SLEEP
EQ
tion
dlin cep
instruc-
EQ
BR
x
tion with
n
BR
h an of e
ptio
g
SSBY
xce
d bit set
En
rr upt
Inte
RES = 1 STBY = 1
RES = 0 Hardware standby
Reset state*1 mode*2
Notes: 1. From any state except hardware standby mode, a transition to the reset state
occurs whenever RES is set to 0.
2. From any state, a transition to hardware standby mode occurs when STBY
is set to 0.
In this state the H8/500 CPU executes program instructions in normal sequence.
The exception-handling state is a transient state that occurs when the H8/500 CPU alters the
normal program flow due to an interrupt, trap instruction, address error, or other exception.
See section 4, "Exception Handling" for further information on the exception-handling state.
When so requested, the H8/500 CPU can grant control of the external bus to an external device.
While an external device has the bus right, the H8/500 CPU is said to be in the bus-released state.
Granting of the bus is controlled by the %5(4 and %$&. signals. Bus requests are input at the
%5(4 pin. When the bus has been released, an acknowledging signal is output at the %$&. pin.
Bit 7 6 5 4 3 2 1 0
− − − − − − − BRLE
Initial value 1 1 1 1 1 1 1 0
R/W − − − − − − − R/W
Bit 0—Bus Release Enable Bit (BRLE): Selects the functions of pins PA6 and PA5.
Bit 0
BRLE Description
0 PA6 and PA5 are used for general-purpose input and output
1 PA6 is used for %$&. output; PA5 is used for %5(4 input
Figure 2-20 shows the timing when the H8/500 CPU acknowledges the %5(4 signal at the end of
a bus cycle.
The %5(4 signal is sampled during every instruction fetch cycle and data read or write cycle. In
word data access by means of two successive byte accesses, first to the upper byte, then to the
lower byte (access to the eight-bit-bus-access address space or an on-chip supporting module), the
H8/500 CPU does not release the bus right until it has accessed the lower byte.
T1 T2 T3 Tx Tx
φ
AS, RD Hi-Z
BREQ (input)
Bus-release acknowledge
BACK (output) signal output
Note: * Instruction fetch or data read cycle. In access to word data in the byte-access
address space, the cycle shown is the lower byte read cycle.
Figure 2-20 Case of %5(4 Acknowledged at End of Bus Cycle (Read Cycle Example)
Figure 2-21 shows the timing when the H8/500 CPU acknowledges the %5(4 signal at the end of
a machine cycle.
The H8/500 CPU acknowledges the %5(4 signal at the end of machine cycles during execution
of the MULXU or DIVXU instruction.
BREQ (input)
Bus-release acknowledge
BACK (output) signal output
Bus-released state
Figure 2-22 shows the timing when the H8/500 CPU acknowledges the %5(4 signal in sleep
mode.
The H8/500 CPU acknowledges the %5(4 signal at any time during sleep mode.
Sleep mode Tx Tx
φ
BREQ (input)
Bus-release acknowledge
BACK (output) signal output
Bus-released state
Figure 2-23 shows the timing when the bus is requested during a two-state access cycle.
When an external device requests the bus during two-state access, the H8/500 CPU enters the bus-
released state as follows:
(1) The %5(4 pin is sampled at the start of the T1 state. If %5(4 is low, at the end of the bus
cycle the H8/500 CPU halts and enters the bus-released state.
(2) In the case of two-state access, at the end of the T2 state the %$&. signal goes low to indicate
that the bus-released state has been entered. The address bus (A19 to A0), data bus (D15 to D0),
and bus control signals ($6, 5', /:5, +:5) are placed in the high-impedance state.
(3) While the bus is released, the H8/500 CPU constantly samples the %5(4 pin (at each Tx state)
and remains in the bus-released state while %5(4 is low.
(4) When %5(4 is high during a Tx state, at the end of the next state the H8/500 CPU drives the
%$&. signal high to indicate that it has regained possession of the bus (and that CPU cycles
will resume).
(5) CPU cycles resume at the end of the next state after %$&. goes high.
Two-state
access
T2 T1 T2 Tx Tx Tx Tx T1
φ
D15-D 0 Data
AS, RD
BREQ (input)
BACK (output)
Figure 2-23 Bus Release during Two-State Access (Read Cycle Example)
Figure 2-24 shows the timing when the bus is requested during a three-state access cycle.
When an external device requests the bus during three-state access, the H8/500 CPU enters the
bus-released state as follows:
(1) The %5(4 pin is sampled at the start of the T1, T2, and TW states. If %5(4 is low, at the end
of the bus cycle the H8/500 CPU halts and enters the bus-released state.
(2) In the case of three-state access, at the end of the T3 state the %$&. signal goes low to indicate
that the bus-released state has been entered. The address bus (A19 to A0), data bus (D15 to D0),
and bus control signals ($6, 5', /:5, +:5) are placed in the high-impedance state.
(3) When %5(4 is high during a Tx state, at the end of the next state the H8/500 CPU drives the
%$&. signal high to indicate that it has regained possession of the bus (and that CPU cycles
will resume).
(4) CPU cycles resume at the end of the next state after %$&. goes high.
Three-state access
T1 T2 TW T3 Tx Tx Tx T1
φ
A19-A 0 Address
D15-D 0 Data
AS, RD
BREQ (input)
BACK (output)
Figure 2-24 Bus Release during Three-State Access (Read Cycle Example)
Figure 2-25 shows the timing when the bus is requested during internal CPU operations.
When an external device requests the bus during internal CPU operations, the H8/500 CPU enters
the bus-released state as follows:
(1) The %5(4 pin is sampled at the start of the T1 state. If %5(4 is low, at the end of the internal
cycle the H8/500 CPU halts and enters the bus-released state.
(2) In the case of internal CPU operations, at the end of a T1 state the %$&. signal goes low to
indicate that the bus-released state has been entered. The address bus (A19 to A0), data bus (D15
to D0), and bus control signals ($6, 5', /:5, +:5) are placed in the high-impedance state.
(3) When %5(4 is high during a Tx state, at the end of the next state the H8/500 CPU drives the
%$&. signal high to indicate that it has regained possession of the bus (and that CPU cycles
will resume).
(4) CPU cycles resume at the end of the next state after %$&. goes high.
T1 T1 T1 T1 Tx Tx Tx T1
φ
A19-A 0 Address
AS, RD High
BREQ (input)
BACK (output)
(7) Notes
• The H8/500 CPU does not accept interrupts while in the bus-released state.
• The %5(4 signal must be held low until %$&. goes low. If %5(4 returns to the high level
before %$&. goes low, the bus release operation may be executed incorrectly.
In the reset state, the H8/500 CPU and all on-chip supporting modules are initialized and placed in
the stopped state. The H8/500 CPU enters the reset state whenever the 5(6 pin goes low, unless
the H8/500 CPU is currently in the hardware standby mode.
See section 4.2, "Reset" for further information on the reset state.
The power-down state comprises three power-down modes: sleep mode, software standby mode,
and hardware standby mode.
3.1 Overview
Modes 1 to 6 are externally expanded modes in which external memory and peripheral devices can
be accessed. Modes 1, 2, and 6 are expanded minimum modes, supporting a 64-kbyte address
space. Modes 3, 4, and 5 are expanded maximum modes, supporting a maximum 1-Mbyte address
space. When using modes 1 to 6, refer to section 3.6, Notes on Use of Externally Expanded
Modes of H8/539F (Dual Power-Source Model). See section 3.7, Notes on H8/539F S-Mask and
A-Mask Models (Single Power Source Model), concerning all modes (1 to 7) in the H8/539F S-
mask and A-mask models (single power source model).
Mode 7 is a single-chip mode: all ports are available for general-purpose input and output, but
external addresses cannot be used.
Mode 0 is reserved for future use and must not be selected in the H8/539F.
Both the pin functions and address space vary depending on the mode. Table 3-1 summarizes the
selection of operating modes.
MCU CPU
Operating Operating On-Chip On-Chip Data Bus
Mode MD2 MD1 MD0 Description Mode RAM ROM Width
Mode 0 0 0 0
1
Mode 1 0 0 1 Expanded Minimum Enabled* Disabled 16 bits
minimum mode
mode
3 1
Mode 2* 0 1 0 Expanded Minimum Enabled* Enabled 8 bits
minimum mode
mode
1
Mode 3 0 1 1 Expanded Maximum Enabled* Disabled 16 bits
maximum mode
mode
3 1
Mode 4* 1 0 0 Expanded Maximum Enabled* Enabled 16 bits
maximum mode
mode
MCU CPU
Operating Operating On-Chip On-Chip Data Bus
Mode MD2 MD1 MD0 Description Mode RAM ROM Width
1 2
Mode 5 1 0 1 Expanded Maximum Enabled* Disabled 16 bits*
maximum mode
mode
1 2
Mode 6 1 1 0 Expanded Minimum Enabled* Disabled 16 bits*
minimum mode
mode
3
Mode 7* 1 1 1 Single-chip Maximum Enabled Enabled
mode mode
Legend
0: Low
1: High
: Not available
Notes: 1. If RAM enable bits 1 and 2 (RAME1 and RAME2) in the RAM control register (RAMCR)
are cleared to 0, these addresses become external addresses.
2. Eight-bit three-state-access address space after a reset.
3. In the dual power source model (VPP = 12 V), when pin settings are made for mode 2, 4,
or 7 and 12 V is applied to the VPP pin, flash memory can be programmed or erased.
See section 19, Flash Memory (H8/539F Dual Power Source System (VPP = 12 V)) for
details.
In the S-mask model (single power source), when pin settings are made for mode 4 or 7
and pin FWE is in the high level input state, flash memory can be programmed or
erased. See section 20, Flash Memory (H8/539F S-Mask and A-Mask Models: Single
Power Source) for details.
The MCU operating mode can be monitored in the mode control register (MDCR). Table 3-2
summarizes this register.
Bit 7 6 5 4 3 2 1 0
− − − − − MDS2 MDS1 MDS0
Initial value 1 1 0 0 0 − * − * − *
R/W − − − − − R R R
Mode select 2 to 0
Bits indicating the current
operating mode
Reserved bits
Note: * Determined by pins MD2 to MD0. MDCR latches the inputs at the mode pins
(MD2 to MD0) at the rise of the RES signal.
Mode Select 2 to 0 (MDS2 to MDS0): These bits indicate the values of pins
(3) Bits 2 to 0
MD2 to MD0 latched at the rise of the 5(6 signal (the current operating mode).
In mode 1 the data bus is 16 bits wide. The bus controller's byte area register (ARBT) is enabled
in mode 1, so part of the address space can be accessed with an eight-bit bus width. The
maximum address space supported in mode 1 is 64 kbytes.
In mode 2 the data bus is eight bits wide. The on-chip ROM is enabled.
In mode 3 the data bus is 16 bits wide. The bus controller's byte area register (ARBT) is enabled
in mode 3, so part of the address space can be accessed with an eight-bit bus width. The
maximum address space supported in mode 3 is 1 Mbyte.
In mode 4 the data bus is 16 bits wide. The bus controller's byte area register (ARBT) is enabled
in mode 4, so part of the address space can be accessed with an eight-bit bus width. The
maximum address space supported in mode 4 is 1 Mbyte. The on-chip ROM is enabled.
Mode 5 is functionally identical to mode 3, and mode 6 is functionally identical to mode 1. When
the chip comes out of reset, however, the bus controller's byte area register (ARBT) is disabled in
modes 5 and 6 and eight-bit, three-state access is performed throughout the address space. The
byte area register can be enabled by setting the BCRE bit to 1 in the bus control register (BCR).
H'0000 H'0000
Vector table H'00FF Vector table
H'00FF
H'0100 H'0100
On-chip ROM
External (16 kbytes)
Memory space
H'3FFF
H'4000 External
H'EE7F H'EE7F Memory space
H'EE80 H'EE80
On-chip RAM On-chip RAM
H'FE7F (4 kbytes) H'FE7F (4 kbytes)
H'FE80 On-chip registers H'FE80 On-chip registers
(384 bytes) (384 bytes)
H'FFFF H'FFFF
Modes 1 and 6 Mode 2
On-chip ROM
External (16 kbytes)
Memory space Page 0 Page 0
H'03FFF
H'04000
External
H'0EE7F H'0EE7F Memory space
H'0EE80 On-chip RAM H'0EE80 On-chip RAM
H'0FE7F (4 kbytes) H'0FE7F (4 kbytes)
H'0FE80 On-chip registers H'0FE80 On-chip registers
(384 bytes) (384 bytes)
H'0FFFF H'0FFFF
H'10000 H'10000
External Page 1 On-chip ROM Page 1
Memory space (64 kbytes)
H'1FFFF H'1FFFF
H'20000 H'20000
On-chip ROM
Pages (64 kbytes) Pages
2 to 15 H'2FFFF 2 to 15
H'30000 External
Memory space
H'FFFFF H'FFFFF
Modes 3 and 5 Mode 4
On-chip ROM
(16 kbytes)
H'03FFF
H'04000
H'0EE7F
H'0EE80 On-chip RAM
(4 kbytes)
H'0FE7F
H'0FE80
On-chip registers
(384 bytes)
H'0FFFF
H'10000
On-chip ROM
(64 kbytes)
H'1FFFF
H'20000
On-chip ROM
(64 kbytes)
H'2FFFF
Mode 7
When using the H8/539F in an externally expanded mode with on-chip ROM enabled (mode 2 or
4), the φOE bit in the φ control register (φCR) must be initialized to 1 before accessing the external
bus space.
When using the H8/539F in an externally expanded mode with on-chip ROM disabled (mode 1, 3,
5, or 6), hardware standby mode must be entered at power-on. Figure 3-4 shows the power-on
timing.
Note that when ø output is inhibited, the φ pin goes to the high-impedance state and external space
accesses will not function correctly .
Note: * For details, see section 21.5, φ Clock Output Prohibit Function.
See section 3.7, Notes on H8/539F S-Mask and A-Mask Models (Single Power Source Model), for
further information concerning the H8/539F S-mask and A-mask models (single power source
model).
4.5 V
VCC
VIH (VCC-0.7 V)
STBY VIL (0.4 V)
VIL (0.4 V)
RES
At power-on, set hardware standby mode in all modes (1 to 7) with the H8/539F S-mask and A-
mask Models (single power source).
Note that when ø output is disabled the φ pin goes to the high-impedance state, and external space
access will not function correctly.
For information concerning the H8/539F (dual power source model), see section 3.6, Notes on Use
of Externally Expanded Mode of H8/539F (Dual Power Supply Model).
4.5 V
VCC
VIH (VCC-0.7 V)
STBY VIL (0.4 V)
VIL (0.4 V)
RES
4.1 Overview
There are five types of exceptions: reset, address error, trace, interrupt, and instruction exceptions.
There are three types of instruction exceptions: invalid instruction, trap instruction, and DIVXU
instruction with zero divisor.
Table 4-1 lists the types of exception handling for exceptions other than instruction exceptions,
and indicates their priority. The system assigns a reserved priority to each of these exception
types. If two or more exceptions occur simultaneously, they are accepted and handled in priority
order.
Table 4-2 lists the types of instruction exception handling. Instruction exceptions cannot occur
simultaneously, so there is no priority order.
Exception handling other than reset exception handling is described next. For reset exception
handling, see section 4.2, "Reset."
In minimum mode, the program counter (PC) and status register (SR) are saved on the stack. In
maximum mode the code page register (CP), PC, and SR are saved on the stack. Next the T bit in
the status register is cleared to 0, the start address corresponding to the exception source is read
from the exception vector table, and program execution begins from the indicated address.
Exception
Exception handling
PC → @ − SP
State saving:
CP → @ − SP PC, CP, and SR are pushed in that order on
the stack. CP is pushed only in maximum mode.
SR → @ − SP
0 → T bit (SR)
Preparations for program execution:
Start address → CP After the trace bit is cleared to 0, an address is
loaded from the vector table into CP and PC.
CP is loaded only in maximum mode.
Start address → PC
Figure 4-2 classifies the exception sources. Table 4-3 shows the exception vector table. The
vector addresses differ between minimum and maximum modes. In maximum mode the vector
table is located in page 0. For internal interrupt vectors, see table 6-3, "Interrupt Priorities and
Vector Addresses."
• Reset
• Address error
• Trace
NMI
External interrupts IRQ0
IRQ1−3
39 interrupt sources
Internal interrupts in on-chip supporting
modules
Invalid instruction
TRAPA instruction
• Instructions
TRAP/VS instruction
Zero divide
Vector Address
Exception Source Minimum Mode Maximum Mode
Reset (initial PC value) H'0000−H'0001 H'0000−H'0003
(Reserved for system) H'0002−H'0003 H'0004−H'0007
Invalid instruction H'0004−H'0005 H'0008−H'000B
DIVXU instruction (zero divisor) H'0006−H'0007 H'000C−H'000F
TRAP/VS instruction H'0008−H'0009 H'0010−H'0013
(Reserved for system) H'000A−H'000B H'0014−H'0017
. .
. .
. .
H'000E−H'000F H'001C−H'001F
Address error H'0010−H'0011 H'0020−H'0023
Trace H'0012−H'0013 H'0024−H'0027
(Reserved for system) H'0014−H'0015 H'0028−H'002B
External interrupt: NMI H'0016−H'0017 H'002C−H'002F
(Reserved for system) H'0018−H'0019 H'0030−H'0033
. .
. .
. .
H'001E−H'001F H'003C−H'003F
TRAPA instruction (16 sources) H'0020−H'0021 H'0040−H'0043
. .
. .
. .
H'003E−H'003F H'007C−H'007F
External interrupt: IRQ0 H'0040−H'0041 H'0080−H'0083
WDT interval interrupt H'0042−H'0043 H'0084−H'0087
External interrupts: IRQ1 H'0048−H'0049 H'0090−H'0093
IRQ2 H'004A−H'004B H'0094−H'0097
IRQ3 H'004C−H'004D H'0098−H'009B
Internal interrupts H'0044−H'0045 H'0088−H'008B
H'0050−H'0051 H'00A0−H'00A3
. .
. .
. .
H'009E−H'009F H'013C−H'013F
4.2.1 Overview
When the 5(6 pin goes low, all processing halts and the chip enters the reset state. A reset
initializes the internal state of the H8/500 CPU and the registers of on-chip supporting modules.
When the 5(6 pin rises from low to high, the H8/500 CPU begins reset exception handling.
The chip enters the reset state when the 5(6 pin goes low.
To ensure that the chip is reset, the 5(6 pin should be held low for at least 20 ms at power-up. To
reset the chip during operation, the 5(6 pin should be held low for at least six system clock cycles
(6φ) in the H8/539F. In the H8/539F S-mask and A-mask models, the 5(6 pin should be held low
for at least 20 system clock cycles (20φ). When an external clock is used, the 5(6 pin should be
held low for at least the external clock output setting delay time (tDEXT) at power-up and in a reset
start from the standby state.
See appendix G, "Pin States" for the states of the pins in the reset state.
When the 5(6 pin rises to the high level after being held low for the necessary time, the H8/500
CPU begins reset exception handling. Figure 4-3 shows the sequence of operations at the end of
the reset state.
RES pin
End of reset (low-to-high transition)
MD2−0 → MDS2−0 (1) Values of mode pins (MD2 to MD0) are latched
in bits MDS2 to MDS0 in MDCR.
0 → T bit (SR)
(2) T bit in SR is cleared to 0 to disable trace mode.
1 → I2 to I0 bits (SR) Interrupt mask bits I2 to I0 are all set to 1 (level 7).
Start address → CP
(3) Start address is loaded from vector table. H8/500
Start address → PC CPU starts program execution from that address.
(1) Minimum Mode: Figure 4-4 shows the reset vector in minimum mode.
In minimum mode the reset vector is located at addresses H'0000 and H'0001. When exception
handling begins, the H8/500 CPU copies the reset vector into the program counter (PC). Program
execution then starts from the PC address.
H'0000 PCH
H'0001 PCL
Figure 4-5 shows the case in which the program area and stack area are both located in the eight-
bit-bus three-state-access address space.
RES
RD
Reset interval* Internal pro- Fetching Fetching Prefetching first instruc- Instruction
cessing cycles reset reset tion of program execution
vector (PCH) vector (PCL) starts
In maximum mode the reset vector is located at addresses H'0000 to H'0003. When exception
handling begins, the H8/500 CPU copies the reset vector into the code page register (CP) and
program counter (PC), ignoring the vector data at H'0000. Program execution then starts from the
CP and PC address.
Figure 4-7 shows the case in which the program area and stack area are both located in the 16-bit-
bus two-state-access address space.
RES
V: Vector address
Internal (1) V V + 2 (3)
address bus
Internal (2) (4)
data bus
D15 - D0 CP PC
Internal
read signal
Reset
vector
If an interrupt is accepted after a reset but before the stack pointer (SP) is initialized, the program
counter and status register will not be saved correctly, leading to a program crash. This danger
can be avoided as explained next.
When the chip comes out of the reset state all interrupts, including NMI, are disabled, so the first
instruction is always executed. Crashes can be avoided by using this first instruction to initialize
SP. In minimum mode, the first instruction after a reset should initialize SP. In maximum mode,
the first instruction after a reset should initialize the stack page register (TP), and the next
instruction should initialize SP.
Examples:
1. Minimum mode
.ORG H'0000
MOV.W #H'FE80, SP
·
·
·
2. Maximum mode
.ORG H'0000
LDC.B #H'00, TP
MOV.W #H'FE80, SP
·
·
·
When an address error occurs, the H8/500 CPU begins address error exception handling and clears
the T bit of the status register to 0. The interrupt mask level in bits I2 to I0 is not changed.
An attempt to prefetch an instruction from the on-chip registers at addresses H'FE80 to H'FFFF
causes an address error.
The address error exception handling sequence for this case is:
The PC value pushed on the stack is the start address of the instruction immediately following the
last instruction executed.
Program code should not be located in addresses H'FE7D to H'FE7E. If program code is located
in these addresses, instruction prefetch will be attempted in the on-chip register area, causing an
address error.
Figure 4-8 shows the areas in which instruction prefetch leads to an address error.
<Page 0>
H'0000
H'FE7D (3 bytes)
H'FE80
On-chip register area Areas in which instruction
H'FFFF prefetch leads to address error
An address error occurs if an attempt is made to access word data starting at an odd address. The
PC value pushed on the stack is the address of the next instruction after the instruction that
attempted to access word data at an odd address.
2m
In single-chip mode there is no external memory, so in addition to the word access address errors
described in section 4.3.2, Address Error in Word Data Access, address errors can occur due to
access to missing areas in the address space.
(1) Access to Addresses H'04000 to H'0EE7F and H'30000 to H'FFFFF: In single-chip mode
these addresses form a missing address area; they are assigned neither to on-chip memory nor to
on-chip registers.
Instruction prefetch, byte data access, or word data access in the missing address area causes an
address error. An address error also occurs if an instruction is located in the last three bytes of on-
chip ROM in page 0, because the H8/500 CPU will attempt to prefetch the next instruction from
addresses H'04000 to H'04002 in the missing address area.
The same type of error will not occur if an instruction is located in the last three bytes of on-chip
ROM in page 1 or page 2.
ROM area
(3 bytes)
H'03FFD Missing address area
H'04000 (data access also causes an address error)
H'0EE7F
H'0EE80
On-chip
RAM area
H'0FE7D (3 bytes)
H'0FE80 Areas in which instruction prefetch
On-chip register area leads to address error
H'0FFFF
(2) Access to Disabled RAM Area: When the on-chip RAM area is disabled in single-chip mode,
addresses H'04000 to H'0FE7F are also a missing area. Instruction prefetch, byte data access, or
word data access in this missing address area causes an address error. An address error also occurs
if an instruction is located in the last three bytes of on-chip ROM in page 0, because the H8/500
CPU will attempt to prefetch the next instruction from addresses H'04000 to H'04002 in the
missing address area.
The same type of error will not occur if an instruction is located in the last three bytes of on-chip
ROM in page 1 or page 2.
H'00000
ROM area
(3 bytes)
H'03FFD
H'04000
(1) Trace Mode: When the trace bit (T bit) in the status register (SR) is set to 1, the H8/500 CPU
operates in trace mode. A trace exception occurs at the completion of each instruction.
In trace exception handling the T bit in SR is cleared to 0 to disable trace mode. The interrupt
mask level in bits I2 to I0 is not changed, however; interrupts are accepted during trace exception
handling.
The trace exception-handling routine should end with an RTE instruction. When the trace routine
returns with the RTE instruction, the status register is popped from the stack and trace mode
resumes.
(2) Contention with Address Error Exception Handling: Address error exception handling
occurs at the end of a bus cycle, so it does not normally conflict with trace exception handling.
One instruction is always executed after returning from exception handling, however, so
contention may occur at this point, requiring special consideration.
If address error and trace exceptions both occur at the end of an instruction, because of the priority
relationship between these exceptions, address error exception handling is carried out. Trace
mode is disabled during execution of the instruction that caused the address error and during the
address error exception handling routine. After return from address error exception handling, one
instruction is executed, then trace mode resumes.
4.5 Interrupts
There are five external sources of interrupt exception handling (NMI, ,540, ,541, ,542, ,543) and
39 sources in the on-chip supporting modules. Table 4-4 classifies the interrupt sources. The on-
chip supporting modules that can request interrupts are the 16-bit integrated timer pulse unit
(IPU), serial communication interfaces 1 and 2 (SCI1 and SCI2), A/D converter, and watchdog
timer (WDT).
NMI is the highest-priority interrupt and is always accepted*. The other 43 interrupt sources are
controlled by the interrupt controller. The interrupt controller arbitrates between simultaneous
interrupts by means of internal registers in which interrupt priorities are assigned to each module.
The interrupt priorities are set in interrupt priority registers A to F (IPRA to IPRF) in the interrupt
controller. An interrupt priority level from 7 to 0 can be assigned to IRQ0. A single priority level
from 7 to 0 can be assigned collectively to IRQ1, IRQ2, and IRQ3. Independent priority levels
from 7 to 0 can also be assigned to each of the on-chip supporting modules.
The interrupt controller also controls the starting of the data transfer controller (DTC) in response
to an interrupt. The DTC can transfer data in either direction between memory and I/O without
using the CPU.
Whether to start the DTC can be selected on an individual interrupt basis in data transfer enable
registers A to F (DTEA to DTEF) in the interrupt controller. The DTC is started if the
corresponding bit in DTEA to DTEF is set to 1. If this bit is cleared to 0, interrupt exception
handling is carried out. A few interrupts, including NMI, cannot start the DTC. The CPU halts
during DTC operation.
For details of DTC interrupts, see section 7, "Data Transfer Controller." Interrupt controller
functions are detailed in section 6, "Interrupt Controller."
In the invalid instruction exception-handling sequence the T bit of the status register is cleared to
0, but the interrupt mask level (I2 to I0) is not changed.
In the exception-handling sequences for these exceptions the T bit of the status register is cleared
to 0, but the interrupt mask level (I2 to I0) is not changed.
(1) TRAPA Instruction: When the TRAPA instruction is executed, the H8/500 CPU starts
exception handling according to the CPU operating mode.
The TRAPA instruction includes a vector number from 0 to 15. The start address is read from the
corresponding location in the vector table.
(2) TRAP/VS Instruction: When the TRAP/VS instruction is executed, the H8/500 CPU starts
exception handling if the overflow (V) flag in the condition code register (CCR) is set to 1.
If the V flag is cleared to 0, no exception occurs and the next instruction is executed.
(3) DIVXU Instruction with Zero Divisor: The H8/500 CPU starts exception handling if an
attempt is made to divide by zero in a DIVXU instruction.
Interrupts are disabled immediately after the execution of five instructions: XORC, ORC, ANDC,
LDC, and RTE.
After executing one of these instructions, the H8/500 CPU always executes the next instruction. If
the next instruction is also one of these five, the next instruction after that is executed too.
Exception handling starts after the next instruction that is not one of these five has been executed.
See the following example.
Example:
Program flow
MOV.W #H'FE80,SP
H8/500 CPU executes next instruction before
starting exception handling
After carrying out reset exception handling, the H8/500 CPU always executes the initial
instruction.
If an interrupt is accepted after a reset but before SP is initialized, the program counter and status
register will not be saved correctly, leading to a program crash. To prevent this, in minimum
mode the first instruction after a reset should initialize SP. In maximum mode, the first instruction
after a reset should be an LDC instruction initializing TP, and the next instruction should initialize
SP.
If an interrupt starts the data transfer controller and a second interrupt is requested during the data
transfer cycle, when the data transfer cycle ends, the H8/500 CPU always executes the next
instruction before handling the second interrupt.
Even if a nonmaskable interrupt (NMI) occurs during a data transfer cycle, it is not accepted until
the next instruction has been executed. An example is shown next.
Example:
Program flow
Table 4-5 shows the stack after completion of exception handling for various types of exceptions
in minimum and maximum modes.
Exception
Source Minimum Mode Maximum Mode
Trace, interrupt,
trap instruction,
DIVXU SP SR (upper 8 bits) TP:SP SR (upper 8 bits)
(zero divide) SR (lower 8 bits)
SR (lower 8 bits)
Next instruction address (upper 8 bits) Don't care
Next instruction address (lower 8 bits) Next instruction page address (8 bits)
Next instruction address (upper 8 bits)
Next instruction address (lower 8 bits)
Note: The RTE instruction returns to the next instruction after the instruction being executed when
the exception occurred.
Invalid instruction
Note: The CP and PC values pushed on the stack are not necessarily the address of the first byte
of the invalid instruction.
Address error
Note: The CP and PC values pushed on the stack are the address of the next instruction after
the last instruction executed.
The PC value pushed on the stack for a trace, interrupt, trap, or zero divide exception is the
address of the next instruction at the time when the interrupt was accepted.
4.9.2 PC Value Pushed on Stack for Address Error and Invalid Instruction Exceptions
The PC value pushed on the stack for an address error or invalid instruction exception differs
depending on the conditions when the exception occurs.
5.1 Overview
The on-chip multiplier module (H8MULT) can perform 16-bit × 16-bit signed or unsigned
multiply and multiply-accumulate operations. These operations can be speeded up by a bus-
stealing function.
5.1.1 Features
MLTBR
S-ON
Module data bus
MAC,
MUL,
CLR
MCA
Multiplier matrix
MACXH MCB
MACH
MCC
MACL
MR
Legend
MLTCR: MULT control register
MLTAR: MULT multiplier address register MMR
MLTMAR: MULT multiplicand address register
MLTBR: MULT base address register
MCA: MULT multiplier register A
MCB: MULT multiplier register B
MCC: MULT multiplier register C
MACXH: MULT result register, extended high word
MACH: MULT result register, high word
MACL: MULT result register, low word
MR: MULT immediate multiplier register
MMR: MULT immediate multiplicand register
Table 5-1 summarizes the internal registers of the H8MULT module. The type of operation
(multiply or multiply-accumulate, signed or unsigned) and the bus-stealing function can be
selected by register settings.
The MULT control register (MLTCR) is an eight-bit readable/writable register that clears the
MULT result registers, selects the type of multiplication operation, and selects the bus-stealing
function. The bit structure of MLTCR is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 1 1 1 0 0 0
R/W R/W R/W R R R R/W R/W R/W
Multiply-accumulate bit
Enables or disables the
multiply-accumulate
function
Multiply bit
Enables or disables
the multiply function
Sign bit
Selects signed arithmetic
Reserved bits
Bus-steal on bit
Enables or disables the bus-stealing function
Clear bit
Simplifies the procedure for initializing MULT result
registers MACXH, MACH, and MACL
Bit 7—Clear (CLR): The purpose of this bit is to simplify the procedure for initializing MULT
result registers MACXH, MACH, and MACL. If the CLR bit is set to 1, when a write access is
made to one of these three registers (MACXH, MACH, or MACL), regardless of the value of the
write data, the other two registers are initialized to H'0000.
Bits 5 to 3—Reserved: These bits are reserved for future expansion. They are always read as 1
and cannot be modified.
Bit 2—Sign (SIGN): Specifies signed arithmetic. The multiplication is performed in signed mode
if the SIGN bit is set to 1, and in unsigned mode if the SIGN bit is cleared to 0. When a multiply-
accumulate operation is executed, the operation is performed in non-saturating mode or saturating
mode. The results of saturating multiply-accumulate operations are stored in 32-bit form of
MACH and MACL registers. In this case, MACXH register is not used. When an overflow occurs,
set bit 0 in the MACXH register to 1. The results of non-saturating multiply-accumulate
operations are stored in 42-bit form of MACXH, MACH, and MACL registers. In this case, an
overflow is not detected.
For details on the SIGN bit and the operation contents, see section 5.3.4 "Multiply and Multiply-
Accumulate Functions."
Bit 1—Multiply (MUL): Enables or disables the multiply function. The multiply function is
enabled when the MUL bit is set to 1. Do not set both the MUL bit and MAC bit (bit 0) to 1 at the
same time. If both bits are set to 1, neither function is enabled.
The MULT base address register (MLTBR) is a readable/writable register that specifies the upper
eight bits of the memory address of the multiplier or multiplicand in multiply or multiply-
accumulate operations when the bus-stealing function is enabled.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
The MULT multiplier address register (MLTAR) is a readable/writable register that specifies the
lower eight bits of the memory address of the multiplier in multiply or multiply-accumulate
operations when the bus-stealing function is enabled.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
The MULT multiplicand address register (MLTMAR) is a readable/writable register that specifies
the lower eight bits of the memory address of the multiplicand in multiply or multiply-accumulate
operations when the bus-stealing function is enabled.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
MULT multiplier register A (MCA) is a 16-bit readable/writable register that stores a multiplier
for use in multiply or multiply-accumulate operations.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
MULT multiplier register B (MCB) is a 16-bit readable/writable register that stores a multiplier
for use in multiply or multiply-accumulate operations.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
MULT multiplier register C (MCC) is a 16-bit readable/writable register that stores a multiplier
for use in multiply or multiply-accumulate operations.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
The MULT immediate multiplier register (MR) is a 16-bit write-only register into which a
multiplier value can be loaded for use in multiply or multiply-accumulate operations.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Initial value − − − − − − − − − − − − − − − −
R/W W W W W W W W W W W W W W W W W
The MULT immediate multiplicand register (MMR) is a 16-bit write-only register into which a
multiplicand value can be loaded for use in multiply or multiply-accumulate operations.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Initial value − − − − − − − − − − − − − − − −
R/W W W W W W W W W W W W W W W W W
The MULT result register (MACXH) is a 16-bit readable/writable register that stores the upper 10
bits of the 42-bit result of a non-saturating multiply-accumulate operation. The sign-extended
value of bit 9 is set in bits 15 to 10 of MACXH.
MACXH is not used in multiply operations, and bits 15 to 1 are not used in saturating multiply-
accumulate operations.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Initial value − − − − − − − − − − − − − − − −
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
Bit 0 of the MACXH register is an overflow flag (OVF) that is set to 1 when the result of a
saturating multiply-accumulate operation overflows.
The MULT result register, high word (MACH) is a 16-bit readable/writable register that stores bits
31 to 16 of a non saturating multiply-accumulate operation.
Initial value − − − − − − − − − − − − − − − −
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
The MULT result register, low word (MACL) is a 16-bit readable/writable register that stores bits
15 to 0 of a non saturating multiply-accumulate operation.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Initial value − − − − − − − − − − − − − − − −
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
5.3 Operation
The operation of the H8/539F’s on-chip multiplier module will be described in the following
order: initialization of MULT result registers; register write; bus-stealing function; then multiply
and multiply-accumulate operations.
MULT result registers MACXH, MACH, and MACL are not initialized by a reset. In a multiply-
accumulate operation, in which the multiplication result is added to the value in the MULT result
registers, the MULT result registers must be initialized before use, either by clearing them or by
writing the necessary values in them ahead of time. Initialization is not necessary when these
registers are only used for multiplication.
(1) Individual Register Initialization: The registers can be initialized by writing to them
individually. The MACH and MACL registers must be written to consecutively.
CLR.W @MACXH
CLR.W @MACH ; Do not change the order of these two instructions
CLR.W @MACL
(2) One-Step Initialization: All three registers can be initialized at once. MACXH, MACH, and
MACL are all initialized to #H'0000, regardless of the write data.
Example:
The one-step initialization function operates at a write access to MACXH, MACH, or MACL. It
does not operate at a read access, or a write access to any other register, so the CLR bit does not
necessarily have to be cleared to 0 after one-step initialization.
The MULT multiplier registers (MCA, MCB, MCC) can be loaded by writing to them directly, or
by bus stealing. The bus-stealing function and direct writing are performed independently for
MCA, MCB, and MCC, so both types of loading can be used together.
(1) Direct Writing: This method writes to MCA, MCB, or MCC by direct addressing. Specify
the address of MCA, MCB, or MCC as the destination operand in a write instruction. Be sure to
use a word-size instruction.
Example:
(2) Loading Data by Bus Stealing: When the CPU accesses its memory address space, the data
on the data bus can be loaded automatically into a MULT multiplier register (bus stealing). Bus
stealing is performed only for particular addresses, which are specified in the MULT multiplier
address register (MLTAR) and MULT base address register (MLTBR).
MOV.W #aa:16, @FE80 ; Write data #aa:16 to @FE80 and load same data into MCA
·
·
·
MOV.W @FE80, R0 ; Read data from @FE80 and load same data into MCA
· ; TST.W @FE80 instruction would do the same
·
·
The bus-stealing function loads the value on the data bus into the H8MULT module when the
CPU accesses its memory address space. The bus-stealing function can be used to multiply or
multiply-and-accumulate two values stored in memory.
The bus-stealing function can be enabled or disabled by bit 6 (S_ON) in the MULT control
register (MLTCR).
(1) Loading of Multiplier by Bus Stealing: Figure 5-2 shows the loading of data into register
MCA by bus stealing. If the S_ON bit is set to 1, the H8MULT module monitors the address bus
when the CPU accesses its memory address space, and compares the address on the bus with the
MULT base address register (MLTBR) and MULT multiplier address register (MLTAR).
If MLTBR (upper 8 bits) and MLTAR (lower 8 bits) = @aa:16, the data on the data bus is loaded
into MULT multiplier register A (MCA).
If MLTBR (upper 8 bits) and MLTAR (lower 8 bits) + 2 = @aa:16, the data on the data bus is
loaded into MULT multiplier register B (MCB).
If MLTBR (upper 8 bits) and MLTAR (lower 8 bits) + 4 = @aa:16, the data on the data bus is
loaded into MULT multiplier register C (MCC).
Upper 8 Lower 8
address bits address bits
Address decoder MLTBR MLTAR
(@aa: 16)
Write
Address comparator
Match
S_ON (MLTCR bit 6)
MCA (#aa: 16)
Bus Read/write
MCB interface
MCC Controls writing to registers
(2) Loading of Multiplicand and Activation of Multiplier by Bus Stealing: Figure 5-3 shows
the loading of the multiplicand and automatic selection of the multiplier register by bus stealing. If
the S_ON bit is set to 1, the H8MULT module monitors the address bus when the CPU accesses
its memory address space, and compares the address on the bus with the MULT base address
register (MLTBR) and MULT multiplicand address register (MLTMAR).
If MLTBR (upper 8 bits) and MLTMAR (lower 8 bits) = @aa:16, the data on the data bus is
loaded as the multiplicand, the multiplier is fetched from MULT multiplier register A (MCA), and
these values are multiplied, or multiplied and accumulated.
If MLTBR (upper 8 bits) and MLTMAR (lower 8 bits) + 2 = @aa:16, the multiplier is fetched
from MULT multiplier register B (MCB).
If MLTBR (upper 8 bits) and MLTMAR (lower 8 bits) + 4 = @aa:16, the multiplier is fetched
from MULT multiplier register C (MCC).
Upper 8 Lower 8
Activate multiplier address bits address bits
matrix MLTBR MLTMAR
(@aa: 16)
Multiplicand
Address comparator
Match
Multiplier matrix
S_ON (MLTCR bit 6)
Multiplier
Read/write
The H8MULT module can execute 16 × 16-bit multiplication, and accumulate products up to a
data length of 42 bits. The multiplier and multiplicand on which arithmetic is carried out can be
specified in two ways. They can be loaded directly into the H8MULT module, or data in memory
can be loaded into the H8MULT module by the bus-stealing function. Multiply and multiply-
accumulate operations are described below.
(1) Multiply: Direct Loading of Multiplier and Multiplicand: The procedure is given next.
(2) Multiply: Multiplier Loaded by Bus Stealing, Multiplicand Loaded Directly: The
procedure is given next.
Memory
H8MULT
H'EE82 #(multiplier 1)
H'EE84 #(multiplier 2)
Memory
R0
Multiplier matrix
#BBBB #(multiplier 0) is loaded by bus stealing
into MCA and multiplier matrix
MCA
MCB
MCC
H'EEA0 #(multiplicand 0)
H'EEA2 #(multiplicand 1)
H'EEA4 #(multiplicand 2)
(5) Multiply and Accumulate: Multiplier Loaded by Bus Stealing, Multiplicand Loaded
Directly: The procedure is given next.
(6) Multiply and Accumulate: Multiplier and Multiplicand Loaded by Bus Stealing
6.1 Overview
The interrupt controller decides when to start interrupt exception handling and when to start the
data transfer controller (DTC), and arbitrates between competing interrupts. This section
describes the interrupts and the functions, features, internal structure, and registers of the interrupt
controller.
For details of data transfers performed by the DTC, see section 7, "Data Transfer Controller."
6.1.1 Features
Note: * The exception is when programming or erasing flash memory, in which case NMI input is
disabled. See section 19.4.9, "NMI Input Masking" and section 20.4.8, "NMI Input
Masking" for details.
Interrupt controller
NMI NMI
request
IPU
from modules
Comparator
WDT
SCI1
Interrupt
SCI2/SCI3 request
A/D converter
DTEA . . . DTEF
DTC
request
I2 I1 I0 SR (CPU)
Legend
IPU: Integrated-timer pulse unit
WDT: Watchdog timer
SCI: Serial communication interface
SR: Status register
IPR: Interrupt priority register
DTE: Data transfer enable register
The interrupt controller has six interrupt priority registers (IPRA to IPRF) and six data transfer
enable registers (DTEA to DTEF). See section 7.2.5, "Data Transfer Enable Registers A to F" for
details of DTEA to DTEF.
Table 6-2 summarizes the NMI control register (NMICR), IRQ control register (IRQCR), and IRQ
flag register (IRQFR).
When multiple interrupts occur simultaneously, the interrupt with the highest priority is served
first. Using IPRA to IPRF, software can assign priorities to interrupts on a module basis. Relative
priorities within the same module are fixed. If the same priority is assigned to two or more
modules, simultaneous interrupt requests from those modules are served in the priority order
shown in table 6-3.
After a reset, all interrupts except NMI are assigned priority 0 and are disabled.
NMI has the highest interrupt priority level (8) and cannot be masked*. Input at the NMI pin is
edge-sensed. Either the rising edge or falling edge can be selected by setting or clearing the
nonmaskable interrupt edge bit (NMIEG) in the NMI control register (NMICR).
In NMI exception handling the T bit in the status register (SR) is cleared to 0 and I2 to I0 are all
set to 1, thereby setting the interrupt mask level to 7.
Note: * The exception is when programming or erasing flash memory, in which case NMI input is
disabled. See section 19.4.9, "NMI Input Masking" and section 20.4.8, "NMI Input
Masking" for details.
NMI Control Register (Address H'FF1C): The NMI control register (NMICR) selects the
sensitive edge of the NMI input. NMICR is initialized to H'FE by a reset and in hardware standby
mode. It is not initialized in software standby mode. The NMICR bit structure is shown next.
Bit 7 6 5 4 3 2 1 0
− − − − − − − NMIEG
Initial value 1 1 1 1 1 1 1 0
R/W − − − − − − − R/W
Nonmaskable
interrupt edge
Selects sensitive
Reserved bits edge of NMI input
Bit 0—Nonmaskable Interrupt Edge (NMIEG): Selects the sensitive edge of the NMI input.
Bit 0
NMIEG Description
0 NMI is requested on falling edge of NMI input (Initial value)
1 NMI is requested on rising edge of NMI input
An IRQ0 interrupt can be requested by an interrupt signal from the ,540 pin or an interrupt signal
from the watchdog timer (WDT). These two interrupt sources have different vectors.
The interrupt from the ,540 pin is level-sensed. A ,540 input requests an IRQ0 interrupt if the
interrupt request enable 0 bit (IRQ0E) in the IRQ control register (IRQCR) is set to 1. A WDT
overflow requests an IRQ0 interrupt when the WDT is set to interval timer mode. The WDT then
requests an IRQ0 interrupt each time the timer counter (TCNT) overflows.
A priority level from 7 to 0 can be assigned to IRQ0 in the upper four bits of IPRA. If bit 4 in
DTEA is set to 1, IRQ0 is served by the DTC.
In IRQ0 exception handling the T bit in SR is cleared to 0 and the interrupt mask level is set to the
value selected in the four upper bits of IPRA.
Interrupts IRQ1 to IRQ3 are requested by interrupt signals from the ,541 to ,543 pins. The ,541
to ,543 inputs are sensed on the falling edge. The falling edge generates an ,541 to I#,543
interrupt request if the interrupt request enable 1, 2, or 3 bit (IRQ1E, IRQ2E, or IRQ3E) in the
IRQ control register (IRQCR) is set to 1.
A priority level from 7 to 0 can be assigned to IRQ1, IRQ2, and IRQ3 collectively in the lower
four bits of IPRA. If bits 2 to 0 in DTEA are set, these interrupts are served by the DTC.
In IRQ1, IRQ2, and IRQ3 exception handling the T bit in SR is cleared to 0 and the interrupt mask
level is set to the value selected in the lower four bits of IPRA.
IRQ Control Register (Address H'FF1D): The IRQ control register (IRQCR) enables and
disables inputs at ,541 to ,543, and ,540. IRQCR is initialized to H'F0 by a reset and in hardware
standby mode. It is not initialized in software standby mode. The bit structure of IRQCR is
shown next.
Bit 7 6 5 4 3 2 1 0
− − − − IRQ3E IRQ2E IRQ1E IRQ0E
Initial value 1 1 1 1 0 0 0 0
R/W − − − − R/W R/W R/W R/W
Bit 3—Interrupt Request 3 Enable (IRQ3E): Selects the function of pin P61.
Bit 3
IRQ3E Description
0 P61 is used for general-purpose input and output (Initial value)
1 P61 is used for ,543 input
Bit 2—Interrupt Request 2 Enable (IRQ2E): Selects the function of pin P60.
Bit 2
IRQ2E Description
0 P60 is used for general-purpose input and output (Initial value)
1 P60 is used for ,542 input
Bit 1—Interrupt Request 1 Enable (IRQ1E): Selects the function of pin P71.
Bit 1
IRQ1E Description
0 P71 is used for general-purpose input and output (Initial value)
1 P71 is used for ,541 input
Bit 0—Interrupt Request 0 Enable (IRQ0E): Selects the function of pin P70.
Bit 0
IRQ0E Description
0 P70 is used for general-purpose input and output (Initial value)
1 P70 is used for ,540 input
IRQFR is initialized to H'F1 by a reset and in hardware standby mode. It is not initialized in
software standby mode. The bit structure of IRQFR is shown next.
Bit 7 6 5 4 3 2 1 0
− − − − IRQ3F IRQ2F IRQ1F −
Initial value 1 1 1 1 0 0 0 1
R/W − − − − R/W* R/W* R/W* −
Reserved bit
Bit 3—Interrupt Request 3 Flag (IRQ3F): Indicates that interrupt request 3 (IRQ3) has been
input.
Bit 3
IRQ3F Description
0 Interrupt request 3 (IRQ3) has not been input (Initial value)
1 Interrupt request 3 (IRQ3) has been input and is waiting for interrupt service
[Clearing conditions]
• Cleared to 0 automatically when the H8/500 CPU accepts IRQ3 and the
interrupt vector is output
• Can also be cleared by reading 1, then writing 0, in which case the pending
IRQ3 interrupt request is deleted
Bit 2
IRQ2F Description
0 Interrupt request 2 (IRQ2) has not been input (Initial value)
1 Interrupt request 2 (IRQ2) has been input and is waiting for interrupt service
[Clearing conditions]
• Cleared to 0 automatically when the H8/500 CPU accepts IRQ2 and the
interrupt vector is output
• Can also be cleared by reading 1, then writing 0, in which case the pending
IRQ2 interrupt request is deleted
Bit 1—Interrupt Request 1 Flag (IRQ1F): Indicates that interrupt request 1 (IRQ1) has been
input.
Bit 1
IRQ1F Description
0 Interrupt request 1 (IRQ1) has not been input (Initial value)
1 Interrupt request 1 (IRQ1) has been input and is waiting for interrupt service
[Clearing conditions]
• Cleared to 0 automatically when the H8/500 CPU accepts IRQ1 and the
interrupt vector is output
• Can also be cleared by reading 1, then writing 0, in which case the pending
IRQ1 interrupt request is deleted
There are 39 internal interrupt sources in the on-chip supporting modules. A different interrupt
vector address is assigned to each source, so the interrupt handling routine does not have to
determine which interrupt has occurred.
Priority levels from 7 to 0 are assigned to each module in IPRA to IPRF. DTEA to DTEF indicate
which interrupts in each module are served by the DTC.
When an internal interrupt request is accepted, the T bit in SR is cleared to 0 and the interrupt
mask level in I2 to I1 is set to the value selected in IPRA to IPRF.
The six interrupt priority registers (IPRA to IPRF) assign priority levels from 7 to 0 to interrupt
sources other than NMI. A reset initializes IPRA to IPRF to H'00.
Bit 7 6 5 4 3 2 1 0
0 0
Initial value 0 0 0 0 0 0 0 0
R/W − R/W R/W R/W − R/W R/W R/W
Bits 7 to 4—Interrupt Priority, Upper Four Bits: These bits select an interrupt priority level.
Bit 7 must always be cleared to 0.
Bits 3 to 0—Interrupt Priority, Lower Four Bits: These bits select an interrupt priority level.
Bit 3 must always be cleared to 0.
The on-chip supporting modules are mapped onto the interrupt priority registers as shown in table
6-4. Each interrupt priority register is assigned two on-chip supporting modules. The upper four
bits of the interrupt priority register specify the priority level of one module; the lower four bits
specify the priority of the other module.
Table 6-5 indicates how priority levels are set in the interrupt priority registers. For example, to
assign level 7 to SCI1, set bits 6 to 4 in IPRF to 111.
Bits 6 to 4 Bits 2 to 0
Register On-Chip Supporting Module On-Chip Supporting Module
IPRA ,540, WDT, A/D converter ,541 to ,543
IPRB IPU channel 1 IPU channel 1
IPRC IPU channel 2 IPU channel 3
IPRD IPU channel 4 IPU channel 5
IPRE IPU channel 6 IPU channel 7
IPRF SCI1 SCI2/SCI3
Bits 6 to 4
or Bits 2 to 0 Interrupt Priority Level
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
The interrupt controller requires two system clock cycles (2φ) to determine the priority level of an
interrupt. Therefore, when an instruction modifies an instruction priority register (IPRA to IPRF),
the new priority takes effect starting from the third state after that instruction has been executed.
Figure 6-2 is a flowchart of the interrupt sequence up to the point at which an interrupt is accepted.
1. The interrupt controller receives interrupt request signals from one or more on-chip supporting
modules or external interrupt sources.
Rev. 3.0, 02/99, page 129 of 904
2. The interrupt controller checks the interrupt priorities assigned in IPRA to IPRF and selects the
interrupt with the highest priority level. Interrupts with lower priorities remain pending.
Among interrupts with the same assigned level, the interrupt controller determines priority as
explained in table 6-3.
3. The interrupt controller compares the priority level of the selected interrupt request with the
mask level in SR bits I2 to I0. If the priority level is equal to or less than the mask level, the
interrupt request remains pending. If the priority level is higher than the mask level, the
interrupt controller accepts the interrupt request.
4. After accepting an interrupt, the interrupt controller checks the corresponding bit in DTEA to
DTEF. If this bit is set to 1, the data transfer controller is started. If it is cleared to 0,
interrupt exception handling is started.
Interrupt No
requested?
Yes
Address No
error?
No
Trace?
Yes
No
NMI?
Yes Level-7 No
Yes interrupt?
Level-6 No
Yes interrupt?
Level-1 No
Yes interrupt?
Yes
SR mask
level ≤ 6? No
SR mask
Yes
level ≤ 5? No
SR mask
Yes level = 0? No
Yes
Held pending
No
Interrupt exception handling is described below. Figure 6-3 shows a flowchart. For DTC
operations, see section 7, "Data Transfer Controller."
1. When the interrupt controller accepts an interrupt, after the H8/500 CPU finishes executing the
current instruction, PC and SR (in minimum mode) or PC, CP, and SR (in maximum mode)
are pushed on the stack, leaving the stack in the condition shown in section 6.4.4, "Stack after
Interrupt Exception Handling."
2. The interrupt controller clears the T bit in SR to 0, and sets the interrupt mask level (I2 to I0)
to the priority level of the interrupt.
3. In minimum mode, the interrupt controller reads a one-word vector address corresponding to
the accepted interrupt from the vector table and copies this word into PC. Execution of the
interrupt handling routine then starts from the PC address. In maximum mode, the interrupt
controller reads a two-word vector address corresponding to the accepted interrupt from the
vector table, copies the lower byte of the first word into CP, and copies the second word into
PC. Execution of the interrupt handling routine then starts from the address indicated by CP
and PC.
Maximum Yes
mode?
No
Save CP
Save SR
Clear T bit
No
Trace?
Yes
Address No
error?
Vectoring
Figure 6-4 is a timing diagram of the interrupt sequence in minimum mode, for the case in which
the interrupt handling routine starts at an even address and the program area and stack area are in
the external 16-bit-bus two-state-access address space.
NMI, IRQ0,
IRQn (n = 1-3)
Data bus
(2) (2) (2) PC SR Vector (4)
(16 bits)
RD
WR
Interrupt is accepted
Figure 6-5 is a timing diagram of the interrupt sequence in maximum mode, for the case in which
the interrupt handling routine starts at an even address and the program area and stack area are in
the external 16-bit-bus two-state-access address space.
NMI, IRQ0,
IRQn (n = 1-3)
RD
WR
Priority level Inter- Stack access Interrupt vector Prefetch first Start
decision and nal instruction of instruc-
wait for end cy- interrupt- tion
of current cles handling routine execu-
instruction tion
Interrupt is accepted
Figure 6-6 shows the stack before and after interrupt exception handling in minimum mode.
Figure 6-7 shows the stack before and after interrupt exception handling in maximum mode. The
PC value saved on the stack is the address of the next instruction to be executed.
SP must always point to an even address. If an odd address is set in SP, an address error will
occur when the stack is accessed.
Figure 6-6 Stack before and after Interrupt Exception Handling in Minimum Mode
Address Address
2m-6 2m-6 SR (upper 8 bits) SP
2m-5 2m-5 SR (lower 8 bits)
2m-4 2m-4 Don't care
2m-3 2m-3 CP
2m-2 2m-2 PC (upper 8 bits)
2m-1 2m-1 PC (lower 8 bits)
2m SP 2m
Stack area
Figure 6-7 Stack before and after Interrupt Exception Handling in Maximum Mode
Example:
Program flow
Number of States
1 2
Stack Area: 16* Stack Area: 8*
Instruction: Instruction: Instruction: Instruction:
3 4 3 4
Reason for Wait 16* 8* 16* 8*
Interrupt priority decision and 2 2 2 2
comparison with SR mask level
Maximum number of states to 38 38
completion of current instruction 74 + 16 m 74 + 16 m
Saving of PC and SR 16 16
28 + 6 m 28 + 6 m
Total number of states 56 92 + 16 m 68 + 6 m 104 + 22 m
Notes: 1. Stack area in 16-bit-bus two-state-access address space
2. Stack area in 8-bit-bus three-state-access address space
3. Instruction in 16-bit-bus two-state-access address space
4. Instruction in 8-bit-bus three-state-access address space
m: Number of wait states inserted in memory access
Table 6-7 indicates the interrupt response time in maximum mode. The maximum number of
states occurs when the LDM instruction is executed with all registers specified.
Number of States
1 2
Stack Area: 16* Stack Area: 8*
Instruction: Instruction Instruction Instruction
3 4 3 4
Reason for Wait 16* 8* 16* 8*
Interrupt priority decision and 2 2 2 2
comparison with SR mask level
Maximum number of states to 38 74 + 16 m 38 74 + 16 m
completion of current instruction
Saving of PC, CP, and SR 21 21 41 + 10 m 41 + 10 m
Total number of states 61 97 + 16 m 81 + 10 m 117 + 26 m
Notes: 1. Stack area in 16-bit-bus two-state-access address space
2. Stack area in 8-bit-bus three-state-access address space
3. Instruction in 16-bit-bus two-state-access address space
4. Instruction in 8-bit-bus three-state-access address space
m: Number of wait states inserted in memory access
7.1 Overview
An interrupt-triggered data transfer controller (DTC) is included on-chip. The DTC can transfer
data between memory and I/O, memory and memory, or I/O and I/O without using the CPU. For
example, the DTC can set data in the registers of an on-chip supporting module or send data to an
I/O port or serial communication interface (SCI) independently of program execution. The
H8/500 CPU halts while the DTC is operating.
7.1.1 Features
• The source address and destination address can be set anywhere in the 64-kbyte address space
of page 0.
• The source address and destination address can be incremented or left unchanged after a data
transfer.
• The DTC can be programmed to transfer one byte or one word of data per interrupt.
• A data transfer count of up to 65,536 bytes or words can be set in the data transfer counter
register (DTCR).
• After a data transfer, if the data transfer count is zero, the interrupt request that started the DTC
is transferred to the H8/500 CPU. The H8/500 CPU then starts normal interrupt exception
handling.
When DTC service is requested, the DTC loads its control registers from memory with
information corresponding to the interrupt source, transfers a byte or word of data, and writes any
altered register information back to memory.
IRQ1 Register
information 1
DTEA DTMR
DTEB DTSR
DTDR
DTEF DTCR
Legend
DTMR: Data transfer mode register
DTSR: Data transfer source address register
DTDR: Data transfer destination address register
DTCR: Data transfer count register
DTEA to DTEF: Data transfer enable registers A to F
These registers cannot be accessed directly. To set information in the DTC control registers,
software should alter the information in memory.
Starting of the DTC is controlled by the interrupt controller's data transfer enable registers.
The data transfer mode register (DTMR) is a 16-bit register that selects the data size and specifies
whether to increment the source and destination addresses. The DTMR bit structure is shown
next.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Sz SI DI − − − − − − − − − − − − −
R/W − − − − − − − − − − − − − − − −
Reserved bits
Size bit
Selects byte-size or word-size data transfer
Bit 15
Sz Description
0 Byte transfer
1 Word (two-byte) transfer*
Note: * For word transfer, DTSR and DTDR must indicate even addresses.
(2) Bit 14–Source Increment Mode (SI): Specifies whether to increment the source address.
Bit 14
SI Description
0 Not incremented
1 1. If Sz = 0: incremented by 1 after each data transfer
2. If Sz = 1: incremented by 2 after each data transfer
Bit 13
DI Description
0 Not incremented
1 1. If Sz = 0: incremented by 1 after each data transfer
2. If Sz = 1: incremented by 2 after each data transfer
The data transfer source address register (DTSR) is a 16-bit register that designates the data
transfer source address. The DTSR bit structure is shown next.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R/W − − − − − − − − − − − − − − − −
For word transfer the source address must be even. In maximum mode, the source address is
implicitly located in page 0.
The data transfer destination address register (DTDR) is a 16-bit register that designates the data
transfer destination address. The DTDR bit structure is shown next.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R/W − − − − − − − − − − − − − − − −
For word transfer the destination address must be even. In maximum mode, the destination
address is implicitly located in page 0.
The data transfer count register (DTCR) is a 16-bit register that designates the number of bytes or
words to be transferred. The initial count can be set from 1 to 65,536. A register value of 0
designates an initial count of 65,536. The DTCR bit structure is shown next.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R/W − − − − − − − − − − − − − − − −
The data transfer count register is decremented automatically after each byte or word is
transferred. When the count reaches 0, indicating that the designated number of bytes or words
have been transferred, the DTC sends the H8/500 CPU an interrupt request with the same interrupt
source that started the data transfer.
The six data transfer enable registers (DTEA to DTEF) specify whether an interrupt starts the
DTC. (Certain interrupts, such as NMI, cannot start the DTC.) The bit structure of DTEA to
DTEF is shown next.
Bit 7 6 5 4 3 2 1 0
0 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
The bits in these registers are assigned to interrupts as indicated in table 7-3.
If the bit for a certain interrupt is set to 1, that interrupt is regarded as a request for DTC service.
If the bit is cleared to 0, the interrupt is regarded as an H8/500 CPU interrupt request.
Only the interrupts indicated in table 7-3 can request DTC service in the H8/539F. DTE bits not
assigned to any interrupt (indicated by "−" in table 7-3) must be cleared to 0.
On-Chip On-Chip
Supporting Supporting
Register Module Bits 7 to 4 Module Bits 3 to 0
DTEA IRQ0, ADI 7 6 5 4 IRQ1-3 3 2 1 0
− ADI (IRQ0) IRQ0 − IRQ3 IRQ2 IRQ1
The interrupt controller requires two system clock cycles (2φ) to determine the priority level of an
interrupt. When an instruction modifies one of registers DTEA to DTEF, the new setting takes
effect starting from the third state after the instruction has been executed.
Data transfer operations when the DTC is activated are described below. Figure 7-2 is a flowchart
of the DTC operations.
Figure 7-2 is a flowchart of the data transfer operations performed by the DTC. For operations
from the occurrence of an interrupt until the DTC is activated, see section 6.4.1, "Operations up to
Interrupt Acceptance."
1. From the DTC vector table, the DTC reads the address at which the register information for the
interrupt is stored in memory and loads the stored information into its control registers.
When the DTC is activated, the interrupt source that activated the DTC is cleared, except for
interrupts from the serial communication interface.
2. The DTC transfers the data and increments the source and destination addresses as required,
then decrements DTCR.
If the DTC was activated by an interrupt from the serial communication interface, the interrupt
source is cleared when the DTC accesses the transmit data register (TDR) or receive data
register (RDR).
3. The DTC writes updated register information back to memory.
4. If the DTCR value is 0, the H8/500 CPU starts interrupt exception handling for the interrupt
that activated the DTC.
No
DTC interrupt? H8/500 CPU
Yes interrupt handling
DTC
starts. See section
Read DTC vector 6.4.2, "Interrupt
Exception Handling."
Read data transfer mode
Read data
Source
Yes
address increment
mode?
Increment source address (+1 or +2)
No
Write source address
Write data
Destination Yes
address increment
mode?
Increment destination address
No (+1 or +2)
Read DTCR
DTCR -1 → DTCR
Write DTCR
Yes
DTCR = 0?
No
Program execution state
For each interrupt that can request DTC service, the DTC vector table provides a pointer to an
address in memory where the DTC control register information for that interrupt is stored.
Register information tables can be placed in any available locations in page 0.
Figure 7-3 shows an example in which the register information is located in RAM. Register
information can also be stored in ROM if there is no need to update the information after each
transfer (if the source and destination addresses are not incremented and the desired data transfer
count is one).
DTMR0
TA0
Register DTSR0
Exception information 0 DTDR0
vector table
DTCR0
TA1 DTMR1
TA0*
Register DTSR1
information 1 DTDR1
TA1*
DTCR1
DTC vector
table
Note: * TA0, TA1, ...: Addresses of DTC register information tables in memory.
The DTC vector table structure differs between minimum and maximum modes. In maximum
mode there is no page specification: page 0 is assumed implicitly.
Figure 7-4 shows a DTC vector table entry in minimum and maximum mode.
Address Address
Note: * Addresses 2m and 2 m + 1 are not accessed when the vector is read.
Table 7-4 lists the address of the entry in the DTC vector table for each interrupt source.
For each interrupt, the DTC control register information is stored in memory in the order shown in
figure 7-5.
DTMR
TA + 2 DTSR
TA TA + 4 DTDR
TA + 6 DTCR
8 bits 8 bits
Table 7-5 lists the number of states required per data transfer, assuming that the DTC control
register information is stored in the 16-bit-bus two-state-access address space.
N = 26 + 2 × SI + 2 × DI + MS + MD
If the DTC control register information is stored in the eight-bit-bus three-state-access address
space, 20 + 4 × SI + 4 × DI must be added to the values in table 7-5.
Table 7-6 indicates the number of additional states between the occurrence of an interrupt request
and the starting of the DTC (states during which the interrupt controller checks priority and waits
for execution of the current instruction to end). At maximum, this number of states is the sum of
the values indicated for items No. 1 and 2 in table 7-4.
Number of States
No. Reason for Wait Minimum Mode Maximum Mode
1 Interrupt priority decision and comparison 2
with mask level in SR
2 Number of states to Instruction is in 16-bit-bus (LDM instruction specifying all
completion of current two-state-access address registers)
instruction space 38
Instruction is in 8-bit-bus (LDM instruction specifying all
three-state-access address registers)
space 74 + 16 m
3 Number of statues Instruction is in 16-bit-bus 16 21
from saving of PC two-state-access address
and SR or PC, CP, space
and SR until
Instruction is in 8-bit-bus 28 + 6 m 41 + 10 m
prefetching of first
three-state-access address
instruction of
space
interrupt-handling
routine
Notation
m: Number of wait states inserted in memory access
1. DTC register setup: Set the appropriate DTMR, DTSR, DTDR, and DTCR register
information in the memory location indicated in the DTC vector table.
2. DTEn, IPRn (n = A to F), and SR setup: Set the data transfer enable bit of the pertinent
interrupt to 1, and set the priority of the interrupt source (in the interrupt priority register) and
the interrupt mask level (in the CPU status register) so that the interrupt can be accepted.
3. Interrupt enabling: Set the interrupt enable bit for the interrupt source in the control register of
the on-chip supporting module (or IRQ control register).
Following these preparations, the DTC will be started each time the interrupt occurs.
DTC
#DTMR→ @DT_REG
#DTSR→ @DT_REG + 2
Set DTC register values
#DTDR→ @DT_REG + 4
#DTCR→ @DT_REG + 6
DTC is enabled
(2) Conditions:
Table 7-7 shows the DTC control register information to be set in RAM.
(3) Operation
(a) Software sets DTMR, DTSR, DTDR, and DTCR information in RAM addresses H'F680 to
H'F687 as shown in table 7-7.
(b) Software sets the RI (SCI1 Receive Interrupt) bit in data transfer enable register F (DTEF) to
1.
(c) Software sets the interrupt mask level in SR bits I2 to I0 to 4, and the SCI1 interrupt priority
level in the upper four bits of interrupt priority register F (IPRF) to 0101 (5).
(d) Software sets SCI1 to the appropriate receive mode, and sets the receive interrupt enable bit
(RIE) in the serial control register (SCR) to 1 to enable receive interrupts.
(e) Thereafter, each time SCI1 receives one byte of data, the DTC is activated and transfers the
byte of receive data into RAM. The DTC automatically clears the SCI1 receive interrupt
request.
(f) When 128 bytes have been transferred (DTCR = 0), SCI1 receive interrupt exception handling
begins.
(g) The interrupt-handling routine executes a receive wrap-up routine.
DTC setup
#DTMR → @F680
#DTSR → @F682
(a) Write DTC control register information on RAM
#DTDR → @F684
#DTCR → @F686
<100> → I2 to I0 (SR)
(c) Set interrupt mask level (SR) and interrupt
<101> → IPRF (bits 6 to 4) priority level (IPRF)
Set up SCI1 and enable (d) Set SCI1 to receive mode and enable interrupt
interrupt requests
End of setup
Start DTC
Clear interrupt request (f) Test for end of data: start interrupt handling if
DTCR = 0
DTCR - 1 → DTCR (e) (g) Interrupt handling: receive-data wrap-up routine
No
DTCR = 0? <Interrupt handling routine>
(f) Yes SCI1 receive wrap-up (g)
routine
H'00
Transfer count
H'F687 H'80
Transferred
by DTC
H'FC7F Receive data 128
RDR
SCI
8.1 Overview
For interfacing to low-speed external devices, an on-chip wait-state controller (WSC) can insert
wait states (TW) into bus cycles. The wait function can be used in CPU and DTC access cycles to
the external three-state-access address space. It is not used in access to the two-state-access
address space or the on-chip register area (H'FE80 to H'FFFF).
Wait states are inserted between the T2 state and T3 state in the bus cycle. The number of wait
states can be selected by a value set in the wait control register (WCR), or by holding the :$,7
pin low for the required interval.
8.1.1 Features
WCR
− − − − WMS1 WMS0 WC1 WC0
Wait counter
Legend
WCR: Wait control register
WMS1/0: Wait mode select bits 1 and 0
WC1/0: Wait count bits 1 and 0
Bit 7 6 5 4 3 2 1 0
− − − − WMS1 WMS0 WC1 WC0
Initial value 1 1 1 1 0 0 1 1
R/W − − − − R/W R/W R/W R/W
Reserved bits
WCR is initialized to H'F3 by a reset and in hardware standby mode. WCR is not initialized in
software standby mode.
Bits 3 and 2–Wait Mode Select 1 and 0 (WMS1 and WMS0): These bits select the wait mode.
Bit 3 Bit 2
WMS1 WMS0 Description
0 0 Programmable wait mode (Initial value)
0 1 No wait states (TW) inserted, regardless of wait count
1 0 Pin wait mode
1 1 Pin auto-wait mode
Bit 1 Bit 0
WC1 WC0 Description
0 0 No programmable wait states (TW) inserted
0 1 1 wait state inserted
1 0 2 wait states inserted
1 1 3 wait states inserted (Initial value)
8.3 Operation
Table 8-2 summarizes the operation of the three wait modes.
Description
Number of Wait
Mode WAIT Pin Function Insertion Conditions States Inserted
Programmable Disabled Inserted in access to 1 to 3 states are inserted
wait mode external three-state- as specified by bits WC0
WMS1 = 0 access address space and WC1
WMS0 = 0
Pin wait mode Enabled Inserted in access to • 0 to 3 states are
WMS1 = 1 external three-state- inserted as specified
WMS0 = 0 access address space
by bits WC0 and WC1
• Additional states can
be inserted by driving
the :$,7 signal low
Whenever the CPU or DTC accesses the external three-state-access address space, the number of
wait states selected by bits WC1 and WC0 are inserted. The PA4/#:$,7 pin is not used for wait
control; it is available for general-purpose input or output.
Figure 8-2 shows the timing of operation in this mode when the wait count is 1 (WC1 = 0, WC0 =
1).
T1 T2 T1 T2 TW T3 T1
AS
RD
(read access)
Read data Read data
D15-D 0
(read access)
HWR, LWR
(write access)
D15-D 0
Write data
(write access)
Pin wait mode is selected when WMS1 = 0 and WMS0 = 1. In this mode the :$,7 function of
the PA4/#:$,7 pin is used automatically.
The number of wait states indicated by wait count bits WC1 and WC0 are inserted into any bus
cycle in which the CPU or DTC accesses the external three-state-access address space. In
addition, wait states are inserted if the :$,7 signal is driven low, even if the wait count is 0.
Wait states continue to be inserted until the :$,7 signal goes high.
This mode is useful for inserting four or more wait states, or when different external devices
require different numbers of wait states.
Figure 8-3 shows the timing of operation in this mode when the wait count is 1 (WC1 = 0, WC0 =
1) and the :$,7 signal is held low to insert one additional wait state.
T1 T2 T1 T2 TW TW T3
φ * *
WAIT
AS
RD
(read access)
Read data Read data
D15-D 0
(read access)
HWR, LWR
(write access)
Pin auto-wait mode is selected when WMS1 = 1 and WMS0 = 1. In this mode the :$,7 function
of the PA4/#:$,7 pin is used automatically. When the CPU or DTC accesses the external three-
state-access address space, if the :$,7 pin is low the number of wait states indicated by bits
WC1 and WC0 are inserted.
This mode offers a simple way to interface a low-speed device: wait states can be inserted by
routing the address strobe signal ($6) and a decoded address signal to the :$,7 pin.
Figure 8-4 shows the timing of operation in this mode when the wait count is 1 (WC1 = 0, WC0 =
1).
In pin auto-wait mode the :$,7 pin is sampled only once, on the falling edge of the system clock
(φ) in the T2 state. If the :$,7 signal is low at this time, the wait-state controller inserts the
number of wait states indicated by bits WC1 and WC0. The :$,7 pin is not sampled during the
TW and T3 states, so no additional wait states are inserted even if the :$,7 signal continues to be
held low.
T1 T2 T3 T1 T2 TW T3
* *
φ
WAIT
AS
RD
(read access)
Read data Read data
D15-D 0
(read access)
HWR, LWR
(write access)
D15-D 0
Write data
(write access)
9.1 Overview
This LSI has an on-chip clock pulse generator (CPG). The clock pulse generator consists of an
oscillator, system clock frequency divider, and frequency dividers (prescalers) for the clock
signals of the on-chip supporting modules.
The 1:1 clock pulse generator does not include a frequency divider, but includes a circuit for
adjusting the duty of the input clock.
Figure 9-1 shows the configuration of the 1:1 clock pulse generator.
CPG
XTAL Duty
Oscillator adjustment Prescalers
EXTAL circuit
φ φ /2-φ /4096
(1) Circuit Configuration: A crystal resonator can be connected as in the example in figure 9-2.
An AT-cut parallel resonating crystal should be used. For the 1:1 clock pulse generator, insert a
damping resistor as listed in table 9-1.
CL
EXTAL
Rd
XTAL
* CL = 10-22 pF CL
Frequency (MHz) 2 4 8 10 12 16
Rd max (Ω) 1k 500 200 0 0 0
(2) Crystal Resonator: Figure 9-3 shows an equivalent circuit of the crystal resonator. The
crystal resonator should have the characteristics listed in table 9-2. Use a crystal resonator with a
frequency equal to the system clock frequency (φ).
L Rs
XTAL EXTAL
C0
AT-cut parallel resonator
Frequency (MHz) 2 4 8 10 12 16
Rs max (Ω) 500 120 80 70 60 50
C0 max (pF) 7
(3) Notes on Board Design: When a crystal resonator is connected, the following points should
be noted:
• Other signal lines should be routed away from the oscillator circuit to prevent induction from
interfering with correct oscillation. See figure 9-4.
• When the board is designed, the crystal resonator and its load capacitors should be placed as
close as possible to the XTAL and EXTAL pins.
Signal Signal
Not allowed
line A line B
H8/539F
CL
XTAL
EXTAL
CL
(1) Circuit Configuration: An external clock signal can be input at the EXTAL pin as shown in
the example in figure 9-5. A reverse-phase clock should be input at the XTAL pin.
When the circuit configuration in figure 9-5 is used, the external clock should be held high in
standby mode.
EXTAL
External clock input
XTAL
74HC04 or equivalent
Note: The H8/539F can be driven with the XTAL pin left open if the stray capacitance at the
XTAL pin does not exceed 10 pF and the clock input can be held high in standby mode.
Table 9-3 and figure 9-6 indicate the required clock timing.
The external clock output settling delay time is shown in table 22-5 in section 22.2.2, "AC
Characteristics" and in table 23-5 in section 23.2.2 "AC Characteristics". The external clock
output settling delay timing is shown in figure 22-2 in section 22.3.3, "Clock Timing", and in table
23-11 in section 23.3.3, "Clock Timing".
When the specified clock is input at the EXTAL pin, internal clock signal output settles after the
elapse of the external clock output settling delay time (tDEXT). As the clock signal output remains
unsettled during the tDEXT period, the reset signal should be driven low to retain the reset state.
tcyc
EXTAL
VCC × 0.5
tEXr tEXf
tcyc
φ
VCC × 0.5
10.1 Overview
The H8/539F has twelve I/O ports. Ports 1, 2, 4, 5, 7, B, and C are eight-bit input/output ports.
Port 3 is a six-bit input/output port. Port 6 is a five-bit input/output port. Port A is a seven-bit
input/output port. Port 8 is a four-bit input port. Port 9 is an eight-bit input port.
These ports are multiplexed with inputs and outputs of the on-chip supporting modules. The
functions of ports 1, 2, A, B, and C also differ depending on the operating mode.
Each port has a data direction register (DDR) for selecting input or output, and a data register
(DR) for holding output data. In addition to DR and DDR, port A has a bus release control
register (BRCR), and ports B and C have MOS input pull-up transistor control registers (PBPCR
and PCPCR).
Ports 1, 2, A, B, and C can drive one TTL load and a 90-pF capacitive load. Ports 3 to 7 can drive
one TTL load and a 30-pF capacitive load. Ports 3 and 5 can drive LEDs (with 10-mA current
sink). Ports 4 and 5 have Schmitt-trigger input circuits.
PWM output pin functions have been added to ports 6 and 7 of the H8/539F, and both serial
communication input/output and PWM output pin functions have been added to port A.
Table 10-1 summarizes ports 1 to C of the H8/539F, giving the pin names and functions in each
mode.
10.2.1 Overview
Pins in port 1 can drive one TTL load and a 90-pF capacitive load. They can also drive a
Darlington transistor pair.
Figure 10-1 summarizes the pin functions. Figure 10-2 shows examples of output loads for port 1.
P17/D15
P16/D14
P15/D13
P14/D12
Port 1
P13/D11
P12/D10
P11/D9
P10/D8
HD7404 etc.
Darlington pair
2 kΩ
H8/539F H8/539F
Port 1 HD74LS04 etc. Port 1
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port 1 Data Direction Register: The port 1 data direction register (P1DDR) is an eight-bit
register. Each bit selects input or output for one pin in port 1. These input/output designations are
valid only in mode 7.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W W W W W W W W W
A pin in port 1 becomes an output pin if the corresponding P1DDR bit is set to 1, and an input pin
if this bit is cleared to 0. P1DDR is a write-only register. All bits always return the value 1 when
read.
P1DDR is initialized to H'00 by a reset and in hardware standby mode. P1DDR is not initialized
in software standby mode.
(2) Port 1 Data Register: The port 1 data register (P1DR) is an eight-bit register that stores data
for pins P10 to P17. P1DR is used only in mode 7. In modes 1 to 6, the bit values in P1DR cannot
be modified and always read 1.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a bit in P1DDR is set to 1, the corresponding P1DR bit value is output at the corresponding
pin. If port 1 is read the value in P1DR is returned, regardless of the actual state of the pin.
P1DR is initialized to H'00 by a reset and in hardware standby mode. P1DR is not initialized in
software standby mode.
The functions of port 1 differ between the externally expanded modes (modes 1 to 6) and single-
chip mode (mode 7). The pin functions in each mode are described below.
(1) Pin Functions in Externally Expanded Modes (Modes 1 to 6): The settings in P1DDR are
ignored. Port 1 automatically becomes a bidirectional data bus. Figure 10-3 shows the pin
functions in modes 1 to 6.
Pin Functions
D15 (bidirectional data bus)
D14 (bidirectional data bus)
D13 (bidirectional data bus)
D12 (bidirectional data bus)
Port 1
D11 (bidirectional data bus)
D10 (bidirectional data bus)
D9 (bidirectional data bus)
D8 (bidirectional data bus)
Pin Functions
P17 (input/output pin)
P16 (input/output pin)
P15 (input/output pin)
P14 (input/output pin)
Port 1
P13 (input/output pin)
P12 (input/output pin)
P11 (input/output pin)
P10 (input/output pin)
(3) Software Standby Mode: Transition to software standby does not change the pin functions in
single-chip mode. In the externally expanded modes, port 1 is in the high-impedance state during
software standby.
P1DR and P1DDR have different read/write functions depending on whether port 1 is used as a
data bus (D15 to D8) or for general-purpose input or output (P17 to P10). The operating states and
functions of port 1 are described next.
(1) Data Bus (Modes 1 to 6): Figure 10-5 shows a block diagram illustrating the data-bus
function. Table 10-3 indicates register read/write data. When port 1 operates as a data bus, the
values in the port 1 data register (P1DR) have no effect on the bus lines. When read, P1DR
returns all 1s.
VCC
Read
Write
P1DR
Read Write
P1DR Always 1 Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Input Port (Mode 7): Figure 10-6 shows a block diagram illustrating the general-purpose
input function. Table 10-4 indicates register read/write data. When port 1 operates as an input
pin, values written in the port 1 data register (P1DR) have no effect on general-purpose input
lines. When read, P1DR returns the value at the pin.
Internal data bus
Read
P17-P1 0
Write
P1DR
Read Write
P1DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
Read Write
P1DR P1DR value Value output at pin
10.3.1 Overview
Pins in port 2 can drive one TTL load and a 90-pF capacitive load. They can also drive a
Darlington transistor pair.
Figure 10-8 summarizes the pin functions. Figure 10-9 shows examples of output loads for port 2.
P27/D7
P26/D6
P25/D5
P24/D4
Port 2
P23/D3
P22/D2
P21/D1
P20/D0
2 kΩ
H8/539F H8/539F
Port 2 HD74LS04 etc. Port 2
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port 2 Data Direction Register: The port 2 data direction register (P2DDR) is an eight-bit
register. Each bit selects input or output for one pin in port 2. These input/output designations are
valid only in modes 2 and 7.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W W W W W W W W W
A pin in port 2 becomes an output pin if the corresponding P2DDR bit is set to 1, and an input pin
if this bit is cleared to 0. P2DDR is a write-only register. All bits always return the value 1 when
read.
P2DDR is initialized to H'00 by a reset and in hardware standby mode. P2DDR is not initialized
in software standby mode.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a bit in P2DDR is set to 1, the corresponding P2DR bit value is output at the corresponding
pin. If port 2 is read the value in P2DR is returned, regardless of the actual state of the pin.
When a bit in P2DDR is cleared to 0, it is possible to write to the corresponding P2DR bit but the
value is not output at the pin. If P2DR is read the value at the pin is returned, regardless of the
value written in P2DR.
P2DR is initialized to H'00 by a reset and in hardware standby mode. P2DR is not initialized in
software standby mode.
The functions of port 2 differ between modes 1, 3, 4, 5, and 6 on the one hand, and modes 2 and 7
on the other hand. The pin functions in each mode group are described below.
(1) Pin Functions in Modes 1, 3, 4, 5, and 6: The settings in P2DDR are ignored. Port 2
automatically becomes a bidirectional data bus. Figure 10-10 shows the pin functions in modes 1,
3, 4, 5, and 6.
Pin Functions
D7 (bidirectional data bus)
D6 (bidirectional data bus)
D5 (bidirectional data bus)
D4 (bidirectional data bus)
Port 2
D3 (bidirectional data bus)
D2 (bidirectional data bus)
D1 (bidirectional data bus)
D0 (bidirectional data bus)
Pin Functions
P27 (input/output pin)
P26 (input/output pin)
P25 (input/output pin)
P24 (input/output pin)
Port 2
P23 (input/output pin)
P22 (input/output pin)
P21 (input/output pin)
P20 (input/output pin)
(3) Software Standby Mode: Transition to software standby does not change the pin functions in
modes 2 and 7. In the externally expanded modes, port 2 is in the high-impedance state during
software standby.
P2DR and P2DDR have different read/write functions depending on whether port 2 is used as a
data bus (D7 to D0) or for general-purpose input or output (P27 to P20). The operating states and
functions of port 2 are described next.
Data bus
Internal data bus
D7-D 0
VCC
Read
Write
P2DR
Read Write
P2DR Always 1 Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Input Port (Modes 2 and 7): Figure 10-13 shows a block diagram illustrating the general-
purpose input function. Table 10-8 indicates register read/write data. Values written in the port 2
data register (P2DR) have no effect on general-purpose input lines. When read, P2DR returns the
value at the pin.
Internal data bus
Read
P27-P2 0
Write
P2DR
Read Write
P2DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(3) Output Port (Modes 2 and 7): Figure 10-14 shows a block diagram illustrating the general-
purpose output function. Table 10-9 indicates register read/write data. The value written in the
port 2 data register (P2DR) is output at the pin. When read, P2DR returns the value written in
P2DR.
Internal data bus
P27-P2 0
Read/
Write
P2DR
Read Write
P2DR P2DR value Value output at pin
10.4.1 Overview
Port 3 is a six-bit input/output port that is multiplexed with output compare pins (T2OC2, T2OC1,
T1OC4 to T1OC1) of the 16-bit integrated-timer pulse unit (IPU). Figure 10-15 summarizes the
pin functions.
Pins in port 3 can drive one TTL load and a 30-pF capacitive load. They can also drive a
Darlington transistor pair or LED (with 10-mA current sink).
H8/539F H8/539F 2 kΩ
Port 3 HD74LS04 etc. Port 3
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
VCC
600 Ω
H8/539F
Port 3
LED
(1) Port 3 Data Direction Register: The port 3 data direction register (P3DDR) is an eight-bit
register. Each bit selects input or output for one pin.
Initial value 1 1 0 0 0 0 0 0
R/W − − W W W W W W
A pin in port 3 becomes an output pin if the corresponding P3DDR bit is set to 1, and an input pin
if this bit is cleared to 0. P3DDR is a write-only register. All bits always return the value 1 when
read.
P3DDR is initialized to H'C0 by a reset and in hardware standby mode. P3DDR is not initialized
in software standby mode.
(2) Port 3 Data Register: The port 3 data register (P3DR) is an eight-bit register that stores data
for pins P35 to P30.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 0 0 0 0 0 0
R/W − − R/W R/W R/W R/W R/W R/W
When a bit in P3DDR is set to 1, the corresponding P3DR bit value is output at the corresponding
pin. If port 3 is read the value in P3DR is returned, regardless of the actual state of the pin.
When a bit in P3DDR is cleared to 0, it is possible to write to the corresponding P3DR bit but the
value is not output at the pin. If P3DR is read the value at the pin is returned, regardless of the
value written in P3DR.
P3DR is initialized to H'C0 by a reset and in hardware standby mode. P3DR is not initialized in
software standby mode.
In all modes port 3 can be used for general-purpose input or output, or for the output compare
function of the 16-bit integrated-timer pulse unit (IPU).
(1) Pin Functions in Modes 1 to 7: When a pin is used for IPU output, the setting in P3DDR is
ignored. T1OC1 to T1OC4, T2OC1, or T2OC2 output is selected automatically. For methods of
selecting pin functions, see appendix D "Pin Function Selection."
(2) Software Standby Mode: Transition to software standby mode initializes the on-chip
supporting modules, so port 3 becomes an input or output port according to P3DDR and P3DR.
P3DR and P3DDR have different read/write functions depending on whether port 3 is used for the
output compare function (T1OC1 to T1OC4, T2OC1, T2OC2) of the 16-bit integrated-timer pulse
unit (IPU) or general-purpose input or output (P35 to P30). The operating states and functions of
port 3 are described next.
(1) Input Port (Modes 1 to 7): Figure 10-17 shows a block diagram illustrating the general-
purpose input function. Table 10-11 indicates register read/write data. Values written in the port
3 data register (P3DR) have no effect on general-purpose input lines. When read, P3DR returns
the value at the pin.
Internal data bus
Read
P35-P3 0
Write
P3DR
Read Write
P3DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Output Port (Modes 1 to 7): Figure 10-18 shows a block diagram illustrating the general-
purpose output function. Table 10-12 indicates register read/write data. The value written in the
port 3 data register (P3DR) is output at the pin. When read, P3DR returns the value written in
P3DR.
Read Write
P3DR P3DR value Value output at pin
(3) Timer Output Pins (Modes 1 to 7): Figure 10-19 shows a block diagram illustrating the
output function using the output compare output pins. Table 10-13 indicates register read/write
data. When a pin in port 3 is used as an output compare output pin, the setting in the port 3 data
direction register (P3DDR) is ignored. The value in the port 3 data register (P3DR) has no effect
on the timer output. When read, P3DR returns the timer output level (T1OC1 to T1OC4, T2OC1, or
T2OC2).
Timer output
Internal data bus
Write
P3DR
Read Write
P3DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
10.5.1 Overview
Port 4 is an eight-bit input/output port that is multiplexed with output compare and input capture
pins (T7IOC2, T7IOC1, T6IOC2, T6IOC1, T5IOC2, T5IOC1, T4IOC2, T4IOC1) of the 16-bit
integrated-timer pulse unit (IPU). Figure 10-20 summarizes the pin functions.
Pins in port 4 can drive one TTL load and a 30-pF capacitive load. They can also drive a
Darlington transistor pair. P47 to P40 have Schmitt-trigger input circuits.
2 kΩ
H8/539F H8/539F
Port 4 HD74LS04 etc. Port 4
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port 4 Data Direction Register: The port 4 data direction register (P4DDR) is an eight-bit
register. Each bit selects input or output for one pin.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W W W W W W W W W
A pin in port 4 becomes an output pin if the corresponding P4DDR bit is set to 1, and an input pin
if this bit is cleared to 0. P4DDR is a write-only register. All bits always return the value 1 when
read.
P4DDR is initialized to H'00 by a reset and in hardware standby mode. P4DDR is not initialized
in software standby mode.
(2) Port 4 Data Register: The port 4 data register (P4DR) is an eight-bit register that stores data
for pins P47 to P40.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a bit in P4DDR is set to 1, the corresponding P4DR bit value is output at the corresponding
pin. If port 4 is read the value in P4DR is returned, regardless of the actual state of the pin.
When a bit in P4DDR is cleared to 0, it is possible to write to the corresponding P4DR bit but the
value is not output at the pin. If P4DR is read the value at the pin is returned, regardless of the
value written in P4DR.
In all modes port 4 can be used for general-purpose input or output, or for the input capture and
output compare functions of the 16-bit integrated-timer pulse unit (IPU).
(1) Pin Functions in Modes 1 to 7: When a pin is used for the IPU output-compare function, the
setting in P4DDR has no effect. T4IOC1, T4IOC2, T5IOC1, T5IOC2, T6IOC1, T6IOC2, T7IOC1, or
T7IOC2 output is selected automatically. When the IPU input capture function is selected, the
P4DDR setting is valid and the pin can simultaneously function as a general-purpose input or
output port. For methods of selecting pin functions, see appendix D "Pin Function Selection."
(2) Software Standby Mode: Transition to software standby mode initializes the on-chip
supporting modules, so port 4 becomes an input or output port according to P4DDR and P4DR.
P4DR and P4DDR have different read/write functions depending on whether port 4 is used for the
input capture or output compare function (T4IOC1, T4IOC2, T5IOC1, T5IOC2, T6IOC1, T6IOC2,
T7IOC1, T7IOC2) of the 16-bit integrated-timer pulse unit (IPU) or for general-purpose input or
output (P47 to P40). The operating states and functions of port 4 are described next.
(1) Input Port (Modes 1 to 7): Figure 10-22 shows a block diagram illustrating the general-
purpose input function. Table 10-15 indicates register read/write data. Values written in the port
4 data register (P4DR) have no effect on general-purpose input lines. When read, P4DR returns
the value at the pin.
Internal data bus
Read
P47-P4 0
Write
P4DR
Read Write
P4DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Output Port (Modes 1 to 7): Figure 10-23 shows a block diagram illustrating the general-
purpose output function. Table 10-16 indicates register read/write data. The value written in the
port 4 data register (P4DR) is output at the pin. When read, P4DR returns the value written in
P4DR.
Internal data bus
P47-P4 0
Read/
Write
P4DR
Read Write
P4DR P4DR value Value output at pin
(3) Timer Output Pins (Modes 1 to 7): Figure 10-24 shows a block diagram illustrating the
output compare function. Table 10-17 indicates register read/write data. When a pin in port 4 is
used for output compare, the value in the port 4 data register (P4DR) has no effect on the timer
output. When read, P4DR returns the timer output level (T4IOC1, T4IOC2, T5IOC1, T5IOC2,
T6IOC1, T6IOC2, T7IOC1, or T7IOC2).
T5IOC1, T5IOC2
Write
P4DR T6IOC1, T6IOC2
T7IOC1, T7IOC2
Read Write
P4DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(4) Timer Input Combined with General-Purpose Output (Modes 1 to 7): Figure 10-25 shows
a block diagram illustrating the input capture function when combined with general-purpose
output. Table 10-18 indicates register read/write data. An input capture pin can also function as
an output port, in which case the output value is input to the timer.
T4IOC1, T4IOC 2
Read/
Write T5IOC1, T5IOC2
P4DR T6IOC1, T6IOC2
T7IOC1, T7IOC2
Read Write
P4DR P4DR value Value output at pin (timer input)
Read
T4IOC1, T4IOC 2
T5IOC1, T5IOC2
Write
P4DR T6IOC1, T6IOC2
T7IOC1, T7IOC2
Read Write
P4DR Timer input Don't care*
Note: The register can be written to, but the value is not output at the pines.
10.6.1 Overview
Port 5 is an eight-bit input/output port that is multiplexed with output compare and input capture
pins (T3IOC2, T3IOC1, T2IOC2, T2IOC1, T1IOC4 to T1IOC1) of the 16-bit integrated-timer pulse
unit (IPU). Figure 10-27 summarizes the pin functions.
Pins in port 5 can drive one TTL load and a 30-pF capacitive load. They can also drive a
Darlington transistor pair or LED (with 10-mA current sink). Inputs are Schmitt-triggered.
H8/539F H8/539F 2 kΩ
Port 5 HD74LS04 etc. Port 5
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
VCC
600 Ω
H8/539F
Port 5
LED
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W W W W W W W W W
A pin in port 5 becomes an output pin if the corresponding P5DDR bit is set to 1, and an input pin
if this bit is cleared to 0. P5DDR is a write-only register. All bits always return the value 1 when
read.
P5DDR is initialized to H'00 by a reset and in hardware standby mode. P5DDR is not initialized
in software standby mode.
(2) Port 5 Data Register: The port 5 data register (P5DR) is an eight-bit register that stores data
for pins P57 to P50.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a bit in P5DDR is set to 1, the corresponding P5DR bit value is output at the corresponding
pin. If port 5 is read the value in P5DR is returned, regardless of the actual state of the pin.
When a bit in P5DDR is cleared to 0, it is possible to write to the corresponding P5DR bit but the
value is not output at the pin. If P5DR is read the value at the pin is returned, regardless of the
value written in P5DR.
P5DR is initialized to H'00 by a reset and in hardware standby mode. P5DR is not initialized in
software standby mode.
In all modes port 5 can be used for general-purpose input or output, or for the input capture and
output compare functions of the 16-bit integrated-timer pulse unit (IPU).
(1) Pin Functions in Modes 1 to 7: When a pin is used for the IPU output compare function, the
setting in P5DDR is ignored. T1IOC1 to T1IOC4, T2IOC1, T2IOC2, T3IOC1, or T3IOC2 output is
selected automatically. When the IPU input capture function is selected, the P5DDR setting is
Rev. 3.0, 02/99, page 203 of 904
valid and the pin can simultaneously function as a general-purpose input or output port. For
methods of selecting pin functions, see appendix D "Pin Function Selection."
(2) Software Standby Mode: Transition to software standby mode initializes the on-chip
supporting modules, so port 5 becomes an input or output port according to P5DDR and P5DR.
P5DR and P5DDR have different read/write functions depending on whether port 5 is used for the
input capture or output compare function (T1IOC1 to T1IOC4, T2IOC1, T2IOC2, T3IOC1, T3IOC2)
of the 16-bit integrated-timer pulse unit (IPU) or for general-purpose input or output. The
operating states and functions of port 5 are described next.
(1) Input Port (Modes 1 to 7): Figure 10-29 shows a block diagram illustrating the general-
purpose input function. Table 10-21 indicates register read/write data. Values written in the port
5 data register (P5DR) have no effect on general-purpose input lines. When read, P5DR returns
the value at the pin.
Internal data bus
Read
P57-P5 0
Write
P5DR
Read Write
P5DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Output Port (Modes 1 to 7): Figure 10-30 shows a block diagram illustrating the general-
purpose output function. Table 10-22 indicates register read/write data. The value written in the
port 5 data register (P5DR) is output at the pin. When read, P5DR returns the value written in
P5DR.
Read Write
P5DR P5DR value Value output at pin
(3) Timer Output Pins (Modes 1 to 7): Figure 10-31 shows a block diagram illustrating the
output compare function. Table 10-23 indicates register read/write data. When a pin in port 5 is
used for output compare, the value in the port 5 data register (P5DR) has no effect on the timer
output. P5DR can be read to monitor the timer output level (T1IOC1 to T1IOC4, T2IOC1, T2IOC2,
T3IOC1, T3IOC2).
Read
T1IOC1 -T1IOC4
Read Write
P5DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
T1IOC1 -T1IOC4
Read/
Write T2IOC1, T2IOC2
P5DR T3IOC1, T3IOC2
Read Write
P5DR P5DR value Value output at pin (Timer input)
(5) Timer Input Combined with General-Purpose Input (Modes 1 to 7): Figure 10-33 shows a
block diagram illustrating the input capture function when combined with general-purpose input.
Table 10-25 indicates register read/write data. An input capture pin can also be read as an input
port, to monitor the timer input level at T1IOC1 to T1IOC4, T2IOC1, T2IOC2, T3IOC1, or T3IOC2.
Read
T1IOC1 -T1IOC4
Read Write
P5DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
10.7.1 Overview
Port 6 is a five-bit input/output port that is multiplexed with the external clock pins (TCLK3 to
TCLK1) of the 16-bit integrated-timer pulse unit (IPU), with external interrupt pins (,543 and
,542), and with a PWM timer output pin (PW3). Figure 10-34 summarizes the pin functions.
Pins in port 6 can drive one TTL load and a 30-pF capacitive load. They can also drive a
Darlington transistor pair.
HD7404 etc.
Darlington pair
2 kΩ
H8/539F H8/539F
Port 6 HD74LS04 etc. Port 6
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port 6 Data Direction Register: The port 6 data direction register (P6DDR) is an eight-bit
register. Each bit selects input or output for one pin.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 0 0 0 0 0
R/W − − − W W W W W
A pin in port 6 becomes an output pin if the corresponding P6DDR bit is set to 1, and an input pin
if this bit is cleared to 0. P6DDR is a write-only register. All bits always return the value 1 when
read.
P6DDR is initialized to H'E0 by a reset and in hardware standby mode. P6DDR is not initialized
in software standby mode.
(2) Port 6 Data Register: The port 6 data register (P6DR) is an eight-bit register that stores data
for pins P64 to P60.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 0 0 0 0 0
R/W − − − R/W R/W R/W R/W R/W
When a bit in P6DDR is set to 1, the corresponding P6DR bit value is output at the corresponding
pin.
When a bit in P6DDR is cleared to 0, it is possible to write to the corresponding P6DR bit but the
value is not output at the pin. If P6DR is read the value at the pin is returned, regardless of the
value written in P6DR.
Rev. 3.0, 02/99, page 208 of 904
P6DR is initialized to H'E0 by a reset and in hardware standby mode. P6DR is not initialized in
software standby mode.
(3) Port 6/7 Control Register: The port 6/7 control register (P67CR) is an eight-bit register that
controls the functions of pin P60 in port 6 and pins P77 and P76 in port 7.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 1 1 1 1 1 0
R/W R/W R/W R R R R R R/W
Bits 7 and 6-PW2 Enable and PW1 Enable (PW2E, PW1E): These bits control the PWM output
function of pins P77/SCK2/PW2 and P76/SCK1/PW1 in port 7. When bits PW2E and PW1E are set
to 1, these pins can be used for PW2 and PW1 output and cannot be used for SCK2 and SCK1
output.
Bit 0-PW3 Enable (PW3E): Controls the PWM output function of pin P60/,542/PW3 in port 6.
When bit PW3E is set to 1, this pin can be used for PW3 output.
(1) Pin Functions in Modes 1 to 7: When a pin is used for IPU external clock input (TCLK3 to
TCLK1) or external interrupt input (,543,#,542), it can simultaneously function as a general-
purpose input or output port. When a pin is used for PWM timer output (PW3), the P6DDR setting
is disregarded and the PW3 function is selected. For methods of selecting pin functions, see
appendix D "Pin Function Selection."
(2) Software Standby Mode: Transition to software standby mode initializes the on-chip
supporting modules, so port 6 becomes an input or output port according to P6DDR and P6DR.
P6DR and P6DDR have different read/write functions depending on whether port 6 is used for
external clock input (TCLK3 to TCLK1) to the 16-bit integrated-timer pulse unit (IPU), external
interrupt input (,543,#,542), PWM timer output (PW3), or general-purpose input or output (P64 to
P60). The operating states and functions of port 6 are described next.
(1) Input Port (Modes 1 to 7): Figure 10-36 shows a block diagram illustrating the general-
purpose input function. Table 10-27 indicates register read/write data. Values written in the port
6 data register (P6DR) have no effect on general-purpose input lines. When read, P6DR returns
the value at the pin.
Write
P6DR
Read Write
P6DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Output Port (Modes 1 to 7): Figure 10-37 shows a block diagram illustrating the general-
purpose output function. Table 10-28 indicates register read/write data. The value written in the
port 6 data register (P6DR) is output at the pin. When read, P6DR returns the value written in
P6DR.
Internal data bus
P64-P6 0
Read/
Write
P6DR
Read Write
P6DR P6DR value Value output at pin
(3) ,543 or ,542 Input Combined with General-Purpose Output (P61, P60: modes 1 to 7):
Figure 10-38 shows a block diagram illustrating the ,543 and ,542 input function of P61 and P60
when combined with general-purpose output. Table 10-29 indicates register read/write data.
When P61 and P60 are used for ,543 and ,542 input they can also function as general-purpose
Figure 10-38 ,543 or ,542 Input Combined with General-Purpose Output (Modes 1 to 7)
Read Write
P6DR P6DR value Value output at pin
(4) ,543 or ,542 Input Combined with General-Purpose Input (P61, P60: Modes 1 to 7):
Figure 10-39 shows a block diagram illustrating the ,543 and ,542 input function when combined
with general-purpose input. Table 10-30 indicates register read/write data. When P61 and P60 are
used for ,543 and ,542 input they can also be read as general-purpose input ports, to monitor the
input level at ,543 or ,542.
Read
IRQ2, IRQ3
Write
P6DR
Figure 10-39 ,543 or ,542 Input Combined with General-Purpose Input (Modes 1 to 7)
Read Write
P6DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
TCLK3 −TCLK 1
Read/
Write
P6DR
Read Write
P6DR P6DR value Value output at pin
(6) Timer Clock Input Combined with General-Purpose Input (P64 to P62: Modes 1 to 7):
Figure 10-41 shows a block diagram illustrating the TCLK3 to TCLK1 input function of P64 to P62
when combined with general-purpose input. Table 10-32 indicates register read/write data. When
P64 to P62 are used for TCLK3, TCLK2, and TCLK1 input they can also be read as general-purpose
input ports, to monitor the input level at TCLK3 to TCLK1.
Read
TCLK3 −TCLK 1
Write
P6DR
Read Write
P6DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(7) PW3 Output Combined with General-Purpose Input (P60: Modes 1 to 7): Figure 10-42
shows a block diagram illustrating the PW3 output function of P60 when combined with general-
purpose input. Table 10-33 indicates register read/write data. When P60 is used for PW3 output it
can also be read as a general-purpose input port, to monitor the state of the PW3 pin.
PW3 output
Internal data bus
Read
PW3
Write
P6DR
Read Write
P6DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
10.8.1 Overview
Port 7 is an eight-bit input/output port that is multiplexed with the serial clock input/output pins
(SCK2 and SCK1), transmit data output pins (TXD2 and TXD1), and receive data input pins (RXD2
and RXD1) of the serial communication interface (SCI), with PWM timer output pins (PW1 and
PW2), with external interrupt pins (IRQ1 and IRQ0), and with the external trigger pin ($'75*) of
the A/D converter. Figure 10-43 summarizes the pin functions. Pins in port 7 can drive one TTL
load and a 30-pF capacitive load. They can also drive a Darlington transistor pair.
HD7404 etc.
Darlington pair
2 kΩ
H8/539F H8/539F
Port 7 HD74LS04 etc. Port 7
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port 7 Data Direction Register: The port 7 data direction register (P7DDR) is an eight-bit
register. Each bit selects input or output for one pin.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W W W W W W W W W
A pin in port 7 becomes an output pin if the corresponding P7DDR bit is set to 1, and an input pin
if this bit is cleared to 0. P7DDR is a write-only register. All bits always return the value 1 when
read.
P7DDR is initialized to H'00 by a reset and in hardware standby mode. P7DDR is not initialized
in software standby mode.
(2) Port 7 Data Register: The port 7 data register (P7DR) is an eight-bit register that stores data
for pins P77 to P70.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a bit in P7DDR is set to 1, the corresponding P7DR bit value is output at the corresponding
pin. If port 7 is read the value in P7DR is returned, regardless of the actual state of the pin.
When a bit in P7DDR is cleared to 0, it is possible to write to the corresponding P7DR bit but the
value is not output at the pin. If P7DR is read the value at the pin is returned, regardless of the
value written in P7DR.
(3) Port 6/7 Control Register: The port 6/7 control register (P67CR) is an eight-bit register that
controls the functions of pin P60 in port 6 and pins P77 and P76 in port 7.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 1 1 1 1 1 0
R/W R/W R/W R R R R R R/W
Bits 7 and 6-PW2 Enable and PW1 Enable (PW2E, PW1E): These bits control the PWM output
function of pins P77/SCK2/PW2 and P76/SCK1/PW1 in port 7. When bits PW2E and PW1E are set
to 1, these pins can be used for PW2 and PW1 output and cannot be used for SCK2 and SCK1
output.
Bit 0-PW3 Enable (PW3E): Controls the PWM output function of pin P60/,542/PW3 in port 6.
When bit PW3E is set to 1, this pin can be used for PW3 output.
(1) Pin Functions in Modes 1 to 7: When a pin is used for input or output by the serial
communication interface (SCI) or a PWM timer, the P7DDR setting is disregarded and the pin is
used for serial clock input or output (SCK2, SCK1), transmit data output (TXD2, TXD1), receive
data input (RXD2, RXD1), or PWM timer output (PW1, PW2).
When P71 and P70 are used for external interrupt input (,541 and ,540), they can simultaneously
function as general-purpose input or output ports. P71 can also function as the external trigger
signal ($'75*) for the A/D converter.
For methods of selecting pin functions, see appendix D "Pin Function Selection."
(2) Software Standby Mode: Transition to software standby mode initializes the on-chip
supporting modules, so port 7 becomes an input or output port according to P7DDR and P7DR.
P7DR and P7DDR have different read/write functions depending on whether port 7 is used for
output of transmit data (TXD1, TXD2), input of receive data (RXD1, RXD2), input or output of
serial clocks (SCK1, SCK2) for the serial communication interface, PWM timer output (PW2, PW1),
external interrupt input (,541,#,540), or general-purpose input or output. The operating states and
functions of port 7 are described next.
Write
P7DR
Read Write
P7DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Output Port (Modes 1 to 7): Figure 10-46 shows a block diagram illustrating the general-
purpose output function. Table 10-36 indicates register read/write data. The value written in the
port 7 data register (P7DR) is output at the pin. When read, P7DR returns the value written in
P7DR.
Internal data bus
P77-P7 0
Read/
Write
P7DR
Read Write
P7DR P7DR value Value output at pin
IRQ1, IRQ0
Read/
Write
P7DR
Figure 10-47 ,541 or ,540 Input Combined with General-Purpose Output (Modes 1 to 7)
Read Write
P7DR P7DR value Value output at pin
(4) ,541 or ,540 Input Combined with General-Purpose Input (P71, P70: Modes 1 to 7):
Figure 10-48 shows a block diagram illustrating the ,541 and ,540 input function when combined
with general-purpose input. Table 10-38 indicates register read/write data. When P71 and P70 are
used for ,541 and ,540 input they can also be read as general-purpose input ports, to monitor the
input level at ,541 or ,540.
Read
IRQ1, IRQ0
Write
P7DR
Figure 10-48 ,541 or ,540 Input Combined with General-Purpose Input (Modes 1 to 7)
Read Write
P7DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(5) TXD2 and TXD1 Output (P74 and P72: Modes 1 to 7): Figure 10-49 shows a block diagram
illustrating the TXD2 and TXD1 output function. Table 10-39 indicates register read/write data.
When P74 and P72 are used for TXD2 and TXD1 output, the value written in P7DR is ignored, but
P7DR can be read to monitor the levels at the TXD2 and TXD1 pins.
Read
TXD2, TXD1
Write
P7DR
Read Write
P7DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(6) RXD2 and RXD1 Input (P75 and P73: Modes 1 to 7): Figure 10-50 shows a block diagram
illustrating the RXD2 and RXD1 input function. Table 10-40 indicates register read/write data.
When P75 and P73 are used for RXD2 and RXD1 input, the value written in P7DR is ignored, but
P7DR can be read to monitor the levels at the RXD2 and RXD1 pins (to detect the line break state,
for example).
Write
P7DR
Read Write
P7DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(7) SCK2 and SCK1 Pins (P77 and P76: Modes 1 to 7): Figure 10-51 shows a block diagram
illustrating the SCK2 and SCK1 input/output function. Table 10-41 indicates register read/write
data. When P77 and P76 are used for SCK2 and SCK1 input or output, the value written in P7DR is
ignored, but P7DR can be read to monitor the levels at the SCK 2 and SCK1 pins.
Read
SCK2, SCK1
Write
P7DR
Read Write
P7DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
PWM output
Write
P7DR
Read Write
P7DR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
10.9.1 Overview
Port 8 is a four-bit input port that is multiplexed with analog input pins of the A/D converter.
Figure 10-53 summarizes the pin functions.
P83/AN11 (input)
P82/AN10 (input)
Port 8
P81/AN9 (input)
P80/AN8 (input)
Table 10-43 summarizes the registers of port 8. Since port 8 is used only for input, there is no
data direction register.
(1) Port 8 Data Register: The port 8 data register (P8DR) is an eight-bit register that indicates
the values of pins P83 to P80.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 − − − −
R/W − − − − R R R R
P8DR is a read-only register. It cannot be written. The upper four bits of P8DR are reserved bits
that always return the value 1 when read.
Rev. 3.0, 02/99, page 222 of 904
10.9.3 Port 8 Read Operation
While being used for analog input, port 8 can also function as a general-purpose input port. When
read, P8DR returns the values at the pins. If P8DR is read when the A/D converter is sampling an
analog input, however, the pin being sampled is read as 1.
Read
P83-P8 0
10.10 Port 9
10.10.1 Overview
Port 9 is an eight-bit input port that is multiplexed with analog input pins of the A/D converter.
Figure 10-55 summarizes the pin functions.
P97/AN7 (input)
P96/AN6 (input)
P95/AN5 (input)
P94/AN4 (input)
Port 9
P93/AN3 (input)
P92/AN2 (input)
P91/AN1 (input)
P90/AN0 (input)
Table 10-44 summarizes the registers of port 9. Since port 9 is used only for input, there is no
data direction register.
(1) Port 9 Data Register: The port 9 data register (P9DR) is an eight-bit register that indicates
the values of pins P97 to P90.
Bit 7 6 5 4 3 2 1 0
Initial value − − − − − − − −
R/W R R R R R R R R
While being used for analog input, port 9 can also function as a general-purpose input port. When
read, P9DR returns the values at the pins. If P9DR is read when the A/D converter is sampling an
analog input, however, the pin being sampled is read as 1.
Read
P97-P9 0
10.11.1 Overview
Port A is a seven-bit input/output port that is multiplexed with output compare pins (T5OC2,
T5OC1, T4OC2, T4OC1, T3OC2, T3OC1) of the 16-bit integrated-timer pulse unit (IPU), pins for
the %5(4, %$&., and :$,7 signals, PWM timer output pins (PW1 to PW3), serial
communication interface 3 input and output pins (TXD 3, RXD3, SCK3), and the page address bus
(A19 to A16). Figure 10-57 summarizes the pin functions. Pins in port A can drive one TTL load and
a 90-pF capacitive load. They can also drive a Darlington transistor pair.
HD7404 etc.
Darlington pair
H8/539F H8/539F 2 kΩ
Port A HD74LS04 etc. Port A
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port A Data Direction Register: The port A data direction register (PADDR) is an eight-bit
register. Each bit selects input or output for one pin.
Bit 7 6 5 4 3 2 1 0
Initial value 1 0 0 0 0 0 0 0
R/W − W W W W W W W
A pin in port A becomes an output pin if the corresponding PADDR bit is set to 1, and an input
pin if this bit is cleared to 0. PADDR is a write-only register. All bits always return the value 1
when read.
PADDR is initialized to H'80 by a reset and in hardware standby mode. PADDR is not initialized
in software standby mode.
(2) Port A Data Register: The port A data register (PADR) is an eight-bit register that stores
data for pins PA6 to PA0.
Bit 7 6 5 4 3 2 1 0
Initial value 1 0 0 0 0 0 0 0
R/W − R/W R/W R/W R/W R/W R/W R/W
When a bit in PADDR is set to 1, the corresponding PADR bit value is output at the corresponding
pin. If port A is read the value in PADR is returned, regardless of the actual state of the pin.
When a bit in PADDR is cleared to 0, it is possible to write to the corresponding PADR bit but the
value is not output at the pin. If PADR is read the value at the pin is returned, regardless of the
value written in PADR.
(3) Port A Control Register: The port A control register (PACR) is an eight-bit register that
controls the functions of pin PA6 to PA0.
Bit 7 6 5 4 3 2 1 0
Initial value 1 0 0 1 0 0 0 0
R/W R R/W R/W R R/W R/W R/W R/W
Bits 6, 5, and 3—TXD3 Enable, RXD3 Enable, and SCK3 Enable (TXD3E, RXD3E, SCK3E):
These bits control the TXD3, RXD3, and SCK3 functions of pins PA6/T3OC2/%$&./TXD3,
PA5/T3OC1/%5(4/RXD3, and PA3/T5OC2/A19/SCK3 in port A. When bits TXD3E, RXD3E, and
SCK3E are set to 1, pins PA6, PA5, and PA3 can be used for TXD3 output, RXD3 input, and SCK3
input or output.
Bits 2 to 0—PW3 Enable, PW2 Enable, and PW1 Enable, (PW3E, PW2E, PW1E): These bits
control the PW3 to PW1 functions of pins PA2/T5OC1/A18/PW3, PA1/T4OC2/A17/PW2, and
PA0/T4OC1/A16/PW1 in port A. When bits PW3E, PW2E, and PW1E are set to 1, these pins can be
used for PW3 output, PW2 output, and PW1 output.
Port A has different functions in different operating modes. A description for each mode is given
next.
(1) Pin Functions in Modes 1, 2, and 6: Port A can be used for the output-compare function
(T3OC2, T3OC1, T4OC2, T4OC1, T5OC2, T5OC1) of the 16-bit integrated-timer pulse unit (IPU),
bus control (%5(4 and %$&.), serial communication interface 3 input and output (SCK3, TXD3,
RXD3), PWM timer output (PW3, PW2, PW1), wait signal input (:$,7), and general-purpose
output.
When a pin is used for output compare, bus control, serial communication interface 3 input or
output, PWM timer output, or wait signal input, the PADDR setting is ignored.
Bus control > TXD3, RXD3 > output compare > general-purpose output
The TXD3 and RXD3 pin functions are available when bits TXD3E and RXD3E are set to 1 in the
port A control register (PACR). When these bits are set to 1, the corresponding pins cannot be
used for output compare.
Rev. 3.0, 02/99, page 227 of 904
The priority of pin functions for PA3/T5OC2/SCK3, PA2/T5OC1/PW3, PA1/T4OC2/PW2, and
PA0/T4OC1/PW1 is:
PWM output pins, serial communication interface pins > output compare output pins > output
portst
The SCK3, PW3, PW2, and PW1 pin functions are available when bits SCK3E, PW3E, PW2E, and
PW1E, respectively, are set to 1 in PACR. When these bits are set to 1, the corresponding pins
cannot be used as output compare pins.
For methods of selecting pin functions, see appendix D "Pin Function Selection."
PA 6/T3OC2/BACK/TXD3
PA 5/T3OC1/BREQ/RXD3
PA 4/WAIT
Port A PA 3/T5OC2/SCK3
PA 2/T5OC1/PW3
PA 1/T4OC2/PW2
PA 0/T4OC1/PW1
(2) Pin Functions in Modes 3 and 5: Port A has pins that can be used for the output compare
function (T3OC2, T3OC1) of the 16-bit integrated-timer pulse unit (IPU), bus control (%5(4 and
%$&.), serial communication interface 3 input and output (TXD3, RXD3), wait signal input
(:$,7), or general-purpose input or output, and pins that are used for page address output (A19 to
A16). When a pin is used for output compare, bus control, serial communication input/output, or
wait signal input, the PADDR setting is ignored.
TXD3, RXD3 > bus control > output compare > general-purpose output
The TXD3 and RXD3 pin functions are available when bits TXD3E and RXD3E are set to 1 in the
port A control register (PACR). When these bits are set to 1, the corresponding pins cannot be
used for output compare.
For methods of selecting pin functions, see appendix D "Pin Function Selection."
PA 6 /T3OC2/BACK/TXD3
PA 5 /T3OC1/BREQ/RXD3
PA 4 /WAIT
Port A A19 (page address bus)
A18 (page address bus)
A17 (page address bus)
A16 (page address bus)
(3) Pin Functions in Mode 4: Port A has pins that can be used for the output compare function
(T3OC2, T3OC1) of the 16-bit integrated-timer pulse unit (IPU), bus control (%5(4 and %$&.),
serial communication interface 3 input and output (SCK3, TXD3, RXD3), PWM timer output (PW1,
PW2, PW3), wait signal input (:$,7), page address output (A19 to A16), and general-purpose input
or output. When a pin is used for output compare, bus control, serial communication input/output,
PWM timer output, or wait signal input, the PADDR setting is ignored.
The SCK3, PW3, PW2, and PW1 functions of pins PA3 to PA0 are available when bits SCK3E,
PW3E, PW2E, and PW1E are set to 1 in the port A control register (PACR). When these bits are
set to 1, the corresponding pins cannot be used for page address output. When bits SCK3E, PW3E,
PW2E, and PW1E are cleared to 0 in PACR, these pins are used for page address output if the
corresponding PADDR bit is set to 1, and for general-purpose input if the corresponding PADDR
bit is cleared to 0.
Bus control > TXD3, RXD3 > output compare > general-purpose output
The TXD3 and RXD3 pin functions are available when bits TXD3E and RXD3E are set to 1 in the
port A control register (PACR). When these bits are set to 1, the corresponding pins cannot be
used for output compare.
The priority of pin functions for PA3/A19/SCK3, PA2/A18/PW3, PA1/A17/PW2, and PA0/A16/PW1 is:
For methods of selecting pin functions, see appendix D "Pin Function Selection."
(4) Pin Functions in Mode 7: Port A can be used for the output compare function (T3OC2,
T3OC1, T4OC2, T4OC1, T5OC2, T5OC1) of the 16-bit integrated-timer pulse unit (IPU), serial
communication interface 3 input and output (SCK3, TXD3, RXD3), PWM timer output (PW1, PW2,
PW3), and general-purpose input or output. When a pin is used for serial communication interface
3 input or output, PWM timer output, or output compare, the PADDR setting is ignored.
The TXD3 and RXD3 pin functions are available when bits TXD3E and RXD3E are set to 1 in the
port A control register (PACR). When these bits are set to 1, the corresponding pins cannot be
used for output compare.
PWM output pins, serial communication interface pins > output compare output pins >
output ports
The SCK3, PW3, PW2, and PW1 pin functions are available when bits SCK3E, PW3E, PW2E, and
PW1E, respectively, are set to 1 in PACR. When these bits are set to 1, these pins cannot be used
as output compare pins.
For methods of selecting pin functions, see appendix D "Pin Function Selection."
PADR and PADDR have different read/write functions depending on whether port A is used for
bus control (%5(4, %$&.), wait signal input (:$,7), the output compare function (T5OC2,
T5OC1, T4OC2, T4OC1, T3OC2, T3OC1) of the 16-bit integrated-timer pulse unit (IPU), serial
communication interface 3 input or output (SCK3, TXD3, RXD3), or general-purpose input or
output. The operating states and functions of port A are described next.
(1) Input Port (PA6 to PA4 in Modes 1 to 7; PA3 to PA0 in Modes 1, 2, 4, 6, and 7): Figure 10-
63 shows a block diagram illustrating the general-purpose input function. Table 10-46 indicates
register read/write data. Values written in the port A data register (PADR) have no effect on
general-purpose input lines. When read, PADR returns the value at the pin.
Internal data bus
Read
PA6-PA 0
Write
PADR
Read Write
PADR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Output Port (PA6 to PA4 in Modes 1 to 7; PA3 to PA0 in Modes 1, 2, 4, 6, and 7): Figure
10-64 shows a block diagram illustrating the general-purpose output function. Table 10-47
indicates register read/write data. The value written in the port A data register (PADR) is output
at the pin. When read, PADR returns the value written in PADR.
Internal data bus
PA6-PA 0
Read/
Write
PADR
Read Write
PADR PADR value Value output at pin
(3) %5(4 Pin (PA5: Modes 1 to 6): Figure 10-65 shows a block diagram illustrating the %5(4
function. Table 10-48 indicates register read/write data. When PA5 is used for %5(4 input, the
value written in the port A data register (PADR) has no effect.
BREQ input
Internal data bus
Read
BREQ
Write
PADR
Read Write
PADR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(4) %$&. Pin (PA6: Modes 1 to 6): Figure 10-66 shows a block diagram illustrating the %$&.
function. Table 10-49 indicates register read/write data. When PA6 is used for %$&. output, the
value written in the port A data register (PADR) has no effect. When read, PADR returns an
undetermined value.
BACK output
Internal data bus
BACK
Write
PADR
Read Write
PADR Undetermined value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(5) :$,7 Pin (PA4: Modes 1 to 6): Figure 10-67 shows a block diagram illustrating the :$,7
function. Table 10-50 indicates register read/write data. When PA4 is used for :$,7 input, the
value written in the port A data register (PADR) has no effect.
WAIT input
Internal data bus
Read
WAIT
Write
PADR
Read Write
PADR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(6) Timer Output Pins (PA6, PA5, PA3 to PA0: Modes 1 to 7): Figure 10-68 shows a block
diagram illustrating the timer output function. Table 10-51 indicates register read/write data.
When PA6, PA5, and PA3 to PA0 are used for T3OC2, T3OC1, T5OC2, T5OC1, T4OC2, and T4OC1
output, values written in the port A data register (PADR) have no effect on the timer output.
PADR can be read to monitor the timer output level (T3OC2, T3OC1, T5OC2, T5OC1, T4OC2,
T4OC1).
Read
T3OC2, T3OC1
Read Write
PADR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(7) Page Address Bus (PA3 to PA0: Modes 3 to 5): Figure 10-69 shows a block diagram
illustrating the page-address-bus function. Table 10-52 indicates register read/write data. When
PA3 to PA0 are used for A19 to A16 output, values written in the port A data register (PADR) have
no effect. When read, PADR returns an undetermined value.
Write
PADR
Read Write
PADR Undetermined value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(8) TXD3 Output (PA6: Modes 1, 2, 4, 6, and 7): Figure 10-70 shows a block diagram
illustrating the TXD3 output function. Table 10-53 indicates register read/write data. When PA6 is
used for TXD3 output, the value written in PADR is ignored, but PADR can be read to monitor the
level at the TXD3 pin.
TXD3
output
Internal data bus
Read
TXD3
Write
PADR
Read Write
PADR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
RXD3
input
Write
PADR
Read Write
PADR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(10) SCK3 Pin (PA3: Modes 1, 2, 4, 6, and 7): Figure 10-72 shows a block diagram illustrating
the SCK3 input/output function. Table 10-55 indicates register read/write data. When PA3 is used
for SCK3 input or output, the value written in PADR is ignored, but PADR can be read to monitor
the level at the SCK3 pin.
SCK3
input or output
Internal data bus
Read
SCK3
Write
PADR
Read Write
PADR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
10.12 Port B
10.12.1 Overview
Port B is an-eight-bit input/output port. Figure 10-73 summarizes the pin functions.
Pins in port B can drive one TTL load and a 90-pF capacitive load. They can also drive a
Darlington transistor pair. They have software-programmable built-in MOS pull-up transistors.
H8/539F H8/539F 2 kΩ
Port B HD74LS04 etc. Port B
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port B Data Direction Register: The port B data direction register (PBDDR) is an-eight-bit
register. Each bit selects input or output for one pin.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W W W W W W W W W
A pin in port B becomes an output pin if the corresponding PBDDR bit is set to 1, and an input pin
if this bit is cleared to 0. PBDDR is a write-only register. All bits always return the value 1 when
read.
PBDDR is initialized to H'00 by a reset and in hardware standby mode. PBDDR is not initialized
in software standby mode.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a bit in PBDDR is set to 1, the corresponding PBDR bit value is output at the corresponding
pin. If port B is read the value in PBDR is returned, regardless of the actual state of the pin.
When a bit in PBDDR is cleared to 0, it is possible to write to the corresponding PBDR bit but the
value is not output at the pin. If PBDR is read the value at the pin is returned, regardless of the
value written in PBDR.
PBDR is initialized to H'00 by a reset and in hardware standby mode. PBDR is not initialized in
software standby mode.
(3) Port B Pull-Up Transistor Control Register: The port B pull-up transistor control register
(PBPCR) is an-eight-bit register that turns the MOS pull-up transistors of PB7 to PB0 on and off.
PBPCR is ignored in modes 1 to 6 and used only in mode 7.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a PBDDR bit is cleared to 0, if the corresponding PBPCR bit is set to 1, the built-in pull-up
transistor is turned on.
PBPCR is initialized to H'00 by a reset and in hardware standby mode. PBPCR is not initialized
in software standby mode.
Port B has one set of functions in modes 1, 3, 5, and 6, another set of functions in modes 2 and 4,
and another set of functions in mode 7. A description for each mode group is given next.
(1) Pin Functions in Modes 1, 3, 5, and 6: Port B is used for address output (A15 to A8). The
PBDDR settings are ignored. Figure 10-75 shows the pin functions in modes 1, 3, 5, and 6.
(2) Pin Functions in Modes 2 and 4: Port B can be used for address output (A15 to A8) or
general-purpose input. A pin is used for address output if the corresponding PBDDR bit is set to
1, and for general-purpose input if this bit is cleared to 0. Figure 10-76 shows the pin functions in
modes 2 and 4.
Port B has built-in MOS pull-up transistors that can be controlled by software. To turn an input
pull-up transistor on, clear its PBDDR bit to 0 and set its PBPCR bit to 1. The input pull-up
transistors are turned off by a reset and in hardware standby mode. Table 10-57 summarizes the
states of the input pull-ups in each mode.
PBDR and PBDDR have different read/write functions depending on whether port B is used for
address output (A15 to A8) or general-purpose input or output. The operating states and functions
of port B are described next.
(1) Input Port (Modes 2 and 4): Figure 10-78 shows a block diagram illustrating the general-
purpose input function. Table 10-58 indicates register read/write data. Values written in the port
B data register (PBDR) have no effect on general-purpose input lines. When read, PBDR returns
the value at the pin.
Internal data bus
Read
PB7-PB 0
Write
PBDR
Read Write
PBDR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
(2) Input Port with Internal Pull-Up (Mode 7): Figure 10-79 shows a block diagram illustrating
the general-purpose input function and built-in input pull-up transistors. Table 10-59 indicates
register read/write data. Values written in the port B data register (PBDR) have no effect on
general-purpose input lines. When read, PBDR returns the value at the pin. When a bit in the port
B pull-up transistor control register (PBPCR) is set to 1, the corresponding PBDR bit always reads
1.
Write
PBDR
Read Write
1 2
PBDR Pin value, or always 1* Don't care*
1
PBPCR PBPCR value 0/1*
Note: 1. If set to 1, the corresponding PBDR bit always reads 1.
2. The register can be written to, but the value is not output at the pines.
(3) Output Port (Mode 7): Figure 10-80 shows a block diagram illustrating the general-purpose
output function. Table 10-60 indicates register read/write data. The value written in the port B
data register (PBDR) is output at the pin. When read, PBDR returns the value written in PBDR.
Internal data bus
PB7-PB 0
Read/
Write
PBDR
Read Write
PBDR PBDR value Value output at pin
Address
Read/
Write
PBDR
Read Write
PBDR PBDR value Don't care*
Note: The register can be written to, but the value is not output at the pines.
10.13.1 Overview
Port C is an-eight-bit input/output port. Figure 10-82 summarizes the pin functions.
Port C is an address bus (A7 to A0) in modes 1, 3, 5, and 6. In modes 2 and 4 port C can be used
for address output (A7 to A0) or general-purpose input. In mode 7 port C is a general-purpose
input/output port.
Pins in port C can drive one TTL load and a 90-pF capacitive load. They can also drive a
Darlington transistor pair. They have software-programmable built-in MOS pull-up transistors.
HD7404 etc.
Darlington pair
2 kΩ
H8/539F H8/539F
Port C HD74LS04 etc. Port C
(1) One TTL load or four LS-TTL loads (2) Darlington transistor pair
(1) Port C Data Direction Register: The port C data direction register (PCDDR) is an-eight-bit
register. Each bit selects input or output for one pin.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W W W W W W W W W
A pin in port C becomes an output pin if the corresponding PCDDR bit is set to 1, and an input pin
if this bit is cleared to 0. PCDDR is a write-only register. All bits always return the value 1 when
read.
PCDDR is initialized to H'00 by a reset and in hardware standby mode. PCDDR is not initialized
in software standby mode.
(2) Port C Data Register: The port C data register (PCDR) is an-eight-bit register that stores data
for pins PC7 to PC0.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a bit in PCDDR is set to 1, the corresponding PCDR bit value is output at the corresponding
pin. If port C is read the value in PCDR is returned, regardless of the actual state of the pin.
When a bit in PCDDR is cleared to 0, it is possible to write to the corresponding PCDR bit but the
value is not output at the pin. If PCDR is read the value at the pin is returned, regardless of the
value written in PCDR.
(3) Port C Pull-Up Transistor Control Register: The port C pull-up transistor control register
(PCPCR) is an-eight-bit register that turns the MOS pull-up transistors of PC7 to PC0 on and off.
PCPCR is ignored in modes 1 to 6 and used only in mode 7.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When a PCDDR bit is cleared to 0, if the corresponding PCPCR bit is set to 1, the built-in pull-up
transistor is turned on.
PCPCR is initialized to H'00 by a reset and in hardware standby mode. PCPCR is not initialized
in software standby mode.
Port C has one set of functions in modes 1, 3, 5, and 6, another set of functions in modes 2 and 4,
and another set of functions in mode 7. A description for each mode group is given next.
(1) Pin Functions in Modes 1, 3, 5, and 6: Port C is used for address output (A7 to A0). The
PCDDR settings are ignored. Figure 10-84 shows the pin functions in modes 1, 3, 5, and 6.
A7 (address bus)
A6 (address bus)
A5 (address bus)
A4 (address bus)
Port C
A3 (address bus)
A2 (address bus)
A1 (address bus)
A0 (address bus)
(3) Pin Functions in Mode 7: Port C consists of general-purpose input/output pins. Input or
output can be selected separately for each pin. A pin becomes an output pin if the corresponding
PCDDR bit is set to 1 and an input pin if this bit is cleared to 0. Figure 10-86 shows the pin
functions in mode 7.
Port C has built-in MOS pull-up transistors that can be controlled by software. To turn an input
pull-up transistor on, clear its PCDDR bit to 0 and set its PCPCR bit to 1. The input pull-up
transistors are turned off by a reset and in hardware standby mode. Table 10-63 summarizes the
states of the input pull-ups in each mode.
PCDR and PCDDR have different read/write functions depending on whether port C is used for
address output (A7 to A0) or general-purpose input or output. The operating states and functions of
port C are described next.
(1) Input Port (Modes 2 and 4): Figure 10-87 shows a block diagram illustrating the general-
purpose input function. Table 10-64 indicates register read/write data. Values written in the port
C data register (PCDR) have no effect on general-purpose input lines. When read, PCDR returns
the value at the pin.
Internal data bus
Read
PC7-PC 0
Write
PCDR
Read Write
PCDR Pin value Don't care*
Note: The register can be written to, but the value is not output at the pines.
Read/
Write
PCPCR
Internal data bus
Read
PC7-PC 0
Write
PCDR
Read Write
1 2
PCDR Pin value, or always 1* Don't care*
1
PCPCR PCPCR value 0/1*
Note: 1. If set to 1, the corresponding PCDR bit always reads 1.
2. The register can be written to, but the value is not output at the pines.
(3) Output Port (Mode 7): Figure 10-89 shows a block diagram illustrating the general-purpose
output function. Table 10-66 indicates register read/write data. The value written in the port C
data register (PCDR) is output at the pin. When read, PCDR returns the value written in PCDR.
Internal data bus
PC7-PC 0
Read/
Write
PCDR
Read Write
PCDR PCDR value Value output at pin
(4) Address Bus (Modes 1 to 6): Figure 10-90 shows a block diagram illustrating the address-
bus function. Table 10-67 indicates register read/write data. When port C is used as an address
bus, values written in the port C data register (PCDR) have no effect on the bus lines. When read,
PCDR returns the value written in PCDR.
Address
Internal data bus
A7-A 0
Read/
Write
PCDR
Read Write
PCDR PCDR value Don't care*
Note: The register can be written to, but the value is not output at the pines.
11.1 Overview
The built-in 16-bit integrated-timer pulse unit (IPU) has seven channels and three types of timers.
The IPU can output 28 independent waveforms, or output 12 waveforms and process 16 pulse
inputs or outputs. It can also provide six-phase PWM output, automatically measure pulse widths
and periods, count input from a two-phase encoder, and start the A/D converter.
11.1.1 Features
• Selection of sixteen counter clock sources (external clock sources are shared by all channels):
φ, φ/2, φ/4, φ/8, φ/16, φ/32, φ/64, φ/128, φ/256, φ/512, φ/1024, φ/2048, φ/4096, TCLK1,
TCLK2, TCLK3
• Input capture function
Rising edge, falling edge, or both edges
• Pulse output
One-shot, toggle, or PWM output
• Counter synchronization function
Software can write to two or more timer counters simultaneously. Counters can be cleared
simultaneously by compare match or input capture.
• PWM output mode
One-phase, two-phase, or three-phase PWM output (up to nine-phase PWM output using the
counter synchronization function)
• Auto-measure function
Two timer channels can be coordinated for automatic measurement of pulse width or
frequency and for two-phase encoder counting
CH4
CH5
CH7
CH2
CH3
CH6
TMDRA
Bus interface
TMDRB On-chip
data bus
TSTR
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
TCNT
Initial value 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
Each of the seven channels has 16-bit capture and compare registers. A capture register latches
the TCNT value when an external capture signal is received or an event occurs. An interrupt can
also be requested at this time compare register contents are compared with the TCNT value at all
times, and a compare match signal and/or interrupt is generated when the two match. The
configuration of each channel will be described next.
The input capture/output compare registers function as output compare registers after a reset.
They can be switched over to input capture by setting bits IEG41 to IEG10 in the timer control
registers.
TCLK1 −TCLK3
φ−φ/4096
T1OC1-T1OC 4
Clock selector Control logic T1IOC1-T1IOC 4
Comparator
Control registers
TCRH TCRL
TSRAH TSRAL
GR1 (ICR/OCR)
GR2 (ICR/OCR)
GR3 (ICR/OCR)
GR4 (ICR/OCR)
Bus interface
16-bit counter
DR1 (OCR)
DR2 (OCR)
DR3 (OCR)
DR4 (OCR)
TOERA On-chip
data bus
TCRA
TSRBH TSRBL
TOERB
Timer control register high (TCRH) is an eight-bit readable/writable register that selects the timer
clock source. Each channel has one TCRH. The bit structure of TCRH in channel 1 is shown
next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 0 0 0 0 0 0
R/W R R R/W R/W R/W R/W R/W R/W
Reserved bits
Bits 5 and 4—Clock Edge 1/0 (CKEG1/0): These bits select the external clock edge.
Bit 5 Bit 4
CKEG1 CKEG0 Description
0 0 Increment on rising edge (Initial value)
0 1 Increment on falling edge
1 0 Increment on both edges
1 1
CKEG1/0 can be set to increment the count on the rising edge, falling edge, or both edges of the
external clock. When TPSC3 to TPSC0 are set so as not to select an external clock source,
CKEG1 and CKEG0 are ignored.
Timer control register low (TCRL) is an eight-bit readable/writable register that selects input
capture edges, and selects the timer counter clear source.
Channel 1 has two timer control registers (low), designated TCRL and TCRA. The bit structure of
TCRL in channel 1 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 0 0 0 0 0 0 0
R/W − R/W R/W R/W R/W R/W R/W R/W
Reserved bit
When CCLR2 is 0 and either CCLR1 or CCLR0 is set to 1, or both CCLR1 and CCLR0 are set to
1, the counter is cleared in synchronization with the clearing of a timer pair selected in timer mode
register A (TMDA).
If GR1 or GR3 is used as a compare register the counter is cleared by compare match. If GR1 or
GR3 is used as a capture register the counter is cleared by input capture.
For further details, see section 11.8.4, "Counter Clearing Function" and section 11.8.6,
"Synchronizing Mode. "
Bits 3 and 2—Input Capture Edge 21/20 (IEG21/20): These bits select the function of GR2 and
the valid edge of the input capture signal.
Bit 3 Bit 2
IEG21 IEG20 Description
0 0 GR2 is not used for input capture (Initial value) *
0 1 Capture in GR2 on rising edge of input capture signal
1 0 Capture in GR2 on falling edge of input capture signal
1 1 Capture in GR2 on both edges of input capture signal
Note: * GR2 becomes an output compare register.
A reset clears bits IEG21 and IEG20 to 0, disabling input capture and making GR2 an output
compare register. If IEG21 or IEG20 is set to 1, or both IEG21 and IEG20 are set to 1, GR2
becomes an input capture register.
For further details, see section 11.8.3, "Input Capture Function. "
Bit 1 Bit 0
IEG11 IEG10 Description
0 0 GR1 is not used for input capture (Initial value)*
0 1 Capture in GR1 on rising edge of input capture signal
1 0 Capture in GR1 on falling edge of input capture signal
1 1 Capture in GR1 on both edges of input capture signal
Note: * GR1 becomes an output compare register.
A reset clears bits IEG11 and IEG10 to 0, disabling input capture and making GR1 an output
compare register. If IEG11 or IEG10 is set to 1, or both IEG11 and IEG10 are set to 1, GR1
becomes an input capture register.
For further details, see section 11.8.3, "Input Capture Function. "
TCRA is an eight-bit readable/writable register. The bit structure of TCRA in channel 1 is shown
next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 0 0 0 0
R/W − − − − R/W R/W R/W R/W
Reserved bits
Bit 3 Bit 2
IEG41 IEG40 Description
0 0 GR4 is not used for input capture (Initial value)*
0 1 Capture in GR4 on rising edge of input capture signal
1 0 Capture in GR4 on falling edge of input capture signal
1 1 Capture in GR4 on both edges of input capture signal
Note: * GR4 becomes an output compare register.
A reset clears bits IEG41 and IEG40 to 0, disabling input capture and making GR4 an output
compare register. If IEG41 or IEG40 is set to 1, or both IEG41 and IEG40 are set to 1, GR4
becomes an input capture register.
For further details, see section 11.8.3, "Input Capture Function. "
Bits 1 and 0—Input Capture Edge 31/30 (IEG31/30): These bits select the function of GR3 and
the valid edge of the input capture signal.
Bit 1 Bit 0
IEG31 IEG30 Description
0 0 GR3 is not used for input capture (Initial value)*
0 1 Capture in GR3 on rising edge of input capture signal
1 0 Capture in GR3 on falling edge of input capture signal
1 1 Capture in GR3 on both edges of input capture signal
Note: * GR3 becomes an output compare register.
A reset clears bits IEG31 and IEG30 to 0, disabling input capture and making GR3 an output
compare register. If IEG31 or IEG30 is set to 1, or both IEG31 and IEG30 are set to 1, GR3
becomes an input capture register.
For further details, see section 11.8.3, "Input Capture Function. "
Timer status register high (TSRH) is an eight-bit readable/writable register that enables and
disables timer interrupts.
After OVIE, CMIE2, CMIE1, IMIE2, or IMIE1 is set to 1 in TSRH, an interrupt is requested
when OVF, CMF2, CMFI, IMF2, or IMF1 is set to 1 in TSRL.
Channel 1 has two timer status registers (high), designated TSRAH and TSRBH. Channels 2 to 7
have one TSRH each. The bit structure of TSRAH in channel 1 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 0 0 0 0 0
R/W − − − R/W R/W R/W R/W R/W
Input capture/
Compare match
interrupt enable
2/1
These bits enable
and disable GR2
and GR1 compare
match and input
capture interrupts
Bit 4
OVIE Description
0 Counter overflow interrupt is disabled (Initial value)
1 Counter overflow interrupt is enabled
Bit 3—Compare Match Interrupt Enable 2 (CMIE2): Enables or disables the DR2 compare
match interrupt. For further details, see section 11.9.1, "Interrupt Timing. "
Bit 3
CMIE2 Description
0 DR2 compare match interrupt is disabled (Initial value)
1 DR2 compare match interrupt is enabled
Bit 2—Compare Match Interrupt Enable 1 (CMIE1): Enables or disables the DR1 compare
match interrupt. For further details, see section 11.9.1, "Interrupt Timing. "
Bit 2
CMIE1 Description
0 DR1 compare match interrupt is disabled (Initial value)
1 DR1 compare match interrupt is enabled
Bit 1—Input Capture/Compare Match Interrupt Enable 2 (IMIE2): Enables or disables the
GR2 compare match or input capture interrupt. For further details, see section 11.9.1, "Interrupt
Timing. "
Bit 1
IMIE2 Description
0 GR2 compare match or input capture interrupt is disabled (Initial value)
1 GR2 compare match or input capture interrupt is enabled
Bit 0
IMIE1 Description
0 GR1 compare match or input capture interrupt is disabled (Initial value)
1 GR1 compare match or input capture interrupt is enabled
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 0 0 0 0
R/W − − − − R/W R/W R/W R/W
Input capture/
Compare match
interrupt enable
4/3
These bits enable
and disable GR4
and GR3 compare
match and input
capture interrupts
Reserved bits
Bit 3
CMIE4 Description
0 DR4 compare match interrupt is disabled (Initial value)
1 DR4 compare match interrupt is enabled
Bit 2—Compare Match Interrupt Enable 3 (CMIE3): Enables or disables the DR3 compare
match interrupt. For further details, see section 11.9.1, "Interrupt Timing. "
Bit 2
CMIE3 Description
0 DR3 compare match interrupt is disabled (Initial value)
1 DR3 compare match interrupt is enabled
Bit 1—Input Capture/Compare Match Interrupt Enable 4 (IMIE4): Enables or disables the
GR4 compare match or input capture interrupt. For further details, see section 11.9.1, "Interrupt
Timing. "
Bit 1
IMIE4 Description
0 GR4 compare match or input capture interrupt is disabled (Initial value)
1 GR4 compare match or input capture interrupt is enabled
Bit 0—Input Capture/Compare Match Interrupt Enable 3 (IMIE3): Enables or disables the
GR3 compare match or input capture interrupt. For further details, see section 11.9.1, "Interrupt
Timing. "
Bit 0
IMIE3 Description
0 GR3 compare match or input capture interrupt is disabled (Initial value)
1 GR3 compare match or input capture interrupt is enabled
Timer status register low (TSRL) is an eight-bit readable/writable register that indicates timer
status. Writing to TSRL is restricted to clearing a flag to 0 after reading the 1 value of that flag.
After OVIE, CMIE2, CMIE1, IMIE2, or IMIE1 is set to 1 in TSRH, an interrupt is requested
when OVF, CMF2, CMF1, IMF2, or IMF1 is set to 1 in TSRL.
Channel 1 has two timer status registers (low), designated TSRAL and TSRBL. Channels 2 to 7
have one TSRL each. The bit structure of TSRAL in channel 1 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 0 0 0 0 0
R/W − − − R/W R/W R/W R/W R/W
Input capture/
Compare match
flag 2/1
Flags indicating
GR2 and GR1
compare match
or input capture
Overflow flag
Flag indicating counter overflow
Reserved bits
Bit 4
OVF Description
0 Cleared by reading OVF after OVF is set to 1, then writing 0 in OVF
(Initial value)
1 Set when counter overflow occurs
Bit 3—Compare Match Flag 2 (CMF2): Set to 1 when the counter value matches the DR2
value. For further details, see section 11.9.1, "Interrupt Timing. "
Bit 3
CMF2 Description
0 1. Cleared by reading CMF2 after CMF2 is set to 1, then writing 0 in CMF2
(Initial value)
2. Cleared when the DTC is activated by a CMI2 interrupt
1 Set when DR2 compare match occurs
Bit 2—Compare Match Flag 1 (CMF1): Set to 1 when the counter value matches the DR1
value. For further details, see section 11.9.1, "Interrupt Timing. "
Bit 2
CMF1 Description
0 1. Cleared by reading CMF1 after CMF1 is set to 1, then writing 0 in CMF1
(Initial value)
2. Cleared when the DTC is activated by a CMI1 interrupt
1 Set when DR1 compare match occurs
Bit 1
IMF2 Description
0 1. Cleared by reading IMF2 after IMF2 is set to 1, then writing 0 in IMF2
(Initial value)
2. Cleared when the DTC is activated by an IMI2 interrupt
1 Set when GR2 input capture or compare match occurs
Bit 0—Input Capture/Compare Match Flag 1 (IMF1): Set to 1 when the counter value matches
the GR1 value, or the counter value is captured in GR1. For further details, see section 11.9.1,
"Interrupt Timing. "
Bit 0
IMF1 Description
0 1. Cleared by reading IMF1 after IMF1 is set to 1, then writing 0 in IMF1
(Initial value)
2. Cleared when the DTC is activated by an IMI1 interrupt
1 Set when GR1 input capture or compare match occurs
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 0 0 0 0
R/W − − − − R/W R/W R/W R/W
Input capture/
Compare match
flag 4/3
Flags indicating
GR4 and GR3
compare match
or input capture
Bit 3—Compare Match Flag 4 (CMF4): Set to 1 when the counter value matches the DR4
value. For further details, see section 11.9.1, "Interrupt Timing. "
Bit 3
CMF4 Description
0 1. Cleared by reading CMF4 after CMF4 is set to 1, then writing 0 in CMF4
(Initial value)
2. Cleared when the DTC is activated by a CMI4 interrupt
1 Set when DR4 compare match occurs
Bit 2
CMF3 Description
0 1. Cleared by reading CMF3 after CMF3 is set to 1, then writing 0 in CMF3
(Initial value)
2. Cleared when the DTC is activated by a CMI3 interrupt
1 Set when DR3 compare match occurs
Bit 1—Input Capture/Compare Match Flag 4 (IMF4): Set to 1 when the counter value matches
the GR4 value, or the counter value is captured in GR4. For further details, see section 11.9.1,
"Interrupt Timing. "
Bit 1
IMF4 Description
0 1. Cleared by reading IMF4 after IMF4 is set to 1, then writing 0 in IMF4
(Initial value)
2. Cleared when the DTC is activated by an IMI4 interrupt
1 Set when GR4 input capture or compare match occurs
Bit 0—Input Capture/Compare Match Flag 3 (IMF3): Set to 1 when the counter value matches
the GR3 value, or the counter value is captured in GR3. For further details, see section 11.9.1,
"Interrupt Timing. "
Bit 0
IMF3 Description
0 1. Cleared by reading IMF3 after IMF3 is set to 1, then writing 0 in IMF3
(Initial value)
2. Cleared when the DTC is activated by an IMI3 interrupt
1 Set when GR3 input capture or compare match occurs
The timer output enable register (TOER) is an eight-bit readable/writable register that enables or
disables output of compare match signals and selects the output level.
Channel 1 has two timer output enable registers, designated TOERA and TOERB. Channels 2 to
7 have one TOER each. The bit structure of TOERA in channel 1 is shown next.
For the selection of general register (GR) functions, see section 11.3.3, "Timer Control Register
(Low). "
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
General register
General register output enable
Dedicated output enable 11/10
Dedicated
register output 21/20 These bits enable
register output and disable output
enable 11/10 These bits enable
enable 21/20 of the counter-GR1
These bits enable and disable output
These bits enable and disable output of the counter-GR2 compare match
and disable output of the counter-DR1 signal, and select
compare match
of the counter-DR2 compare match the output level
signal, and select
compare match signal, and select the output level
signal, and select the output level
the output level
Bit 7 Bit 6
DOE21 DOE20 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
Bits 5 and 4—Dedicated Register Output Enable 11/10 (DOE11/10): These bits enable and
disable output of the counter-DR1 compare match signal, and select the output level. For further
details, see section 11.8.2, "Selection of Output Level. "
Bit 5 Bit 4
DOE11 DOE10 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
Bits 3 and 2—General Register Output Enable 21/20 (GOE21/20): These bits enable and
disable output of the counter-GR2 compare match signal, and select the output level.
Bit 3 Bit 2
GOE21 GOE20 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
When GR2 is used for input capture, however, compare match signal output is disabled regardless
of the setting of GOE21 and GOE20. Bits 3 and 2 are thus ignored except when IEG21 =
IEG20 = 0.
For further details, see section 11.8.2, "Selection of Output Level. "
Bit 1 Bit 0
GOE11 GOE10 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
When GR1 is used for input capture, however, compare match signal output is disabled regardless
of the setting of GOE11 and GOE10. Bits 1 and 0 are thus ignored except when IEG11 =
IEG10 = 0.
For further details, see section 11.8.2, "Selection of Output Level. "
For the selection of general register (GR) functions, see section 11.3.3, "Timer Control Register
(Low). "
Bit 7 6 5 4 3 2 1 0
General register
output enable
General register 31/30
output enable These bits enable
Dedicated
41/40 and disable output
register output
Dedicated enable 31/30 These bits enable of the counter-GR3
register output and disable output compare match
These bits enable
enable 41/40 of the counter-GR4 signal, and select
and disable output the output level
These bits enable compare match
of the counter-DR3
and disable output signal, and select
compare match
of the counter-DR4 the output level
signal, and select
compare match the output level
signal, and select
the output level
Bit 7 Bit 6
DOE41 DOE40 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
Bits 5 and 4—Dedicated Register Output Enable 31/30 (DOE31/30): These bits enable and
disable output of the counter-DR3 compare match signal, and select the output level. For further
details, see section 11.8.2, "Selection of Output Level. "
Bit 5 Bit 4
DOE31 DOE30 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
Bits 3 and 2—General Register Output Enable 41/40 (GOE41/40): These bits enable and
disable output of the counter-GR4 compare match signal, and select the output level.
Bit 3 Bit 2
GOE41 GOE40 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
When GR4 is used for input capture, however, compare match signal output is disabled regardless
of the setting of GOE41 and GOE40. Bits 3 and 2 are thus ignored except when IEG41 =
IEG40 = 0.
For further details, see section 11.8.2, "Selection of Output Level. "
Bit 1 Bit 0
GOE31 GOE30 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
When GR3 is used for input capture, however, compare match signal output is disabled regardless
of the setting of GOE31 and GOE30. Bits 1 and 0 are thus ignored except when IEG31 =
IEG30 = 0.
For further details, see section 11.8.2, "Selection of Output Level. "
The general registers function as output compare registers after a reset. They can be switched over
to input capture by setting bits IEG21 to IEG10 in the timer control registers.
TCLK1 −TCLK3
φ−φ/4096
T2OC1−T2OC2
Clock selector Control logic
T2IOC1−T2IOC2
Comparator
Control registers
Bus interface
TCRH* TCRL
GR1 (ICR/OCR)
GR2 (ICR/OCR)
16-bit counter
On-chip
DR2 (OCR)
DR1 (OCR)
TSRH TSRL
data bus
TOER
Timer control register low (TCRL) is an eight-bit readable/writable register. For timer control
register high (TCRH), see section 11.3.2, "Timer Control Register (High)." The bit structure of
TCRL in channels 2 to 5 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 0 0 0 0 0 0
R/W − − R/W R/W R/W R/W R/W R/W
Reserved bits
Bits 5 and 4—Counter Clear 1 and 0 (CCLR1/0): These bits select the counter clear source.
Bit 5 Bit 4
CCLR1 CCLR0 Description
0 0 Counter not cleared (Initial value)
0 1 Counter cleared on GR1 compare match or capture
1 0 Counter cleared on DR2 compare match*
1 1 Synchronous clearing of counter enabled
Note: * In channels 6 and 7 the counter is cleared on GR2 compare match or capture.
When CCLR1 = CCLR0 = 1, the counter is cleared in synchronization with the clearing of the
paired timer selected in timer mode register A.
If GR1 is used as a compare register the counter is cleared by compare match. If GR1 is used as a
capture register the counter is cleared by input capture.
Bits 3 and 2—Input Capture Edge 21/20 (IEG21/20): These bits select the function of GR2 and
the valid edge of the input capture signal.
Bit 3 Bit 2
IEG21 IEG20 Description
0 0 GR2 is not used for input capture (Initial value)*
0 1 Capture in GR2 on rising edge of input capture signal
1 0 Capture in GR2 on falling edge of input capture signal
1 1 Capture in GR2 on both edges of input capture signal
Note: * GR2 becomes an output compare register.
A reset clears bits IEG21 and IEG20 to 0, disabling input capture and making GR2 an output
compare register. If IEG21 or IEG20 is set to 1, or both IEG21 and IEG20 are set to 1, GR2
becomes an input capture register.
For further details, see section 11.8.3, "Input Capture Function. "
Bits 1 and 0—Input Capture Edge 11/10 (IEG11/10): These bits select the function of GR1 and
the valid edge of the input capture signal.
Bit 1 Bit 0
IEG11 IEG10 Description
0 0 GR1 is not used for input capture (Initial value)*
0 1 Capture in GR1 on s rising edge of input capture signal
1 0 Capture in GR1 on falling edge of input capture signal
1 1 Capture in GR1 on both edges of input capture signal
Note: * GR1 becomes an output compare register.
A reset clears bits IEG11 and IEG10 to 0, disabling input capture and making GR1 an output
compare register. If IEG11 or IEG10 is set to 1, or both IEG11 and IEG10 are set to 1, GR1
becomes an input capture register.
For further details, see section 11.8.3, "Input Capture Function. "
Timer status register high (TSRH) is an eight-bit readable/writable register. After OVIE, CMIE2,
CMIE1, IMIE2, or IMIE1 is set to 1 in TSRH, an interrupt is requested when OVF, CMF2, CMF1,
IMF2, or IMF1 is set to 1 in TSRL. The bit structure of TSRH in channels 2 to 5 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 0 0 0 0 0
R/W − − − R/W R/W R/W R/W R/W
Input capture/
Compare match
interrupt enable
2/1
These bits enable
and disable GR2
and GR1 compare
match and input
capture interrupts
Bit 4—Overflow Interrupt Enable (OVIE): Enables or disables the counter overflow interrupt.
For further details, see section 11.9.1, "Interrupt Timing. "
Bit 4
OVIE Description
0 Counter overflow interrupt is disabled (Initial value)
1 Counter overflow interrupt is enabled
Bit 3
CMIE2 Description
0 DR2 compare match interrupt is disabled (Initial value)
1 DR2 compare match interrupt is enabled
Bit 2—Compare Match Interrupt Enable 1 (CMIE1): Enables or disables the DR1 compare
match interrupt. For further details, see section 11.9.1, "Interrupt Timing."
Bit 2
CMIE1 Description
0 DR1 compare match interrupt is disabled (Initial value)
1 DR1 compare match interrupt is enabled
Bit 1—Input Capture/Compare Match Interrupt Enable 2 (IMIE2): Enables or disables the
GR2 compare match or input capture interrupt. For further details, see section 11.9.1, "Interrupt
Timing.""
Bit 1
IMIE2 Description
0 GR2 input capture or compare match interrupt is disabled (Initial value)
1 GR2 input capture or compare match interrupt is enabled
Bit 0—Input Capture/Compare Match Interrupt Enable 1 (IMIE1): Enables or disables the
GR1 compare match or input capture interrupt. For further details, see section 11.9.1, "Interrupt
Timing.""
Bit 0
IMIE1 Description
0 GR1 input capture or compare match interrupt is disabled (Initial value)
1 GR1 input capture or compare match interrupt is enabled
Timer status register low (TSRL) is an eight-bit readable/writable register. After OVIE, CMIE2,
CMIE1, IMIE2, or IMIE1 is set to 1 in TSRH, an interrupt is requested when OVF, CMF2, CMF1,
IMF2, or IMF1 is set to 1 in TSRL. Writing to TSRL is restricted to clearing a flag to 0 after
reading the 1 value of that flag. The bit structure of TSRL in channels 2 to 5 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 0 0 0 0 0
R/W − − − R/W R/W R/W R/W R/W
Input capture/
Compare match
flag 2/1
Flags indicating
GR2 and GR1
compare match
or input capture
Overflow flag
Flag indicating counter overflow
Reserved bits
Bit 4—Overflow Flag (OVF): Set to 1 when the counter overflows from H'FFFF to H'0000. For
further details, see section 11.9.1, "Interrupt Timing. "
Bit 4
OVF Description
0 Cleared by reading OVF after OVF is set to 1, then writing 0 in OVF
(Initial value)
1 Set when counter overflow occurs
Bit 3
CMF2 Description
0 1. Cleared by reading CMF2 after CMF2 is set to 1, then writing 0 in CMF2
(Initial value)
2. Cleared when the DTC is activated by a CMI2 interrupt
1 Set when DR2 compare match occurs
Bit 2—Compare Match Flag 1 (CMF1): Set to 1 when the counter value matches the DR1
value. For further details, see section 11.9.1, "Interrupt Timing. "
Bit 2
CMF1 Description
0 1. Cleared by reading CMF1 after CMF1 is set to 1, then writing 0 in CMF1
(Initial value)
2. Cleared when the DTC is activated by a CMI1 interrupt
1 Set when DR1 compare match occurs
Bit 1—Input Capture/Compare Match Flag 2 (IMF2): Set to 1 when the counter value matches
the GR2 value, or the counter value is captured in GR2. For further details, see section 11.9.1,
"Interrupt Timing. "
Bit 1
IMF2 Description
0 1. Cleared by reading IMF2 after IMF2 is set to 1, then writing 0 in IMF2
(Initial value)
2. Cleared when the DTC is activated by an IMI2 interrupt
1 Set when GR2 input capture or compare match occurs
Bit 0
IMF1 Description
0 1. Cleared by reading IMF1 after IMF1 is set to 1, then writing 0 in IMF1
(Initial value)
2. Cleared when the DTC is activated by an IMI1 interrupt
1 Set when GR1 input capture or compare match occurs
The timer output enable register (TOER) is an eight-bit readable/writable register. The bit
structure of TOER in channels 2 to 5 is shown next.
For the selection of general register (GR) functions, see section 11.3.3, "Timer Control Register
(Low). "
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
General register
output enable
General register 11/10
output enable These bits enable
Dedicated 21/20 and disable output
These bits enable of the counter-GR1
register output
enable 11/10 and disable output compare match
Dedicated
These bits enable of the counter-GR2 signal, and select
register output compare match the output level
enable 21/20 and disable output
of the counter-DR1 signal, and select
These bits enable the output level
compare match
and disable output
signal, and select
of the counter-DR2
the output level
compare match
signal, and select
the output level
Bit 7 Bit 6
DOE21 DOE20 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1 Toggle on compare match*
Note: * Channels 2 and 3 do not have an output toggle function. If these bits are set to 11, the
output goes to 1 on compare match.
Bits 5 and 4—Dedicated Register Output Enable 11/10 (DOE11/10): These bits enable and
disable output of the counter-DR1 compare match signal, and select the output level. For further
details, see section 11.8.2, "Selection of Output Level. "
Bit 5 Bit 4
DOE11 DOE10 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1 Toggle on compare match*
Note: * Channels 2 and 3 do not have an output toggle function. If these bits are set to 11, the
output goes to 1 on compare match.
Bits 3 and 2—General Register Output Enable 21/20 (GOE21/20): These bits enable and
disable output of the counter-GR2 compare match signal, and select the output level.
Bit 3 Bit 2
GOE21 GOE20 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1 Toggle on compare match*
Note: * Channels 2 and 3 do not have an output toggle function. If these bits are set to 11, the
timer outputs 1 on compare match.
For further details, see section 11.8.2, "Selection of Output Level. "
Bits 1 and 0—General Register Output Enable 11/10 (GOE11/10): These bits enable and
disable output of the counter-GR1 compare match signal, and select the output level.
Bit 1 Bit 0
GOE11 GOE10 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1 Toggle on compare match *
Note: * Channels 2 and 3 do not have an output toggle function. If these bits are set to 11, the
timer outputs 1 on compare match.
When GR1 is used for input capture, however, compare match signal output is disabled regardless
of the setting of GOE11 and GOE10. Bits 1 and 0 are thus ignored except when IEG11 =
IEG10 = 0.
For further details, see section 11.8.2, "Selection of Output Level. "
The general registers function as output compare registers after a reset. They can be switched over
to input capture by setting bits IEG21 to IEG10 in the timer control registers.
Each of channels 6 and 7 can simultaneously measure two waveforms and generate one waveform.
Channels 6 and 7 can each be used to measure waveforms in programmed periodic counting mode.
The timer counter in channel 7 can count up or down according to the phase of two external clock
signals in phase counting mode. Channels 6 and 7 can provide single-phase PWM output in PWM
output mode. See section 11.8, "Examples of Timer Operation" for details.
TCLK1 −TCLK3
φ−φ/4096
T6IOC1−T6IOC2
Clock selector Control logic
Comparator
TCRH*1 TCRL*2
GR1 (ICR/OCR)
GR2 (ICR/OCR)
16-bit counter
On-chip
TSRH TSRL
data bus
TOER
Timer status register high (TSRH) is an eight-bit readable/writable register. After OVIE, IMIE2,
or IMIE1 is set to 1 in TSRH, an interrupt is requested when OVF, IMF2, or IMF1 is set to 1 in
TSRL. For timer control register high and low, see section 11.3.2, "Timer Control Register (High)
" and section 11.4.2, "Timer Control Register (Low). " The bit structure of TSRH in channels 6
and 7 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 1 0 0 0
R/W − − − − − R/W R/W R/W
Input capture/
Compare match
interrupt enable
2/1
These bits enable
and disable
compare match
and input capture
interrupts
Bit 2—Overflow Interrupt Enable (OVIE): Enables or disables the counter overflow interrupt.
For further details, see section 11.9.1, "Interrupt Timing. "
Bit 2
OVIE Description
0 Counter overflow interrupt is disabled (Initial value)
1 Counter overflow interrupt is enabled
Bit 1
IMIE2 Description
0 GR2 input capture or compare match interrupt is disabled (Initial value)
1 GR2 input capture or compare match interrupt is enabled
Bit 0—Input Capture/Compare Match Interrupt Enable 1 (IMIE1): Enables or disables the
GR1 compare match or input capture interrupt. For further details, see section 11.9.1, "Interrupt
Timing. "
Bit 0
IMIE1 Description
0 GR1 input capture or compare match interrupt is disabled (Initial value)
1 GR1 input capture or compare match interrupt is enabled
Timer status register low (TSRL) is an eight-bit readable/writable register. After OVIE, IMIE2, or
IMIE1 is set to 1 in TSRH, an interrupt is requested when OVF, IMF2, or IMF1 is set to 1 in
TSRL. Writing to TSRL is restricted to clearing a flag to 0 after reading the 1 value of that flag.
The bit structure of TSRL in channels 6 and 7 is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 1 0 0 0
R/W − − − − − R/W R/W R/W
Input capture/
Compare match
interrupt enable
2/1
Flags indicating
GR2 and GR1
compare match
or input capture
Overflow flag
Flag indicating counter
overflow
Reserved bits
Bit 2—Overflow Flag (OVF): Set to 1 when the counter overflows from H'FFFF to H'0000 or
when the counter in channel 7 underflows from H'0000 to H'FFFF in phase counting mode. For
further details, see section 11.9.1, " Interrupt Timing," and section 11.8.9, " Phase counting
Mode."
Bit 2
OVF Description
0 Cleared by reading OVF after OVF is set to 1, then writing 0 in OVF
(Initial value)
1 Set when counter overflow occurs
Bit 1
IMF2 Description
0 1. Cleared by reading IMF2 after IMF2 is set to 1, then writing 0 in IMF2
(Initial value)
2. Cleared when the DTC is activated by an IMI2 interrupt
1 Set when GR2 input capture or compare match occurs
Bit 0—Input Capture/Compare Match Flag 1 (IMF1): Set to 1 when the counter value matches
the GR1 value, or the counter value is captured in GR1. For further details, see section 11.9.1,
"Interrupt Timing."
Bit 0
IMF1 Description
0 1. Cleared by reading IMF1 after IMF1 is set to 1, then writing 0 in IMF1
(Initial value)
2. Cleared when the DTC is activated by an IMI1 interrupt
1 Set when GR1 input capture or compare match occurs
The timer output enable register (TOER) is an eight-bit readable/writable register. The bit
structure of TOER in channels 6 and 7 is shown next.
For the selection of general register (GR) functions, see section 11.3.3, "Timer Control Register
(Low)."
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 0 0 0 0
R/W − − − − R/W R/W R/W R/W
General register
output enable
11/10
These bits enable
and disable output
of the counter-GR1
compare match
signal, and select
the output level
Reserved bits
Bit 3 Bit 2
GOE21 GOE20 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
When GR2 is used for input capture, however, compare match signal output is disabled regardless
of the setting of GOE21 and GOE20. Bits 3 and 2 are thus ignored except when IEG21 =
IEG20 = 0.
Bits 1 and 0—General Register Output Enable 11/10 (GOE11/10): These bits enable and
disable output of the counter-GR1 compare match signal, and select the output level.
Bit 1 Bit 0
GOE11 GOE10 Description
0 0 Compare match signal output is disabled (Initial value)
0 1 Output 0 on compare match
1 0 Output 1 on compare match
1 1
When GR1 is used for input capture, however, compare match signal output is disabled regardless
of the setting of GOE11 and GOE10. Bits 1 and 0 are thus ignored except when IEG11 =
IEG10 = 0.
Timer mode register A (TMDRA) is an eight-bit readable/writable register that selects timer
synchronizing and operating modes. The bit structure of TMDRA is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
Bit 7—Timer Mode 6-7 (MD6-7): Operates channels 6 and 7 in programmed periodic counting
mode.
Bit 7
MD6-7 Description
0 Timers 6 and 7 operate normally (Initial value)
1 Timers 6 and 7 operate in programmed periodic counting mode
The counter value in channel 7 is captured in GR2 in channel 7 at intervals set in GR2 in channel
6. If channel 7 is externally clocked, the number of external events occurring in regular intervals
timed by channel 6 can be counted. For further details see section 11.8.8, "Programmed Periodic
Counting Mode."
Bit 6
MD4-7 Description
0 Timers 4 and 7 operate normally (Initial value)
1 Timers 4 and 7 operate in programmed periodic counting mode
The counter value in channel 7 is captured in GR1 in channel 7 at intervals set in DR2 in channel
4. If channel 7 is externally clocked, the number of external events occurring in regular intervals
timed by channel 4 can be counted. For further details see section 11.8.8, "Programmed Periodic
Counting Mode."
Bit 5—Timer Mode 3-5 (MD3-5): Operates channels 3 and 5 in programmed periodic counting
mode.
Bit 5
MD3-5 Description
0 Timers 3 and 5 operate normally (Initial value)
1 Timers 3 and 5 operate in programmed periodic counting mode
The counter value in channel 5 is captured in GR1 in channel 5 at intervals set in DR2 in channel
3. If channel 5 is externally clocked, the number of external events occurring in regular intervals
timed by channel 3 can be counted. For further details see section 11.8.8, "Programmed Periodic
Counting Mode."
Bit 4—Timer Mode 2-6 (MD2-6): Operates channels 2 and 6 in programmed periodic counting
mode.
Bit 4
DM2-6 Description
0 Timers 2 and 6 operate normally (Initial value)
1 Timers 2 and 6 operate in programmed periodic counting mode
The counter value in channel 6 is captured in GR1 in channel 6 at intervals set in DR2 in channel
2. If channel 6 is externally clocked, the number of external events occurring in regular intervals
timed by channel 2 can be counted. For further details see section 11.8.8, "Programmed Periodic
Counting Mode."
Bit 3
SYNC3 Description
0 Timer counters in channels 6 and 7 operate independently (Initial value)
1 Timer counters in channels 6 and 7 are synchronized
When SYNC3 = 1, timer counters can be preset and cleared in synchronization. If two or more
bits among SYNC3, SYNC2, SYNC1, and SYNC0 are set to 1 simultaneously, all selected timer
counters are synchronized. For further details, see section 11.8.6 "Synchronizing Mode."
Bit 2
SYNC2 Description
0 Timer counters in channels 4 and 5 operate independently (Initial value)
1 Timer counters in channels 4 and 5 are synchronized
When SYNC2 = 1, timer counters can be preset and cleared in synchronization. If two or more
bits among SYNC3, SYNC2, SYNC1, and SYNC0 are set to 1 simultaneously, all selected timer
counters are synchronized. For further details, see section 11.8.6 "Synchronizing Mode."
Bit 1
SYNC1 Description
0 Timer counters in channels 2 and 3 operate independently (Initial value)
1 Timer counters in channels 2 and 3 are synchronized
When SYNC1 = 1, timer counters can be preset and cleared in synchronization. If two or more
bits among SYNC3, SYNC2, SYNC1, and SYNC0 are set to 1 simultaneously, all selected timer
counters are synchronized. For further details, see section 11.8.6 "Synchronizing Mode."
Bit 0—Timer Synchronizing Bit 0 (SYNC0): Synchronizes the timer counters in channel 1 and
other channels.
Bit 0
SYNC0 Description
0 Timer counters in channel 1 and other channels operate independently
(Initial value)
1 Timer counters in channels 2 and 3 are synchronized
Timer mode register B (TMDRB) is an eight-bit readable/writable register that selects timer
operating modes. The bit structure of TMDRB is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 0 0 0 0 0 0
R/W − − R/W R/W R/W R/W R/W R/W
Reserved bits
Bit 5—Phase Counting Mode (MDF): Operates channel 7 in phase counting mode. For further
details see section 11.8.9, "Phase Counting Mode."
Bit 5
MDF Description
0 Channel 7 operates normally (Initial value)
1 Timer counters in channels 2 and 3 are synchronized
Bit 4
PWM4 Description
0 Channel 7 operates normally (Initial value)
1 Channel 7 operates as a PWM timer
Channel 7 operates as a PWM timer with independent period and duty cycle, providing one PWM
output. When PWM4 = 1, settings of GOE11 and GOE10 in the channel 7 timer output enable
register (TOER) are ignored. For further details, see section 11.8.5 "PWM Output Mode."
Bit 3
PWM3 Description
0 Channel 6 operates normally (Initial value)
1 Channel 6 operates as a PWM timer
Channel 6 operates as a PWM timer with independent period and duty cycle, providing one PWM
output. When PWM3 = 1, settings of GOE11 and GOE10 in the channel 6 timer output enable
register (TOER) are ignored. For further details, see section 11.8.5 "PWM Output Mode."
Bit 2
PWM2 Description
0 Channel 3 operates normally (Initial value)
1 Channel 3 operates as a PWM timer
Channel 3 operates as a PWM timer with independent period and duty cycle. Channel 3 can
provide two-phase PWM output. When PWM2 = 1, settings of GOE21, GOE20, GOE11, and
GOE10 in the channel 3 timer output enable register (TOER) are ignored. For further details, see
section 11.8.5 "PWM Output Mode."
Bit 1
PWM1 Description
0 Channel 2 operates normally (Initial value)
1 Channel 2 operates as a PWM timer
Channel 2 operates as a PWM timer with independent period and duty cycle. Channel 2 can
provide two-phase PWM output. When PWM1 = 1, settings of GOE21, GOE20, GOE11, and
GOE10 in the channel 2 timer output enable register (TOER) are ignored. For further details, see
section 11.8.5 "PWM Output Mode."
Bit 0
PWM0 Description
0 Channel 1 operates normally (Initial value)
1 Channel 1 operates as a PWM timer
Channel 1 operates as a PWM timer with independent period and duty cycle. Channel 1 can
provide three-phase PWM output. When PWM0 = 1, settings of DOE11, DOE10, GOE21,
GOE20, GOE11, and GOE10 in the channel 1 timer output enable register (TOER) are ignored.
For further details, see section 11.8.5 "PWM Output Mode."
The timer start register (TSTR) is an eight-bit readable/writable register that starts and stops the
counters. The bit structure of TSTR is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 1 0 0 0 0 0 0 0
R/W − R/W R/W R/W R/W R/W R/W R/W
Counter start 7 to 1
These bits start and stop the
Reserved bit counters
Bit 6—Counter Start 7 (STR7): Starts and stops the counter in channel 7.
Bit 6
STR7 Description
0 Timer counter 7 is halted (Initial value)
1 Timer counter 7 is counting
Bit 5—Counter Start 6 (STR6): Starts and stops the counter in channel 6.
Bit 5
STR6 Description
0 Timer counter 6 is halted (Initial value)
1 Timer counter 6 is counting
Bit 4—Counter Start 5 (STR5): Starts and stops the counter in channel 5.
Bit 4
STR5 Description
0 Timer counter 5 is halted (Initial value)
1 Timer counter 5 is counting
Bit 3
STR4 Description
0 Timer counter 4 is halted (Initial value)
1 Timer counter 4 is counting
Bit 2—Counter Start 3 (STR3): Starts and stops the counter in channel 3.
Bit 2
STR3 Description
0 Timer counter 3 is halted (Initial value)
1 Timer counter 3 is counting
Bit 1—Counter Start 2 (STR2): Starts and stops the counter in channel 2.
Bit 1
STR2 Description
0 Timer counter 2 is halted (Initial value)
1 Timer counter 2 is counting
Bit 0—Counter Start 1 (STR1): Starts and stops the counter in channel 1.
Bit 0
STR1 Description
0 Timer counter 1 is halted (Initial value)
1 Timer counter 1 is counting
The timer counters (TCNT), general registers (GR), and dedicated registers (DR) are 16-bit
registers. The H8/500 CPU can access these registers a word at a time using a 16-bit data bus.
Byte access is also possible.
Figure 11-5 shows an example of word write timing to a timer counter. Figure 11-6 shows an
example of byte write timing to a timer counter.
T1 T2 T3
Internal write
signal
Internal data
bus New value
Timer counter
value Old value New value
Internal write
signal
Internal data
New value New value
bus
Timer counter Old value Lower byte only Upper byte only
value
Read and Write Operations: Timer counters, general registers, and dedicated registers can be
written and read a word at a time or a byte at a time. Figure 11-7 illustrates word read/write
operations. Figure 11-8 illustrates upper byte read/write operations. Figure 11-9 illustrates lower
byte read/write operations.
On-chip
data bus 16 16
Module data bus
Bus
H8/500 CPU
interface
8 8
High Low
address address
High Low
address address
On-chip
data bus 16 16
Module data bus
Bus
H8/500 CPU
interface
High Low
address address
The IPU's timer control registers (TCRH and TCRL), timer status registers (TSRH and TSRL),
timer output enable registers (TOER), timer mode register A (TMDA), timer mode register B
(TMDB), and timer start register (TSTR) are eight-bit registers. The H8/500 CPU accesses these
registers a byte at a time using an eight-bit data bus. If an instruction specifies word size, two
registers are accessed at consecutive addresses, upper byte (even address) first and lower byte (odd
address) second.
Figure 11-10 shows an example of byte write timing to a timer control register. Figure 11-11
shows an example of write timing to a timer control register by an instruction specifying word
operand size.
T1 T2 T3
Internal write
signal
Internal data
bus New value
Timer control
register value Old value New value
Figure 11-10 Example of Byte Write Timing for Timer Control Register
Internal write
signal
Timer control
Old value Updated TCRH Updated TCRL
register value
Figure 11-11 Example of Write Timing for Timer Control Register by Instruction
Specifying Word Operand Size
Read and Write Operations: Table 11-6 lists the byte-accessed registers. Figure 11-12
illustrates upper byte read/write operations. Figure 11-13 illustrates lower byte read/write
operations.
Abbreviation
Name Byte Access Word Access
Timer control registers (high) TCRH TCR Upper
Timer control registers (low) TCRL Lower
Timer status registers (high) TSRH TSR Upper
Timer status registers (low) TSRL Lower
Timer output enable registers TOER TOER Upper
Timer mode registers TMDR TMDR Lower
Timer start registers TSTR TSTR Upper
T1CRB Lower
High Low
address address
On-chip
data bus 8 8
Module data bus
Bus
H8/500 CPU
interface
High Low
address address
When a start (STR) bit in the timer start register (TSTR) is set to 1, the corresponding counter
starts counting from H'0000. There are two counting modes: a free-running mode and a periodic
mode. Figure 11-14 shows the procedure for selecting the counting mode.
Counting mode
selection
Counter operation
If compare match is selected as a counter clear source, the IPU operates in periodic counting
mode. Figure 11-17 shows an example of periodic counting. The counter starts from H'0000 and
counts up to H'8000. At this point a compare match with DR2 occurs, so the CMF2 flag in TSRH
is set to 1 and the counter is automatically cleared. Counting then continues from H'0000.
Timer
counter value H'0000 H'0001 H'FFFE H'FFFF H'0000 H'0001
STR bit
(TSTR) Counting starts when STR bit is set to 1
OVF flag
(TSRH)
Overflow flag (OVF) is set
when count changes from
H'FFFF to H'0000
Timer
counter value H'0000 H'0001 H'7FFF ∗ H'0000 H'0001 H'0002
STR bit
(TSTR) Note: ∗ H'8000
Counting starts when STR bit
is set to 1
CMF2 flag
(TSRH) Compare match with DR2 sets
compare match flag 2 (CMF2)
and clears counter
Compare match signals can be output in three modes: high, low, or toggle. Figure 11-18 shows
the procedure for selecting the output level.
Output selection
(1) Select the counting mode.
(2) Set a value in a dedicated or general register to
select the pulse output time.
Select counting mode (1)
(3) Low output: To have the output go low at
compare match, set the GOE or DOE bits in
the timer output enable register (TOER) to 01.
Set compare value
(2) (4) High output: To have the output go high at
in DR or GR
compare match, set the GOE or DOE bits in
TOER to 10.
(5) Toggle output: To have the output toggle at
compare match, set the GOE or DOE bits in
TOER to 11. Toggle output is available only
on channels 4 and 5.
GOE/DOE = 11
GOE/DOE = 01 GOE/DOE = 10
(channel 4 or 5)
CMF/IMF = 1 (1)
or
High output is selected by setting bits GOE11 and GOE10 to 10 in the channel 4 timer output
enable register (TOER). The IPU drives T4IOC1 high when the counter matches the value in GR1
(H'0001). Low output is selected by setting bits GOE21 and GOE20 to 01 in the channel 4 TOER.
The IPU drives T4IOC2 low when the counter matches the value in GR2 (H'0003). Toggle output
is selected by setting bits GOE11 and GOE10 to 11 in the channel 4 TOER. The IPU toggles
T4OC1 when the counter matches the value in DR1 (H'0004). The counter is cleared when the
count matches the value in DR2 (H'00FF).
If high or low output is selected, when compare match occurs, and if the pin is already at the
selected output level, the output level does not change.
• Settings
TOER (channel 4): H'36
TCRL (channel 4): H'E0 (clear on T4DR2 compare match)
Note: * 00FF
Timer counter
value 0001 0002 0003 0004 00FE * 0000 0001 0002 0003 0004
Output
GR2 value goes H'0003
high at
Counter is
compare
cleared at
DR1 value match
H'0004 compare match
Output
DR2 value goes H'00FF
low at
compare
match
T4IOC 1
(GOE11/10 = 10)
Output toggles at
T4IOC 2 compare match
(GOE21/20 = 01)
T4OC1
(GOE11/10 = 11)
The counter value can be captured into a register when a transition occurs at an input capture pin.
Capture can take place on the rising edge, falling edge, or both edges. Figure 11-21 shows the
procedure for selecting the input capture function.
or
The rising edge of T1IOC1 is selected by setting bits IEG11 and IEG10 to 01 in channel 1 timer
control register low (TCRL). The IPU transfers the counter value (H'0001 and H'0100) to GR1 on
the rising edge of the T1IOC1 input. The falling edge of T1IOC2 is selected by setting bits IEG21
and IEG20 in channel 1 TCRL to 10. The IPU transfers the counter value (H'0002 and H'0102) to
GR2 on the falling edge of the T1IOC2 input. The rising and falling edges of T1IOC3 are selected
by setting bits IEG31 and IEG30 in channel 1 timer control register A (TCRA) to 11. The IPU
transfers counter value H'0004 on the rising edge and value H'0104 on the falling edge of the
T1IOC1 input, to GR3.
• Settings
TCRL: H'89
TCRA: H'F3
Timer
0001 0002 0003 0004 0100 0101 0102 0103 0104 0105
counter value
T1IOC1
(IEG11/10 = 01)
T1IOC2
(IEG21/20 = 10)
T1IOC3
(IEG31/30 = 11)
The pulse width of the input capture signal must be at least 1.5tCYC.
tTICS tTICS
Internal capture
signal
IMF1
(channel 2)
A counter can be cleared by input capture or compare match. When compare match is selected as
a counter clear source, the count repeats cyclically from H'0000 to the value in the compare
register. When input capture is selected as a counter clear source, the counter can be cleared at
intervals determined by external events. Figure 11-25 shows the procedure for selecting the
counter clear source.
Selection
of clear source (1) Clear on compare match:
To clear the counter on
compare match, set the
clear period in a dedicated
or general register, then
Compare match (1) Capture (2) set the CCLR bits in TCRL
to 01 or 10. (The counter
operates as a periodic
Set period in DR or GR Select edge(s) counter.)
(2) Clear on capture:
To clear the counter by
CCLR = 01 (IEG ≠ 00)
Set CCLR = 01 (IEG = 00) input capture, select the
or CCLR = 10 input edge or edges in
TCRL, then set the CCLR
bits to 01.
Counter Clear Operation: Figure 11-26 illustrates the counter clear operation.
Counter clear
(1) When the counter clear source condition occurs,
TCNT is reset to 0 and starts counting up again.
If capture is selected, the counter value is first
<Clear condition satisfied> captured in a register, then the counter is cleared.
TCNT ← 0 (1)
In this example the channel-4 counter is cleared by input capture at T4IOC1. This clear condition
is selected by setting CCLR1 and CCLR0 in channel 4 timer control register low (TCRL) to 01.
The rising edge is selected by setting IEG11 and IEG10 to 01. The IPU transfers the counter value
(H'0003) on the rising edge of the T4IOC1 input to GR1, then clears the counter.
To clear the counter on DR2 compare match, set CCLR1 and CCLR0 to 10 in TCRL.
• Settings
TCRL (channel 4): H'D4 (to clear on input capture in T4GR1)
TCRL (channel 4): H'E0 (to clear on compare match with T4DR2)
Counter cleared by
input capture
H'0003 0000
0000
Timer counter
0001 0002 0001 00FE ∗ 0001 0002 0003 0004
value
T4IOC1
(IEG = 01) Note: ∗ H'00FF
Channels 1, 2, 3, 6, and 7 can be used as PWM timers. Channel 1 can provide three-phase PWM
output, channels 2 and 3 can provide two-phase PWM output, and channels 6 and 7 can provide
single-phase PWM output. Figure 11-28 shows the procedure for selecting PWM output mode.
PWM mode
selection
Select periodic counting (2) (2) Select periodic counting and the counter clear
(CCLR ≠ 00) source by setting the CCLR bits in timer control
register low (TCRL).
PWM bit = 1 (3) (3) Set the PWM bit in timer mode register B
(TMDRB) to 1.
<PWM mode>
Note: ∗ Channel 1:
Example of U
phase in 3-phase
PWM output.
The U phase is output at the T1IOC1 pin. The V phase is output at the T1IOC2 pin. The W phase
is output at the T1OC1 pin. The IPU sets T1IOC1 when the timer counter matches GR1 (H'0001),
and resets T1IOC1 when the timer counter matches GR3 (H'00FE). The IPU sets T1IOC2 when the
timer counter matches GR2 (H'0002), and resets T1IOC2 when the timer counter matches GR4
(H'00FD). The IPU sets T1IOC3 when the timer counter matches DR1 (H'0003), and resets
T1IOC3 when the timer counter matches DR3 (H'00FC).
The IPU clears the counter when the timer counter matches DR4 (H'00FF).
Timer counter
* 0000 0001 0002 0003 00FB 00FC 00FD 00FE * 0000 0001
value
GR1 value
(U phase set ) H'0001
GR3 value
(U phase reset ) H'00FE
GR2 value
(V phase set ) H'0002
DR3 value
(W phase reset ) H'00FC
DR4 value
H'00FF
(PWM period)
T1IOC1
(U phase)
T1IOC2
(V phase)
T1OC1
(W phase)
PWM
Note: * H'00FF
Usage Notes
1. In PWM output mode, the output levels of PWM output pins cannot be set in the timer output
enable register (TOER). Any output level settings made will be ignored.
2. Settings of the IEG bits in timer control register low (TCRL) are valid in PWM output mode.
The IEG bits must be cleared to 0.
3. In PWM output mode, periodic counting should be used by selecting a counter clear source in
TCRL. Table 11-7 lists the registers that can set the PWM period in each channel.
In synchronizing mode two or more timer counters can be rewritten or cleared simultaneously.
Figure 11-31 shows the procedure for selecting synchronizing mode.
Master
Note: * Channels 2 to 7
Synchronizing
preset*
Synchronizing preset:
<Write> (4) Writing to channel 2 or
3 writes the same
(5) value simultaneously
into both counters.
TCNT2 ← DATA TCNT3 ← DATA
(4) (5)
Timer counters 2 and 3 are synchronized by setting the SYNC1 bit in timer mode register A
(TMDRA) to 1. The timer counters are synchronously preset by writing a new value to either
timer counter 2 or 3; the IPU simultaneously writes the same value in the other timer counter.
Synchronized clearing is selected by setting CCLR0 = CCLR1 = 1 in timer control register low
(TCRL) as the clear source for timer counter 3. The IPU clears timer counters 2 and 3
simultaneously when timer counter 2 matches T2GR1 (H'00FF).
• Settings
T2GR1: H'00FF
TMDRA: H'02 (SYNC1 = 1)
TCRL (channel 2): H'D0 (clear at compare match with T2GR1)
TCRL (channel 3): H'F0 (enabling synchronized clearing)
Timer counter
n n + 1 0000 m + 2 0000 0001 00FE *1 0001
3 value
0000
T2GR1 value
(channel 2) H'FFFF H'00FF
Synchronization of timer
counters 2 and 3 enabled
Notes: 1. H'00FF
2. Set CCLR1 = CCLR0 = 1 (synchronized clearing)
as the clear source for timer counter 3.
The IPU has three external clock input pins. If external event signals are input at these external
clock input pins, external events can be counted. The counter can be set to increment on the rising
or falling edge, or on both edges of the external clock signal. The value of an externally clocked
counter can be captured at regular intervals to measure external event frequencies. Figure 11-34
shows the procedure for selecting external event counting mode.
(1) Set the TPSC bits in timer control register high (TCRH) to
Input selection select an external clock.
(2) Count on rising edge: To count rising edges of the
external clock signal, set bits CKEG1 and CKEG0 to 00
in TCRH.
Select external clock (1) (3) Count on falling edge: To count falling edges of the
external clock signal, set bits CKEG1 and CKEG0 to 01
in TCRH.
(4) Count on both edges: To count both rising and falling
edges of the external clock signal, set bits CKEG1 and
CKEG0 to 10 or 11 in TCRH.
(5) Counting starts when the corresponding STR bit in the
timer start register (TSTR) is set to 1.
or
STR bit = 1
(5)
<Start incrementing>
In this example timer counters 1, 2, and 3 count external event inputs at TCLK1. In channel 1, the
rising edge of TCLK1 is selected by setting the CKEG1 and CKEG0 bits in TCRH to 00. The IPU
counts rising edges of TCLK1. In channel 2, the falling edge of TCLK1 is selected by setting the
CKEG1 and CKEG0 bits in TCRH to 01. The IPU counts falling edges of TCLK1. In channel 3,
both edges of TCLK1 are selected by setting the CKEG1 and CKEG0 bits in TCRH to 10 or 11.
The IPU counts both rising and falling edges of TCLK1.
• Settings
TCRH (channel 1): H'CD (count rising edges)
TCRH (channel 2): H'DD (count falling edges)
TCRH (channel 3): H'ED or H'FD (count both rising and falling edges)
Incremented on rising
edge of TCLK1
Timer counter 1
value (CKEG = H'0001 H'0002 H'0003 H'0004
00)
Incremented on falling
edge of TCLK1
Timer counter 2
value (CKEG = H'0000 H'0001 H'0002 H'0003
01)
Incremented on both
edges of TCLK1
Timer counter 3
value (CKEG = H'0001 H'0002 H'0003 H'0004 H'0005 H'0006 H'0007
10 or 11)
TCLK1
The IPU latches external clock signals (TCLK1 to TCLK3) on the rising edge of the system clock
(φ). TCNT2 is incremented 1.5 system clock cycles (1.5tCYC) after the external clock is latched.
The pulse width of the external clock signal must be at least 1.5tCYC.
tTCKS: 50 ns (min)
tTCKS tTCKS
TCLK1 −TCLK 3
Minimum width: at least 1.5t CYC
Internal counter
clock
In programmed periodic counting mode, the value of an externally clocked counter is captured
into a general register by compare match on a different channel. No external input capture signal
is needed. Figure 11-37 shows the procedure for selecting programmed periodic counting mode.
Procedure for Selecting Programmed Periodic Counting Mode : Example when bit MD2-6 = 1
in timer mode register A (TMDRA)
In this example external events are counted over a programmed period using channels 2 and 6.
The IPU automatically transfers the value of timer counter 6 (H'0012) to T6GR1 when timer
counter 2 matches T2DR2 (H'0100). Timer counter 2 is set to be cleared by compare match with
T2DR2.
• Settings
TCRL (channel 2): H'E0 (cleared by compare match with T2DR2)
TCRH (channel 6): H'ED or H'FD (increment on both rising and falling edges)
TMDRA: H'10 (capture in T6GR1 on compare match with T2DR2)
Timer counter 2
0000 0001 0002 0003 0004 00F9 00FA 00FB 00FC 00FD 00FE 00FF * 0 0001 0002
value
T2DR2 value
(channel 2)
H'0100
Counter is cleared
by compare match
TCLK1
Timer counter 6
H'0000 H'0001 H'0010 H'0011 H'0012
value
Note: * H'0100
One application of phase counting mode is control of an AC servo motor. If the output of a two-
phase encoder is fed to two external clock pins, the phase relationship between the two clock
signals is detected and the counter is incremented or decremented accordingly. Phase counting is
available only on channel 7. Figure 11-40 shows the procedure for selecting phase counting
mode.
Mode selection
<Increment or decrement>
Phase counting
<Decrement> <Increment>
No No
Underflow? Overflow? (4) When an overflow or
underflow occurs, the
Yes (4) Yes OVF bit in timer status
register low (TSRL)
is set to 1.
OVF ← 1
In up-counting, the counter counts repeatedly from H'0000 to H'FFFF. The IPU sets the overflow
flag (OVF) in timer status register low (TSRL) when the count returns from H'FFFF to H'0000.
For the up/down counting conditions, see figure 11-44 "Counting Conditions" and table 11-9
"Up/Down-Counting Conditions."
Counting up Counting
down
Timer counter
0000 0001 0002 FFFE FFFF 0000 0001 0002 0001 0000
7 value
TCLK2
TCLK1
OVF flag
(TSRL)
Overflow flag (OVF) is set to 1
when count changes from
H'FFFF to H'0000
In down-counting, the counter counts repeatedly from H'FFFF to H'0000. The IPU sets the
overflow flag (OVF) in timer status register low (TSRL) when the count returns from H'0000 to
H'FFFF. For the up/down counting conditions, see figure 11-44 "Counting Conditions" and table
11-9, "Up/Down-Counting Conditions."
Timer counter
0100 00FF 00FE 0001 0000 FFFF FFFE FFFD FFFE FFFF
7 value
TCLK1
TCLK2
OVF flag
(TSRL)
Overflow flag (OVF) is set to 1
when count changes from
H'0000 to H'FFFF
Counter value
Counting up
Counting down
Timer counter 7
Time
TCLK2
TCLK1
The IPU latches the external clock signals on the rising edge of the system clock (φ). The counter
is incremented 1.5 system clock cycles (1.5tCYC) after the external clock is latched.
The external clock pulse width must be at least 1.5 system clock cycles (1.5tCYC). The phase
difference between TCLK1 and TCLK2 must be at least 1.0tCYC.
tTCKS : 50 ns (min)
φ
tTCKS tTCKS
Internal counter
clock
(1) Output Compare Timing: Figure 11-46 shows the timing from counter incrementation to
generation of a compare match interrupt request. One system clock cycle (1.0tCYC) after timer
counter 2 matches the T2GR1 value (N), the IPU sets the input capture/compare match flag (IMF).
A compare match signal (T2IOC1) is output 0.5tCYC after IMF is set. The interrupt request
(T2IMI1) is generated 0.5tCYC after the T2IOC1 output. The T2IMI1 interrupt request therefore
comes 2.0tCYC after the counter is incremented to N.
2.0tCYC
Timer counter
N-1 N N+1
2 value
Compare match
Internal compare
match signal
1.0tCYC
IMF2 (TSRL)
T2IOC1
1.5tCYC
T2IMI1
Compare match
interrupt request
T2GR1 N
3.0tCYC (max)
T2IOC1
Timer counter
2 value N-1 N N+1
Internal capture
signal
T2GR1 N
2.0tCYC (max)
T2IMI1
Input capture
interrupt request
Figure 11-47 Timing from Capture Input to Input Capture Interrupt Request
In phase counting mode, the IPU sets the overflow flag (OVF) when the timer counter value
returns from H'0000 to H'FFFF. For usage in phase counting mode, see section 11.8.9 "Phase
Counting Mode."
1.0tCYC
Timer counter
H'FFFF H'0000 H'0001
2 value
OVF (TSRL)
T2OVI
Overflow interrupt request
The IPU has 35 interrupt sources. Of these, the compare match interrupt sources and the compare
match/input capture interrupt sources can start the data transfer controller (DTC) to transfer data.
Table 11-10 lists the interrupt sources and indicates which can start the DTC.
The exclusive compare match interrupt sources (such as T1CMI1 and T1CMI2) are paired. Both
sources in each pair share the same vector. Data transfer should not be enabled for both interrupt
sources at the same time.
(1) Contention between Counter Read/Write by the H8/500 CPU and IPU Operations
Contention between Writing to Timer Counter by H8/500 CPU (T3) and Clearing by
Compare Match: Clearing the counter has priority.
Timer counter
N-1 N H'0000
value
Internal counter
clear signal
Masked
The internal counter
Internal write clear signal masks the
signal write signal, so clearing
of the counter takes
priority. (The dotted
line shows the normal
write signal.)
Figure 11-49 Contention between Writing to Timer Counter by H8/500 CPU (T3) and
Clearing by Compare Match
Input capture
pin
Capture input generates clear signal
Timer counter
N H'0000
value
Internal counter
clear signal
Masked
The internal counter
Internal write clear signal masks the
signal write signal, so clearing
of the counter takes
priority. (The dotted line
shows the normal write
signal.)
Figure 11-50 Contention between Writing to Timer Counter by H8/500 CPU (T3) and
Clearing by Capture Input
T1 T2 T3
Internal write
signal
Even if H'AAAA is set in
Internal data a compare register,
bus Write data (H'AAAA) a compare match does
not occur here.
Timer counter
N H'AAAA
value
Masked
Internal increment The internal write signal masks
signal the increment signal, so writing
to the counter takes priority.
(The dotted line shows the
normal increment signal.)
Figure 11-51 Contention between Timer Counter Write (T3) by H8/500 CPU and
Increment
T1 T2 T3
Internal write
signal
Timer counter
H'FFFF H'AAAA
value
Overflow flag
(OVF)
If the write occurs at the instant
when the count would have
changed from H'FFFF to H'0000,
the overflow flag (OVF) is set.
Figure 11-52 Contention between Timer Counter Write (T3) by H8/500 CPU and
Setting of Overflow Flag
T1 T2 T3
Internal write
signal
Internal data
bus Write data (H'AA)
Timer counter
value (upper H'FF H'AA
byte)
Timer counter
value (lower H'00 H'01 H'00
byte)
Internal Value prior to increment
increment is retained.
signal
Figure 11-53 Contention between Timer Counter Byte Write (T2) by H8/500 CPU
and Increment
T1 T2 T3
Internal read
signal
Value prior to capture is read
Internal data Read data (H'FFFF)
bus
Figure 11-54 Contention between Capture Register Read (T3) by H8/500 CPU
and Input Capture
A19−A0 GR or DR address
Internal write
signal
TCNT2 FF 00 TCNT2 01 01
TCNT3 AA 55 TCNT3 01 00
TCNT3 AA 01
When the counter increments on the system clock as in figure 11-56, the compare match frequency
is:
T = φ /(N + 1)
(T: compare match frequency. φ: system clock frequency. N: value set in compare register.)
When the counter increments on a clock source other than the system clock as in figure 11-57, the
compare match frequency is:
(T: compare match frequency. φ: system clock frequency. D: frequency ratio of system clock
to counter clock source. N: value set in compare register.)
In this case, if H'0000 is set in the compare register, compare match does not occur.
Counter clock
source
Counter
N H'0000 H'0001 H'0002 N-1 N H'0000 H'0001
value
Compare match
signal
(toggle output)
Cycle: T = φ/(N + 1)
Figure 11-56 Compare Match Frequency when Clock Source is System Clock
Counter clock
source
Counter
value N−1 N H'0000 H'0001 N−1 N H'0000 H'0001
Compare match
signal
(toggle output)
Cycle: T = φ/(D +N)
Figure 11-57 Compare Match Frequency when Clock Source is not System Clock
Note on Rewriting the Compare Match Register: To generate a compare match after rewriting
the register, the following condition must be satisfied. Note that even if the counter value when
rewriting the register and the register value after rewriting the register do match, a compare match
will not be generated.
T0 tcyc T0 T0 T0
Counter value
1/2 tcyc
12.1 Overview
The H8/539F has a built-in pulse-width modulation (PWM) timer module with three independent
channels. Each PWM timer has an eight-bit timer counter (TCNT) and an eight-bit duty register
(DTR). DTR settings can provide pulse output with any duty cycle from 0% to 100%.
12.1.1 Features
DTR
Compare
Bus interface
Output match Internal
PW Comparator data bus
control
TCNT Module
data
bus
TCR
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/(W) R/(W) R/(W) R/(W) R/(W) R/(W) R/(W) R/(W)
The timer counter (TCNT) is an eight-bit up-counter. When the output enable bit (OE) is set to 1
in TCR, TCNT starts counting pulses of the internal clock selected by clock select bits 2 to 0
(CKS2 to CKS0). After counting from H'00 to H'F9, the count repeats from H'00.
TCNT can be written to and read, but the write function is for test purposes only. Do not write to
TCNT during normal operation, because this may have unpredictable effects.
TCNT is initialized to H'00 by a reset and in standby mode, and when the OE bit is cleared to 0.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 1 1 1 1
R/W R/W R/W R/W R/W R/W R/W R/W R/W
The duty register (DTR) specifies the duty cycle of the output pulse. Any duty cycle from 0% to
100% can be output by setting the corresponding value in DTR. The resolution is 1/250. Writing
0 (H'00) in DTR gives a 0% duty cycle. Writing 125 (H'7D) gives a 50% duty cycle. Writing 250
(H'FA) gives a 100% duty cycle.
The DTR and TCNT values are constantly compared. When the values match, the PWM output is
placed in the 0 state. When the TCNT value changes from H'00 to H'01, the PWM output is placed
in the 1 state, unless the DTR value is H'00, in which case the duty cycle is 0% and the PWM
output remains in the 0 state.
DTR is double-buffered. A new value written in DTR does not become valid until after the timer
count changes from H'F9 to H'00. While the OE bit is cleared to 0 in TCR, however, new values
written in DTR become valid immediately. When DTR is read, the value read is the currently valid
value.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 1 1 1 0 0 0
R/W R/W R/W − − − R/W R/W R/W
The timer control register (TCR) is an eight-bit readable/writable register that selects the clock
input to TCNT and controls PWM output.
Bit 7—Output Enable (OE): Starts or stops TCNT and controls PWM output.
Bit 7
OE Description
0 PWM output is disabled and the TCNT value is cleared to 0 (Initial value)
1 PWM output is enabled and TCNT is counting
Bit 6
OS Description
0 Direct PWM output (Initial value)
1 Inverted PWM output
The PWM resolution, period, and frequency can be calculated as follows from the frequency of
the selected internal clock source.
Table 12-3 lists the resolution, PWM period, and PWM frequency for each clock source when the
system clock frequency (φ) is 10 MHz.
(2) Inverted Output (OS = 1): The PWM output is inverted. [(e) in figure 12-2]
TCNT input
clock
OE
Figure 12-2 PWM Operation Timing
N-1 N+1
TCNT (a) H'00 (b) H'01 H'02 N H'F9 (d) H'00 H'01
(c)
To use port 6, 7, or A for PWM output, first set the appropriate bit (PWM1E, PWM2E, or
PWM3E) to 1 in P67CR or PACR. Each of these bits can be set independently.
• Any necessary changes to bits CKS2 to CKS0 and OS should be made before the OE bit is set
to 1.
• If the DTR value is H'00, the duty cycle is 0% (always 0). If the DTR value is H'FA to H'FF,
the duty cycle is 100% (always 1).
For inverted output, these output levels are inverted.
13.1 Overview
System operation can be monitored by the on-chip watchdog timer (WDT, one channel). The
WDT can generate a reset signal for the entire chip if a system crash allows the timer counter
(TCNT) to overflow. When this watchdog function is not needed, the WDT can be used as an
interval timer. In interval timer operation, an IRQ0 interrupt is requested at each counter overflow.
The WDT is also used in recovering from software standby mode.
13.1.1 Features
Overflow
Internal
Interrupt signal Interrupt TCNT data bus
Read/
control write
IRQ0
control
(interval timer) TCSR
Legend
TCNT: Timer counter
TCSR: Timer control/status register
RSTCSR: Reset control/status register
Note:* The H8/539F dual power source model has an external reset output function,
but the H8/539F S-mask and A-mask models (single power source) do not.
Address
Write Read Name Abbreviation R/W Initial Value
H'FF10 H'FF10 Timer control/status register TCSR R/(W)* H'18
H'FF11 Timer counter TCNT R/W H'00
H'FF1F Reset control/status register RSTCSR R/(W)* H'3F
Note: * Software can write 0 in bit 7 to clear the flag, but cannot write 1.
The timer counter (TCNT) is an eight-bit readable and writable* up-counter. The TCNT bit
structure is shown next.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When the timer enable bit (TME) in the timer control/status register (TCSR) is set to 1, the timer
counter starts counting pulses of an internal clock source selected by clock select bits 2 to 0
(CKS2 to CKS0) in TCSR. When the count overflows (changes from H'FF to H'00), an overflow
flag (OVF) in TCSR is set to 1. The timer count is initialized to H'00 by a reset and when the
TME bit is cleared to 0.
Note: * TCNT is write-protected by a password. See section 13.2.4, "Notes on Register Access"
for details.
The timer control/status register (TCSR) is an eight-bit readable and partly writable* register.
Its functions include selecting the timer mode and clock source. The TCSR bit structure is shown
next.
Note: * TCSR is write-protected by a password. See section 13.2.4 "Notes on Register Access"
for details.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 1 1 0 0 0
R/W R/(W)* R/W R/W − − R/W R/W R/W
Reserved bits
Overflow flag
Status flag indicating overflow
Note: * Software can write 0 in bit 7 to clear the flag, but cannot write 1.
Bits 7 to 5 are initialized to 0 by a reset, in hardware standby mode, and in software standby mode.
Bits 2 to 0 are initialized to 0 by a reset and in hardware standby mode, but retain their values in
software standby mode.
Bit 7
OVF Description
0 Cleared by reading OVF after it has been set to 1, (Initial value)
then writing 0 in OVF
1 Set when TCNT overflows
Bit 6
,7
WT/,7 Description
0 Interval timer: IRQ0 interrupt request (Initial value)
1 Watchdog timer: reset request
Bit 5—Timer Enable (TME): Enables or disables the timer counter (TCNT). Always clear TME
to 0 before entering software standby mode.
Bit 5
TME Description
0 Timer disabled: TCNT is initialized to H'00 and stopped. (Initial value)
1 Timer enabled: TCNT starts counting.
The H8/539F S-mask and A-mask models (single power source) do not have a 5(62 pin or a
reset external output function. RSTOE in the RSTCSR register can be set and read, but a reset
external output operation is not performed.
The reset control/status register (RSTCSR) is an eight-bit readable and partly writable* register
that indicates when a reset signal has been generated by WDT overflow, and controls external
output of this reset signal.
Bit 7 6 5 4 3 2 1 0
WRST RSTOE − − − − − −
Initial value 0 0 1 1 1 1 1 1
R/W R/(W)* R/W − − − − − −
Reserved bits
Reset output enable bit
Enables or disables external reset signal output
Note: * Only a 0 can be written in bit 7 to clear the flag, after first reading the RSTCSR register.
Bits 7 and 6 are initialized by input of a reset signal at the 5(6 pin. They are not initialized by a
reset signal generated by the WDT.
Bit 7—Watchdog Timer Reset (WRST): Indicates that the watchdog timer counter has
overflowed and generated a reset signal. This reset signal resets the entire chip. If the reset output
enable bit (RSTOE)is set to 1, the reset signal is also output (low) at the 5(62 pin to initialize
external system devices.
Bit 6—Reset Output Enable (RSTOE): Enables or disables external output at the 5(62 pin* of
the reset signal generated if the timer counter (TCNT) overflows when the WDT is used as a
watchdog timer.
Bit 6
RSTOE Description
0 Reset signal generated by TCNT overflow is not output externally (Initial value)
1 Reset signal generated by TCNT overflow is output externally
Note: * H8/539F (Dual power source model):
The 5(62 pin is an open-drain output pin. Regardless of whether reset output is uesd, the
5(62 pin should be pulled up to Vcc externally. A sample circuit is shown in figure 19-24
in section 19.7, "Flash Memory Programming and Erasing Precautions", and figure 19-28,
section 19.8 "Notes on Mounting Board Development-Handling of VPP and Mode MD2
Pins. " The 5(62 output is multiplexed with Vpp input (the flash memory power supply),
and therefore reset output off-chip must be disabled (by clearing RSTOE to 0) when 12 V is
applied to the Vpp pin. For cautions concerning the 5(62/Vpp pin, see notes 5 and 6 in
section 19.7, "Flash Memory Programming and Erasing Precautions. "
The H8/539F S-mask and A-mask models (single power source) do not have 5(62 pin
function. When set to RSTOE, it is readable but there is no external output reset operation.
The watchdog timer’s TCNT, TCSR, and RSTCSR registers differ from other registers in being
more difficult to write. The procedures for writing and reading these registers are given below.
(1) Writing to TCNT and TCSR: These registers must be written by word access. They cannot
be written by byte instructions. Figure 13-2 shows the format of data written to TCNT and TCSR.
TCNT and TCSR both have the same write address. The write data must be contained in the
lower byte of the written word. The upper byte must contain H'5A (password for TCNT) or H'A5
(password for TCSR). This transfers the write data from the lower byte to TCNT or TCSR.
<TCSR write>
15 8 7 0
Address H'FF10 H'A5 Write data
(2) Writing to RSTCSR: RSTCSR must be written by word access. It cannot be written by byte
instructions. Figure 13-3 shows the format of data written to RSTCSR. To write 0 in the WRST
bit, the write data must have H'A5 in the upper byte and H'00 in the lower byte. The H'00 in the
lower byte clears the WRST bit in RSTCSR to 0. To write to the RSTOE bit, the upper byte must
contain H'5A and the lower byte must contain the write data. Writing this word transfers a write
data value into the RSTOE bit.
(3) Reading TCNT, TCSR, and RSTCSR: These registers are read like other registers. Byte
access instructions can be used. The read addresses are H'FF10 for TCSR, H'FF11 for TCNT, and
H'FF1F for RSTCSR, as listed in table 13-2.
Address Register
H'FF10 TCSR
H'FF11 TCNT
H'FF1F RSTCSR
Figure 13-4 illustrates watchdog timer operation. To use the WDT as a watchdog timer, set the
WT/,7 and TME bits to 1. Software must prevent TCNT overflow by rewriting the TCNT value
(normally by writing H'00) before overflow occurs. If TCNT fails to be rewritten and overflows
due to a system crash etc., the chip is internally reset for 518 system clock cycles (518φ).
The watchdog reset signal can be externally output from the 5(62* pin to reset external system
devices. The reset signal is output externally for 132 system clock cycles (132φ). External output
can be enabled or disabled by the RSTOE bit in RSTCSR.
A watchdog reset has the same vector as a reset generated by input at the 5(6 pin. Software can
distinguish a 5(6 reset from a watchdog reset by checking the WRST bit in RSTCSR.
If a 5(6 reset and a watchdog reset occur simultaneously, the 5(6 reset always takes priority.
WDT overflow
H'FF
TCNT
count value TME set to 1
H'00
OVF = 1
Figure 13-5 illustrates interval timer operation. To use the WDT as an interval timer, clear WT/,7
to 0 and set TME to 1. An IRQ0 request is generated each time the timer count overflows. This
function can be used to generate IRQ0 requests at regular intervals.
This IRQ0 interrupt has a different vector from the interrupt requested by ,540 input. Software
does not have to check whether the interrupt request came from the ,540 pin or the interval timer.
H'FF
TCNT
count value
Time t
H'00
The watchdog timer has a special function in recovery from software standby mode. WDT
settings required when software standby mode is used are described next.
(1) Before Transition to Software Standby Mode: The TME bit in the timer control/status
register (TCSR) must be cleared to 0 to stop the watchdog timer counter before execution of the
SLEEP instruction. The chip cannot enter software standby mode while the TME bit is set to 1.
Before entering software standby mode, software should also set bits CKS2 to CKS0 in TCSR so
that the overflow interval is equal to or greater than the settling time of the clock oscillator (tOSC2)*.
(2) Recovery from Software Standby Mode: In recovery from software standby mode the WDT
operates as follows.
When an NMI request signal is received, the clock oscillator starts running and the timer counter
(TCNT) starts counting at the rate selected by bits CKS2 to CKS0 in TCSR before software
standby mode was entered. When TCNT overflows (changes from H'FF to H'00), the system
clock (φ) is presumed to be stable and usable, clock signals are supplied to the entire chip,
software standby mode ends, and the NMI interrupt-handling routine starts executing. This timer
overflow does not set the OVF flag in TCSR to 1, and the TME bit remains cleared to 0.
Note: * When using an external clock, make a WDT timer control/status register (TCSR) setting
that will secure the external clock output settling delay time (tDEXT).
Figure 13-6 shows the timing of setting of the OVF flag in the timer control/status register
(TCSR). The OVF flag is set to 1 when the timer counter overflows. When OVF is set to 1, an
IRQ0 interrupt is requested simultaneously.
OVF
The WRST bit in the reset control/status register (RSTCSR) is valid when WT/,7 = 1 and TME =
1. Figure 13-7 shows the timing of setting of WRST and the internal reset timing. The WRST bit
is set to 1 when the timer count overflows and OVF is set to 1. At the same time an internal reset
signal is generated for the entire chip. This internal reset signal clears OVF, but the WRST bit
remains set to 1. The reset routine must therefore contain an instruction that clears the WRST bit.
OVF
WDT
internal
reset
WRST
(1) Contention between Timer Counter (TCNT) Write and Increment: If a timer counter
clock pulse is generated during the T3 state of a write cycle to the timer counter, the write takes
priority and the timer counter is not incremented. See figure 13-8.
T1 T2 T3
TCNT
TCNT N M
(2) Changing CKS2 to CKS0 Values: Software should stop the watchdog timer (by clearing the
TME bit to 0) before changing the values of bits CKS2 to CKS0 in the timer control/status register
(TCSR).
14.1 Overview
The H8/539F has an on-chip serial communication interface (SCI) with three independent
channels. All channels are functionally identical. The SCI supports both asynchronous and
clocked synchronous serial communication. It also has a multiprocessor communication function
for serial communication among two or more processors.
14.1.1 Features
In the H8/539F, SCI2 and SCI3 have the same interrupt vectors.
SCR
φ
RSR TSR SMR Baud rate φ//4
RXD
generator φ/16
Transmit/ φ/64
receive control
TXD
Parity generation Clock
Parity check
External clock
SCK
TEI
TXI
Legend RXI
RSR: Receive shift register ERI
RDR: Receive data register
TSR: Transmit shift register
TDR: Transmit data register
SMR: Serial mode register
SCR: Serial control register
SSR: Serial status register
BRR: Bit rate register
Table 14-1 summarizes the serial communication pins for each SCI channel.
Table 14-2 summarizes the SCI registers. These registers select the communication mode
(asynchronous or clocked synchronous), specify the data format and bit rate, and control the
transmitter and receiver sections.
Bit 7 6 5 4 3 2 1 0
R/W − − − − − − − −
Data input at the RXD pin are loaded into RSR in the order received, LSB (bit 0) first. In this way
the SCI converts received data to parallel form. When one byte has been received, it is
automatically transferred to the receive data register (RDR). The H8/500 CPU cannot read or
write RSR directly.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R R R R R R R R
The SCI completes the reception of one byte of serial data by moving the received data from the
receive shift register (RSR) into RDR for storage. RSR is then ready to receive the next data.
This double buffering allows the SCI to receive data continuously.
The H8/500 CPU can read but not write RDR. RDR is initialized to H'00 by a reset and in the
standby modes.
Bit 7 6 5 4 3 2 1 0
R/W − − − − − − − −
The SCI loads transmit data from the transmit data register (TDR) into TSR, then transmits the
data serially from the TXD pin, LSB (bit 0) first. After transmitting one data byte, the SCI
automatically loads the next transmit data from TDR into TSR and starts transmitting again. If
TDRE is set to 1, however, the SCI does not load the TDR contents into TSR. The H8/500 CPU
cannot read or write TSR directly.
The transmit data register (TDR) is an eight-bit register that stores data for serial transmission.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 1 1 1 1
R/W R/W R/W R/W R/W R/W R/W R/W R/W
When the SCI detects that the transmit shift register (TSR) is empty, it moves transmit data written
in TDR into TSR and starts serial transmission. Continuous serial transmission is possible by
writing the next transmit data in TDR during serial transmission from TSR.
The H8/500 CPU can always read and write TDR. TDR is initialized to H'FF by a reset and in the
standby modes.
The serial mode register (SMR) is an eight-bit register that specifies the SCI serial communication
format and selects the clock source for the baud rate generator.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
Parity mode
Selects even or odd parity
Parity enable
Selects whether data includes a parity bit
Character length
Selects data length in asynchronous mode
Communication mode
Selects asynchronous or clocked synchronous mode
The H8/500 CPU can always read and write SMR. SMR is initialized to H'00 by a reset and in the
standby modes.
Bit 7
$
C/$ Description
0 Asynchronous mode (Initial value)
1 Clocked synchronous mode
Bit 6—Character Length (CHR): Selects seven-bit or eight-bit data in asynchronous mode. In
clocked synchronous mode the data length is always eight bits, regardless of the CHR setting.
Bit 6
CHR Description
0 Eight-bit data (Initial value)
1 Seven-bit data*
Note: * When seven-bit data is selected, the MSB of the transmit data register (bit 7) is not
transmitted.
Bit 5—Parity Enable (PE): Selects whether to add a parity bit to transmit data and check parity
of receive data, in asynchronous mode. In clocked synchronous mode the parity bit is neither
added nor checked, regardless of the PE setting.
Bit 5
PE Description
0 Parity bit not added or checked (Initial value)
1 Parity bit added and checked*
Note: * When PE is set to 1 an even or odd parity bit is added to transmit data, depending on the
parity mode (O/() setting. Receive data parity is checked according to the even/odd (O/()
mode setting.
Bit 4
(
O/( Description
1
0 Even parity* (Initial value)
2
1 Odd parity*
Notes: 1. If even parity is selected, the parity bit added to transmit data makes an even number of
1s in the transmitted character and parity bit combined. Receive data must have an
even number of 1s in the received character and parity bit combined.
2. If odd parity is selected, the parity bit added to transmit data makes an odd number of
1s in the transmitted character and parity bit combined. Receive data must have an
odd number of 1s in the received character and parity bit combined.
Bit 3—Stop Bit Length (STOP): Selects one or two bits as the stop bit length in asynchronous
mode. This setting is used only in asynchronous mode. It is ignored in clocked synchronous
mode because no stop bits are added.
Bit 3
STOP Description
1
0 One stop bit* (Initial value)
2
1 Two stop bits*
Notes: 1. In transmitting, a single 1 bit (Stop bit) is added at the end of each transmitted
character.
2. In transmitting, two 1 bits (Stop bit) are added at the end of each transmitted character.
In receiving, only the first stop bit is checked, regardless of the STOP bit setting. If the second
stop bit is 1 it is treated as a stop bit. If the second stop bit is 0 it is treated as the start bit of the
next incoming character.
Bit 2
MP Description
0 Multiprocessor function disabled (Initial value)
1 Multiprocessor format selected
Bits 1 and 0—Clock Select 1 and 0 (CKS1/0): These bits select the internal clock source of the
on-chip baud rate generator. Four clock sources are available: φ, φ/4, φ/16, and φ/64. For further
information on the clock source, bit rate register settings, and bit rate, see section 14.2.8, "Bit Rate
Register."
Bit 1 Bit 0
CKS1 CKS0 Description
0 0 System clock (φ) (Initial value)
0 1 φ/4
1 0 φ/16
1 1 φ/64
The serial control register (SCR) enables the SCI transmitter and receiver, selects serial clock
output in asynchronous mode, enables and disables interrupts, and selects the transmit/receive
clock.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
Transmit enable
Enables and disables the transmitter
Receive interrupt enable
Enables and disables receive-data-full interrupts (RXI)
and receive error interrupts (ERI)
The H8/500 CPU can always read and write SCR. SCR is initialized to H'00 by a reset and in the
standby modes.
Bit 7
TIE Description
0 Transmit-data-empty interrupt request (TXI) is disabled* (Initial value)
1 Transmit-data-empty interrupt request (TXI) is enabled
Note: * The TXI interrupt request can be cleared by reading TDRE after it has been set to 1, then
clearing TDRE to 0, or by clearing TIE to 0.
Bit 6-Receive Interrupt Enable (RIE): Enables or disables the receive-data-full interrupt (RXI)
requested when the receive data register full bit (RDRF) in the serial status register (SSR) is set to
1 due to transfer of serial receive data from RSR to RDR. Also enables or disables receive-error
interrupt (ERI) requests.
Bit 6
RIE Description
0 Receive-data-full interrupt (RXI) and receive-error interrupt (ERI) (Initial value)
requests are disabled*
1 Receive-data-full interrupt (RXI) and receive-error interrupt (ERI)
requests are enabled
Note: * RXI and ERI interrupt requests can be cleared by reading the RDRF flag or error flag (FER,
PER, or ORER) after it has been set to 1, then clearing the flag to 0, or by clearing RIE to 0.
Bit 5
TE Description
1
0 Transmitter disabled* , TXD pin available for general-purpose I/O (Initial value)
2
1 Transmitter enabled* , TXD used for transmit data output
Notes: 1. The transmit data register empty bit (TDRE) in the serial status register (SSR) is locked
at 1.
2. Serial transmitting starts when the transfer data register empty (TDRE) bit in the serial
status register (SSR) is cleared to 0 after writing of transmit data into TDR. Select the
transmit format in SMR before setting TE to 1.
Bit 4
RE Description
1
0 Receiver disabled* , RXD pin available for general-purpose I/O (Initial value)
2
1 Receiver enabled* , RXD used for receive data input
Notes: 1. Clearing RE to 0 does not affect the receive flags (RDRF, FER, PER, ORER). These
flags retain their previous values.
2. Serial receiving starts when a start bit is detected in asynchronous mode, or serial clock
input is detected in clocked synchronous mode. Select the receive format in SMR
before setting RE to 1.
Bit 3
MPIE Description
0 Multiprocessor interrupts are disabled (normal receive operation) (Initial value)
1 Multiprocessor interrupts are enabled.*
Until data is received in which the multiprocessor bit set to 1
receive-data-full interrupt requests (RXI), receive-error interrupt
requests (ERI), and setting of the RDRF, FER, and ORER status
flags in the serial status register (SSR) are disabled.
MPIE is cleared to 0 when:
1. MPIE is cleared to 0, or
2. Multiprocessor bit (MPB) is set to 1 in receive data.
Note: * The SCI does not transfer receive data from RSR to RDR, does not detect receive errors,
and does not set the RDRF, FER, and ORER flags in the serial status register (SSR).
When it receives data with the multiprocessor bit (MPB) set to 1, the SCI automatically
clears MPIE to 0, enables RXI and ERI interrupts (if the TIE and RIE bits in SCR are set to
1), and allows FER and ORER to be set.
Bit 2
TEIE Description
0 Transmit-end interrupt (TEI) requests are disabled* (Initial value)
1 Transmit-end interrupt (TEI) requests are enabled*
Note: * The TEI request can be cleared by reading the TDRE bit in the serial status register (SSR)
after it has been set to 1, then clearing TDRE to 0, thereby clearing the transmit end
(TEND) bit to 0; or by clearing the TEIE bit to 0.
Bits 1 and 0-Clock Enable 1 and 0 (CKE1/0): These bits select the SCI clock source and enable
or disable clock output from the SCK pin. Depending on the combination of CKE1 and CKE0,
the SCK pin can be used for general-purpose input/output, serial clock output, or serial clock
input.
The CKE0 setting is valid only in asynchronous mode, and only when the SCI is internally
clocked (CKE1 = 0). The CKE0 setting is ignored in clocked synchronous mode, or when an
external clock source is selected (CKE1 = 1). Select the SCI operating mode in the serial mode
register (SMR) before setting CKE1 and CKE0. For further details on selection of the SCI clock
source, see table 14-9 in section 14.3, "Operation."
Bit 1 Bit 0
CKE1 CKE0 Description
0 0 Asynchronous mode Internal clock, SCK pin available for general-
1
purpose input/output*
Clocked synchronous mode Internal clock, SCK pin used for serial clock
1
output*
2
0 1 Asynchronous mode Internal clock, SCK pin used for clock output*
Clocked synchronous mode Internal clock, SCK pin used for serial clock
output
3
1 0 Asynchronous mode External clock, SCK pin used for clock input*
Clocked synchronous mode External clock, SCK pin used for serial clock input
3
1 1 Asynchronous mode External clock, SCK pin used for clock input*
Clocked synchronous mode External clock, SCK pin used for serial clock input
Notes: 1. Initial value
2. The output clock frequency is the same as the bit rate.
3. The input clock frequency is 16 times the bit rate.
The serial status register (SSR) is an eight-bit register containing multiprocessor bit values, and
status flags that indicate SCI operating status.
The H8/500 CPU can always read and write SSR, but cannot write 1 in the status flags (TDRE,
RDRF, ORER, PER, and FER). These flags can be cleared to 0 only if they have first been read
after being set to 1. Bits 2 (TEND) and 1 (MPB) are read-only bits and cannot be written.
Bit 7 6 5 4 3 2 1 0
Initial value 1 0 0 0 0 1 0 0
R/W R/(W)* R/(W)* R/(W)* R/(W)* R/(W)* R R R/W
Multiprocessor
bit transfer
Value of multi-
processor bit to
be transmitted
Multiprocessor bit
Stores received multi-
processor bit value
Transmit end
Status flag indicating end
of transmission
Parity error
Status flag indicating detection
of a receive parity error
Framing error
Status flag indicating detection of a receive
framing error
Overrun error
Status flag indicating detection of a receive overrun error
Receive data register full
Status flag indicating that the SCI has stored receive data in RDR
Transmit data register empty
Status flag indicating that the SCI has loaded transmit data
from TDR into TSR and new data can be written in TDR
Note: * Software can write 0 to clear the flag, but cannot write 1.
Bit 7
TDRE Description
0 TDR contains valid transmit data
TDRE is cleared to 0 when:
1. Software reads TDRE after it has been set to 1, then writes 0 in TDRE
2. The DTC writes data in TDR
1 TDR does not contain valid transmit data (Initial value)
TDRE is set to 1 when:
1. The chip is reset or enters standby mode
2. The TE bit in the serial control register (SCR) is cleared to 0, or
3. TDR contents are loaded into TSR, so new data can be written in TDR
Bit 6—Receive Data Register Full (RDRF): Indicates that RDR contains new receive data.
Bit 6
RDRF Description
0 RDR does not contain new receive data (Initial value)
RDRF is cleared to 0 when:
1. The chip is reset or enters standby mode
2. Software reads RDRF after it has been set to 1, then writes 0 in RDRF
3. The DTC reads data from RDR
1 RDR contains new receive data
RDRF is set to 1 when serial data are received normally and transferred from RSR
to RDR.
Note: RDR and RDRF are not affected by detection of receive errors or by clearing of the RE bit
to 0 in the serial control register. They retain their previous contents. If RDRF is still set to
1 when reception of the next data ends, an overrun error (ORER) occurs and receive data
is lost.
Bit 5
ORER Description
1
0 Receiving is in progress or has ended normally (Initial value)*
ORER is cleared to 0 when:
1. The chip is reset or enters standby mode
2. Software reads ORER after it has been set to 1, then writes 0 in ORER
2
1 A receive overrun error occurred*
ORER is set to 1 if reception of the next serial data ends when RDRF is set to 1
Notes: 1. Clearing the RE bit to 0 in the serial control register does not affect the ORER bit, which
retains its previous value.
2. RDR continues to hold the receive data before the overrun error, so subsequent receive
data are lost. Serial receiving cannot continue while ORER is set to 1. In clocked
synchronous mode, serial transmitting is also disabled.
Bit 4—Framing Error (FER): Indicates that data reception ended abnormally due to a framing
error in asynchronous mode.
Bit 4
FER Description
1
0 Receiving is in progress or has ended normally (Initial value)*
FER is cleared to 0 when:
1. The chip is reset or enters standby mode
2. Software reads FER after it has been set to 1, then writes 0 in FER
1 A receive framing error occurred
FER is set to 1 if the stop bit at the end of receive data is checked and found to be
2
0* .
Notes: 1. Clearing the RE bit to 0 in the serial control register does not affect the FER bit, which
retains its previous value.
2. When the stop bit length is two bits, only the first bit is checked. The second stop bit is
not checked. When a framing error occurs the SCI transfers the receive data into RDR
but does not set RDRF. Serial receiving cannot continue while FER is set to 1. In
clocked synchronous mode, serial transmitting is also disabled.
Bit 3
PER Description
1
0 Receiving is in progress or has ended normally)* (Initial value)
PER is cleared to 0 when:
1. The chip is reset or enters standby mode
2. Software reads PER after it has been set to 1, then writes 0 in PER
2
1 A receive parity error occurred* .
PER is set to 1 if the number of 1s in receive data, including the parity bit, does not
match the even or odd parity setting of the parity mode bit (O/E) in the serial mode
register (SMR).
Notes: 1. Clearing the RE bit to 0 in the serial control register does not affect the PER bit, which
retains its previous value.
2. When a parity error occurs the SCI transfers the receive data into RDR but does not set
RDRF. Serial receiving cannot continue while PER is set to 1. In clocked synchronous
mode, serial transmitting is also disabled.
Bit 2—Transmit End (TEND): Indicates that when the last bit of a serial character was
transmitted TDR did not contain new transmit data, so transmission has ended. TEND is a read-
only bit and cannot be written.
Bit 2
TEND Description
0 Transmission is in progress
TEND is cleared to 0 when:
1. Software reads TDRE after it has been set to 1, then writes 0 in TDRE
2. The DTC writes data in TDR
1 End of transmission (Initial value)
TEND is set to 1 when:
1. The chip is reset or enters standby mode
2. TE is cleared to 0 in the serial control register (SCR)
3. TDRE is 1 when the last bit of a serial character (1 byte) is transmitted
Bit 1
MPB Description
0 Multiprocessor bit value in receive data is 0* (Initial value)
1 Multiprocessor bit value in receive data is 1
Note: * If RE is cleared to 0 when a multiprocessor format is selected, MPB retains its previous
value.
Bit 0—Multiprocessor Bit Transfer (MPBT): Stores the value of the multiprocessor bit added to
transmit data when a multiprocessor format is selected for transmitting in asynchronous mode.
The MPBT setting is ignored in clocked synchronous mode, when a multiprocessor format is not
selected, or when the SCI is not transmitting.
Bit 0
MPBT Description
0 Multiprocessor bit value in transmit data is 0 (Initial value)
1 Multiprocessor bit value in transmit data is 1
The bit rate register (BRR) is an eight-bit register that, together with the CKS1 and CKS0 bits in
the serial mode register (SMR) that select the baud rate generator clock source, determines the
serial transmit/receive bit rate.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 1 1 1 1
R/W R/W R/W R/W R/W R/W R/W R/W R/W
The H8/500 CPU can always read and write BRR. BRR is initialized to H'FF by a reset and in the
standby modes. SCI1 and SCI2 have independent baud rate generator control, so different values
can be set in the two channels.
Table 14-3 Examples of Bit Rates and BRR Settings in Asynchronous Mode (1)
φ (MHz)
1 1.2288 2 2.097152
Bit Rate Error Error Error Error
(bits/s) n N (%) n N (%) n N (%) n N (%)
110 1 70 +0.03 1 86 +0.31 1 141 +0.03 1 148 -0.04
150 0 207 +0.16 0 255 0 1 103 +0.16 1 108 +0.21
300 0 103 +0.16 0 127 0 0 207 +0.16 0 217 +0.21
600 0 51 +0.16 0 63 0 0 103 +0.16 0 108 +0.21
1200 0 25 +0.16 0 31 0 0 51 +0.16 0 54 -0.70
2400 0 12 +0.16 0 15 0 0 25 +0.16 0 26 +1.14
4800 − − − 0 7 0 0 12 +0.16 0 13 -2.48
9600 − − − 0 3 0 − − − − − −
19200 − − − 0 1 0 − − − − − −
31250 0 0 0.00 − − − 0 1 0 − − −
38400 − − − 0 0 0 − − − − − −
φ (MHz)
2.4576 3 3.6864 4
Bit Rate Error Error Error Error
(bits/s) n N (%) n N (%) n N (%) n N (%)
110 1 174 -0.26 1 212 +0.03 2 64 +0.70 2 70 +0.03
150 1 127 0 1 155 +0.16 1 191 0 1 207 +0.16
300 0 255 0 1 77 +0.16 1 95 0 1 103 +0.16
600 0 127 0 0 155 +0.16 0 191 0 0 207 +0.16
1200 0 63 0 0 77 +0.16 0 95 0 0 103 +0.16
2400 0 31 0 0 38 +0.16 0 47 0 0 51 +0.16
4800 0 15 0 0 19 -2.34 0 23 0 0 25 +0.16
9600 0 7 0 0 9 -2.34 0 11 0 0 12 +0.16
19200 0 3 0 0 4 -2.34 0 5 0 − − −
31250 − − − 0 2 0 − − − 0 3 0
38400 0 1 0 − − − 0 2 0 − − −
Table 14-3 Examples of Bit Rates and BRR Settings in Asynchronous Mode (3)
φ (MHz)
4.9152 5 6 6.144
Bit Rate Error Error Error Error
(bits/s) n N (%) n N (%) n N (%) n N (%)
110 2 86 +0.31 2 88 -0.25 2 106 -0.44 2 108 +0.08
150 1 255 0 2 64 +0.16 2 77 0 2 79 0
300 1 127 0 1 129 +0.16 1 155 0 1 159 0
600 0 255 0 1 64 +0.16 1 77 0 1 79 0
1200 0 127 0 0 129 +0.16 0 155 +0.16 0 159 0
2400 0 63 0 0 64 +0.16 0 77 +0.16 0 79 0
4800 0 31 0 0 32 -1.36 0 38 +0.16 0 39 0
9600 0 15 0 0 15 +1.73 0 19 -2.34 0 19 0
19200 0 7 0 0 7 +1.73 − − − 0 9 0
31250 0 4 -1.70 0 4 0 0 5 0 0 5 +2.40
38400 0 3 0 0 3 +1.73 − − − 0 4 0
φ (MHz)
7.3728 8 9.8304 10
Bit Rate Error Error Error Error
(bits/s) n N (%) n N (%) n N (%) n N (%)
110 2 130 -0.07 2 141 +0.03 2 174 -0.26 3 43 +0.88
150 2 95 0 2 103 +0.16 2 127 0 2 129 +0.16
300 1 191 0 1 207 +0.16 1 255 0 2 64 +0.16
600 1 95 0 1 103 +0.16 1 127 0 1 129 +0.16
1200 0 191 0 0 207 +0.16 0 255 0 1 64 +0.16
2400 0 95 0 0 103 +0.16 0 127 0 0 129 +0.16
4800 0 47 0 0 51 +0.16 0 63 0 0 64 +0.16
9600 0 23 0 0 25 +0.16 0 31 0 0 32 -1.36
19200 0 11 0 0 12 +0.16 0 15 0 0 15 +1.73
31250 − − − 0 7 0 0 9 -1.70 0 9 0
38400 0 5 0 − − − 0 7 0 0 7 +1.73
307200 − − − − − − 0 0 0 − − −
312500 − − − − − − − − − 0 0 0
φ (MHz)
12 12.288 14 14.7456
Bit Rate Error Error Error Error
(bits/s) n N (%) n N (%) n N (%) n N (%)
110 2 212 0.03 2 217 0.08 2 248 - 0.17 3 64 0.07
150 2 155 0.16 2 159 0.00 2 181 0.16 2 191 0.00
300 2 77 0.16 2 79 0.00 2 90 0.16 2 95 0.00
600 1 155 0.16 1 159 0.00 1 181 0.16 1 191 0.00
1200 1 77 0.16 1 79 0.00 1 90 0.16 1 95 0.00
2400 0 155 0.16 0 159 0.00 0 181 0.16 0 191 0.00
4800 0 77 0.16 0 79 0.00 0 90 0.16 0 95 0.00
9600 0 38 0.16 0 39 0.00 0 45 -0.93 0 47 0.00
19200 0 19 -2.34 0 19 0.00 0 22 -0.93 0 23 0.00
31250 0 11 0.00 0 11 2.40 0 13 0.00 0 14 -1.70
38400 0 9 -2.34 0 9 0.00 0 10 3.57 0 11 0.00
φ (MHz)
16
Bit Rate Error
(bits/s) n N (%)
110 3 70 0.03
150 2 207 0.16
300 2 103 0.16
600 1 207 0.16
1200 1 103 0.16
2400 0 207 0.16
4800 0 103 0.16
9600 0 51 0.16
19200 0 25 0.16
31250 0 15 0.00
38400 0 12 0.16
Notes: 1. Settings with an error of 1% or less are recommended.
2. The BRR setting is calculated as follows:
N = [φ/(64 × 2 × B)] × 10 - 1
2n-1 6
B: Bit rate
N: BRR setting for baud rate generator (0 ≤ N ≤ 255)
φ: Operation frequency (MHz)
n: Baud rate generator clock source (n = 0, 1, 2, 3)
(For the clock sources and values of n, see table 14-4.)
SMR Settings
n Clock Source CKS1 CKS0
0 φ 0 0
1 φ/4 0 1
2 φ/16 1 0
3 φ/64 1 1
3. Error is calculated as follows:
Error (%) = {[φ × 10 / (N + 1) × B × 64 ] - 1} × 100
6 2n-1
Table 14-5 Maximum Bit Rates for Various Frequencies (Asynchronous Mode)
Settings
φ (MHz) Maximum Bit Rate (Bits/s) n N
1 31250 0 0
1.2288 38400 0 0
2 62500 0 0
2.097152 65536 0 0
2.4576 76800 0 0
3 93750 0 0
3.6864 115200 0 0
4 125000 0 0
4.9152 153600 0 0
5 156250 0 0
6 187500 0 0
6.144 192000 0 0
7.3728 230400 0 0
8 250000 0 0
9.8304 307200 0 0
10 312500 0 0
12 375000 0 0
12.288 384000 0 0
14 437500 0 0
14.7456 460800 0 0
16 500000 0 0
17.2032 537600 0 0
18 562500 0 0
19.6608 614400 0 0
20 625000 0 0
Table 14-7 Examples of Bit Rates and BRR Settings in Synchronous Mode
φ (MHz)
1 2 4 8 10 16
Bit Rate (Bits/s) n N n N n N n N n N n N
110 − − 3 70 − − − − − − − −
250 1 249 2 124 2 249 3 124 − − 3 249
500 1 124 1 249 2 124 2 249 − − 3 124
1k 0 249 1 124 1 249 1 124 − − 3 249
2.5 k 0 99 0 199 1 99 1 199 1 249 2 99
5k 0 49 0 99 0 199 1 99 1 124 1 199
10 k 0 24 0 49 0 99 0 199 0 249 1 99
25 k 0 9 0 19 0 39 0 79 0 99 0 159
50 k 0 4 0 9 0 19 0 39 0 49 0 79
100 k − − 0 4 0 9 0 19 0 24 0 39
250 k 0 0* 0 1 0 3 0 7 0 9 0 15
500 k 0 0* 0 1 0 3 0 4 0 7
1M 0 0* 0 1 − − 0 3
2.5 M − − 0 0* − −
Blank: No setting available
−: Setting possible, but error occurs
* : Continuous transmit/receive not possible
Note: The BRR setting is calculated as follows:
N = [φ/(8 × 2 × B)] × 10 - 1
2n-1 6
B: Bit rate
N: BRR setting for baud rate generator (0 ≤ N ≤ 255)
φ: Operation frequency (MHz)
n: Baud rate generator clock source (n = 0, 1, 2, 3)
(For the clock sources and values of n, see table 14-8.)
SMR Settings
n Clock Source CKS1 CKS0
0 φ 0 0
1 φ/4 0 1
2 φ/16 1 0
3 φ/64 1 1
14.3.1 Overview
The SCI has an asynchronous mode in which characters are synchronized individually, and a
clocked synchronous mode in which communication is synchronized with clock pulses. Serial
communication is possible in either mode. Asynchronous or clocked synchronous mode and the
communication format are selected in the serial mode register (SMR), as shown in table 14-9. The
SCI clock source is selected by the C/$ bit in the serial mode register (SMR) and the CKE1 and
CKE0 bits in the serial control register (SCR), as shown in table 14-10.
Table 14-10 SMR and SCR Settings and SCI Clock Source Selection
In asynchronous mode each transmitted or received character begins with a start bit and ends with
a stop bit. Serial communication is synchronized one character at a time.
The transmitting and receiving sections of the SCI are independent, so full duplex communication
is possible. The transmitter and receiver are both double buffered, so data can be written and read
while transmitting and receiving are in progress, enabling continuous transmitting and receiving.
Figure 14-2 shows the general format of asynchronous serial communication. In asynchronous
serial communication the communication line is normally held in the mark (high) state. The SCI
monitors the line and starts serial communication when the line goes to the space (low) state,
indicating a start bit. One serial character consists of a start bit (low), data (LSB first), parity bit
(high or low), and stop bit (high), in that order.
When receiving in asynchronous mode, the SCI synchronizes on the falling edge of the start bit.
The SCI samples each data bit on the eighth pulse of a clock with a frequency 16 times the bit rate.
Receive data is latched at the center of each bit.
CHR PE MP STOP 1 2 3 4 5 6 7 8 9 10 11 12
When an external clock is input at the SCK pin, it must have a frequency equal to 16 times the
desired bit rate.
When the SCI operates on an internal clock, it can output a clock signal at the SCK pin. The
frequency of this output clock is equal to the bit rate. The phase is aligned as in figure 14-3 so that
the rising edge of the clock occurs at the center of each transmit data bit.
SCK
Serial 0 D0 D1 D2 D3 D4 D5 D6 D7 0/1 1 1
data
1 frame
Figure 14-3 Phase Relationship between Output Clock and Serial Data
(Asynchronous Mode)
SCI Initialization (Asynchronous Mode): Before transmitting or receiving, software must clear
the TE and RE bits to 0 in the serial control register (SCR), then initialize the SCI as follows.
When changing the communication mode or format, always clear the TE and RE bits to 0 before
following the procedure given below. Clearing TE to 0 sets TDRE to 1 and initializes the transmit
shift register (TSR). Clearing RE to 0, however, does not initialize the RDRF, PER, FER, and
OER flags and receive data register (RDR), which retain their previous contents.
When an external clock is used, the clock should not be stopped during initialization or subsequent
operation. SCI operation becomes unreliable if the clock is stopped.
No
1 bit interval elapsed?
(2) Read TDRE bit in SSR (2) SCI status check and transmit data
write: read the serial status
register (SSR), check that the
No TDRE bit is 1, then write transmit
TDRE = 1?
data in the transmit data register
Yes (TDR) and clear TDRE to 0.
No
(3) All data transmitted? (3) To continue transmitting serial
data: read the TDRE bit to check
Yes whether it is safe to write; if so,
write data in TDR, then clear
TDRE to 0. When the DTC is
Read TEND bit in SSR started by a transmit-data-empty
interrupt request (TXI) to write data
in TDR, the TDRE bit is checked
No and cleared automatically.
TEND = 1?
Yes
No
(4) Output break signal? (4) To output a break signal at the end
of serial transmission: set the DDR
Yes bit to 1 and the DR bit to 0 (DDR
and DR are I/O port registers),
Set DR = 0, DDR = 1 then clear TE to 0 in SCR.
End
1. The SCI monitors the TDRE bit in SSR. When TDRE is cleared to 0 the SCI recognizes that
the transmit data register (TDR) contains new data, and loads this data from TDR into the
transmit shift register (TSR).
2. After loading the data from TDR into TSR, the SCI sets the TDRE bit to 1 and starts
transmitting. If the transmit-data-empty interrupt enable bit (TIE) is set to 1 in SCR, the SCI
requests a transmit-data-empty interrupt (TXI) at this time.
Serial transmit data is transmitted in the following order from the TXD pin:
a. Start bit: one 0 bit is output.
b. Transmit data: seven or eight bits are output, LSB first.
c. Parity bit or multiprocessor bit: one parity bit (even or odd parity) or one multiprocessor bit
is output. Formats in which neither a parity bit nor a multiprocessor bit is output can also
be selected.
d. Stop bit: one or two 1 bits (stop bits) are output.
e. Mark state: output of 1 bits continues until the start bit of the next transmit data.
3. The SCI checks the TDRE bit when it outputs the stop bit. If TDRE is 0, the SCI loads new
data from TDR into TSR, outputs the stop bit, then begins serial transmission of the next
frame. If TDRE is 1, the SCI sets the TEND bit to 1 in SSR, outputs the stop bit, then
continues output of 1 bits in the mark state. If the transmit-end interrupt enable bit (TEIE) in
SCR is set to 1, a transmit-end interrupt (TEI) is requested.
TDRE
TEND
1 frame
End
Yes
ORER = 1?
Yes
Break?
No
Yes
FER = 1? No
Framing error
No handling
Yes
PER = 1?
No
Parity error
Clear ORER, PER, Clear RE to 0 in SCR
handling
and FER to 0 in SSR
End
RTS
1. The SCI monitors the receive data line. When it detects a start bit 0, the SCI synchronizes
internally and starts receiving.
2. Receive data is shifted into RSR in order from LSB to MSB.
3. The parity bit and stop bit are received.
After receiving these bits, the SCI makes the following checks:
a. Parity check: the number of 1s in the receive data must match the even or odd parity setting
of the O/( bit in SMR.
b. Stop bit check: the stop bit value must be 1. If there are two stop bits, only the first stop bit
is checked.
c. Status check: RDRF must be 0 so that receive data can be loaded from RSR into RDR.
If these checks all pass, the SCI sets RDRF to 1 and stores the received data in RDR. If one of
the checks fails (receive error), the SCI operates as indicated in table 14-12.
Note: When a receive error flag is set, further receiving is disabled. When receiving resumes
after an error flag was set, the RDRF bit is not set to 1.
4. After setting RDRF to 1, if the receive-data-full interrupt enable bit (RIE) is set to 1 in SCR,
the SCI requests a receive-data-full interrupt (RXI). If one of the error flags (ORER, PER, or
FER) is set to 1 and the receive-data-full interrupt enable bit (RIE) in SCR is also set to 1, the
SCI requests a receive-error interrupt (ERI).
Rev. 3.0, 02/99, page 427 of 904
Figure 14-8 shows an example of SCI receive operation in asynchronous mode.
RDRF
FER
In clocked synchronous mode, the SCI transmits and receives data in synchronization with clock
pulses. This mode is suitable for high-speed serial communication.
The SCI transmitter and receiver share the same clock but are otherwise independent, so full
duplex communication is possible. The transmitter and receiver are also double buffered, so
continuous transmitting or receiving is possible by reading or writing data while transmitting or
receiving is in progress.
Figure 14-9 shows the general format in clocked synchronous serial communication.
Rev. 3.0, 02/99, page 428 of 904
Transfer direction
* *
Serial clock
LSB MSB
Serial
Don't care Bit 0 Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 Don't care
data
In clocked synchronous serial communication, each data bit is placed on the communication line
from one falling edge of the serial clock to the next. Data is guaranteed valid at the rising edge of
the serial clock. In each character, the serial data bits are transmitted in order from LSB (first) to
MSB (last). After output of the MSB, the communication line remains in the state of the MSB. In
clocked synchronous mode the SCI receives data by synchronizing with the rising edge of the
serial clock.
(1) Communication Format: The data length is fixed at eight bits. No parity bit or
multiprocessor bit can be added.
(2) Clock: An internal clock generated by the on-chip baud rate generator or an external clock
input from the SCK pin can be selected according to the setting of the C/$ bit in the serial mode
register (SMR) and the CKE1 and CKE0 bits in the serial control register (SCR). See table 14-9.
When the SCI operates on an internal clock, it outputs the clock signal at the SCK pin. Eight
clock pulses are output per transmitted or received character. When the SCI is not transmitting or
receiving, the clock signal remains in the high state.
When changing the communication mode or format, always clear the TE and RE bits to 0 before
following the procedure given below. Clearing TE to 0 sets TDRE to 1 and initializes the transmit
shift register (TSR). Clearing RE to 0, however, does not initialize the RDRF, PER, FER, and
ORER flags and receive data register (RDR), which retain their previous contents.
Start of initialization
Wait
(4) Wait for at least the interval
required to transmit or receive one
No
1 bit interval elapsed? bit, then set TE or RE to 1 in the
serial control register (SCR). Also
set RIE, TIE, TEIE, and MPIE as
Yes necessary. Setting TE or RE
enables the SCI to use the TXD or
Set TE or RE to 1 in SCR RXD pin.
(4) Set RIE, TIE, TEIE, and MPIE
as necessary
Start transmitting
or receiving
End
1. The SCI monitors the TDRE bit in SSR. When TDRE is cleared to 0 the SCI recognizes that
the transmit data register (TDR) contains new data, and loads this data from TDR into the
transmit shift register (TSR).
2. After loading the data from TDR into TSR, the SCI sets the TDRE bit to 1 and starts
transmitting. If the transmit-data-empty interrupt enable bit (TIE) in SCR is set to 1, the SCI
requests a transmit-data-empty interrupt (TXI) at this time.
If clock output is selected, the SCI outputs eight serial clock pulses. If an external clock
source is selected, the SCI outputs data in synchronization with the input clock. Data is output
from the TXD pin in order from LSB (bit 0) to MSB (bit 7).
3. The SCI checks the TDRE bit when it outputs the MSB (bit 7). If TDRE is 0, the SCI loads
data from TDR into TSR and begins serial transmission of the next frame. If TDRE is 1, the
SCI sets the TEND bit in SSR to 1, and after transmitting the MSB, holds the transmit data pin
(TXD) in the MSB state. If the transmit-end interrupt enable bit (TEIE) in SCR is set to 1, a
transmit-end interrupt (TEI) is requested at this time.
4. After the end of serial transmission, the SCK pin is held in the high state.
Serial
clock
Serial
Bit 0 Bit 1 Bit 7 Bit 0 Bit 1 Bit 6 Bit 7
data
TDRE
TEND
1 frame
Clear RE to 0 in SCR
End
(3) Start of error
handling
Yes
ORER = 1?
Overrun error
No handling
Clear ORER to 0
in SSR
RTS
1. The SCI synchronizes with serial clock input or output and initializes internally.
2. Receive data is shifted into RSR in order from LSB to MSB.
After receiving the data, the SCI checks that RDRF is 0 so that receive data can be loaded from
RSR into RDR. If this check passes, the SCI sets RDRF to 1 and stores the received data in
RDR. If the check does not pass (receive error), the SCI operates as indicated in table 14-12.
Note: Both transmitting and receiving are disabled while a receive error flag is set. The
RDRF bit is not set to 1. Be sure to clear the error flag.
3. After setting RDRF to 1, if the receive-data-full interrupt enable bit (RIE) is set to 1 in SCR,
the SCI requests a receive-data-full interrupt (RXI). If the ORER bit is set to 1 and the
receive-data-full interrupt enable bit (RIE) in SCR is also set to 1, the SCI requests a receive-
error interrupt (ERI).
Transmit direction
Serial
clock
Serial
Bit 7 Bit 0 Bit 7 Bit 0 Bit 1 Bit 6 Bit 7
data
RDRF
ORER
1 frame
(1) Initialize * (1) SCI initialization: the transmit data output function of the TXD
pin and receive data input function of the RXD pin are
selected, enabling simultaneous transmitting and receiving.
Start transmitting
and receiving
(2) SCI status check and transmit data write: read the serial
status register (SSR), check that the TDRE bit is 1, then write
(2) Read TDRE bit in SSR transmit data in the transmit data register (TDR) and clear
TDRE to 0.
Yes
ORER = 1?
No (3)
Yes
The multiprocessor communication function enables several processors to share a single serial
communication line. The processors communicate in asynchronous mode using a format with an
additional multiprocessor bit (multiprocessor format).
The transmitting processor should start by sending the ID of the receiving processor with which it
wants to communicate as data with the multiprocessor bit set to 1. Next the transmitting processor
should send transmit data with the multiprocessor bit cleared to 0.
When a receiving processor receives data with the multiprocessor bit set to 1, if multiprocessor
interrupts are enabled, an interrupt is requested. The interrupt-handling routine should compare
the data with the processor's own ID. If the ID matches, the processor should continue to receive
data. If the ID does not match, the processor should skip further incoming data until it again
receives data with the multiprocessor bit set to 1. Multiple processors can send and receive data in
this way.
(1) Communication Formats: Four formats are available. Parity-bit settings are ignored when a
multiprocessor format is selected. For details see table 14-9.
Transmitting Multiprocessor Serial Data: Figure 14-17 shows a sample flowchart for
transmitting multiprocessor serial data and indicates the procedure to follow.
(2) Read TDRE bit in SSR (2) SCI status check and transmit data
write: read the serial status register
(SSR), check that the TDRE bit is 1,
No then write transmit data in the
TDRE=1? transmit data register (TDR). Also
Yes set MPBT (multiprocessor bit
transfer) to 0 or 1 in SSR. Finally,
Write transmit data in TDR
clear TDRE to 0.
and set MPBT in SSR
No
(3) All data transmitted? (3) To continue transmitting serial data:
Yes read the TDRE bit to check whether
it is safe to write; if so, write data in
TDR, then clear TDRE to 0. When
Read TEND bit in SSR the DTC is started by a transmit-
data-empty interrupt request (TXI)
No to write data in TDR, the TDRE bit is
TEND=1? checked and cleared automatically.
Yes
No
(4) To output a break signal at the end
(4) Output break signal?
of serial transmission: set the DDR
Yes bit to 1 and the DR bit to 0 (DDR
and DR are I/O port registers), then
clear TE to 0 in SCR.
Set DR = 0, DDR = 1
End
1. The SCI monitors the TDRE bit in SSR. When TDRE is cleared to 0 the SCI recognizes that
the transmit data register (TDR) contains new data, and loads this data from TDR into the
transmit shift register (TSR).
2. After loading the data from TDR into TSR, the SCI sets the TDRE bit to 1 and starts
transmitting. If the transmit-data-empty interrupt enable bit (TIE) in SCR is set to 1, the SCI
requests a transmit-data-empty interrupt (TXI) at this time.
Serial transmit data is transmitted in the following order from the TXD pin:
a. Start bit: one 0 bit is output.
b. Transmit data: seven or eight bits are output, LSB first.
c. Multiprocessor bit: one multiprocessor bit (MPBT value) is output.
d. Stop bit: one or two 1 bits (stop bits) are output.
e. Mark state: output of 1 bits continues until the start bit of the next transmit data.
3. The SCI checks the TDRE bit when it outputs the stop bit. If TDRE is 0, the SCI loads data
from TDR into TSR, outputs the stop bit, then begins serial transmission of the next frame. If
TDRE is 1, the SCI sets the TEND bit in SSR to 1, outputs the stop bit, then continues output
of 1 bits in the mark state. If the transmit-end interrupt enable bit (TEIE) in SCR is set to 1, a
transmit-end interrupt (TEI) is requested at this time.
Figure 14-18 shows an example of SCI transmit operation using a multiprocessor format.
RDRF
FER
No
RDRF = 1?
Yes
Read receive data from RDR
(5)
Error handling
No
Finished receiving?
Yes
Clear RE to 0 in SCR
End
No Yes
Yes Break?
FER = 1?
No No
Framing error Clear RE bit to
Clear ORER and FER handling? 0 in SCR
bits to 0 in SSR
End
RTS
Figure 14-19 Sample Flowchart for Receiving Multiprocessor Serial Data (cont)
MPIE
RDRF
MPB detection RXI generation RXI handler Not own ID, No RXI request,
MPIE = 0 reads RDR so MPIE is RDR not updated
data and set to 1 again
clears RDRF
to 0
(Multiprocessor interrupt)
MPIE
RDRF
MPB detection RXI generation RXI handler Own ID, so receiv- MPIE set to
MPIE = 0 reads RDR ing continues, with 1 again
data and data received at
clears RDRF each RXI
to 0
(Multiprocessor interrupt)
These interrupts can be enabled and disabled by the TIE, RIE bits in the serial control register
(SCR). Each interrupt request is sent separately to the interrupt controller. TXI is requested when
the TDRE bit in SSR is set to 1. TEI is requested when the TEND bit in SSR is set to 1. TXI can
start the data transfer controller (DTC) to transfer data. TDRE is automatically cleared to 0 when
the DTC executes the data transfer. TEI cannot start the DTC.
RXI is requested when the RDRF bit in SSR is set to 1. ERI is requested when the ORER, PER,
or FER bit in SSR is set to 1. RXI can start the DTC to transfer data. RDRF is automatically
cleared to 0 when the DTC executes the data transfer. ERI cannot start the DTC.
(1) TDR Write and TDRE: The TDRE bit in the serial status register (SSR) is a status flag
indicating loading of transmit data from TDR into TSR. The SCI sets TDRE to 1 when it transfers
data from TDR to TSR.
Data can be written into TDR regardless of the state of TDRE. If new data is written in TDR
when TDRE is 0, the old data stored in TDR will be lost because this data has not yet been
transferred to TSR. Before writing transmit data to TDR, be sure to check that TDRE is set to 1.
(2) Simultaneous Multiple Receive Errors: Table 14-14 indicates the state of SSR status flags
when multiple receive errors occur simultaneously. When an overrun error occurs the RSR
contents are not transferred to RDR, so receive data is lost.
(3) Break Detection and Processing: Break signals can be detected by reading the RXD pin
directly when a framing error (FER) is detected. In the break state the input from the RXD pin
consists of all 0s, so FER is set and the parity error flag (PER) may also be set. In the break state
the SCI receiver continues to operate, so if the FER bit is cleared to 0 it will be set to 1 again.
(4) Sending a Break Signal: When TE is cleared to 0 the TXD pin becomes an I/O port, the level
and direction (input or output) of which are determined by the DR and DDR bits. This feature can
be used to send a break signal.
After the serial transmitter is initialized, the DR value substitutes for the mark state until TE is set
to 1 (the TXD pin function is not selected until TE is set to 1). The DDR and DR bits should
therefore both be set to 1 beforehand.
To send a break signal during serial transmission, clear the DR bit to 0, then clear TE to 0. When
TE is cleared to 0 the transmitter is initialized, regardless of its current state, so the TXD pin
becomes I/O port outputting the value 0.
(5) Receive Error Flags and Transmitter Operation (Clocked Synchronous Mode Only):
When a receive error flag (ORER, PER, or FER) is set to 1, the SCI will not start transmitting
even if TDRE is set to 1. Be sure to clear the receive error flags to 0 when starting to transmit.
Note that clearing RE to 0 does not clear the receive error flags.
(6) Receive Data Sampling Timing in Asynchronous Mode and Receive Margin: In
asynchronous mode the SCI operates on an base clock with 16 times the bit rate frequency. In
receiving, the SCI synchronizes internally with the falling edge of the start bit, which it samples
on the base clock. Receive data is latched on the rising edge of the eighth base clock pulse. See
figure 14-21.
8 clocks
0 7 15 0 7 15 0
Internal base
clock
Synchronization
sampling timing
Data sampling
timing
The receive margin in asynchronous mode can therefore be expressed as in equation (1).
1 1 |D – 0.5|
M = {(0.5 – ) - (L – 0.5 – ) F- (1 + F)} × 100% ..................................... (1)
2N 2N N
M: Receive margin (%)
N: Ratio of clock frequency to bit rate (N = 16)
D: Clock duty cycle (D = 0 to 1.0) L: Frame length (L = 9 to 12)
F: Absolute deviation of clock frequency
From equation (1), if F = 0 and D = 0.5 the receive margin is 46.875%, as given by equation (2).
D = 0.5, F = 0
M = (0.5 - 1/2 ×16) ×100%
= 46.875% ........................................................................................................ (2)
(7) SCI Channel 3: Use of pins for this channel must be enabled by setting bits 6, 5, and 3 in the
port A control register (PACR).
Problem in Operation: After setting DDR and DR to 1 and using synchronous SCI clock output,
when the SCK pin is switched to the port function at the end of transmission, a low-level signal is
output for one half-cycle before the port output state is established.
When switching to the port function by making the following settings while DDR = 1, DR = 1,
C/$ = 1, CKE1 = 0, CKE0 = 0, and TE = 1, low-level output occurs for one half-cycle.
SCK/port
(1) End of transmission (4) Low-level output
Data Bit 6 Bit 7
(2) TE=0
TE
(3) C/A=0
C/A
CKE1
CKE0
Figure 14-22 Operation when Switching from SCK Pin Function to Port Pin Function
As this procedure temporarily places the SCK pin in the input state, the SCK/port pin should be
pulled up beforehand with an external circuit.
With DDR = 1, DR = 1, C/$ = 1, CKE1 = 0, CKE0 = 0, and TE = 1, make the following settings
in the order shown.
High-level output
SCK/port
(1) End of transmission
Data Bit 6 Bit 7
(2) TE=0
TE
(4) C/A=0
C/A
(3) CKE1=1
(5) CKE1=0
CKE1
CKE0
Figure 14-23 Operation when Switching from SCK Pin Function to Port Pin Function
(Preventing Low-Level Output)
15.1 Overview
The H8/539F includes a 10-bit successive-approximations A/D converter. Software can select a
maximum of 12 analog input channels.
15.1.1 Features
• Ten-bit resolution
Number of input channels: 12
• High-speed conversion
Conversion time: minimum 8.3 µs per channel (φ = 16-MHz system clock)
• Two conversion modes
Single mode: A/D conversion of one channel
Scan mode: continuous conversion on one to 12 channels
• Twelve 10-bit A/D data registers
A/D conversion results are transferred for storage into 12 A/D data registers. Each channel has
its own A/D data register.
• Built-in sample-and-hold function
A sample-and-hold circuit is built into the A/D converter, permitting a simplified external
analog input circuit.
• A/D conversion interrupt with DTC (data transfer controller) support
At the end of A/D conversion, an A/D end interrupt request (ADI) can be sent to the H8/500
CPU. The ADI interrupt can also be served by the DTC.
• External triggering
A/D conversion can be started by an external trigger signal.
• Selectable analog conversion voltage range
The analog voltage conversion range can be set by input at the VREF pin.
• A/D conversion can also be started by the IPU.
VREF
Successive-approximations
AVCC
ADDRB
ADDRA
ADDR0
ADDR1
ADDR2
ADDR3
ADDR4
ADDR5
ADDR6
ADDR7
ADDR8
ADDR9
register
10-bit
D/A
AVSS
Bus interface
AN0
− A/D conversion
ADCSR
ADCR
control circuit
AN1 On-chip
AN2 data bus
Analog multiplexer
AN3
AN4 Sample-and-hold
AN5 circuit
AN6
AN7
AN8
AN9 ADI interrupt request signal
AN10 ADTRG external trigger signal
AN11 (or IPU compare match signal)
φ/8
φ/16
Legend
ADDR0: A/D data register 0 ADDR7: A/D data register 7
ADDR1: A/D data register 1 ADDR8: A/D data register 8
ADDR2: A/D data register 2 ADDR9: A/D data register 9
ADDR3: A/D data register 3 ADDRA: A/D data register A
ADDR4: A/D data register 4 ADDRB: A/D data register B
ADDR5: A/D data register 5 ADCR: A/D control register
ADDR6: A/D data register 6 ADCSR: A/D control/status register
Table 15-1 summarizes the A/D converter’s input pins. The 12 analog input pins (AN0 to AN11)
are divided into three groups: AN0 to AN3 (group 0), AN4 to AN7 (group 1), and AN8 to AN11
(group 2). The $'75* pin can trigger the start of A/D conversion externally. The A/D converter
starts A/D conversion when a low pulse is applied to this pin. AVCC and AVSS are the power
supply for the analog circuits in the A/D converter. VREF is a conversion reference voltage.
To protect the reliability of the chip, AVCC , AVSS , VCC , and VSS should be related as follows: AVCC
= VCC ± 10%; AVSS = VSS. AVCC and AVSS must not be left open, even if the A/D converter is not
used (including hardware/software standby mode). Voltages applied to the analog input pins
should be in the range AVSS ≤ ANn ≤ VREF .
A/D data registers 0 to B (ADDR0 to ADDRB) are 16-bit read-only registers that store the results
of A/D conversion of the analog inputs. There are 12 registers, corresponding to analog inputs 0
to 11 (AN0 to AN11). The A/D data registers are initialized to H'0000 by a reset and in the standby
modes.
Bit 7 6 5 4 3 2 1 0
ADDRnH
AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2
(upper byte)
Initial value 0 0 0 0 0 0 0 0
R/W R R R R R R R R
Bit 7 6 5 4 3 2 1 0
ADDRnL
AD1 AD0 − − − − − −
(lower byte)
Initial value 0 0 0 0 0 0 0 0
R/W R R R R R R R R
(n = 0 to B)
The on-chip A/D converter converts the analog inputs to 10-bit digital values. The upper eight of
the 10 bits are stored in the upper byte of the A/D data register of the selected channel. The lower
two bits are stored in the lower byte of the A/D data register. Only the two upper bits of the lower
byte of an A/D data register are valid. Table 15-3 indicates the pairings of analog input channels
and A/D data registers.
The H8/500 CPU can always read and write the A/D data registers. The upper byte must always
be read before the lower byte. It is possible to read only the upper byte of an A/D data register,
but it is not possible to read only the lower byte. For further details see section 15.3, "H8/500
CPU Interface." Bits 5 to 0 of the A/D data registers are reserved bits that cannot be modified and
always read 0.
Analog Input A/D Data Analog Input A/D Data Analog Input A/D Data
Channel Register Channel Register Channel Register
AN0 ADDR0 AN4 ADDR4 AN8 ADDR8
AN1 ADDR1 AN5 ADDR5 AN9 ADDR9
AN2 ADDR2 AN6 ADDR6 AN10 ADDRA
AN3 ADDR3 AN7 ADDR7 AN11 ADDRB
The A/D control status register (ADCSR) is an eight-bit readable/writable register that selects the
A/D conversion mode. ADCSR is initialized to H'00 by a reset and in the standby modes.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 0 0 0 0 0
R/W R/(W)* R/W R/W R/W R/W R/W R/W R/W
Note: * Software can write 0 to clear the flag, but cannot write 1.
Bit 7
ADF Description
0 A/D conversion is in progress or the A/D converter is idle (Initial value)
ADF is cleared to 0 when:
1. Software reads ADF after it has been set to 1, then writes 0 in ADF
2. The DTC is started by ADI
1 A/D conversion has ended and a digital value has been loaded into one or more
A/D data registers
ADF is set to 1 when:
1. A/D conversion ends in single mode
2. All conversion in one selected analog group ends
After ADF is set to 1, the A/D converter operates differently in single mode and scan mode. In
single mode, after loading a digital value into an A/D data register, the A/D converter sets ADF to
1 then goes into the idle state. In scan mode, after completing all conversion in one selected
analog group, the A/D converter sets ADF to 1 then continues converting.
Bit 6—A/D Interrupt Enable (ADIE): Enables or disables the A/D end interrupt (ADI). ADIE
is initialized to 0 by a reset and in the standby modes.
Bit 6
ADIE Description
0 A/D end interrupt (ADI) is disabled (Initial value)
1 A/D end interrupt (ADI) is enabled
When A/D conversion ends and the ADF bit in ADCSR is set to 1, if ADIE is also set to 1 an A/D
end interrupt (ADI) is requested. The ADI interrupt request can be cleared by clearing ADF to 0
or clearing ADIE to 0.
Bit 5 Bit 4
ADM1 ADM0 Description
0 0 Single mode (Initial value)
0 1 Four-channel scan mode (analog group 0, 1, or 2)
1 0 Eight-channel scan mode (analog groups 0 and 1)
1 1 Twelve-channel scan mode (analog groups 0, 1, and 2)
When ADM1 and ADM0 are cleared to 00, single mode is selected. In single mode one analog
channel is converted once. The channel is selected by bits CH3 to CH0 in ADCSR.
Setting ADM1 and ADM0 to 01 selects four-channel scan mode. In scan mode, one or more
channels are converted continuously. The channels converted in scan mode are selected by bits
CH3 to CH0 in ADCSR. In four-channel scan mode, A/D conversion is performed in the four
channels in analog group 0 (AN0 to AN3), analog group 1 (AN4 to AN7), or analog group 2 (AN8 to
AN11).
Setting ADM1 and ADM0 to 10 selects eight-channel scan mode. A/D conversion is peformed in
the eight channels in analog group 0 (AN0 to AN3) and analog group 1 (AN4 to AN7).
Setting ADM1 and ADM0 to 11 selects 12-channel scan mode. A/D conversion is performed in
the 12 channels in analog group 0 (AN0 to AN3), analog group 1 (AN4 to AN7), and analog group 2
(AN8 to AN11).
For further details on operation in single and scan modes, see section 15.4, "Operation."
The A/D control register (ADCR) is an eight-bit readable/writable register that controls the start of
A/D conversion and selects the A/D clock. ADCR is initialized to H'1F by a reset and in the
standby modes. Bits 4 to 0 of ADCR are reserved for future expansion. They cannot be modified
and always read 1.
Bit 7 6 5 4 3 2 1 0
Initial value 0 0 0 1 1 1 1 1
R/W R/W R/W R/W − − − − −
Reserved bits
A/D start
Starts and stops A/D conversion
Clock select
Selects the A/D conversion time
Trigger enable
Enables and disables external triggering of A/D conversion
Bit 7—Trigger Enable (TRGE): Enables or disables external triggering of A/D conversion.
When TRGE is set to 1, P71 automatically becomes the $'75* input pin. TRGE is initialized to
0 by a reset and in the standby modes.
Bit 7
TRGE Description
0 A/D conversion cannot be externally triggered (Initial value)
1 A/D conversion can be externally triggered (P71 is the $'75* pin)
After TRGE is set to 1, if a low pulse is input at the $'75* pin, the A/D converter detects the
falling edge of the pulse and sets the ADST bit in ADCR to 1. Subsequent operation is the same
as if software had set the ADST bit to 1. External triggering operates only when the ADST bit is
cleared to 0.
When the external trigger function is used, the low pulse input at the $'75* pin must have a
width of at least 1.5 system clocks (1.5φ). For further details see section 15.4.4, "External
Triggering of A/D Conversion."
Bit 6
CKS Description
0 Conversion time = 266 states (maximum) (Initial value)
1 Conversion time = 134 states (maximum)
Bit 5—A/D Start (ADST): Starts and stops A/D conversion. A/D conversion starts when ADST
is set to 1 and stops when ADST is cleared to 0. ADST is initialized to 0 by a reset and in the
standby modes.
Bit 5
ADST Description
0 A/D conversion is stopped (Initial value) (Initial value)
1 A/D conversion is in progress
Clearing conditions:
1. Single mode: cleared to 0 automatically at the end of A/D conversion
2. Scan mode: check that ADF is set to 1 in ADCSR, then write 0 in ADST
The ADST bit operates differently in single and scan modes. In single mode, ADST is cleared to
0 automatically after A/D conversion of one channel. In scan mode, after all selected analog
inputs have been converted A/D conversion of all these channels begins again, so ADST remains
set to 1. When the conversion time or analog input channel selection is changed in scan mode, the
ADST bit should first be cleared to 0 to halt A/D conversion.
Before changing the A/D conversion time (CKS bit in ADCR), operating mode (ADM1/0 bits in
ADCSR), or analog input channel selection (bits CH3 to CH0 in ADCSR), always check that the
A/D converter is stopped (ADST = 0). Making these changes while the A/D converter is
operating (ADST = 1) may produce incorrect values in the A/D data registers.
Bits 4 to 0—Reserved: These bits are reserved for future expansion. They cannot be modified
and always read 1.
The A/D trigger register (ADTRGR) is used to switch the A/D external trigger. The A/D external
trigger can be selected from the ADTRG pin or an IPU channel 1 DR3 compare match. ADTRGR
is set to H'FF in standby mode and by a reset.
EXTRG − − − − − − −
Initial value 1 1 1 1 1 1 1 1
R/W R/W − − − − − − −
Reserved bits
Bit 7—External Trigger Source Select (EXTRG): This bit selects the A/D external trigger from
an IPU channel 1 compare match or the ADTRG pin. The A/D external trigger source is the
ADTRG pin when EXTRG is set to 1, and an IPU channel 1 DR3 compare match when EXTRG is
cleared to 0. EXTRG is initialized to 1 by a reset and in standby mode.
Bit 7
EXTRG Description
0 A TPU channel 1 DR3 compare match is set as the A/D external trigger source
1 The ADTRG pin is set as the A/D external trigger source (Initial value)
Bit 6—Bits 6 to 0: Reserved: These bits are reserved for future expansion. They are always read
as 1 and cannot be modified.
For a description of a sample operation, see section 15.4.5 "Starting the A/D Converter with the
IPU."
An A/D data register is read as follows. The upper byte must be read first. The H8/500 CPU
receives the upper-byte data directly at this time. At the same time, the A/D converter transfers
the lower-byte data internally into TEMP. Next, when the lower byte is read, the H8/500 CPU
receives the contents of TEMP.
When reading an A/D data register using byte operand size, always read the upper byte before the
lower byte. It is possible to read only the upper byte, but if only the lower byte is read incorrect
data may be obtained. When an A/D data register is read using word operand size, the upper byte
will automatically be read before the lower byte.
Figure 15-2 shows the data flow when an A/D data register is read. In the example shown, the
upper byte of the A/D data register contains H'AA and the lower byte contains H'40. First the
H8/500 CPU reads H'AA directly from the upper byte while H'40 is transferred to TEMP in the
A/D converter. Next, when the H8/500 CPU reads the lower byte of the A/D data register, it
obtains the TEMP contents.
Bus interface
H8/500 CPU
(H'AA)
On-chip bus
A TEMP (H'40)
H8/500 CPU
(H'40)
On-chip bus
C
TEMP (H'40)
Single mode can be selected to perform one A/D conversion on one channel. Single mode is
selected by clearing bits ADM1 and ADM0 to 00 in the A/D control/status register (ADCSR).
A/D conversion then starts when the ADST bit is set to 1 in ADCR. The ADST bit remains set to
1 during A/D conversion and is automatically cleared to 0 when conversion ends. When
conversion ends the ADF bit is set to 1 in ADCSR. If the ADIE bit is also set to 1, an ADI
interrupt is requested. To clear ADF to 0, first read ADF after ADF has been set to 1, then write 0
in ADF. If the ADI interrupt is served by the data transfer controller (DTC), however, ADF is
cleared to 0 automatically.
Figure 15-3 shows a flowchart for selecting analog input channel 1 (AN1) and performing A/D
conversion in single mode. Figure 15-4 is a timing diagram.
No
End
ADDR2 H'0000
ADDR3 H'0000
ADDR4 H'0000
ADDR5 H'0000
ADDR6 H'0000
ADDR7 H'0000
ADDR8 H'0000
ADDR9 H'0000
ADDRA H'0000
ADDRB H'0000
Figure 15-4 Example of A/D Converter Operation (Single Mode, Channel 1 Selected)
Scan mode can be selected to perform A/D conversion on one or more channels repeatedly (to
monitor the channels continuously, for example). Scan mode is selected by setting bits ADM1
and ADM0 in the A/D control/status register (ADCSR) to 01, 10, or 11. The 01 setting selects
four-channel scan mode. The 10 setting selects eight-channel scan mode. The 11 setting selects
12-channel scan mode. A/D conversion starts when the ADST bit in ADCR is set to 1.
In scan mode the channels are converted in ascending order of channel number (AN0, AN1, …,
AN11). The ADST bit remains set to 1 until software clears it to 0.
When all conversion in one selected analog group is completed, the ADF bit in ADCSR is set to 1,
then A/D conversion is performed again. If the ADIE bit in ADCSR is set to 1, then when ADF is
set to 1 an ADI interrupt is requested. To clear ADF to 0, first read ADF after it has been set to 1,
then write 0 in ADF. If the ADI interrupt is served by the data transfer controller (DTC),
however, ADF is cleared to 0 automatically.
Figure 15-5 shows a flowchart for selecting analog input channels 0 and 1 (AN0 and AN1) and
performing A/D conversion in four-channel scan mode. Figure 15-6 is a timing diagram.
End
ADDR4 H'0000
ADDR5 H'0000
ADDR6 H'0000
ADDR7 H'0000
ADDR8 H'0000
ADDR9 H'0000
ADDRA H'0000
ADDRB H'0000
The A/D converter has a built-in sample-and-hold circuit. The A/D converter starts sampling the
analog inputs at a time tD (synchronization delay) after the ADST bit is set to 1 in the A/D control
register (ADCR). Figure 15-7 shows the sampling timing.
The A/D conversion time (tCONV) includes tD and the analog input sampling time (tSPL). The length
of tD varies because it includes time needed to synchronize the A/D converter. The total
conversion time therefore varies within the ranges indicated in table 15-4.
In scan mode, the tCONV values given in table 15-4 apply to the first conversion. In the second and
subsequent conversions there is no tD, and tCONV is fixed at 256 states when CKS = 0 or 128 states
when CKS = 1.
CKS = 0 CKS = 1
Item Symbol Min Typ Max Min Typ Max Unit
Synchronization delay tD 10 — 17 6 — 9 States
Input sampling time tSPL — 80 — — 40 —
A/D conversion time tCONV 259 — 266 131 — 134
A/D synchroni-
Write cycle zation time
(3 states) (max 14 states)
Internal write
signal
ADST write
Analog input timing
sampling signal
End of A/D
conversion
ADF (ADCR)
A/D conversion can be started by input of an external trigger signal. External triggering is enabled
by setting the TRGE bit to 1 in the A/D control register. When the TRGE bit is set to 1, P71
automatically becomes the $'75* input pin. If a low pulse is input at the $'75* pin in this
state, the A/D converter detects the falling edge of the pulse and sets the ADST bit to 1. Figure
15-8 shows the external trigger input timing.
The ADST bit is set to 1 one state after the A/D converter samples the falling edge of the $'75*
signal. The time from when the ADST bit is set to 1 until A/D conversion begins is the same as
when software writes 1 in ADST.
1 state
ADST bit
(ADCR) ADST = 1
In the H8/539F, A/D conversion can be started by a compare match in the on-chip integrated-timer
pulse unit (IPU). To start A/D conversion by IPU compare match, follow the procedure given
next.
1. Set bits DOE21 and DOE20 (bits 7 and 6) to 1, 0 in IPU channel 1 timer output enable register
A (TOERA).
2. Set the starting time of the A/D converter in IPU channel 1 dedicated register 2 (DR2).
3. Set the TRGE bit (bit 7) in the A/D control register (ADCR) to 1.
4. Clear bit 7 of the ADTRGR register at address H'FEDC to 0.
After these settings, A/D conversion will start when the IPU channel 1 timer counter value
matches DR2. In this case A/D conversion cannot be started by input at the $'75* pin. When
Rev. 3.0, 02/99, page 472 of 904
the IPU starts A/D conversion, the timing is the same as if the T1OC2 pin were externally
connected to the $'75* pin. See the relevant timing diagrams for these pins.
If the ADI bit in the interrupt controller’s data transfer enable register A (DTEA) is set to 1, the
ADI interrupt is served by the data transfer controller (DTC). When the DTC is started by ADI to
perform a data transfer, the ADF bit in ADCSR is automatically cleared to 0. For further details
on the DTC, see section 7, "Data Transfer Controller."
(1) Analog Input Voltage Range: During A/D conversion, the voltages input to the analog input
pins should be in the range AVSS ≤ ANn ≤ VREF .
(2) Relationships of AVCC and AVSS to VCC and VSS : AVCC , AVSS , VCC , and VSS should be related
as follows: AVCC = VCC ± 10%; AVSS = VSS. AVCC and AVSS must not be left open, even if the A/D
converter is not used (include hardware/software stand-by mode).
(3) VREF Input Range: The reference voltage input at the VREF pin should be in the range
VREF ≤ AVCC .
Failure to observe points (1), (2), and (3) above may degrade chip reliability.
(4) Note on Board Design: In board layout, separate the digital circuits from the analog circuits as
much as possible. Particularly avoid layouts in which the signal lines of digital circuits cross or
closely approach the signal lines of analog circuits. Induction and other effects may cause the
analog circuits to operate incorrectly, or may adversely affect the accuracy of A/D conversion.
The analog input signals (AIN), analog reference voltage (VREF), and analog supply voltage (AVCC)
must be separated from digital circuits by the analog ground (AVSS). The analog ground (AVSS)
should be connected to a stable digital ground (VSS) at one point on the board.
(5) Note on Noise: To prevent damage from surges and other abnormal voltages at the analog
input pins (AIN) and analog reference voltage pin (VREF), connect a protection circuit like the one in
figure 15-9 between AV CC and AVSS. The bypass capacitors connected to AVCC and VREF and the
filter capacitors connected to AIN must be connected to AVSS. If filter capacitors like those in
figure 15-9 are connected, the voltage values input to the analog input pins (AIN) will be smoothed,
AVCC
VREF
*2
Rin 100 Ω H8/539F
AIN (AN0-AN11)
*1 *1
0.1µF
AVSS
Notes: 1.
10 µF 0.01 µF
10.0 kΩ
AN0−11 To A/D converter
20 pF
Conditions: VCC = 5.0 ± 10%, AVCC = 5.0 ± 10%, VREF = 5.0 ± 10%, (VREF ≤ AVCC),
VSS = AVSS = 0V
(6) A/D Conversion Accuracy Definitions: A/D conversion accuracy in the H8/539F is defined
as follows:
110
101
100
011
001
000
0 1/7 2/7 3/7 4/7 5/7 6/7 7/FS
Analog input voltage
Nonlinearity
error
FS
Analog input voltage
Offset error
16.1 Overview
The on-chip bus controller (BSC) can dynamically alter the bus width and the length of the bus
cycle. When a 16-bit bus mode is selected by the inputs at the mode pins, the bus controller can
reserve part of the address space as a byte access area accessed via an eight-bit bus, switch another
part from a three-state bus cycle to a high-speed two-state bus cycle, and switch the eight-bit-bus
area to 16-bit access.
16.1.1 Features
• An eight-bit access area can be defined in the 16-bit bus modes (modes 1, 3, 4, 5*, and 6*)
The eight-bit access area consists of addresses greater than the value set in the byte area top
register (ARBT). (This area does not include the address set in ARBT, which is the boundary
of the word area.) When an address greater than the ARBT value is accessed, only the upper
data bus (D15 to D8) is valid. The access is performed with eight-bit bus width. The ARBT
setting does not change the bus width of the on-chip ROM, on-chip RAM, and on-chip register
areas.
Note: * Modes 5 and 6 have a 16-bit bus, but when the chip comes out of reset the ARBT and
AR3T settings are ignored: the entire external address space is accessed in three states via
an eight-bit bus. Software can enable the ARBT and AR3T settings by altering a value in
the bus control register (BCR).
Mode 5 or 6
BCR
ARBT < Addr ARBT < Addr AR3T < Addr AR3T ≤ Addr
Mode
3, 4, or 5
Mode 2
On-chip
register area*
ROM/RAM
area
Table 16-1 summarizes the bus controller's registers. The bus controller has three 8-bit registers: a
byte area top register (ARBT) that designates the boundary of the word area; a three-state area top
register (AR3T) that designates the boundary of the three-state-access address space; and a bus
control register (BCR) used to switch the bus width in modes 5 and 6. The H8/500 CPU can
always read and write ARBT, AR3T, and BCR.
The byte area top register (ARBT) specifies the boundary address that separates the area accessed
with 16-bit bus width from the area accessed using only the upper eight bits of the 16-bit bus. The
address set in ARBT is the word area boundary: the last address accessed with 16-bit bus width.
Bit 7 6 5 4 3 2 1 0
Initial value 1 1 1 1 1 1 1 1
R/W R/W R/W R/W R/W R/W R/W R/W R/W
The bus controller controls the H8/500 CPU so that external addresses exceeding the ARBT value
are accessed with eight-bit bus width.
In expanded maximum mode, the ARBT value is treated as bits A19 to A12 (the upper eight bits) of
the word area boundary address. The word area boundary can be set in minimum 4-kbyte steps. In
expanded maximum mode, addresses H'00000 to H'00FFF are always a word access area.
The ARBT setting applies only to external addresses. It cannot change the bus width of the on-
chip ROM or RAM or on-chip register areas. In mode 2 the ARBT setting is ignored: the external
address bus has a fixed eight-bit width. In modes 5 and 6 the ARBT setting is ignored until the
BCRE bit is set to 1 in the bus control register (BCR).
ARBT is initialized to H'FF by a reset and in hardware standby mode. ARBT is not initialized in
software standby mode.
The three-state area top register (AR3T) specifies the boundary address that separates the area
accessed in two states from the area accessed in three states. The address set in AR3T is the
Bit 7 6 5 4 3 2 1 0
Note: * Modes 3 to 5
The bus controller controls the H8/500 CPU so that external addresses equal to or greater than the
ARBT value are accessed in three states. Wait states cannot be inserted into the two-state-access
area.
In expanded maximum mode, the AR3T value is treated as bits A19 to A12 (the upper eight bits) of
the three-state area boundary address. The three-state area boundary can be set in minimum 4-
kbyte steps. In expanded maximum mode, addresses H'FF000 to H'FFFFF are always a three-
state-access area.
In expanded minimum mode, the AR3T value is treated as bits A15 to A8 (the upper eight bits) of
the three-state area boundary address. The three-state area boundary can be set in minimum 256-
byte steps. In expanded minimum mode, addresses H'FF00 to H'FFFF are always a three-state-
access area.
The AR3T setting applies only to external addresses. It cannot change the bus cycle length of the
on-chip ROM or RAM or on-chip register areas. In mode 2 the AR3T setting is ignored: the
Rev. 3.0, 02/99, page 482 of 904
external address space is always a three-state-access area. In modes 5 and 6 the AR3T setting is
ignored until the BCRE bit is set to 1 in the bus control register (BCR).
The bus control register (BCR) enables or disables the bus controller's bus control functions in
modes 5 and 6, and enables or disables on-chip I/O port functions.
Ports 1 and 2
enable
Enables and
disables
reading and
writing of
ports 1 and 2
When the bus controller enable bit (BCRE) is set to 1, the bus controller controls the bus
according to the values in ARBT and AR3T. As an exception, when the zero page three-state bit
(0P3T; bit 6) is set to 1, all external addresses in page 0 are placed in the three-state-access area
regardless of the AR3T setting.
Bit 3 is for I/O port expansion. When this bit is cleared to 0, H'0FE9C to H'0FE9F become part of
the external eight-bit three-state-access area.
For precautions on modifying the BCR value, see section 16.4, "Usage Notes."
(1) Bit 7—Bus Controller Enable (BCRE): Enables or disables bus control functions using the
values in ARBT and AR3T in modes 5 and 6.
Bit 7
BCRE Description
0 The H8/500 CPU accesses all external addresses in three states using an eight-bit
bus* (Initial value in modes 5 and 6)
This bit cannot be cleared to 0 in modes 1 to 4 and 7.
1 The H8/500 CPU accesses external addresses according to the ARBT and AR3T
settings (Initial value in modes 1 to 4 and 7; cannot be cleared to 0)
Note: * Access is performed using only the upper eight bits (D15 to D8) of the 16-bit bus.
(2) Bit 6—Zero Page Three-State (0P3T): Selects three-state access for all external addresses in
page 0, regardless of the AR3T setting.
Bit 6
0P3T Description
0 The H8/500 CPU accesses external addresses according to (Initial value)
the ARBT and AR3T settings
1 The H8/500 CPU accesses external addresses according to the ARBT and AR3T
settings except in page 0, where three-state access is selected regardless of the
AR3T setting*
Note: * In mode 7 there is no external address space, so the 0P3T value has no meaning.
(3) Bit 5—Reserved: Read-only bit, always read as 1. Reserved for future expansion.
Bit 4
P9AE Description
0 On-chip I/O ports 9 and A cannot be written or read
The DR and DDR addresses of ports 9 and A (H'0FE90 to H'0FE93) become part
of the external eight-bit three-state-access area.*
1 On-chip I/O ports 9 and A can be written and read (Initial value)
Note: * Cannot be cleared to 0 in mode 7.
(5) Bit 3—Expanded I/O Ports (EXIOP): Enables or disables expansion of I/O ports, allowing
I/O ports to be configured off-chip.
Bit 3
EXIOP Description
0 External I/O ports can be written and read
H'0FE9C to H'0FE9F become part of the external eight-bit three-state-access
area.*
1 External I/O ports cannot be written or read (Initial value)
Note: * Cannot be cleared to 0 in mode 7.
(6) Bit 2—Pull-Up Transistor Control Register Enable (PCRE): Enables or disables reading
and writing of port B and C pull-up transistor control registers (PBPCR and PCPCR).
Bit 2
PCRE Description
0 Port B and C pull-up transistor control registers (PBPCR and PCPCR) cannot be
written or read
PBPCR and PCPCR addresses (H'0FE98 to H'0FE9B) become part of the external
eight-bit three-state-access area.*
1 Port B and C pull-up transistor control registers (PBPCR and (Initial value)
PCPCR) can be written and read
Note: * Cannot be cleared to 0 in mode 7.
Bit 1
PBCE Description
0 On-chip I/O ports B and C cannot be written or read
The DR and DDR addresses of ports B and C (H'0FE94 to H'0FE97) become part
of the external eight-bit three-state-access area.*
1 On-chip I/O ports B and C can be written and read (Initial value)
Note: * Cannot be cleared to 0 in mode 7.
(8) Bit 0—Port 1 and 2 Enable (P12E): Enables or disables reading and writing of ports 1 and 2,
allowing these I/O ports to be reconfigured off-chip.
Bit 0
P12E Description
0 On-chip I/O ports 1 and 2 cannot be written or read
The DR and DDR addresses of ports 1 and 2 (H'0FE80 to H'0FE83) become part
of the external eight-bit three-state-access area.*
1 On-chip I/O ports 1 and 2 can be written and read (Initial value)
Note: * Cannot be cleared to 0 in mode 7.
(1) Mode 1: The external data bus space. H'0000 to H'EDFF are a 16-bit two-state-access area.
H'EE00 to H'FE7F are a 16-bit three-state-access area. When the on-chip RAM is enabled,
however, the on-chip RAM area is a 16-bit two-state-access area.
H'0000
External bus area
16 bits, 2 states
H'EDFF
H'EE00 16 bits, 3 states
H'EE7F
H'EE80 On-chip RAM area
16 bits, 2 states
H'F67F (16 bits, 3 states)
H'F680 On-chip RAM area
16 bits, 2 states
H'FE7F (16 bits, 3 states)
H'FE80 On-chip register area
H'FFFF 8 bits, 3 states
Figure 16-2 Bus Width and Bus Cycle Length after Reset (Mode 1)
(2) Mode 2: The external data bus space is eight bits wide. H'0000 to H'3FFF (on-chip ROM) are
a 16-bit two-state-access area. H'4000 to H'FE7F are an eight-bit three-state-access area. When
the on-chip RAM is enabled, however, the on-chip RAM area is a 16-bit two-state-access area.
Figure 16-3 Bus Width and Bus Cycle Length after Reset (Mode 2)
(3) Mode 3: The external data bus space. H'00000 to H'0DFFF are a 16-bit two-state-access area.
H'0E000 to H'0FE7F and H'10000 to H'FFFFF are a 16-bit three-state-access area. When the on-
chip RAM is enabled, however, the on-chip RAM area is a 16-bit two-state-access area.
Figure 16-4 Bus Width and Bus Cycle Length after Reset (Mode 3)
Figure 16-5 Bus Width and Bus Cycle Length after Reset (Mode 4)
(5) Mode 5: The external data bus space uses a 16-bit bus width. After a reset, H'00000 to
H'FFFFF are an eight-bit three-state-access area because BCRE = 0 in the bus control register
(BCR). In this case, the upper half of the data bus (D15 to D8) is enabled (see Table 16-2 (2)).
When the on-chip RAM is enabled, however, the on-chip RAM area is a 16-bit two-state-access
area.
H'00000
External bus area
8 bits, 3 states
H'0EE7F
H'0EE80 On-chip RAM area
16 bits, 2 states
H'0F67F (8 bits, 3 states)
H'0F680 On-chip RAM area
16 bits, 2 states
(8 bits, 3 states)
H'0FE7F
H'0FE80 On-chip register area
H'0FFFF 8 bits, 3 states
H'10000
External bus area
8 bits, 3 states
H'FFFFF
Figure 16-6 Bus Width and Bus Cycle Length after Reset (Mode 5)
(6) Mode 6: The external data bus space. H'0000 to H'FE80 are an eight-bit three-state-access
area (BCRE = 0 in BCR). In this case, the upper half of the data bus (D15 to D8) is enabled (see
Table 16-2 (2)). When the on-chip RAM is enabled, however, the on-chip RAM area is a 16-bit
two-state-access area.
H'0000
H'EE7F
H'EE80 On-chip RAM area
16 bits, 2 states
H'F67F (8 bits, 3 states)
H'F680 On-chip RAM area
16 bits, 2 states
H'FE7F (8 bits, 3 states)
H'FE80
On-chip register area
8 bits, 3 states
H'FFFF
Figure 16-7 Bus Width and Bus Cycle Length after Reset (Mode 6)
H'00000
On-chip ROM area
16 bits, 2 states
H'03FFF
Figure 16-8 Bus Width and Bus Cycle Length after Reset (Mode 7)
Changes in the bus areas and bus size take effect in the next bus cycle after the write cycle to
ARBT or AR3T.
T1 T2 T3
Internal write
signal
Internal write
signal
Internal data
ARBT setting data AR3T setting data
bus
Bus control register bits 4 to 0 can be set for I/O port expansion. This function enables ports 1, 2,
A, B, and C, which cannot be used in the bus expansion modes (modes 1 to 6 ), to be reconfigured
off-chip. Figure 16-11 shows an example of I/O port reconfiguration.
Address
decoder
A19-0
DDR
DR +5 V
74LS74 × 1/2
(DDR)
74LS02
PR
RD CK CLR RES
D Q
HWR
OE 74LS373 × 1/8
(DR)
D Q Port
G
74LS04
× 1/6 GND
OC S
Y A
74LS257
× 1/6
(1) Restrictions on AR3T and ARBT Settings: AR3T and ARBT settings should satisfy
equation (1).
No eight-bit, two-state-access area is defined for the H8/539F. If AR3T > ARBT + 1, eight-bit
three-state access is performed.
(2) Possible Partitionings of the Address Space: The address space can be partitioned in eight
ways as follows:
Notes: 1. Possible only in modes 5 and 6 when BCRE = 0 in the bus control register (BCR).
2. Set by the 0P3T bit in BCR.
(3) Modification of ARBT, AR3T, and BCR: When ARBT, AR3T, and BCR settings are
modified, an invalid bus area may be created temporarily. This may prevent normal program
execution. Crashes can be avoided by one of the following methods:
1. Place routines that modify ARBT, AR3T, and BCR in on-chip ROM or RAM.
Perform the modification in an area that is not affected by the ARBT, AR3T, and BCR
settings. The modification can be followed by a jump to any area without crashing.
(Example 1)
2. Place a branch instruction after the instruction that modifies ARBT, AR3T, or BCR.
After the write to ARBT, AR3T, or BCR,* the instruction fetch from the temporary invalid bus
area is cleared by execution of the branch instruction, thus preventing a crash.
(Example 2)
Note: * To modify both ARBT and AR3T simultaneously, a word access instruction is
recommended.
Rev. 3.0, 02/99, page 496 of 904
On-chip ROM
or RAM
Example 1: Placing the modifying subroutine Example 2: Placing a branch instruction after
in on-chip ROM or RAM the modifying instruction
Figure 16-12 Example of Program Structure for Modifying ARBT, AR3T, and BCR
Table 16-2 (1) Data Bus and Control Signal Operation in Various Types of Access
(Mode 2)
AR3T ≤ ARBT + 1
16 bits
Bus cycle Bus width
H'00000
On-chip ROM area 2 states 16 bits
H'03FFF
H'04000
External bus area 2 states 16 bits
H'0EE7F
H'0EE80
On-chip RAM area 2 states 16 bits
H'0FE7F
H'0FE80
On-chip register area 3 states 8 bits
H'0FFFF
H'10000
On-chip ROM area 2 states 16 bits
H'2FFFF
H'30000 2 states 16 bits
AR3T
3 states 16 bits
ARBT
H'FFFFF
Mode 4
16 bits
Bus cycle Bus width
H'00000
2 states
8 bits,
External bus area
3 states
8 bits
AR3T
3 states
H'FFFFF
Mode 4
17.1 Overview
The H8/539F has 4 kbytes of on-chip static RAM. The RAM is connected to the H8/500 CPU by a
16-bit data bus. The H8/500 CPU accesses both byte data and word data in two states, making the
RAM suitable for rapid data transfer and high-speed computation.
The on-chip RAM is assigned to addresses H'EE80 to H'FE7F. The RAM control register
(RAMCR) enables this area to be switched between on-chip RAM and external memory.
RAME1, 2
Bus interface and control section
2
H'FE7C H'FE7D
H'FE7E H'FE7F
Legend
RAMCR: RAM control register
The RAM is controlled by the RAM control register (RAMCR). Table 17-1 gives the address and
initial value of RAMCR.
Bit 7 6 5 4 3 2 1 0
Initial value 1 * 1 * * 0 0 0
R/W R/W − R/W − − R/W R/W R/W
RAM2 to RAM0
Reserved bits Specify the RAM area
overlapping flash memory
RAM enable bit 2
Enables or disables access to
on-chip RAM (H'EE80 to H'F67F)
Reserved bit
(1) Bits 7—and 5-RAM Enable 1 and 2 (RAME1, RAME2): These bits enable or disable
access to on-chip RAM.
Bit 7
RAME1 Description
0 On-chip RAM (H'F680 to H'FE7F) cannot be accessed
1 On-chip RAM (H'F680 to H'FE7F) can be accessed (Initial value)
Bit 5
RAME2 Description
0 On-chip RAM (H'EE80 to H'F67F) cannot be accessed
1 On-chip RAM (H'EE80 to H'F67F) can be accessed (Initial value)
The RAME1 and RAME2 bits are initialized on the rising edge of the reset signal. They are not
initialized in software standby mode. In modes 1 to 6, when the RAME1 and RAME2 bits are
cleared to 0 to disable access to on-chip RAM, addresses H'F680 to H'FE7F and H'EE80 to
H'F67F become an external memory area.
(3) Bits 2 to 0: RAM2 to RAM0: Bits 2 to 0 are used in RAM emulation of flash memory. For
details, see section 19.2.4, RAM Control Register (RAMCR).
17.3 Operation
In the expanded modes (modes 1 to 6), when bits RAME1 and RAME2 are set to 1, accesses to
addresses H'F680 to H'FE7F and H'EE80 to H'F67F are directed to the on-chip RAM. When bits
RAME1 and RAME2 are cleared to 0, accesses to addresses H'F680 to H'FE7F and H'EE80 to
H'F67F are directed to off-chip memory.
In single-chip mode (mode 7), when bits RAME1 and RAME2 are set to 1, accesses to addresses
H'F680 to H'FE7F and H'EE80 to H'F67F are directed to the on-chip RAM. When bits RAME1
and RAME2 are cleared to 0, any type of access to addresses H'F680 to H'FE7F and H'EE80 to
H'F67F (instruction fetch or data read/write) causes an address error. For the exception handling
when an address error occurs, see section 4, "Exception Handling."
18.1 Overview
The H8/539F S-mask and A-mask models have 4 kbytes of on-chip static RAM. The RAM is
connected to the H8/500 CPU by a 16-bit data bus. The H8/500 CPU accesses both byte data and
word data in two states, making the RAM suitable for rapid data transfer and high-speed
computation.
The on-chip RAM is assigned to addresses H'EE80 to H'FE7F. The RAM control register
(RAMCR) enables this area to be switched between on-chip RAM and external memory.
RAME1, 2
Bus interface and control section
2
H'FE7C H'FE7D
H'FE7E H'FE7F
Legend
RAMCR: RAM control register
The RAM is controlled by the RAM control register (RAMCR). Table 18-1 gives the address and
initial value of RAMCR.
Bit 7 6 5 4 3 2 1 0
Initial value 1 * 1 * * 0 0 *
R/W R/W − R/W − − R/W R/W −
RAM2 and RAM1 Reserved bit
Reserved bits Specify the RAM area
overlapping flash memory
RAM enable bit 2
Enables or disables access to
on-chip RAM (H'EE80 to H'F67F)
Reserved bit
Bits 7 and 5—RAM Enable 1 and 2 (RAME1, RAME2): These bits enable or disable access to
on-chip RAM.
Bit 7
RAME1 Description
0 On-chip RAM (H'F680 to H'FE7F) cannot be accessed
1 On-chip RAM (H'F680 to H'FE7F) can be accessed (Initial value)
Bit 5
RAME2 Description
0 On-chip RAM (H'EE80 to H'F67F) cannot be accessed
1 On-chip RAM (H'EE80 to H'F67F) can be accessed (Initial value)
The RAME1 and RAME2 bits are initialized on the rising edge of the reset signal. They are not
initialized in software standby mode. In modes 1 to 6, when the RAME1 and RAME2 bits are
cleared to 0 to disable access to on-chip RAM, addresses H'F680 to H'FE7F and H'EE80 to
H'F67F become an external memory area.
Bits 2 and 1—RAM2 and RAM1: Bits 2 and 1 are used in RAM emulation of flash memory.
For details, see section 20.2.3, RAM Control Register (RAMCR).
18.3 Operation
In the expanded modes (modes 1 to 6), when bits RAME1 and RAME2 are set to 1, accesses to
addresses H'F680 to H'FE7F and H'EE80 to H'F67F are directed to the on-chip RAM. When bits
RAME1 and RAME2 are cleared to 0, accesses to addresses H'F680 to H'FE7F and H'EE80 to
H'F67F are directed to off-chip memory.
In single-chip mode (mode 7), when bits RAME1 and RAME2 are set to 1, accesses to addresses
H'F680 to H'FE7F and H'EE80 to H'F67F are directed to the on-chip RAM. When bits RAME1
and RAME2 are cleared to 0, any type of access to addresses H'F680 to H'FE7F and H'EE80 to
H'F67F (instruction fetch or data read/write) causes an address error. For the exception handling
when an address error occurs, see section 4, "Exception Handling."
19.1 Overview
Table 19-1 illustrates the principle of operation of the dual power source system H8/539F's on-
chip flash memory.
Like EPROM, flash memory is programmed by applying a high gate-to-drain voltage that draws
hot electrons generated in the vicinity of the drain into a floating gate. The threshold voltage of a
programmed memory cell is therefore higher than that of an erased cell. Cells are erased by
grounding the gate and applying a high voltage to the source, causing the electrons stored in the
floating gate to tunnel out. After erasure, the threshold voltage drops. A memory cell is read like
an EPROM cell, by driving the gate to the high level and detecting the drain current, which
depends on the threshold voltage. Erasing must be done carefully, because if a memory cell is
overerased, its threshold voltage may become negative, causing the cell to operate incorrectly.
Section 19.4.6 shows an optimal erase control flowchart and sample program.
0V VPP 0V
0V 0V 0V
As its on-chip ROM, the H8/539F has 128 kbytes of flash memory. ROM is connected to the
CPU by a 16-bit data bus. The CPU accesses both byte data and word data in two states.
The flash memory is assigned to addresses H'00000 to H'03FFF and H'10000 to H'2FFFF on the
memory map. The contents of flash memory addresses H'00000 to H'03FFF are the same as the
contents of addresses H'10000 to H'13FFF. The mode pins enable either on-chip flash memory or
external memory to be selected for this area. Table 19-2 summarizes the mode pin settings and
usage of the flash memory area.
8
Internal data bus (lower)
MD2
Operating
FLMCR Bus interface and control section MD1
mode
MD0
Legend
FLMCR: Flash memory control register
EBR1: Erase block register 1
EBR2: Erase block register 2
Note: Memory at addresses H'10000 to H'13FFF can also be read from addresses
H'00000 to H'03FFF. The space comprising addresses H'10000 to H'13FFF
is an image of addresses H'00000 to H'03FFFF.
The transmit data and receive data pins are used in boot mode.
The flash memory control register (FLMCR) is an eight-bit register that controls the flash memory
operating modes. Transitions to program mode, erase mode, program-verify mode, and erase-
verify mode are made by setting bits in this register. FLMCR is initialized to H'00 by a reset, in
the standby modes, and when 12 V is not applied to VPP. When 12 V is applied to VPP, a reset or
entry to a standby mode initializes FLMCR to H'80. The FLMCR bit structure is shown next.
It is not possible to set the EV, PV, E, or P bit, or any bit in the EBR1 or EBR2 register, to 1, until
the VPPE bit is set.
Bit 7 6 5 4 3 2 1 0
Vpp VppE − − EV PV E P
Initial value 0 0 0 0 0 0 0 0
R/W R R/W − − R/W R/W R/W R/W
Program mode
Designates
transition to
or exit from
program mode
Erase mode
Designates transition
to or exit from erase
mode
Program-verify mode
Designates transition to
or exit from program-verify
mode
Erase-verify mode
Designates transition to
Reserved bits or exit from erase-verify
mode
Vpp enable
Designates enabling or disabling
of 12 V application to Vpp
Programming power
Status flag indicating that
12 V is applied to Vpp
Bit 7
VPP Description
0 Cleared when 12 V is not applied to VPP (Initial value)
1 Set when 12 V is applied to VPP
VPP Enable (VPPE)* * * : Selects enabling or disabling of 12 V application to the VPP pin.
1 2 3
Bit 6
When programming and erasing, a wait of at least 5 µs is necessary after setting this bit to allow
on-chip oscillation to settle. The VPPE bit should only be cleared after the other bits (the P, E, PV,
and EV bits) have been cleared.
Bit 6
VPPE Description
0 On-chip power supply disabled (Initial value)
1 On-chip power supply enabled
Bit 3
EV Description
0 Exit from erase-verify mode (Initial value)
1 Transition to erase-verify mode
Bit 2
PV Description
0 Exit from program-verify mode (Initial value)
1 Transition to program-verify mode
Bit 1
E Description
0 Exit from erase mode (Initial value)
1 Transition to erase mode
Bit 0
P Description
0 Exit from program mode (Initial value)
1 Transition to program mode
Notes: 1. Do not set two or more of these bits simultaneously.
Do not cut the VCC or VPP power while any of these bits is set.
2. Do not or clear the VPPE bit at the same time as another bit (the P, E, PV, or EV bit).
3. Do not set or clear the VPPE bit during execution of a program in flash memory. For
details, see item (3) in section 19.7, "Flash Memory Programming and Erasing
Precautions."
4. Set the P and E bits in accordance with the programming and erasing algorithms shown
in section 19.4, "Programming and Erasing Flash Memory." When one of these bits is
set, watchdog timer setting should be carried out beforehand to provide for the
possibility of program runaway. See section 19.7, "Flash Memory Programming and
Erasing Precautions" for notes on the use of these bits.
Erase block register 1 (EBR1) is an eight-bit register that designates large flash-memory blocks for
erasure. EBR1 is initialized to H'00 by a reset, in the standby modes, and when 12 V is not
applied to VPP. When a bit in EBR1 is set to 1, the corresponding block is selected and can be
erased. Figure 19-2 shows a block map. No bits in the EBR1 or EBR2 register can be set to 1
until the VPPE bit is set to 1 in the FLMCR register.
Bit 7 6 5 4 3 2 1 0
LB7 LB6 LB5 LB4 LB3 LB2 LB1 LB0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
Bits 7 to 0
LB7 to LB0 Description
0 Block LB7 to LB0 is not selected (Initial value)
1 Block LB7 to LB0 is selected
Erase block register 2 (EBR2) is an eight-bit register that selects small flash-memory blocks for
programming and erasure. EBR2 is initialized to H'00 by a reset, in the standby modes, and when
12 V is not applied to VPP. When a bit in EBR2 is set to 1, the corresponding block is selected for
programming and erasure. Figure 19-2 shows a block map.
Bit 7 6 5 4 3 2 1 0
SB7 SB6 SB5 SB4 SB3 SB2 SB1 SB0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
Small Block 7 to 0 (SB7 to SB0): These bits select small blocks (SB7 to SB0) to be
Bits 7 to 0
programmed and erased.
Bits 7 to 0
SB7 to SB0 Description
0 Block SB7 to SB0 is not selected (Initial value)
1 Block SB7 to SB0 is selected
The RAM control register (RAMCR) enables or disables access to the on-chip RAM and controls
RAM area overlapping.
Bit 7 6 5 4 3 2 1 0
RAME − RAME2 − − RAM2 RAM1 RAM0
Initial value 1 * 1 * * 0 0 0
R/W R/W − R/W − − R/W R/W R/W
RAM2/1/0
Specify a flash-memory
area to be overlapped
by RAM
Reserved bits
RAM enable 2
Enables or disables access to
on-chip RAM (H'EE80 to H'F67F)
Reserved bit
RAM enable 1
Enables or disables access to on-chip RAM
(H'F680 to H'FE7F)
Note: * Bit 6, 4, and 3 have undetermined values when read.
Bits 7 and 5RAM Enable 1 and 2 (RAME1, RAME2): When bit 7 or 5 is cleared to 0, access
to the respective on-chip RAM area is disabled. For details see section 17.2, "RAM Control
Register."
RAM2 to RAM0: Bits 2 to 0 are used together with bits 7, 3, 2, and 1 of the flash
Bits 2 to 0
memory emulation register (FLMER) to specify a ROM area for which overlapping is to be
performed (see table 19-5). In modes 2, 4, and 7 (with on-chip flash memory enabled), the initial
value of these bits is 0, but they can be modified by writing 1*. In other modes these bits cannot
be modified and always read 0. They are initialized by a reset and in hardware standby mode.
They are not initialized in software standby mode.
The flash memory emulation register (FLMER) performs enabling and disabling of flash memory
RAM emulation and RAM area modification when RAM emulation is started.
Bit 7 6 5 4 3 2 1 0
OVLPE − − − A11E A10E A9E −
Initial value 0 1 1 1 0 0 0 1
R/W R/W − − − R/W R/W R/W −
Reserved bits
A9E bit
Bits A11E to A9E
specify a RAM area
to be overlapped onto
flash memory
A10E bit
Bits A11E to A9E
specify a RAM area
to be overlapped onto
flash memory
A11E bit
Bits A11E to A9E
specify a RAM area
to be overlapped onto
flash memory
Reserved bit
Bit 7Emulation RAM Enable (OVLPE): Used with 3 to 1 to specify a RAM area (see table
19-5). When bit 7 is set, all flash memory blocks are protected from programming and erasing,
1
regardless of the values of bits 3 to 1. This state is referred to as emulation protection* . In this
state the flash memory will not enter program mode or erase mode even if the P or E bit is set in
the flash memory control register (FLMCR). Only transitions to verify modes are possible. Bit 7
must be cleared to 0 to enable flash memory to be actually programmed or eraed.
A11E to A9E: Bits 3 to 1 select the RAM area to be overlapped onto ROM when
Bits 3 to 1
performing RAM emulation of flash memory (see table 19-6).
In modes 2, 4, and 7 (with on-chip flash memory enabled), the initial value of these bits is 0, but
they can be modified by writing. In other modes, these bits cannot be modified and always read 0.
They are initialized by a reset and in hardware standby mode. They are not initialized in software
standby mode.
Notes: 1. For details of emulation protection, see section 19.4.8, "Protect Modes."
2. Bits 7, 3, 2, and 1 of the flash memory emulation register (FLMER) and bits 2 to 0 of
the RAM control register (RAMCR) can be written to in modes 2, 4, and 7.
(In the H8/538F it was necessary to apply 12 V as the program voltage VPP when
performing RAM emulation, but in the H8/539F RAM emulation can be performed
regardless of the VPP voltage.)
The flash memory status register (FLMSR) is used to detect a flash memory error.
Bit 7 6 5 4 3 2 1 0
FLER − − − − − − −
Initial value 0 1 1 1 1 1 1 1
R/W R − − − − − − −
Reserved bit
Bits 7
FLER Description
0 Flash memory is not write/erase-protected (Initial value)
1
(is not in error protect mode* )
[Clearing conditions]
Reset by 5(6 pin* or hardwer standby mode
3
1 Indicates that an error occurred while flash memory was being programmed or
1
erased, and error protection* is in effect
[Setting conditions]
•
2
Flash memory was read* while being programmed or erased (including vector
read or instruction fetch, but not including reading of a RAM area overlapped
onto flash memory).
• A hardware exception-handling sequence (other than a reset, invalid
instruction, trap instruction, or zero-divide exception) was executed just before
4
programming erasing.*
• The SLEEP instruction (for transition to sleep mode or software standby mode)
was executed during programming or erasing.
2
Table 19-6 RAM Area* Setting
H'F000-H'F1FF 0 0 0 1 1
(512 byts)
H'F200-H'F3FF
0 0 1 1 1
(512 byts)
H'F400-H'F5FF
0 1 0 1 1
(512 byts)
H'F600-H'F7FF
0 1 1 1 1
(512 byts)
H'F800-H'F9FF
1 0 0 1 1
(512 byts)
H'FA00-H'FBFF
(512 byts) 1 0 1 1 1
H'FC00-H'FDFF
(512 byts) 1 1 0 1 1
Use prohibited * 3 1 1 1 1 1
To use boot mode, a user program for programming and erasing the flash memory must be
provided in advance on the host machine (which may be a personal computer). Serial
communication interface channel 1 is used in asynchronous mode. If the H8/539F is placed in
boot mode, after it comes out of reset, a built-in boot program is activated. This program starts by
measuring the low period of data transmitted from the host and setting the bit rate register (BRR)
accordingly. The H8/539F's built-in serial communication interface (SCI) can then be used to
download the user program from the host machine. The user program is stored in on-chip RAM.
After the program has been stored, execution branches to the start address of the user program in
on-chip RAM (H'F380), and the program stored on RAM is executed to program and erase the
flash memory. Figure 19-4 shows the boot-mode execution procedure.
Start
1. Program the H8/539F pins for boot mode, and
start the H8/539F from a reset.
1 Program H8/539F pins for boot mode, 2. Set the host's data format to 8 bits + 1 stop bit,
and reset select the desired bit rate (2400, 4800, or 9600
bps), and transmit H'00 data continuously.
3. The H8/539F repeatedly measures the low period
2 Host transmits H'00 data continuously
at desired bit rate of the RXD1 pin and calculates the host's
asynchronous-communication bit rate.
4. When SCI bit-rate alignment is completed, the
H8/539F measures low period H8/539F transmits one H'00 data byte to indicate
of H'00 data transmitted from host completion of alignment.
3 5. The host should receive the byte transmitted from
H8/539F computes bit rate and the H8/539F to indicate that bit-rate alignment is
sets bit rate register completed, check that this byte is received
normally, then transmit one H'55 byte.
6. After transmitting H'55, the host transmits the byte
After completing bit-rate alignment, H8/539F length of the user program to be transferred to the
4 sends one H'00 data byte to host to indicate H8/539F. The byte length must be sent as two-
that alignment is completed byte data, most significant byte first and least
significant byte second. After that, the host
Host checks that this byte, indicating proceeds to transmit the user program. As
5 completion of bit-rate alignment, is received verification, the H8/539F echoes each byte of the
normally, then transmits one H'55 byte received byte-length data and user program back
to the host.
7. The H8/539F stores the received user program in
H8/539F receives two bytes indicating byte on-chip RAM in a 2.8-kbyte area from H'F380 to
6 length (N) of program to be downloaded
H'FE7F.
to on-chip RAM*1
8. Before executing the downloaded user program,
the H8/539F branches to the boot program area in
RAM (H'EE80 to H'F37F), then checks whether
H8/539F transfers one user program the flash memory already contains any
byte to RAM*2 programmed data. If so, all bocks are erased.
9. The H8/539F branches to address H'F380 in on-
H8/539F calculates number of bytes left chip RAM and executes the user program stored
7 to be transferred (N = N - 1) in the area from H'F380 to H'FE7F.
Start Stop
D0 D1 D2 D3 D4 D5 D6 D7
bit bit
When started in boot mode, the H8/539F measures the low period in asynchronous SCI data
transmitted from the host (figure 19-5). The data format is eight data bits, one stop bit, and no
parity bit. From the measured low period (nine bits), the H8/539F computes the host's bit rate.
After aligning its own bit rate, the H8/539F sends the host one byte of H'00 data to indicate that
bit-rate alignment is completed. The host should check that this alignment-completed indication is
received normally, then transmit one H'55 byte. If the host does not receive a normal alignment-
completed indication, the H8/539F should be reset, then restarted in boot mode to measure the low
period again. There may be some alignment error between the host's and H8/539F's bit rates,
depending on the host's bit rate and the H8/539F's system clock frequency. To have the SCI
1
operate normally, set the host's bit rate to 2400, 4800, or 9600 bps.* Table 19-8 lists typical host
bit rates and indicates the clock-frequency ranges over which the H8/539F can align its bit rate
2
automatically. Boot mode should be used within these frequency ranges.*
H'EE80
Boot
program Note: * This area is unavailable until transition
area* to user program execution (branch to
(1.25 kbytes) RAM area address H'F380).
Also note that the boot program remains
H'F380 in the boot program area (H'EE80 to
H'F37F) in RAM after the branch to the
user program.
User program
transfer area
(2.75 kbytes)
H'FE7F
1. When the H8/539F comes out of reset in boot mode, it measures the low period of the input at
the SCI's RXD1 pin. The reset should end with RXD1 high. After the reset ends, it takes about
100 states for the H8/539F to get ready to measure the low period of the RXD1 input.
2. In boot mode, if any data has been programmed into the flash memory (if all data are not
H'FF), all flash memory blocks are erased. Boot mode is for use when user program mode is
unavailable, e.g. the first time on-board programming is performed, or if the update program
activated in user program mode is accidentally erased.
3. Interrupts cannot be used while the flash memory is being programmed or erased.
4. The RXD1 and TXD1 lines should be pulled up on-board.
5. Before branching to the user program (at address H'F380 in the RAM area), the H8/539F
terminates transmit and receive operations by the on-chip SCI (by clearing the RE and TE bits
to 0 in the serial control register (SCR)), but the auto-aligned bit rate remains set in bit rate
register BRR1. The transmit data pin (TXD1) is in the high output state (in port 7, the P72DDR
and P72DR bits are set to 1).
When the branch to the user program occurs, the contents of general registers in the CPU are
undetermined. After the branch, the user program should begin by initializing general registers,
especially the stack pointer (SP), which is used implicitly in subroutine calls and at other
times. The stack pointer must be set to provide a stack area for use by the user program. The
other on-chip registers do not have specific initialization requirements.
When set to user program mode, the H8/539F can erase and program its flash memory by
executing a user program. On-board updates of the on-chip flash memory can be carried out by
providing on-board circuits for supplying VPP and data, and storing an update program in part of
the program area.
To select user program mode, select a mode that enables the on-chip ROM (mode 2, 4, or 7) and
apply 12 V to the VPP pin. In this mode, the on-chip peripheral modules operate as they normally
would in mode 2, 4, or 7, except for the flash memory. A watchdog timer overflow, however,
cannot output a reset signal while 12 V is applied to VPP. The watchdog timer's reset output enable
bit (RSTOE) should not be set to 1.
The flash memory cannot be read while being erased, so the update program must either be stored
in external memory, or transferred temporarily to the RAM area and executed in RAM.
Example of User Program Mode Execution Procedure*: Figure 19-7 shows the procedure for
user program mode execution in RAM.
Note: * Do not apply 12 V to the VPP pin during normal operation. To prevent microcontroller
errors caused by accidental programming or erasing, apply 12 V to VPP only when the flash
memory is programmed or erased, or when flash memory is emulated by RAM.
Overprogramming or overerasing due to program runaway, etc., may prevent memory
cells from operating normally. While 12 V is applied, the watchdog timer should be
running and enabled to halt runaway program execution, so that program runaway will not
lead to overprogramming or overerasing.
1
Procedure
MD2 to MD0= 010, 100, or 111
(MD2 = 0 to 5 V application) The user should write a program that executes operations 3 to 9
below to flash memory in advance.
2
1. Set the mode pins to a mode with on-chip ROM enabled
Reset start (mode 2, 4, or 7).
9
Execute user application
program in flash memory
The flash memory can operate in program mode, erase mode, program-verify mode, erase-verify
mode, or prewrite-verify mode. Transitions to these modes can be made by setting the P, E, PV,
and EV bits in the flash memory control register (FLMCR). A wait time of at least 5 µs should be
left after setting the VPPE bit when making a trasition to an operating mode. The area to be
programmed in flash memory (target block is specified by means of erase block registers 1 and 2
(EBR1, EBR2).
The flash memory cannot be read while being programmed or erased. The program that controls
the programming and erasing of the flash memory must be stored and executed in on-chip RAM or
in external memory. A description of each mode is given below, with recommended flowcharts
and sample programs for programming and erasing. Recommended programming and erasing
flowcharts adopt an algorithm which doubles the programming or erasing time successively. This
algorithm can decrease the number of repetitions and shorten the verify time, enabling high-speed
programming and erasing. The high-speed alogorithm is specially effective, when the H8/539F is
used at a low clock frequency.
Section 19.7, "Flash Memory Programming and Erasing Precautions," gives further notes on
programming and erasing. See section 22.2.4, Flash Memory Characteristics, for the wait time
after a bit is set or cleared in the flash memory control register (FLMCR).
To write data into the flash memory, follow the programming algorithm shown in figure 19-8.
This programming algorithm can write data without subjecting the device to voltage stress or
impairing the reliability of programmed data.
To program data, first write the data to the address to be programmed, as in writing to RAM. The
flash memory latches the address and data in an address latch and data latch. Next set the P bit in
FLMCR, selecting program mode. The programming duration is the time during which the P bit is
n-1
set. Programming duration should be set to increase by 2 times (n=1, 2, 3, 4, 5, 6) of the initial
setting value. A software timer should be used to provide an initial setting value of 10 to 15.8 µs.
Set n so that the total programming time does not exceed 1ms. Programming for too long a time,
due to program runaway for example, can cause device damage. Before selecting program mode,
set up the watchdog timer so as to prevent overprogramming.
In program-verify mode, after data has been programmed in program mode, the data is read to
check that it has been programmed correctly.
After the programming time has elapsed, exit programming mode (clear the P bit to 0) and select
program-verify mode (set the PV bit to 1). In program-verify mode, a program-verify voltage is
applied to the memory cells at the latched address. If the flash memory is read in this state, the
data at the latched address will be read. After selecting program-verify mode, wait 4 µs or more
before reading, then compare the programmed data with the verify data. If they agree, exit
program-verify mode and program the next address. If they do not agree, select program mode
again and repeat the same program and program-verify sequence. When repeating the program and
program-verify sequence for the same bit, set the total programming time to a maximum of 1ms.
Start
Wait (tvs3) µs *4
n =1
n ≤ N ? *4
NO (programming error)
YES (reprogram)
Clear PV bit
Clear PV bit
4
Wait (tVS1) µs *
Wait (tFRS) µs *4
End
R0: Specifies program data as byte data./Return value (0: Normal, 1: Write error).
R1: Used to specify the program target block.
R2: Used for program address page specification.
R3: Used for program address specification.
After the values of R0 (program data), R1 (program target block), R2 (program address page), and
R3 (program address) have been specified, arbitrary data can be programmed at an arbitrary
address by calling the fwrite subroutine.
The wait time due to software looping after bit setting depends on the operating frequency. The
relevant operating frequency can be specified by setting the MHZ symbol value. In this program
the wait time (number of loops) is calculated on the assumption that the scb/f instruction is located
at an even address in two-state access space (on-chip RAM).
The read setup time (tFRS) after clearing the VPPE bit is the value for the case where VCC ≥ 4.5 V.
See section 22.2.4, "Flash Memory Characteristics," for the wait time after setting a bit in the flash
memory control register (FLMCR).
0001:; ***************************************************************************
0002:; * fwrite, src (Ver. 0.10)
0003:; * Sample program for programming one byte of H8/539F flash memory
0004:; *
0005:; ***************************************************************************
0006:;
0007:;
0008: MHZ .equ d'10 ; Depends on operating frequency (10 MHz)
0009: RAMSTR .equ H'EE80 ; Program transfer destination RAM address
0010:; Register addresses
0011: FLMCR .equ H'FEE0 ; Flash memory control register
0012: EBR .equ H'FEE2 ; Target block specification register
0013: TCSR .equ H'FF10 ; Timer control/status register
0014: WCR .equ H'FF14 ; Wait control register
0015:;
0016:;
0017: align H'2
0018: main: equ $
0019: ldc.b #H'00:8,tp ; Stack page register setting
Notes: 1. The program code shown here illustrates an example of how to program or erase the
on-chip flash memory. It is not compatible with all chip models, so it cannot be used
unmodified. It is only intended as an example for program developers.
2. Always confirm program execution before actually using program code in an
application.
3. This program code may be changed without notice due to improvements, etc.
To erase the flash memory, follow the erasing algorithm shown in figure 19-9. This erasing
algorithm can erase data without subjecting the device to voltage stress or impairing the reliability
of programmed data.
To erase flash memory, before starting to erase, first place all memory data in all blocks to be
erased in the programmed state (program all memory data to H'00). If all memory data is not in
the programmed state, follow the sequence described later to program the memory data to H'00.
Select the flash memory areas to be erased with erase block registers 1 and 2 (EBR1 and EBR2).
Next set the E bit in FLMCR, selecting erase mode. The erase time is the time during which the E
bit is set. To prevent overerasing, divide the first three times into 6.25 ms, 12.5 ms, and 25 ms
intervals, followed by 50 ms intervals repeated a maximum of 599 times, so that the total erase
time does not exceed 30s. Overerasing, due to program runaway for example, can give memory
cells a negative threshold voltage and cause them to operate incorrectly. Before selecting erase
mode, set up the watchdog timer so as to prevent overerasing.
In program-verify mode, after data has been erased, it is read to check that it has been erased
correctly. After the erase time has elapsed, exit erase mode (clear the E bit to 0) and select erase-
verify mode (set the EV bit to 1). Before reading data in erase-verify mode, write H'FF dummy
data to the address to be read. As a result of this dummy write, the erase-verify voltage is applied
to the memory cells at the latched address. When the flash memory is read in this state, the data at
the latched address is read. After selecting erase-verify mode, wait at least 4 µs, plus at least 2 µs
for the dummy write to each address, before reading. If the read data has been successfully erased,
perform the dummy write and erase-verify for the next address. If the read data has not been
erased, select erase mode again and repeat the same erase and erase-verify sequence through the
last address, until all memory data has been erased H'FF. Do not repeat the erase and erase-verify
sequence more than 602 times, however.
Rev. 3.0, 02/99, page 544 of 904
19.4.6 Erasing Flowchart and Sample Program
erase * 5
Erase target blocks
erasevf * 6
Erase-verify
NO
All erase target blocks erased?
(EBR1, EBR2 = 0?)
n=n+1
YES
Yes (Re-erase)
n ≤ N ?* 2
No (Erase error)
End
Start
NO
Erase target block ?
YES
Set start address of erase target block to
prewrite address
prebyt
One-byte prewrite
NO
One-byte prewrite OK?
YES
Prewrite address + 1
NO
Last address of block?
YES
Block table + 1
NO
End of all blocks ?
YES
End
Start
n=1
Read flash memory data and write Notes: 1. Write the data with a byte transfer
inverted data * 1 instruction.
(Write one's complement data to latch 2. Set the timer overflow interval (CKS2 =
address and data) 0, CKS1 = 1, CKS0 = 0).
3. In prewrite-verify mode, VppE = 1, P = E
= PV = EV = 0, and 12 V is applied to
Enable watchdog timer * 2 the Vpp pin. Read the memory data with
a byte transfer instruction.
4. x: x=initial value x 2n-1 (n = 1,2,3,4,5,6)
Select program mode (Set an initial value of 10 to 15.8 µs)
(set P bit in FLMCR to 1) tVS1: 4 µs or more
N: 6 (Set N so that total programming
time does not exceed 1 ms)
Wait (X) µs * 4
Wait (tvs1) µs * 4
Prewrite verify * 3 NG
(read data = H'00?)
OK (prewrite completed)
n = n+ 1
No (programming error)
n ≤ N ? *4
YES (reprogram)
Set return code
0: Normal, 1: Programming error (n>N)
End
Wait (X) ms *2
End
Start
Waite (tvs2) µs *1
Verify *3
(Read memory)
Address + 1→ address
NO
Last address of block ?
YES
(Erasing of one block completed)
Block table + 1
NO (Next block)
End of all blocks ?
Clear EV bit
End
The value set in TCSR to provide the watchdog timer overflow interval setting when erase mode
is selected depends on the operating frequency. TCSR set values for different operating
frequencies are shown in table 19-10.
As software loops are used, there is intrinsic error in the wait times, and the calculated value and
actual time may not be the same. Therefore, initial values should be set so that the total
programming time does not exceed 1 ms, and the total erase time does not exceed 30 s.
The set value for the watchdog timer is calculated on the basis of the number of instructions
including the programming time and erase time from the time the watchdog timer is started until it
stops. Therefore, no other instructions should be added between starting and stopping of the
watchdog timer in these program examples.
The loop counter value for each frequency is calculated as shown below.
(1) Program time (P bit set) and calculation formula: When the scb/f instruction is in two-state
access space, and the branch destination is at an even address, the processing time is 4 states when
the register value = 0 (no branch) and 8 states when the register value ≥ 1 (branch). Thus the
calculation formula, with truncation of the decimal part, is as follows.
Loop counter value = ((Wait time (µs) × operating frequency (MHz)) states - 4 states)/8 states
(2) Erase time (E bit set) calculation formula: For the same access space as in (1) above, the
calculation formula is as follows.
Loop counter value = ((Wait time (µs) × operating frequency (MHz)) states - 14 states)/18 states.
(3) Wait time (after PV setting: t vs1), (after EV setting: tvs1), (after latching: tvs2) (after VPPE
clearing: tvps) calculation formula: With the same number of states as in (1) above, the
calculation formula, with rounding of the decimal part, is as follows.
Loop counter value = ((Wait time (µs) × operating frequency (MHz)) states-4 + 4 states)/8 states
Operating Frequency
f = 16 MHz f = 10 MHz f = 8 MHz f = 2 MHz
Counter Counter Counter Counter
Set Value Set Value Set Value Set Value
Program time 15.8 µs H'001E H'0013 H'000F H'0003
(initial set value)
tVS1 4 µs H'0008 H'0005 H'0004 H'0001
tVS2 2 µs H'0004 H'0002 H'0002 H'0001
tVPS 5 µs H'000A H'0006 H'0005 H'0001
Erase time 6.25ms H'15B2 H'0D8F H'0AD9 H'02B5
(initial set value)
Table 19-10 Watchdog Timer Overflow Interval Settings when Erase Mode is set
Variable
Operating Frequency [MHz] TCSR Set Value
10 MHz ≤ frequency ≤ 16 MHz H'A57F
2 MHz ≤ frequency < 10 MHz H'A57E
After a value is specified in R0 (erase block), an arbitrary block can be erased by calling the ferase
subroutine. After the ferase subroutine ends, the return value is returned in R0 and an NG block in
R1.
The wait time due to software looping after bit setting depends on the operating frequency. The
relevant operating frequency can be specified by setting the MHZ symbol value. In this program
the wait time (number of loops) is calculated on the assumption that the scb/f instruction is located
at an even address in two-state access space (on-chip RAM). The read setup time (tFRS) after VPPE
bit clearing used here is for the case where VCC ≥ 4.5 V. See section 22.2.4, Flash Memory
Characteristics, for the wait time after a bit is set in the flash memory control register (FLMCR).
Each bit in R0 corresponds to a bit in the erase block registers (EBR1, EBR2). A bit map of R0
and an example of the method of calling the subroutine are shown below.
A bit map of R0 and an example setting for erasing specific blocks are shown next.
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R0 LB7 LB6 LB5 LB4 LB3 LB2 LB1 LB0 SB7 SB6 SB5 SB4 SB3 SB2 SB1 SB0
Bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
R0 LB7 LB6 LB5 LB4 LB3 LB2 LB1 LB0 SB7 SB6 SB5 SB4 SB3 SB2 SB1 SB0
Setting 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1
Ferase subroutine calling is performed as shown for the all_erase subroutine in list 1.
0001:;****************************************************************************
0002:;* ferase, src (Ver. 0.13) *
0003:;* Sample program for H8/539F flash memory block erasing *
0004:;* *
0005:;****************************************************************************
0006:;
0007:;
0008:MHZ .equ d'16 ; Depends on operating frequency (16 MHz)
0009:RAMSTR .equ H'EE80 ; Program transfer destination RAM address
0010:; Register addresses
0011:FLMCR .equ H'FEE0 ; Flash memory control register
0012:EBR .equ H'FEE2 ; Target block specification register
0013:TCSR .equ H'FE10 ; Timer control/status register
0014:WCR .equ H'FE14 ; Wait control register
0015:MDCR .equ H'FE19 ; Mode control register
0016:;
0017:;
0018: .align H'2
0019:main:.equ $
0020: ldc.b #H'00:B,tp ; Stack page register setting
0021: mov.w #H'FE80,sp ; Stack pointer setting
0022: ldc.b #H'00:8,ep ; Page register initialization
0023: ldc.b #H'00:8,dp ; Page register initialization
0024:;
0025: mov.w #prog_start,R0 ; Transfer start address
0026: mov.w #prog_stop,R1 ; Transfer end address
0027: bsr tensou:16 ; Program transfer to RAM
0028:;
0029: ; Argument setting and subroutine call
0030: jsr @RAMSTR ; JMP SUB to RAM area program (prog_start)
0031: ; (All-mat erase example)
0032:;
0033:main_end: ; End of erase
0034: bra main_end
0035:;
0036:;
Notes: 1. The program code shown here illustrates an example of how to program or erase the
on-chip flash memory. It is not compatible with all chip models, so it cannot be used
unmodified. It is only intended as an example for program developers.
2. Always confirm program execution before actually using program code in an
application.
3. This program code may be changed without notice due to improvements, etc.
Prewrite-verify mode is a verify mode used after zeroizing all bits to equalize their threshold
voltages before erasing them.
To program all bits, use the one-byte prewrite algorithm shown in figure 19-10. Use this
procedure to set all flash memory data to H'00 after programming. After the necessary
programming time has elapsed, exit program mode (by clearing the P bit to 0) and select prewrite-
verify mode (leave the P, E, PV, and EV bits all cleared to 0). In prewrite-verify mode, a
prewrite-verify voltage is applied to the memory cells at the read address. If the flash memory is
read in this state, the data at the read address will be read. After selecting prewrite-verify mode,
wait 4 µs before reading.
Note: For a sample prewriting program, see the prewrite subroutine in the sample erasing
program.
Flash memory can be protected from programming and erasing by software or hardware methods.
These two protection modes are described below.
Software Protection: Prevents transitions to program mode and erase mode even if the P or E bit
is set in the flash memory control register (FLMCR). Details are as follows.
Function
1
Protection Description Program Erase Verify*
Block protect Individual blocks can be Disabled Disabled Enabled
program/erase-protected by the erase
block registers (EBR1 and EBR2). If
EBR1 and EBR2 are both set to H'00,
all blocks are program/erase-
protected.
3
Emulation When the OVLPE bit is set in the flash Disabled Disabled* Enabled
2
protect* memory emulation register (FMLER),
all blocks are protected from both
programming and erasing.
Notes: 1. Three modes: program-verify, erase-verify, and prewrite-verify.
2. Except in RAM areas overlapped onto flash memory.
3. All blocks are erase-disabled. It is not possible to specify individual blocks.
Hardware Protection: Suspends or disables the programming and erasing of flash memory, and
resets the flash memory control register (FLMCR) and erase block registers (EBR1 and EBR2).
The error-protect function permits the P and E bits to be set, but prevents transitions to program
mode and erase mode. Details of hardware protection are as follows.
Rev. 3.0, 02/99, page 565 of 904
Function
1
Protection Description Program Erase Verify*
2
Programing When VPP is not applied, FLMCR, Disabled Disabled* Disabled
voltage (VPP) EBR1, and EBR2 are initialized,
protect disabling programming and erasing.
To obtain this protection, VPP should
3
not exceed VCC.*
2
Reset and When a reset occurs (including a Disabled Disabled* Disabled
standby watchdog timer reset) or standby
protect mode is entered, FLMCR, EBR1, and
EBR2 are initialized, disabling
programming and erasing. Note that
5(6 input does not ensure a reset
unless the 5(6 pin is held low for at
least 20 ms at power-up (to enable the
oscillator to settle), or at least six
system clock cycles (6φ) during
4
operation.*
2
Error protect If an operational error is detected Disabled Disabled* Enabled
during programming or erasing of
flash memory (FLER = 1), the FLMCR,
EBR1, and EBR2 settings are
preserved, but programming or
erasing is aborted immediately. This
type of protection can be cleared only
by a reset by means of the 5(6 pin*
5
or hardware standby.
Notes: 1. Three modes: program-verify, erase-verify, and prewrite-verify.
2. All blocks are erase-disabled. It is not possible to specify individual blocks.
3. For details, see section 19.7, "Flash Memory Programming and Erasing Precautions."
4. See section 4.2.2, "Reset Sequence" and section 19.7, "Flash Memory Programming
and Erasing Precautions."
5. In the H8/538F, this includes the FLER bit clearing conditions and a watchdog timer
reset, but in the H8/539F only 5(6 pin reset input is applicable.
Error Protect: This protection mode is entered if one of the error conditions that set the FLER bit
1
in FLMSR* is detected while flash memory is being programmed or erased (while the P bit or E
3
bit is set in FLMCR* ). These conditions can occur if microcontroller operations do not follow the
programming or erasing algorithm. Error protect is a flash-memory state. It does not affect other
microcontroller operations.
In this state the settings of the flash memory control register (FLMCR) and erase block registers
2
(EBR1 and EBR2) are preserved,* but program mode or erase mode is terminated as soon as the
error is detected. While the FLER bit is set, it is not possible to enter program mode or erase
mode, even by setting the P bit or E bit in FLMCR again. The PV and EV bits in FLMCR remain
valid, however. Transitions to verify modes are possible in the error-protect state.
Rev. 3.0, 02/99, page 566 of 904
The error-protect state can be cleared only by a reset by means of the 5(6 pin or entry to
hardware standby mode.
Notes: 1. For the detailed conditions that set the FLER bit, see section 19.2.4, "RAM Control
Register (RAMCR)."
2. It is possible to write to the FLMCR, EBR1, and EBR2 registers. Note that a transition
to software standby mode in the error protect state initializes these registers.
2. Note that NMI input is disabled when the P bit or E bit is set. For details, see section
19.4.9, "NMI Input Masking."
Memory read
or verify mode Reset, or hardware standby,
or software standby
RD VF PR ER
FLER = 0
Reset or standby
Reset cleared and hardware (hardware protect)
standby cleared and software
P = 1 or E = 1 P = 0 and E = 0 standby cleared RD VF PR ER
Reset or INIT
hardware standby FLER = 0
This protection function does not cover abnormal conditions other than the setting conditions of
the flash memory error bit (FLER), however. Also, if too much time elapses before the error-
protect state is reached, the flash memory may already have been damaged. This function
accordingly does not offer foolproof protection from damage to flash memory.
NMI input is disabled when flash memory is being programmed or erased (when the P or E bit is
set in FLMCR). NMI input is also disabled while the boot program is executing in boot mode,
1
until the branch to the on-chip RAM area takes place.* There are three reasons for this.
1. NMI input during programming or erasing might cause a violation of the programming or
erasing algorithm. Normal operation could not be assured.
2. In the NMI exception-handling sequence during programming or erasing, the vector would not
2
be read correctly.* The result might be a program runaway.
3. If NMI input occurred during boot program execution, the normal boot-mode sequence could
not be executed.
For these reasons, under certain conditions the H8/539F masks the normally nonmaskable NMI
input. This masking does not, however, ensure normal programming, erasing, and other
microcontroller operations. NMI requests should be disabled externally whenever VPP is applied.
NMI input is also disabled in the error-protect state and while the P or E bit remains set in the
flash memory control register (FLMCR) during emulation of flash memory using RAM.
Notes: 1. The disabled state lasts until the branch to the boot program area in on-chip RAM
(addresses H'EE80 to H'F37F) that takes place as soon as the transfer of the user
program is completed. After the branch to the RAM area, NMI input is enabled except
during programming or erasing. NMI interrupt requests must therefore be disabled
externally until the user program has completed initial programming (including the
vector table and the NMI interrupt-handling program).
2. In this case, the vector may not be read correctly for the following two reasons.
a. If flash memory is read while being programmed or erased (while the P or E bit
is set in FLMCR), correct read data will not be obtained. Undetermined values
are returned.
b. If the NMI entry in the vector table has not been programmed yet, NMI
exception handling will not be executed correctly.
After a flash memory area has been overlapped by RAM, it can be accessed from two address
areas: the overlapped flash memory area (mapping RAM area), and the original RAM area (the
actual RAM area). Bits 7, 3, 2, and 1 of FLMER and bits 2 to 0 of RAMCR are valid in Modes 2,
4, and 7. In other modes, they always read 0 and the RAM area cannot be reassigned. When the
flash memory emulation function is used, bits 7 and 5 of RAMCR should both be set (RAME1 =
RAME2 = 1). Table 19-10 indicates how to assign a mapping RAM area. Bits 7 and 5 of
RAMCR should both be set (RAME1 = RAME2 = 1). Table 19-10 indicates how to assing a
mapping RAM area.
Bit 7 6 5 4 3 2 1 0
OVLPE − − − A11E A10E A9E −
Initial value 0 1 1 1 0 0 0 1
R/W R/W − − − R/W R/W R/W −
In the following example, RAM area H'F200 to H'F3FF is overlapped onto the SB5 flash memory
area (H'3A00 to H'3BFF).
H'FE7F
00000
*1
16 kbytes
Flash memory 03FFF
*2
04000
Mapping area *1
Page 0
0EE80
*2
0FE7F
Area used
RAM
in RAM emulation *2
ROM :03000 to 03FFF
RAM:0F000 to 0FDFF
10000
(16 kbytes) *1
Flash memory 13FFF
14000
Page 1 64 kbytes
(48 kbytes)
Flash memory
1FFFF
20000
2FFFF
Notes: 1. Area 00000 to 03FFF and 10000 to 13FFF are mapping areas. They can be accessed
from both page 0 and page 1.
2. When the RAM emulation function is used and RAM is overlapped onto a ROM area, the overlapped
page 0 RAM area is not mapped onto page 1. (RAM emulation can only be used in page 0.)
In this case, ROM contents be read by accessing page 1.
For details, see section 19.7, "Flash Memory Programming and Erasing Precautions."
NMI input disabling conditions: When the emulation function is used, NMI input is disabled
when the P bit or E bit in the flash memory control register (FLMCR) is set, in the same way as
with normal programming and erasing.
The P and E bits are cleared by a reset (including a watchdog timer reset), in standby mode, and
when 12 V is not being applied to VPP.
The on-chip flash memory of the H8/539F can be programmed and erased not only in the on-board
programming modes but also in PROM mode, using a general-purpose PROM programmer. In
PROM mode, make sure that the socket adapter listed in table 19-13 is used.
Programs can be written and verified by attaching a special 112-pin/32-pin socket adapter to the
general-purpose PROM programmer. Table 19-13 gives ordering information for the socket
adapter. Figure 19-18 shows a memory map in PROM mode.
H'2FFFF
Note: Use an appropriate tool when inserting the device in the IC socket and removing it. For
example, the tool shown in table 19-14 can be used.
The program/erase/verify specifications in PROM mode are the same as for the standard
HN28F101 flash memory. The H8/539F does not have a device recognition code, so the
programmer cannot read the device name automatically. Table 19-15 indicates how to select the
various operating modes in PROM mode. Table 19-15 indicates how to select the various
operating modes in PROM mode, and table 19-16 lists the commands used in PROM mode.
Pins
Mode VPP VCC &( 2( :( D7 to D0 A16 to A0
Read Read VCC VCC L L H Data output Address input
Output VCC VCC L H H High impedance
disable
Standby VCC VCC H X X High impedance
Command Read VPP VCC L L H Data output
write
Output VPP VCC L H H High impedance
disable
Standby VPP VCC H X X High impedance
Write VPP VCC L H L Data input
Legend
L: Low level
H: High level
VPP: VPP level
VCC: VCC level
X: Don't care
Start
Address = 0
n=0
n+1→n
Program command
Program-verify command
Wait (6 µs)
Address + 1 → address
No Go
Verification?
Go No
n = 20?
No
Last address?
Yes
Yes
End Fail
Start
Address = 0
n=0
n+1→n
Erase-verify command
Wait (6 µs)
Address + 1 → address
No Go
Verification?
Go No
n = 3000?
No
Last address?
Yes
Yes
End Fail
Note: * Follow the high-speed, high-reliability programming flowchart in programming all bits.
(Conditions: VCC = 5.0 V ±10%, VPP = 12.0 V ±0.6 V, VSS = 0 V, Ta = 25°C ±5°C)
(Conditions: VCC = 5.0 V ±10%, VPP = 12.0 V ±0.6 V, VSS = 0 V, Ta = 25°C ±5°C)
Address
CE
tCEH tCES
Status polling
12 V
VPP
5.0 V tVPS
tVPH
Address Valid address
tAH
tAS
CE
tCEH
tCES
OE tCWC tCES
tCES tCEH
tWEP tPPW
tCEH tWEP tWEP tOERS
tOEWS
WE tWEH
tDH tDH tDH tVA tDF
tDS tDS tDS
I/O7 Command Data Command Valid data
input input input output
Note: Program-verify data output values maybe intermediate between 1 and 0 if programming is insufficient.
12 V
VPP
5.0 V tVPS tVPH
CE
WE tCEH
tWEH tVA
tDH tDH tDH tDF
tDS tDS tDS
Note: Erase-verify data output values maybe intermediate between 1 and 0 if erasing is insufficient.
(1) Program with the specified voltages and timing. The rated programming voltage (VPP) of
the flash memory is 12.0 V.
Applied voltages in excess of the rating can permanently damage the device. In particular, ensure
that the peak overshoot does not exceed the maximum rating of 13 V at the VPP and MD2 pins.
In PROM mode, VPP can be set to 12.0 V if HN28F101 is selected as the PROM programmer
setting. 12 V must not be applied to the S-mask model (single power source model), as this will
permanently damage the device.
For information concerning the use of the S-mask model, see section 20, Flash Memory (H8/539F,
S-Mask Model, Single Power Source).
(2) Design a current margin into the programming voltage (VPP) power supply. Bypass
capacitors must be connected to the VPP pin. (See figures 19-24 and 19-28.) Ensure that VPP
remains within the range 12.0 ±0.6 V (11.4 V to 12.6 V) during programming and erasing.
Programming and erasing may become impossible outside this range. Connect decoupling
capacitors as close to the VPP pin as possible. When boot mode is used, also, decoupling
capacitors should be connected to the MD2 pin in the same way.
For details, see section 19.8, "Notes on Mounting Board DevelopmentHandling of VPP and
Mode MD2 Pins."
+5 V
Example of circuit when pull-up
resistor is inserted
Vpp
+12 V
RESO
H8/539F
(Duel Power System)
1.0 µF 0.01 µF
Note: This sample circuit cannot be used with the S-mask model (single power system).
(a) Apply the programming voltage (VPP) after VCC has stabilized, and shut off VPP before VCC.
To avoid programming or erasing flash memory by mistake, VPP should only be applied and
released when the microcontroller is in a "stable operating condition" as described below.
• The VCC voltage must be within the rated voltage range (VCC = 4.5 V to 5.5 V).
If the VCC voltage is turned on or off while VCC is not within its rated voltage range (VCC = 4.5
V to 5.5 V), since the microcontroller is unstable, the flash memory may be programmed or
erased by mistake. This can occur even if VCC = 0 V. Adequate power supply measures should
be taken, such as the insertion of a decoupling capacitor, to prevent fluctuation of the VCC
power supply when VPP is applied.
• Oscillation must have stabilized (following the elapse of the oscillation settling time).
When the VCC power is turned on, hold the 5(6 pin low for the duration of the oscillation
settling time (tOSC1 = 20 ms) before applying VPP. Do not apply or release VPP when
oscillation has been stopped or is unstable.
• In boot mode, VPP should be applied and released during a reset.
In boot mode, release a reset after the VPP and MD2 voltages have been stabilized at the
programming voltage level (12.0 V ±0.6 V).
For a reset during operation, apply or release VPP only after the 5(6 pin has been held low for
at least six system clock cycles (6φ).
• The VPPE, P, E, PV, and EV bits must be cleared in the flash memory control register
(FLMCR).
When applying or releasing VPP, make sure that the VPPE, P, E, PV, or EV bit is not set by
mistake.
• There must be no program runaway.
When VPP is applied, program execution must be supervised, e.g. by the watchdog timer.
These power-on and power-off timing requirements for VCC and VPP should also be satisfied in the
event of a power failure and in recovery from a power failure. If these requirements are not
satisfied, overprogramming or overerasing may occur due to program runaway, etc., which could
cause memory cells to malfunction.
(b) The VPP flag is set and cleared by a threshold decision on the voltage applied to the VPP
pin. The threshold level is approximately in the range from VCC +2 V to 11.4 V.
When this flag is set, it becomes possible to set the VPP enable bit (VPPE) in the flash memory
control register (FLMCR), even though the VPP voltage may not yet have settled in the
programming voltage range of 12.0 V ±0.6 V after VPP power is turned on. Do not actually
program or erase the flash memory until VPP has reached the programming voltage range.
Rev. 3.0, 02/99, page 584 of 904
The programming voltage range for programming and erasing flash memory is 12.0 V ±0.6 V
(11.4 V to 12.6 V). Programming and erasing cannot be performed correctly outside this range.
When not programming or erasing the flash memory, ensure that the VPP voltage does not exceed
the VCC voltage. This will prevent unintentional programming and erasing.
(c) After the programming voltage (VPP) is shut off, make sure that the flash memory read
setup time (tFRS)* has elapsed before reading the flash memory. When switching from boot
mode or user program mode to normal mode (VPP ≠ 12 V, MD ≠ 12 V), this setup time is required
as the interval before reading flash memory after clearing the VPPE bit. When switching from boot
mode to another mode, the mode programming setup time (tMDS) is required with respect to the
5(6 release timing.
Note: * The flash memory read setup time stipulates the period, from clearing of the VPPE bit until
flash memory is read (figure 22-21). Also, when using an external clock (EXTAL input),
after powering on and when returning from standby mode, the flash memory read setup
time must be allowed to elapse before flash memory is read (figure 22-22).
(d) Set the VPP enable bit (VPPE) before programming or erasing. Setting the VPPE bit makes it
possible to write to the flash memory control register (FLMCR) and the erase block registers
(EBR1 and EBR2).
Programming/
tVPS erasing possible tFRS
φ
tOSC1 min 0 µs
4.5 to 5.5 V
Vcc
12 ± 0.6 V
0 to Vcc V 0 to Vcc V
min 0 µs min 6φ
Vpp
12 ± 0.6 V
0 to Vcc V 0 to Vcc V
tMDS
MD2
min 0 µs
RES
VppE set
VppE cleared
VppE bit
φ
tOSC1 min 0 µs
4.5 to 5.5 V
Vcc
12 ± 0.6 V
0 to Vcc V 0 to Vcc V
*1 *1
Vpp
0 to Vcc V 0 to Vcc V
MD2 to
MD0 tMDS
RES
VppE set
VppE cleared
VppE bit
Notes: 1. The level of the mode pins (MD2 to MD0) must be fixed from power-on to power-off by pulling the pins up or down.
φ
tOSC1
4.5 to 5.5 V
Vcc
12 ± 0.6 V
0 to Vcc V min 0 µs
Vpp min 6φ
12 ± 0.6 V
0 to Vcc V
MD2 tMDS
tMDS*2
min 0 µs
RES
VppE
VppE set cleared tFRS*2
VppE bit
Mode change*1 Boot mode Mode User User program mode User User
change*1 mode mode program
mode
(4) Do not apply 12 V to the VPP pin during normal operation. To prevent program runaway
caused by accidental programming or erasing, apply 12 V to VPP only when the flash memory is
programmed or erased, or when flash memory is emulated by RAM. Overprogramming or
overerasing due to program runaway, etc., may prevent memory cells from operating normally.
While 12 V is applied, the watchdog timer should be running and enabled to halt runaway
program execution, so that program runaway will not lead to overprogramming or overerasing.
(7) Follow the recommended algorithm for programming and erasing flash memory. This
algorithm enables programming and erasing to be performed without subjecting the device to
voltage stress or sacrificing programmed data reliability.
When setting the program (P) bit or erase (E) bit in the flash memory control register (FLMCR),
the watchdog timer should be set beforehand to prevent program runaway.
(8) Do not set or clear the VPPE bit while a program is running in flash memory. Flash
memory data cannot be read normally when the VPPE bit is set or cleared. Also, although flash
memory data can be rewritten after waiting for the elapse of the VPP enable setup time (tVPS), flash
memory can only be accessed for the purpose of verification (verification during the program,
erase, or prewrite flow). Flash memory program execution and data reading should only be
performed after the elapse of the flash memory setup time after the VPPE bit is cleared.
In the same way, when using the function for emulation by RAM with 12 V applied to the VPP pin,
the flash memory read setup time must be provided after clearing the VPPE bit when executing a
program or reading data in flash memory. However, read and write accesses can be carried out in
flash memory space and the overlapped RAM area regardless of whether the VPPE bit is set or
cleared.
(9) Do not use interrupts while programming or erasing flash memory. When VPP is applied,
disable all interrupt requests, including NMI, to give the programming or erase operation
(including emulation by RAM) the highest priority.
(10) Before programming, check that the chip is correctly mounted in the PROM
programmer. Overcurrent damage to the device can result if the index marks on the PROM
programmer socket, socket adapter, and chip are not correctly aligned.
(11) Do not touch the socket adapter or chip while programming. Touching either of these
can cause contact faults and write errors.
(a) Bypass capacitors should be inserted to eliminate overshoot and noise. These should be
positioned as close as possible to the chip's VPP and mode MD2 pins.
1.0 µF: Stabilizes fluctuations in the power supply low-frequency components, such as power
supply ripple.
0.01 µF: Bypasses high-frequency components such as induction noise.
(b) The VPP and mode MD2 pin wiring should be kept as short as possible to suppress
induction noise. When designing a new board, in particular, noise may be increased by jumper
wires, etc. In this case too, the power supply waveform should be monitored and measures taken
to prevent the maximum rating from being exceeded.
(c) The maximum rated voltage is based on the potential of the VSS pin. If the potential of this
pin oscillates due to current fluctuations, etc., the voltage of the VPP and mode MD2 pins may
exceed the maximum rated voltage. Careful attention must therefore be paid to stabilizing the
reference potential.
Note: When the user system's 12 V power supply is connected, attention must be paid to the
current capacity. A power supply with a small current capacity will not be able to handle
fluctuations in the chip's operating voltage, resulting in voltage drops and rises or
oscillation that may make it impossible to obtain the rated operating voltage. Caution is
required if the power supply has a large current capacity, or if the 12 V voltage is turned
on abruptly by means of a switch, etc., since a voltage exceeding the maximum rating may
be generated due to the inductance component of the power supply wiring or the power
supply characteristics.
Before using the power supply, check the power supply waveform to ensure that the above
problems will not arise.
(2) 12 V is applied to the VPP and mode MD2 pins when erasing or programming flash
memory. When these pins are pulled up to the VCC line in normal operation, diodes should be
inserted to prevent reverse current from flowing to the VCC line when 12 V is applied.
VCC
VPP pin
12 V
VPP H8/539F
(dual power
system)
VCC
0.01 µF 1.0 µF
12 V
MD2
Mode pin
Mode pin
0.01 µF 1.0 µF
Adapter board
User system
Note: This sample circuit cannot be used with the S-mask or A-mask model (single power system).
Figure 19-27 Example of Mounting Board Design for H8/539F (dual power system)
When VPP Pin and Mode Pin Settings are 1)
(Connection to Adapter Board
20.1 Overview
There are three models of the H8/539F with on-chip flash memory: a dual power source model
and two single power source (S-mask and A-mask) models. Points to be noted when using the
H8/539F single power source S-mask and A-mask models are given below.
For the differences between the dual power source model and single power source (S-mask and A-
mask) models, see section 1.4.3, Differences in S-Mask and A-Mask Models.
12 V must not be applied to the S-mask or A-mask model (single power source), as this will
permanently damage the device.
The flash memory programming power source for the S-mask and A-mask models (single power
source) is VCC.
The programming power source for the dual power source model was the VPP pin (12 V), but there
is no VPP pin in the single power source models. In the S-mask and A-mask models the FWE pin
is provided at the same pin position as the VPP pin in the dual power source model, but FWE is not
a power source pin—it is used to control flash memory write enabling.
Also, in boot mode, 12 V must be applied to the MD2 pin in the dual power source model, but this
is not necessary in the S-mask or A-mask model (single power source).
The maximum rating of the FWE and MD2 pins in the S-mask and A-mask models (single power
source) is VCC +0.3 V. Applying a voltage in excess of the maximum rating will permanently
damage the device.
Do not select the HN28F101 programmer setting for the S-mask or A-mask model (single power
source). If this setting is made by mistake, 12.0 V will be applied to the FWE pin, permanently
damaging the device.
When using a PROM programmer to program the on-chip flash memory in the S-mask model
(single power source), use a PROM programmer that supports Hitachi microcomputer device
types with 128-kbyte on-chip flash memory.
Table 20-1 shows examples of product type names and markings for the H8/539F (dual power
source model) and H8/539F S-mask and A-mask models (single power source), and the
differences in flash memory programming power source.
Table 20-1 Differences between H8/539F, H8/539F S-Mask, and A-Mask Model Markings
The H8/539F has 128 kbytes of on-chip flash memory. The ROM is connected to the CPU by a
16-bit data bus. The CPU accesses flash memory in two states for both byte-size and word-size
instructions.
20.1.3 Features
Four flash memory operating states There are four flash memory operating states: program
mode, program-verify mode, erase mode, and erase-verify mode.
Erase block specification The flash memory space block to be erased can be specified by setting
the corresponding register bit. The flash memory is divided into three 32-kbyte blocks, one 28-
kbyte block, and four 1-kbyte blocks.
Programming/erase times The flash memory programming time is 10 ms (typ.) for simultaneous
32-byte programming, equivalent to 300 µs (typ.) per byte, and the erase time for one block is 100
ms (typ.).
On-board programming modes There are two modes in which flash memory can be
programmed, erased, and verified on-board: boot mode and user program mode.
Automatic bit rate adjustment For data transfer in boot mode, the H8/539F's bit rate can be
automatically adjusted to match the transfer bit rate of the host (9600, 4800, or 2400 bps).
Flash memory emulation in RAM Flash memory programming can be emulated in real time by
overlapping a part of RAM onto flash memory.
PROM mode Flash memory can be programmed and erased in PROM mode, using a PROM
programmer, as well as in on-board programming mode.
Rev. 3.0, 02/99, page 593 of 904
20.1.4 Block Diagram
8
On-chip data bus (lower 8 bits)
MD2*
Operating MD1
FLMCR Bus interface/controller MD0
mode
FWE*
EBR1 H'0000 H'0001
H'0002 H'0003
H'0004 H'0005
On-chip flash memory
(128 kbytes)
H'2FFFC H'2FFFD
H'2FFFE H'2FFFF
Upper byte Lower byte
(Even address) (Odd address)
Legend
FLMCR: Flash memory control register
EBR1: Erase block register 1
Note: Memory at addresses H'10000 to H'13FFF can also be read from addresses
H'00000 to H'03FFF.
Addresses H'10000 to H'13FFF comprise a mapping space for addresses
H'00000 to H'03FFFF.
* 12 V must on no account be applied to the S-mask or A-mask model (single power
source), as this will permanently damage the chip.
The flash memory is controlled by means of the pins shown in table 20-2.
The transfer data pin and receive data pin are used in boot mode.
The registers used to control the on-chip flash memory are shown in table 20-3.
2
Table 20-3 Flash Memory Registers*
FLMCR is an 8-bit register used for flash memory operating mode control. Program-verify mode
or erase-verify mode is entered by setting SWE to 1 when FWE = 1, then setting the
corresponding bit. Program mode is entered by setting SWE to 1 when FWE = 1, then setting the
PSU bit, and finally setting the P bit. Erase mode is entered by setting SWE to 1 when FWE = 1,
then setting the ESU bit, and finally setting the E bit. FLMCR is initialized by a reset and in
standby mode. Its initial value is H'80 when a high level is input to the FWE pin, and H'00 when a
low level is input. When on-chip flash memory is disabled, a read will return H'00, and writes are
invalid.
Writes to bits ESU, PSU, EV, and PV in FLMCR are enabled only when FWE = 1 and SWE = 1;
writes to the E bit only when FWE = 1, SWE = 1, and ESU = 1; and writes to the P bit only when
FWE = 1, SWE = 1, and PSU = 1.
Program mode
Selects program
mode transition
or clearing
Erase mode
Selects erase mode
transition or clearing
Program-verify mode
Selects program-verify
mode transition or clearing
Erase-verify mode
Selects erase-verify mode
transition or clearing
Program setup
Prepares for a transition
to program mode
Erase setup
Prepares for a transition
to erase mode
Bit 7
FWE Description
0 When a low level is applied to the FWE pin (hardware-protected state)
1 When a high level is applied to the FWE pin
Software Write Enable (SWE)* , * : Enables or disables flash memory programming and
1 2
Bit 6
erasing. This bit should be set before setting FLMCR bits 5 to 0 and EBR bits 7 to 0. (Do not set
the ESU, PSU, EV, PV, E, or P bit at the same time.)
Bit 6
SWE Description
0 Programming/erasing disabled (Initial value)
1 Programming/erasing enabled [Setting condition] When FWE = 1
Erase Setup (ESU)* : Prepares for a transition to erase mode. (Do not set the SWE, PSU,
1
Bit 5
EV, PV, E, or P bit at the same time.)
Bit 5
ESU Description
0 Erase setup cleared (Initial value)
1 Erase setup [Setting condition] When FWE = 1 and SWE = 1
Program Setup (PSU)* : Prepares for a transition to program mode. (Do not set the
1
Bit 4
SWE, ESU, EV, PV, E, or P bit at the same time.)
Bit 4
PSU Description
0 Program setup cleared (Initial value)
1 Program setup [Setting condition] When FWE = 1 and SWE = 1
Bit 3
EV Description
0 Erase-verify mode cleared (Initial value)
1 Transition to erase-verify mode [Setting condition] When FWE = 1 and SWE = 1
Bit 2
PV Description
0 Program-verify mode cleared (Initial value)
1 Transition to program-verify mode [Setting condition] When FWE = 1 and SWE = 1
Erase Mode (E)* , * : Selects erase mode transition or clearing. (Do not set the SWE,
1 3
Bit 1
ESU, PSU, EV, PV, or P bit at the same time.)
Bit 1
E Description
0 Erase mode cleared (Initial value)
1 Transition to erase mode [Setting condition] When FWE = 1, SWE = 1, and ESU =
1
Bit 0
P Description
0 Program mode cleared (Initial value)
1 Transition to program mode [Setting condition] When FWE = 1, SWE = 1, and PSU
=1
Notes: 1. Do not set multiple bits simultaneously. Do not cut VCC when a bit is set.
2. The SWE bit must not be set or cleared at the same time as other bits (ESU, PSU, EV,
PV, E, or P).
3. P bit and E bit setting should be carried out in accordance with the program/erase
algorithm shown in section 20.4, Flash Memory Programming/Erasing. Before setting
either of these bits, a watchdog timer setting should be made to prevent program
runaway. See section 20.7, Flash Memory Programming and Erasing Precautions, for
more information on the use of these bits.
EBR1 is an 8-bit register that specifies the flash memory block to be erased. EBR1 is initialized to
H'00 by a reset, in standby mode, when a high level is not being input to the FWE pin, and when a
high level is input to the FWE pin while the SWE bit in FLMCR is cleared to 0. When a bit in
EBR1 is set to 1, the corresponding block can be erased. Other blocks are erase-protected. Only
one bit in EBR1 can be set at a time (do not set 1 simultaneously for multiple erase blocks). An
EBR1 bit cannot be set to 1 until the SWE bit is set to 1 in FLMCR. The erase block
configuration is shown in table 20-2. Erasing is performed one block at a time. To erase the
entire flash memory, individual blocks must be erased in succession.
Bit 7 6 5 4 3 2 1 0
EB7 EB6 EB5 EB4 EB3 EB2 EB1 EB0
Initial value 0 0 0 0 0 0 0 0
R/W R/W R/W R/W R/W R/W R/W R/W R/W
Block 7 to Block 0 (EB7 to EB0): Setting one of these bits specifies the
Bits 7 to 0
corresponding block (EB7 to EB0) for erasure.
Bits 7 to 0
EB7 to EB0 Description
0 Corresponding block (EB7 to EB0) not selected (Initial value)
1 Corresponding block (EB7 to EB0) selected
Notes: 1. The mapping area can be accessed from both page 0 and page 1. If addresses for which only
the page is different are specified (e.g. H'003FF and H'103FF), the same memory will be
accessed. Consequently, when performing programming or erasing on this mapping area,
(EB0 to EB3, but not EB4) only page 0 or page 1, but not both, should be specified.
When the RAM emulation function is used to overlap RAM onto a ROM area, the overlapped
page 0 RAM area is not mapped in page 1 (since RAM emulation can only be used in page 0).
In this case, a read access to page 1 will return the ROM contents.
2. The first part of the area (block EB4) includes a mapping area, but should be specified in
page 1 when erasing. In mode 2 (on-chip ROM enabled, minimum mode), user program mode
is prohibited. When mode 2 is set, the FWE pin must be set to 0.
RAMCR controls enabling and disabling of access to on-chip RAM, and RAM area overlapping.
Bit 7 6 5 4 3 2 1 0
RAME1 - RAME2 - - RAM2 RAM1 -
Initial value 1 * 1 * * 0 0 *
R/W R/W - R/W - - R/W R/W -
Reserved bits
RAM2, RAM1
Specify a flash memory
to be overlapped
Reserved bits
Reserved bit
Bits 7 and 5—RAM Enable 1, RAM Enable 2 (RAME1, RAME2): When bits 7 and 5 are
cleared to 0, access to on-chip RAM is disabled. For details, see section 18.2, RAM Control
Register.
Reserved: These bits cannot be modified and will return an undefined value if
Bits 6, 4, 3, 0
read.
Bits 2 and 1RAM2, RAM1: Used together with bits 7, 3, and 2 in the flash memory emulation
register (FLMER) to select the ROM area to be overlapped (see table 20-4.) In modes 2, 4, and 7
1
(on-chip flash memory enabled), these bits have an initial value of 0 and can be modified* . In
other modes they cannot be modified and are always read as 0. These bits are initialized by a reset
and in hardware standby mode. They are not initialized in software standby mode.
FLMER performs enabling and disabling of flash memory RAM emulation and RAM area
modification when RAM emulation is started.
Bit 7 6 5 4 3 2 1 0
OVLPE - - - A11E A10E - -
Initial value 0 1 1 1 0 0 1 1
R/W R/W - - - R/W R/W - -
Reserved bits
A10E bit
Bits A11E and A10E
specify a RAM area to
be overlapped onto
flash memory
A11E bit
Bits A11E and A10E
specify a RAM area to be
overlapped onto flash memory
Reserved bit
In modes 2, 4, and 7 (with on-chip flash memory enabled), the initial value of this bit is 0, but it
2
can be modified by writing 1* . In other modes this bit cannot be modified and always reads 0. It
is initialized by a reset and in hardware standby mode. It is not initialized in software standby
mode. Flash memory programming must not performed in mode 2.
A11E, A10E: These bits specify a RAM area to be overlapped onto ROM when
Bits 3 and 2
performing flash memory emulation in RAM (see table 20-5).
In modes 2, 4, and 7 (with on-chip flash memory enabled), the initial value of these bits is 0, but
they can be modified. In other modes these bits cannot be modified and always read 0. They are
initialized by a reset and in hardware standby mode. They are not initialized in software standby
mode. Flash memory programming must not performed in mode 2.
Notes: 1. For details of emulation protection, see section 20.4.8, Protection Modes.
2. Bits 7, 3, and 2 of the flash memory emulation register (FLMER) and bits 2 and 1 of
the RAM control register (RAMCR) can be written to in modes 2, 4, and 7.
(In the H8/538F it was necessary to apply 12 V as the program voltage VPP when
performing RAM emulation, but in the H8/539F RAM emulation can be performed
regardless of the VPP voltage. The H8/539F S-mask and A-mask models use a single 5
V power source, and do not have a VPP pin. As with the regular H8/539F, the H8/539F
S-mask and A-mask models can perform RAM emulation in modes 2, 4, and 7 (on-
chip flash memory enabled).)
Flash memory programming must not performed in mode 2.
Bit 7 6 5 4 3 2 1 0
FLER − − − − − − −
Initial value 0 1 1 1 1 1 1 1
R/W R − − − − − − −
Reserved bit
Bit 7
FLER Description
1
0 Flash memory program/erase protection (error protection* ) (Initial value)
is disabled
[Clearing condition]
5(6 pin reset* or hardware standby mode
3
Bits 6 to 0 are reserved. They cannot be modified and are always read as 1.
2
Table 20-5 RAM Area* Setting
When boot mode is used, a user program for flash memory programming and erasing must be
prepared beforehand in the host personal computer, etc., and channel 1 of the SCI to be used must
be set to asynchronous mode. When the H8/539F is set to boot mode, after reset release the boot
program already incorporated in the H8/539F is activated, the low period of the data sent from the
host is first measured, and the bit rate register (BRR) value determined. It is then possible to
receive a user program from off-chip using the H8/539F's on-chip serial communication interface
(SCI), and the received user program is written into RAM.
Control then branches to the start address (H'F380) of the on-chip RAM, the program written in
RAM is executed, and flash memory programming/erasing can be carried out. Figure 20-3 shows
a system configuration diagram when using boot mode, and figure 20-4 shows the boot program
mode execution procedure.
Start Stop
D0 D1 D2 D3 D4 D5 D6 D7
bit bit
When boot mode is initiated, the H8/539F measures the low period of the asynchronous SCI
communication data transmitted continuously from the host (figure 20-5). The data format should
be set as 8-bit data, 1 stop bit, no parity. The H8/539F calculates the bit rate of the transmission
from the host from the measured low period (9 bits), and transmits one H'00 byte to the host to
indicate the end of bit rate adjustment. The host should confirm that this adjustment end
indication has been received normally, and transmit one H'55 byte to the H8/539F. If reception
cannot be performed normally, initiate boot mode again (reset), and repeat the above operations.
Depending on the host's transmission bit rate and the H8/539F's system clock frequency, there will
be a discrepancy between the bit rates of the host and the H8/539F. To ensure correct SCI
1
operation, the host's transfer bit rate should be set to 2400, 4800, or 9600 bps* . Table 20-7 shows
typical host transfer bit rates and system clock frequencies for which automatic adjustment of the
H8/539F bit rate is possible. The boot program should be executed within this system clock
2
range* .
Notes: 1. Use a host bit rate setting of 2400, 4800, or 9600 bps only. No other setting should be
used.
2. Although the H8/539F may also perform automatic bit rate adjustment with bit rate
and system clock combinations other than those shown in table 20-7, a degree of error
will arise between the bit rates of the host and the H8/539F, and subsequent transfer
will not be performed normally. Therefore, only a combination of bit rate and system
clock frequency within one of the ranges shown in table 20-7 can be used for boot
mode execution.
Table 20-7 System Clock Frequencies for which Automatic Adjustment of H8/539F Bit
Rate is Possible
In boot mode, the 1280-byte area from H'EE80 to H'F37F is reserved for boot program use, as
shown in figure 20-6. The area to which the user program is transferred is H'F380 to H'FE7F
(2.75 kbytes). The boot program area becomes available when a transition is made to the
execution state for the user program transferred to RAM.
H'EE80
Boot
program Note: * The boot program area cannot be used
area * until a transition is made to the execution
(1.25 kbytes) state for the user program transferred to
RAM (i.e. a branch is made to RAM
H'F380 address H'F380). Note also that the boot
program remains in the boot program
area in RAM (H'EE80−H'F37F) even
after control branches to the user program.
User program
transfer area
(2.75 kbytes)
H'FE7F
1. When the H8/539F comes out of reset in boot mode, it measures the low period of the input at
the SCI's RXD1 pin. The reset should end with RXD1 high. After the reset ends, it takes about
100 states for the chip to get ready to measure the low period of the RXD1 input.
2. In boot mode, if any data has been programmed into the flash memory (if all data is not H'FF),
all flash memory blocks are erased. Boot mode is for use when user program mode is
unavailable, such as the first time on-board programming is performed, or if the program
activated in user program mode is accidentally erased.
3. Interrupts cannot be used while the flash memory is being programmed or erased.
4. The RXD1 and TXD1 lines should be pulled up on the board.
5. Before branching to the user program (RAM address H'F380), the H8/539F terminates transmit
and receive operations by the on-chip SCI (channel 1) (by clearing the RE and TE bits to 0 in
the serial control register (SCR)), but the adjusted bit rate value remains set in the bit rate
register (BRR). The transmit data output pin, TXD1, goes to the high-level output state
(P72DDR = 1 in the port 7 data direction register, P72DR = 1 in the port 7 data register).
6. Boot mode can be entered by setting pins MD0 to MD2 and FWE in accordance with the mode
setting conditions shown in table 20.5, and then executing a reset-start.
1
On reset release (a low-to-high transition)* , the H8/539F latches the current mode pin states
internally and maintains the boot mode state. Boot mode can be cleared by driving the FWE
1
pin low, then executing reset release* , but the following points must be noted.
(a) When switching from boot mode to normal mode, the boot mode state within the chip must
first be cleared by reset input via the 5(6 pin. The 5(6 pin must be held low for at least
3
20 system clock cycles.*
(b) If input level at the MD0 and FWE pins is changed in boot mode, the boot mode state will
be maintained in the MCU, and boot mode continued, unless 5(6 pin reset input is
performed. Also, if a watchdog timer reset occurs in the boot mode state, the MCU's
internal state will not be cleared, and the on-chip boot program will be restarted regardless
of the stae of the mode pins.
(c) The FWE pin must not be driven low while the boot program is running or flash memory is
2
being programmed or erased* .
7. If the MD0 and FWE pin input levels are changed from 0 V to 5 V or from 5 V to 0 V during a
reset (while a low level is being input at the 5(6 pin), the MCU's operating mode will change.
As a result, the state of ports with multiplexed address functions and bus control output pins
($6, 5', +:5, /:5) will also change. Therefore, care must be taken to make pin settings to
prevent these pins from becoming output signal pins during a reset, or to prevent collision with
signals outside the MCU.
Notes: 1. Mode pin and FWE pin input must satisfy the mode programming setup time (tMDS)
with respect to the reset release timing.
2. For further information on FWE application and disconnection, see section 20.7, Flash
Memory Programming and Erasing Precautions.
3. See section 4.2.2, Reset Sequence, and section 20.7, Flash Memory Programming and
Erasing Precautions. The reset period during operation is a minimum of 6 system
clock cycles for the H8/538F and H8/539F, but a minimum of 20 system clock cycles
for the H8/539F S-mask and A-mask models.
When set to user program mode, the H8/539F can program and erase its flash memory by
executing a user program. Therefore, on-board reprogramming of the on-chip flash memory can
be carried out by providing on-board means of FWE control and supply of programming data, and
storing a programming control program in part of the program area as necessary.
To select user program mode, select a mode that enables the on-chip flash memory (mode 4 or 7),
and apply a high level to the FWE pin. In this mode, on-chip supporting modules other than flash
memory operate as they normally would in modes 4 and 7.
The flash memory itself cannot be read while being programmed or erased, so the control program
that performs programming should be placed in external memory or transferred to RAM and
executed there. Flash memory programming and erasing should not be carried out in mode 2.
When mode 2 is set, the FWE pin must be driven low.
The execution procedure when user program mode is entered during program execution in RAM
is shown below. It is also possible to start from user program mode in a reset-start.
Note: *. Do not apply a constant high level to the FWE pin. To prevent inadvertent programming
or erasing due to program runaway, etc., apply a high level to the FWE pin only when the
flash memory is programmed or erased (including execution of flash memory emulation
using RAM). Memory cells may not operate normally if overprogrammed or overerased
due to program runaway, etc. Also, while a high level is applied to the FWE pin, the
watchdog timer should be activated to prevent overprogramming or overerasing due to
program runaway, etc. Flash memory rewriting should not be carried out in mode 2.
When mode 2 is set, the FWE pin must be driven low.
6 7. After rewriting, clear the SWE bit. Drive the FWE pin from high to
Execute on-board low, and clear user program mode.*
programming program in
RAM (flash memory rewriting) 8. On completion of programming, branch to the user application
program in flash memory and run the program.
7 Note * For further information on FWE application and disconnection,
Clear SWE bit, see section 20.7, Flash Memory Programming and Erasing
then release FWE Precautions.
(user program mode clearing)
8
Execute user application
program in flash memory
The flash memory cannot be read while being programmed or erased. Therefore, the program
(user program) that controls flash memory programming/erasing should be located and executed
in on-chip RAM or external memory.
See section 20.7, Flash Memory Programming and Erasing Precautions, for points to note
concerning programming and erasing, and "Flash Memory Characteristics" in sections 23 and 24,
Electrical Characteristics, for the wait times after setting or clearing FLMCR bits.
Notes: 1. Operation is not guaranteed if setting/resetting of the SWE, ESU, PSU, EV, PV, E, and
P bits in FLMCR is executed by a program in flash memory.
2. When programming or erasing, set FWE to 1 (programming/erasing will not be
executed if FWE = 0).
When writing data or programs to flash memory, the program/program-verify flowchart shown in
figure 20-10 should be followed. Performing programming operations according to this flowchart
will enable data or programs to be written to flash memory without subjecting the device to
voltage stress or sacrificing program data reliability. Programming should be carried out 32 bytes
at a time.
The wait times (x, y, z, α, β, γ, ε, η) after bits are set or cleared in the flash memory control
register (FLMCR) and the maximum number of programming operations (N) are shown in "Flash
Memory Characteristics" in sections 23 and 24, Electrical Characteristics.
Following the elapse of (x) µs or more after the SWE bit is set to 1 in FLMCR, 32-byte data is
written consecutively to the write addresses. The value of the lower 8 bits of the first address
written to must be divisible by 32 (H'00, H'20, H'40, H'60, H'80, H'A0, H'C0, or H'E0). Thirty-
two consecutive byte data transfers are performed. The program address and program data are
latched in the flash memory. A 32-byte data transfer must be performed even if writing fewer
than 32 bytes; in this case, H'FF data must be written to the extra addresses.
Next, to prevent overprogramming in the event of program runaway, etc., the watchdog timer is
set. Set a value greater than (y + z + α + β) µs as the WDT overflow period. Next, preparation for
the program mode (program setup) is carried out by setting the PSU bit in FLMCR, and after the
elapse of (y) µs or more, the operating mode is switched to program mode by setting the P bit in
In program-verify mode, the data written in program mode is read to check whether it has been
correctly written in the flash memory.
After the elapse of a given programming time, the programming mode is exited (the P bit in
FLMCR is cleared, then the PSU bit is cleared at least (α) µs later). The watchdog timer is cleared
after (β) µs or more has elapsed. The operating mode is then switched to program-verify mode by
setting the PV bit in FLMCR. Before reading in program-verify mode, a dummy write of H'FF
data should be made to the addresses to be read. The dummy write should be executed after the
elapse of (γ) µs or more. When the flash memory is read in this state (verify data is read in 16-bit
units), the data at the latched address is read. Wait at least (ε) µs after the dummy write before
performing this read operation. Next, the originally written data is compared with the verify data,
and reprogram data is computed (see figure 20-10) and transferred to RAM. After 32 bytes of
data have been verified, exit program-verify mode, wait for at least (η) µs, then clear the SWE bit
in FLMCR. If reprogramming is necessary, set program mode again, and repeat the
program/program-verify sequence as before. However, ensure that the program/program-verify
sequence is not repeated more than (N) times on the same bits.
=1
U
ES
=0
U
ES
FWE=0 FWE=1
Erase-verify mode
*2 =1
EV
On-board
SWE=1 Software =0
programming mode EV
programming
Software programming
disable state SWE=0 enable state PS
U= *4
1
PS P=1
U=
0 Program setup state Program mode
P=0
PV
=1
PV
=0
Program-verify mode
Figure 20-8 Flash Memory Programming State Transitions Permitted by FLMCR Bit
Settings
Start *1
1. Programming should be performed in the
erased state. Do not perform additional Set SWE bit in FLMCR *6
programming. (Perform 32-byte Wait (x) µsec
programming on memory after all 32 bytes
Store 32-byte write data
have been erased.) in reprogram data area
2. Data transfer is performed by byte transfer
(word transfer is not possible). The first Programming operation counter n 1
address written to must be at a 32-byte
boundary with a lower 8-bit value of H'00, Consecutively write 32-byte data *2
in reprogram data area in RAM
H'20, H'40, H'60, H'80, H'A0, H'C0, or H'E0. to flash memory
A 32-byte data transfer must be performed
Enable WDT
even if writing fewer than 32 bytes; H'FF
data must be written to the extra addresses. Set PSU bit in FLMCR *6
3. Verify data is read in 16-bit (word) units. Wait (y) µsec
0 0 1 Programming YES
*6
completed Clear PV bit in FLMCR
Wait (η) µsec
0 1 0 Programming incomplete;
reprogram Programming end flag = 0?
1 0 1 NO n n+1
YES
1 1 1 Still in erased state; n>N?
NO
no action YES
Clear SWE bit in FLMCR SWE in FLMCR
Note: The memory erased state is "1". Programming
is performed on "0" reprogram data. End of programming Programming failure
1: ; ********************************************************************
2: ; * fwrites.src (Ver. 0.12) *
3: ; * Sample program for programming 32 bytes of H8/539FS flash memory *
4: ; * *
5: ; ********************************************************************
6: ;
7: ;
8: MHZ .equ d'16 ; Depends on operating frequency (16 MHz)
9: RAMSTR .equ H'EE80 ; Program transfer destination RAM address
10: MAXWT .equ d'403 ; Maximum number of writes
11:; Register addresses
12: FLMCR .equ H'FEE0 ; Flash memory control register
13: TCSR .equ H'FF10 ; Timer control/status register
14: WCR .equ H'FF14 ; Wait control register
15: ;
16: ;
17: .align H'2
18: main: .equ $
19: ldc.b #H'00:8,tp ; Stack page register setting
20: mov.w #H'FE80,sp ; Stack pointer setting
21: ldc.b #H'00:8,dp ; Data page register setting
22: ldc.b #H'00:8,ep ; Extension page register setting
23: ;
Notes: 1. The sample programs in this manual are provided to illustrate programming/erasing of
flash memory incorporated in an MCU. They do not make provisions for various kinds
of applications, and cannot be used as they are. They are intended solely for reference
in program development.
2. Program operation must be confirmed in actual use.
3. These programs are subject to change without notice due to improvements, etc.
When erasing flash memory, the single-block erase flowchart shown in figure 20-10 (single-block
erase) should be followed for each block.
The wait times (x, y, z, α, β, γ, ε, η) after bits are set or cleared in the flash memory control
register (FLMCR) and the maximum number of erase operations (N) are shown in "Flash Memory
Characteristics" in sections 23 and 24, Electrical Characteristics.
To erase flash memory contents, make a 1-bit setting for the flash memory area to be erased in
erase block register 1 (EBR1) at least (x) µs after setting the SWE bit to 1 in FLMCR. To prevent
overprogramming in the event of program runaway, etc., the watchdog timer is set. Set a value
greater than (y + z + α + β) µs as the WDT overflow period. Next, preparation for erase mode
(erase setup) is carried out by setting the ESU bit in FLMCR, and after the elapse of (y) µs or
more, the operating mode is switched to erase mode by setting the E bit in FLMCR. The time
during which the E bit is set is the flash memory erase time. Ensure that the erase time does not
exceed (z) ms.
Note: With flash memory erasing in the H8/539F S-mask and A-mask models, preprogramming
(setting all memory data in the memory to be erased to all "0") is not necessary before
starting the erase procedure.
In erase-verify mode, data is read after memory has been erased to check whether it has been
correctly erased.
After the elapse of a the erase time, erase mode is exited (the E bit in FLMCR is cleared, then the
ESU bit is cleared at least (α) µs later), the watchdog timer is cleared after (β) µs or more has
elapsed, and the operating mode is switched to erase-verify mode by setting the EV bit in
FLMCR. Before reading in erase-verify mode, a dummy write of H'FF data should be made to the
addresses to be read. The dummy write should be executed after the elapse of (y) µs or more.
When the flash memory is read in this state (verify data is read in 16-bit units), the data at the
latched address is read. Wait at least (ε) µs after the dummy write before performing this read
operation. If the read data has been erased (all "1"), a dummy write is performed to the next
address, and erase-verify is performed. If the read data is unerased, perform an erase-verify on the
next block. The erase-verify operation is carried out on all the erase blocks; the erase block
register bit for an erased block should be cleared to prevent excessive application of the erase
voltage. When verification is completed, exit erase-verify mode, and wait for at least (η) µs. If
erasure has been completed on all the erase blocks after completing erase-verify operations on all
these blocks, clear the SWE bit in FLMCR. If there are any unerased blocks, set erase mode
again, and repeat the erase/erase-verify sequence as before. However, ensure that the erase/erase-
verify sequence is not repeated more than (N) times.
Start *1
Erase counter n 1
*4
Set EBR1 *5
*2
Set ESU bit in FLMCR
Wait (y) µsec
Enable WDT
Disable WDT
*2
Clear ESU bit in FLMCR
Wait (β) µsec
Clear EBR1
*2
Set EV bit in FLMCR
Wait (γ) µsec
*2
H'FFFF dummy write to verify address
Wait (ε) µsec
NO
Verify data = H'FFFF?
OK YES
NO
Last address of block?
n n+1
YES
Increment address Clear EV bit in FLMCR *2 Clear EV bit in FLMCR *2
Wait (η) µsec Wait (η) µsec
NO
n>N?
YES
Clear SWE bit in FLMCR Clear SWE bit in FLMCR
Notes: 1. No prewriting (setting all the data bits in the block to be erased to 0) is necessary.
2. The values of x, y, z, α, β, γ, ε, η, and N are listed in "Flash Memory Characteristics" in sections 23 and 24, Electrical Characteristics.
3. Verify data is read in 16-bit words. (Note that it can also be read in byte units.)
4. Set only bit 1 of EBR. Bits 2 and above should not be set.
5. Erase data in block units. To erase multiple blocks, erase the blocks sequentially, one block at a time.
The value set in TCSR to provide the watchdog timer overflow interval setting when erase mode
is selected depends on the operating frequency. TCSR set values for different operating
frequencies are shown in table 20-8.
As software loops are used, there is intrinsic error in the wait times, and the calculated value and
actual time may not be the same. Therefore, initial values should be set so that the total
programming time does not exceed tP s/byte (max.), and the total erase time does not exceed tE s
(max.). The total programming time, tP µs/byte (max.), and total erase time, tE s (max.), are
shown in "Flash Memory Characteristics" in sections 23 and 24, Electrical Characteristics.
The set value for the watchdog timer (WDT) is calculated on the basis of the number of
instructions including the programming time and erase time from the time the WDT is started until
it stops. Therefore, no other instructions should be added between starting and stopping of the
WDT in these program examples.
The loop counter value for each operating frequency is calculated as shown below.
Formulas:
(1) Program time (P bit setting) calculation formula When the scb/f instruction is at an even
address in two-state access space, the processing time is 4 states when the register value = 0 (no
branch) and 8 states when the register value ≥ 1 (branch). Thus the calculation formula, with
truncation of the decimal part, is as follows.
(3) Wait time (time after FLMCR bit setting/clearing other than P bit setting or E bit
setting) With the same number of states as in (1) above, the calculation formula, with rounding
of the decimal part, is as follows.
Table 20-8 WDT Overflow Interval Setting when Erase Mode is Set
Variable
Operating Frequency [MHz] Value Set in TCSR
10 MHz to 16 MHz H'A57F
2 MHz to less than 10 MHz H'A57E
(1) Registers and method used After the values of the following register (R0) has been
specified, an block can be erased by calling the ferases subroutine.
(2) Wait times after setting/clearing FLMCR bits The number of software loops required to
provide a specific wait time depends on the operating frequency. The relevant operating
frequency can be specified by setting the MHZ symbol value.
(3) In this program the wait time (number of loops) is calculated on the assumption that the
scb/f instruction jump destination is located at an even address in two-state access space (on-
chip RAM).
1: ; ********************************************************************
2: ; * ferases.src (Ver. 0.08) *
3: ; * Sample program for H8/539FS flash memory block erasing *
4: ; * *
5: ; *****************************************************************
6: ;
7: ;
8: MHZ .equ d'16 ; Depends on operating frequency (16 MHz)
9: RAMSTR .equ H'EE80 ; Program transfer destination RAM address
10: MAXET .equ d'60 ; Maximum number of erases
11: ;
12: FLMCR .equ H'FEE0 ; Flash memory control register
13: EBR1 .equ H'FEE2 ; Target block specification register
14: TCSR .equ H'FF10 ; Timer control/status register
15: WCR .equ H'FF14 ; Wait control register
16: MDCR .equ H'FF19 ; Mode control register
17: ;
18: ;
19: .align H'2
20: main: .equ $
21: ldc.b #H'00:8,tp ; Stack page register setting
22: mov.w #H'FE80,sp ; Stack pointer setting
23: ldc.b #H'00:8,dp ; Data page register setting
24: ldc.b #H'00:8,ep ; Extension page register setting
25: ;
26: ;
27: ;
28: mov.w #prog_start,R0 ; Transfer start address
29: mov.w #prog_stop,R1 ; Transfer end address
30: bsr tensou:16 ; Program transfer to RAM
31: ;
32: ; Argument setting and subroutine call
33: jsr @RAMSTR ; JMP SUB to RAM area program (prog_start)
34: ; (All-mat erase example)
35: ;
36: main_end: ; End of erase
37: bra main_end
38: ;
39: ;
Notes: 1. The sample programs in this manual are provided to illustrate programming/erasing of
flash memory incorporated in an MCU. They do not make provisions for various kinds
of applications, and cannot be used as they are. They are intended solely for reference
in program development.
2. Program operation must be confirmed in actual use.
3. These programs are subject to change without notice due to improvements, etc.
There are two modes for flash memory program/erase protection: hardware protection and
software protection. These protection modes are described below.
(1) Software Protection With software protection, setting the P or E bit in the flash memory
control register (FLMCR) does not cause a transition to program mode or erase mode.
Function
1
Item Description Program Erase Verify*
Block Erase protection can be set for possible Not possible possible
specification individual blocks by settings in the
protection erase block register (EBR1).
However, protection against
programming is disabled. Setting
EBR1 to H'00 places all blocks in the
erase-protected state.
3
Emulation Setting the OVLPE bit in the flash Not possible Not possible* possible
2
protection* memory emulation register (FLMER)
enables program/erase protection for
all blocks.
Notes: 1. Two modes: program-verify and erase-verify.
2. Excluding a RAM area overlapping flash memory.
3. All blocks are unerasable and block-by-block specification is not possible.
Function
1
Item Description Program Erase Verify*
2
FWE pin When a high level is not being Not possible Not possible* Not possible
protection applied to the FWE pin, FLMCR and
EBR1 are initialized, and the
program/erase-protected state is
3
entered.*
2
Reset/standby In a reset (including a watchdog timer Not possible Not possible* Not possible
protection reset) and in standby mode, FLMCR
and EBR1 are initialized, and the
program/erase-protected state is
entered. In a reset via the 5(6 pin,
the reset state is not reliably entered
unless the 5(6 pin is held low for at
least 20 ms (oscillation settling time)
after powering on . In the case of a
reset during operation, the 5(6 pin
must be held low for a minimum of 20
4
system clock cycles (20φ).*
2
Error If abnormal MCU operation is Not possible Not possible* Not possible
protection detected during flash memory
programming or erasing (error
occurrence: FLER = 1), error
protection is enabled. FLMCR and
EBR1 settings are retained but
programming/erasing is aborted at
the point at which the error occurred.
Error protection is released only by a
5(6 pin reset* and in hardware
5
standby mode.
Notes: 1. Two modes: program-verify and erase-verify.
2. All blocks are unerasable and block-by-block specification is not possible.
3. For details, see section 20.7, Flash Memory Programming and Erasing Precautions.
4. See section 4.2.2, Reset Sequence, and section 20.7, Flash Memory Programming and
Erasing Precautions. The reset period during operation is a minimum of 6 system clock
cycles for the H8/538F and H8/539F, but a minimum of 20 system clock cycles for the
H8/539F S-mask and A-mask models.
5. In the H8/538F, a watchdog timer reset is included in the FLER bit clearing conditions,
but only 5(6 pin reset input is applicable in the case of the H8/539F.
The error protection state is released only by a 5(6 pin reset and in hardware standby mode.
Notes: 1. For details of FLER bit setting conditions, see section 20.2.3, RAM Control Register
(RAMCR).
2. FLMCR and EBR1 can be written to. However, registers will be initialized if a
transition is made to software standby mode in the error protection state.
3. Note that NMI input is disabled when the P or E bit is set. For details see section
20.4.8, NMI Input Disabling Conditions.
Memory read
verify mode Reset or hardware standby or
software standby
RD VF PR ER
FLER = 0
Reset release and Reset or standby
hardware standby release and (hardware protection)
P = 1 or E = 1 P = 0 and E = 0 software standby release
RD VF PR ER
Reset or INIT
hardware standby FLER = 0
However, the error protection function is invalid for abnormal operations other than the FLER bit
setting conditions. Also, if a certain time has elapsed before this protection state is entered,
damage may already have been caused to the flash memory. Consequently, this function cannot
provide complete protection against damage to flash memory.
NMI input is disabled when flash memory is being programmed or erased (while the P or E bit is
set in FLMCR) and while the boot program is executing in boot mode (until a branch is made to
1
the on-chip RAM area* ), to give priority to the program or erase operation. There are three
reasons for this:
1. NMI input during programming or erasing might cause a violation of the programming or
erasing algorithm, with the result that normal operation could not be assured.
2. In the NMI exception handling sequence during programming or erasing, the vector would not
2
be read correctly* , possibly resulting in MCU runaway.
3. If NMI input occurred during boot program execution, it would not be possible to execute the
normal boot mode sequence.
For these reasons, in the H8/539F's on-board programming modes alone there are conditions for
disabling NMI input, as an exception to the general rule. However, this provision does not
guarantee normal erasing and programming or MCU operation. All requests, including NMI,
must therefore be restricted inside and outside the MCU during FWE application. NMI input is
also disabled in the error protection state and while the P or E bit remains set in FLMCR during
flash memory emulation in RAM.
This RAM area overlapping is executed by means of bits 7, 3, and 2 in the flash memory
emulation register (FLMER) and bits 2 and 1 in the RAM control register (RAMCR). After RAM
overlapping, access is possible both from the area overlapped onto flash memory (mapping RAM
area) and from the original RAM area (actual RAM area).
Bits 7, 3, and 2 in FLMER and bits 2 and 1 in RAMCR are valid in modes 2, 4, and 7. Flash
memory programming must not be performed in mode 2. In other modes, a read will always
return 0 and RAM area overlapping cannot be carried out. When the flash memory emulation
function is used, RAMCR bits 7 and 5 should both be set (RAME1 = 1 and RAME2 = 1). The
mapping RAM area setting method is shown in tables 20-9 and 20-10.
Bit 7 6 5 4 3 2 1 0
OVLPE − − − A11E A10E − −
Initial value 0 1 1 1 0 0 1 1
R/W R/W − − − R/W R/W − −
2
Table 20-10 RAM Area* Setting
In the following example, RAM area H'F000 to H'F3FF is overlapped onto flash memory area
EB2 (H'0800 to H'0BFF).
On-chip RAM
area
H'FE7F
*2
00000
*1 16 kbytes
Flash memory 03FFF
04000
Mapping area *1
Page 0
0EE80
*2
0FE7F
Area used
RAM
in RAM emulation *2
ROM :00000 to 00FFF
RAM:0F000 to 0FBFF
10000
(16 kbytes) *1
Flash memory 13FFF
14000
Page 1 64 kbytes
(48 kbytes)
Flash memory
1FFFF
20000
2FFFF
Notes: 1. Areas 00000 to 03FFF and 10000 to 13FFF are mapping areas. They can be accessed from both page 0 and
page 1.
2. When the RAM emulation function is used and RAM is overlapped onto a ROM area, the overlapped page 0
RAM area is not mapped onto page 1. (RAM emulation can only be used in page 0.) In this case, ROM
contents can be read by accessing page 1.
As in on-board program mode, care is required when applying and releasing FWE to prevent
erroneous programming or erasing. To prevent erroneous programming and erasing due to
program runaway during FWE application, in particular, the watchdog timer should be set when
the P or E bit is set in the flash memory control register (FLMCR), even while the emulation
function is being used. For details, see section 20.7, Flash Memory Programming and Erasing
Precautions.
When the emulation function is used, NMI input is disabled when the P bit or E bit is set to 1 in
FLMCR, in the same way as with normal programming and erasing.
The P and E bits are cleared by a reset (including a watchdog timer reset), in standby mode, when
a high level is not being input to the FWE pin, or when the SWE bit in FLMCR is 0 while a high
level is being applied to the FWE pin.
The H8/539F S-mask and A-mask models, in which the on-chip ROM is flash memory, have a
PROM mode as well as the on-board programming modes for programming and erasing flash
memory. In PROM mode, the on-chip ROM can be freely programmed using a PROM
programmer that supports Hitachi microcomputer device types with 128-kbyte on-chip flash
memory.
PROM mode requires the use of the socket adapter shown in table 20-11. For notes on the use of
PROM mode, see section 20.6.9, Notes on Memory Programming, and section 20.7, Flash
Memory Programming and Erasing Precautions.
For program writing and verification, a special-purpose 112-to-32-pin adapter is mounted on the
PROM programmer. The socket adapter product code is given in table 20-11.
Socket Adapter
Product Code Package Product Code Device Type
HD64F5389FS 112-pin plastic QFP (FP-112) HS538FESH01H* Hitachi microcomputer with
128-kbyte on-chip flash
memory
Note: * The same socket adapter is used for the H8/539F dual power source model, but the Hitachi
128-kbyte on-chip flash memory microcomputer device type must be selected. Selecting
HN28F101 may cause permanent damage to the chip.
H'2FFFF
Note: An appropriate tool should be used to insert the adapter into, and remove it from, the IC
socket. A sample tool is shown in table 20-12.
Manufacturer Model
ENPLAS Corporation HP-100 (vacuum pen)
The PROM mode program/erase/verify specifications are the Hitachi 128-kbyte on-chip flash
memory microcomputer device type specifications.
Table 20-13 shows how the different operating modes are set when using PROM mode, and table
20-14 lists the commands used in PROM mode. Details of each mode are given below.
Auto-Program Mode
Auto-program mode supports programming of 128 bytes at a time. Status polling is used to
confirm the end of auto-programming.
Auto-Erase Mode
Auto-erase mode supports automatic erasing of the entire flash memory. Status polling is used to
confirm the end of auto-erasing.
Pin Names
Mode FWE &( 2( :( D0 to D7 A0 to A17
Read VCC or 0 L L H Data output Ain
Output disable VCC or 0 L H H Hiz X
Command write VCC or 0 L H L Data input *Ain
Chip disable VCC or 0 H X X Hiz X
Legend
L: Low level
H: High level
X: Undefined
Hi-z: High impedance
Notes: 1. Chip disable is not a standby state; internally, it is an operation state.
2. *Ain indicates that there is also address input in auto-program mode.
3. For the command write when making a transition to auto-program or auto-erase mode,
set the FWE pin to VCC (V).
Figure 20-16 shows the timing waveforms in a transition to memory read mode.
Figures 20-17 and 20-18 show the timing waveforms in a memory contents read.
Table 20-18 shows the AC characteristics in a transition from memory read mode to another
mode.
Figure 20-19 shows the timing waveforms in a transition from memory read mode to another
mode.
twep tceh
CE
tnxtc
OE
tces
WE
tf tr
tdh
CE VIL
tacc
OE VIL
WE VIH
tacc toh toh
DATA
DATA DATA
tce tce
CE
OE
toe toe
WE tacc
tacc tdf tdf VIH
toh toh
CE
twep tceh
OE
tnxtc tces
WE
tf tr
tdh
tds
Note: Do not enable WE and OE simultaneously. VCC = 5.0 V ±10%
CE tas tah
tceh
OE tnxtc
tnxtc
twep
WE Data transfer
tces
1 byte 128byte twsts tspa
twrite(1 to 3000msec)
Programming operation
tf tr end identification signal
I/O7
tds tdh
Programming normal
end identification signal
I/O6
Programming wait
DATA H'40 DATA DATA I/O0 to 5=0
(1) In auto-program mode, 128 bytes are programmed simultaneously. This should be carried out
by executing 128 consecutive byte transfers.
(2) A 128-byte data transfer is necessary even when programming fewer than 128 bytes. In this
case, H'FF data must be written to the extra addresses.
(3) If a value other than an effective address is input, processing will switch to a memory write
operation but a write error will be flagged.
(4) Memory address transfer is performed in the second cycle (figure 20-20). Do not perform
transfer after the second cycle.
(5) Do not perform a command write during a programming operation.
(6) Perform one auto-programming operation for a 128-byte block for each address.
Characteristics are not guaranteed for two or more programming operations.
(7) Confirm normal end of auto-programming by checking I/O6. Alternatively, status read mode
can also be used for this purpose.
ADDRESS
tces tceh
CE
twep
WE
terase(100 to 40000msec) tnxtc
tf tr
tds
Erase end
identification signal
I/O7 tdh
ADDRESS
CE
tce tnxtc
OE tnxtc tnxtc
twep twep
WE tces tceh tces tceh toe tdf
tf tr tf tr
tds tdh tds tdh
Initial value 0 0 0 0 0 0 0 0
After exiting auto-program mode or auto-erase mode, status read mode must be executed without
dropping the power supply.
The return code is undefined immediately after powering on, or if the power supply is dropped.
Commands cannot be accepted during the oscillation settling period or the PROM mode setup
period. A transition is made to memory read mode after the PROM mode setup time.
Don't Care
FWE
Note: The FWE input pin level should be set to VCC. When not performing auto-programing or auto-erasing, drive the FWE pin low.
Figure 20-22 Oscillation Settling Time and Boot Program Transfer Time
(1) When programming addresses which have previously been programmed, carry out auto-
erasing before auto-programming.
Programming of previously
programmed addresses
Auto-program
End
(2) When performing programming using a PROM programmer on a chip that has been
programmed/erased in an on-board programming mode, auto-erasing is recommended before
carrying out auto-programming.
Notes: 1. The memory is initially in the erased state when the device is shipped by Hitachi. For
other chips for which the erasure history is unknown, it is recommended that auto-
erasing be executed to check and supplement the initialization (erase) level.
2. In PROM mode, auto-programming should be performed once only on a 128-byte
programming unit block. Additional programming cannot be performed on a
Rev. 3.0, 02/99, page 666 of 904
previously programmed 128-byte programming unit block. Programming should be
carried out using auto-programming after an auto-erase.
(1) Use the specified voltages and timing for programming and erasing. Applied voltages in
excess of the rating can permanently damage the device. Note, in particular, that the maximum
ratings for the FWE pin and the VPP and MD2 pins are different for the H8/539F S-mask and A-
mask models (single power source) and the H8/539F (dual power source).
Use a PROM programmer that supports the Hitachi microcomputer device type with 128-kbyte
on-chip flash memory.
Do not select the HN28F101 setting for the PROM programmer. An incorrect setting will result in
application of 12.0 V to the FWE pin, damaging the device.
(2) Powering on and off (see figures 20-25 to 20-27) Do not apply a high level to the FWE pin
until VCC has stabilized. Also, drive the FWE pin low before turning off VCC.
When applying or disconnecting VCC power, fix the FWE pin low and place the flash memory in
the hardware protection state.
The power-on and power-off timing requirements should also be satisfied in the event of a power
failure and subsequent recovery. Failure to do so may result in overprogramming or overerasing
due to MCU runaway, and loss of normal memory cell operation.
(3) FWE application/disconnection (see figures 20-25 to 20-27) FWE application should be
carried out when MCU operation is in a stable condition. If MCU operation is not stable, fix the
FWE pin low and set the protection state.
The following points must be observed concerning FWE application and disconnection to prevent
unintentional programming or erasing of flash memory:
• Apply FWE when the VCC voltage has stabilized within its rated voltage range.
If FWE is applied when the MCU's VCC power supply is not within its rated voltage range (VCC
= 4.5 V to 5.5 V), MCU operation will be unstable and flash memory may be erroneously
programmed or erased.
• Apply FWE when oscillation has stabilized (after the elapse of the oscillation settling time).
When VCC power is turned on, hold the 5(6 pin low for the duration of the oscillation settling
time (tOSC1 = 20 ms) before applying FWE. Do not apply FWE when oscillation has stopped
or is unstable.
(4) Do not apply a constant high level to the FWE pin. To prevent erroneous programming or
erasing due to program runaway, etc., apply a high level to the FWE pin only when programming
or erasing flash memory (including execution of flash memory emulation using RAM). A system
configuration in which a high level is constantly applied to the FWE pin should be avoided. Also,
while a high level is applied to the FWE pin, the watchdog timer should be activated to prevent
overprogramming or overerasing due to program runaway, etc.
(5) Use the recommended algorithm when programming and erasing flash memory. The
recommended algorithm enables programming and erasing to be carried out without subjecting the
device to voltage stress or sacrificing program data reliability. When setting the program (P) or
erase (E) bit in FLMCR, the watchdog timer should be set beforehand as a precaution against
program runaway, etc.
(6) Do not set or clear the SWE bit during execution of a program in flash memory. Clear
the SWE bit before executing a program or reading data in flash memory. When the SWE bit is
set, data in flash memory can be rewritten, but flash memory should only be accessed for verify
operations (verification during programming/erasing).
Similarly, when using the RAM emulation function while a high level is being input to the FWE
pin, the SWE bit must be cleared before executing a program or reading data in flash memory.
However, the RAM area overlapping flash memory space can be read and written to regardless of
whether the SWE bit is set or cleared.
(8) Do not perform additional programming. Erase the memory before reprogramming. In on-
board programming, perform only one programming operation on a 32-byte programming unit
block. In PROM mode, too, perform only one programming operation on a 128-byte
programming unit block. Programming should be carried out with the entire programming unit
block erased.
(9) Before programming, check that the chip is correctly mounted in the PROM
programmer. Overcurrent damage to the device can result if the index marks on the PROM
programmer socket, socket adapter, and chip are not correctly aligned.
(10) Do not touch the socket adapter or chip during programming. Touching either of these
can cause contact faults and write errors.
Programming/
Wait time: x erasing possible
φ
tOSC1 min 0 µs
4.5 V
VCC 4.5 V
FWE
tMDS
min 0 µs
*1
MD2 to 0
tMDS
RES
SWE set
SWE cleared
SWE bit
φ
tOSC1 min 0 µs
4.5 V 4.5 V
VCC
FWE
*1
MD2 to 0
tMDS
RES
SWE set
SWE cleared
SWE bit
φ
tOSC1
VCC 4.5 V
min 0 µs
FWE
tMDS *2
tMDS
MD2 to 0
tMDS
tRESW
RES
Mode change*1 Boot mode Mode User User program mode User User
change*1 mode mode program
mode
21.1 Overview
TheH8/539F has a power-down state that greatly reduces power consumption by halting CPU
functions. The power-down state includes three modes: sleep mode, software standby mode, and
hardware standby mode. Table 21-1 indicates the methods of entering and exiting the power-down
modes.
State
Entering CPU Peripheral Exiting
Mode Procedure Clock CPU Registers Functions RAM I/O Ports Methods
Sleep Execute Active Halted Held Active Held Held • Interrupt
mode SLEEP • 5(6
instruction • 67%<
Software Set SSBY bit Halted Halted Held Halted and Held Held • NMI
standby in SBYCR to 1, initialized • 5(6
mode then execute • 67%<
SLEEP
instruction
Hardware Low input at Halted Halted Not held Halted Held High • 67%<
standby 67%< pin impedance & 5(6
mode
Legend
SBYCR: Software standby control register
SSBY: Software standby bit
Execution of the SLEEP instruction causes a transition from the program execution state to sleep
mode. Immediately after executing the SLEEP instruction the H8/500 CPU halts, but the contents
of its internal registers remain unchanged. The on-chip peripheral modules do not halt in sleep
mode.
The chip exits sleep mode when it receives an interrupt request, or a low input at the 5(6 or
67%< pin.
(1) Exit by Interrupt: An interrupt terminates sleep mode and starts the interrupt-handling
routine or data transfer controller (DTC). The chip does not exit sleep mode if the interrupt
priority level is equal to or less than the level set in the H8/500 CPU's status register (SR), or if the
interrupt is disabled in an on-chip peripheral module.
(2) Exit by 5(6 Input: When the 5(6 signal goes low, the chip exits from sleep mode to the
reset state.
(3) Exit by 67%< Input: When the 67%< signal goes low, the chip exits from sleep mode to
hardware standby mode.
If software sets the standby bit (SSBY) to 1 in the software standby control register (SBYCR),
then executes the SLEEP instruction, the chip enters software standby mode. Table 21-2 gives
register information about SBYCR.
In software standby mode current dissipation is reduced to an extremely low level because the
CPU and on-chip peripheral modules all halt. The on-chip peripheral modules are reset. As long
as the specified voltage is supplied, however, CPU register contents, on-chip RAM data, and I/O
port states are held.
The software standby control register (SBYCR) is an eight-bit register that must be set in order to
enter software standby mode. The bit structure is described next.
Bit 7 6 5 4 3 2 1 0
SSBY − − − − − − −
Initial value 0 1 1 1 1 1 1 1
R/W R/W − − − − − − −
Reserved bits
(1) Bit 7—Software Standby (SSBY): Enables transition to software standby mode.
Bit 7
SSBY Description
0 SLEEP instruction causes transition to sleep mode. (Initial value)
1 SLEEP instruction causes transition to software standby mode
The SSBY bit cannot be set to 1 while the timer enable bit (TME) is set to 1 in the timer
control/status register (TCSR) of the watchdog timer (WDT). Before entering software standby
mode, software must clear the TME bit to 0.
The SSBY bit is automatically cleared to 0 when the chip recovers from software standby mode
by NMI or reset, or enters hardware standby mode.
The chip can be brought out of software standby mode by input at the NMI, 5(6, or 67%< pin.
(1) Recovery by NMI: To recover from software standby mode by NMI input, software must set
clock select bits 2 to 0 (CKS2 to CKS0) in the watchdog timer's timer control/status register
(TCSR) beforehand to select the oscillator setting time*, and must also select the desired NMI
input edge.
When an NMI interrupt request signal is input, the clock oscillator begins operating. At first clock
pulses are supplied only to the watchdog timer. The watchdog timer receives the supplied clock
and starts counting. After the oscillator settling time selected by bits CKS2 to CKS0 in the
control/status register (TCSR), the watchdog timer overflows. After the watchdog timer
overflows, the clock is supplied to the entire chip, software standby mode ends, and the NMI
exception-handling sequence begins.
(2) Recovery by 5(6 Input: When software standby mode is exited by 5(6 input, clock pulses
are supplied to the entire chip as soon as the clock oscillator starts. The clock oscillator starts
when the 5(6 signal goes low. After the oscillator settling time, when the 5(6 signal goes high,
the CPU begins executing the reset sequence. The 5(6 signal must be held low long enough for
the clock to stabilize.
(3) Recovery by 67%< Input: When the 67%< signal goes low, the chip exits from software
standby mode to hardware standby mode.
Note: * When using an external clock, the watchdog timer's timer control/status register (TCSR)
should be set so as to secure the external clock output settling delay time (tDEXT).
(1) With the nonmaskable interrupt edge bit (NMIEG) in the NMI control register (NMICR)
cleared to 0 (falling edge), NMI goes low.
(2) The NMIEG bit is set to 1.
(3) Software sets the SSBY bit to 1, then executes the SLEEP instruction. The chip enters
software standby mode.
(4) When the NMI signal goes high, the chip exits software standby mode.
Clock
oscillator
(1) (4)
NMI
NMIEG
bit (2) Oscillator
settling time
SSBY (3)
bit
21.3.5 Note
The I/O ports are not initialized in software standby mode. If a port is in the high output state, it
remains in that state and power reduction is lessened by the amount of current output.
Regardless of its current state, the chip enters hardware standby mode whenever the 67%< pin
goes low. Hardware standby mode reduces power consumption drastically by halting the CPU
and stopping all functions of the on-chip peripheral modules. The on-chip peripheral modules are
reset, but as long as the specified voltage is supplied, on-chip RAM contents are held. To hold
RAM contents, the RAME bit in the RAM control register (RAMCR) should be cleared to 0. I/O
ports are placed in the high-impedance state.
Recovery from the hardware standby mode requires inputs on both the 67%< and 5(6 lines.
When 67%< goes high, the clock oscillator begins running. 5(6 should be low at this time. After
the oscillator settling time, when the 5(6 signal goes high, the H8/500 CPU begins executing the
reset sequence. The H8/500 CPU then returns to the program execution state, ending hardware
standby mode.
Clock
oscillator
RES
STBY
Note: The relationship VCC=AVCC should also be maintained in the power-down state.
If AVCC is left open, the analog/digital interface inside the chip will be undetermined,
current dissipation will increase, and other problems will arise regarding reliability.
21.5.1 Overview
The φ pin outputs the system clock. The φ pin can drive one TTL load and a 90-pF capacitive load.
(1) φ Control Register: The φ control register (φCR) is an eight-bit register that enables or
disables output of the system clock (φ).
Bit 7 6 5 4 3 2 1 0
φOE − − − − − − −
Note: * The φOE bit is initialized to 1 in standby mode. It is not initialized by a reset.
When the φOE bit is cleared to 0, the φ pin goes to the high-impedance state.
(1) H8/539F (Dual Power Source Model) Limitations: Do not disable system clock output
except in single-chip mode (mode 7). When using a mode with on-chip ROM disabled (mode 1,
3, 5, or 6), standby mode must be entered at power-on, so that the φOE bit is set to 1. Also note
that the φOE bit must be set to 1 before accessing the external space. If system clock (φ) output is
disabled in an expanded mode (modes 1-6), external data input and output will not be performed
correctly. For details, see section 3.6, Notes on Use of Externally Expanded Modes of H8/539F
(Dual Power Source Model).
(2) H8/539F S-Mask and A-Mask Models (Single Power Source Model) Limitations:After
applying power to the H8/539F S-mask or A-mask model (single power source model), switch to
the hardware standby mode in all modes (modes 1 to 7). For details, see 3.7 Notes on H8/539F S-
Mask and A-Mask Models (Single Power Source), Power-On Timing.
Bit 7
φOE Description
0 System clock (φ) output is disabled
1 System clock (φ) output is enabled
Table 21.4 shows the φpin status in the various processing modes.
22.2.1 DC Characteristics
Tables 22-2 lists the DC characteristics. Table 22-3 lists the permissible output currents.
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Test
Item Symbol Min Typ Max Unit Conditions
Input high 5(6, 67%<, VIH VCC – 0.7 — VCC + 0.3 V
voltage MD2–MD0
EXTAL VCC × 0.7 — VCC + 0.3 V
Ports 8 and 9 2.2 — AVCC + 0.3 V
Other input pins 2.2 — VCC + 0.3 V
(except ports 4
and 5)
Input low 5(6, 67%<, VIL –0.3 — 0.4 V
voltage MD2–MD0
Other input pins –0.3 — 0.8 V
(except ports 4
and 5)
–
Schmitt trigger Ports 4 and 5 VT 1.0 — 2.5 V
input voltages VT
+
2.0 — 3.5 V
+ –
VT – VT 0.4 — — V
Input 5(62/VPP | |in | — — 20 mA VCC+0.5V<Vin≤12.6V
leakage current — — 10.0 µA 0.5V≤Vin≤VCC+0.5V
MD2 — — 50.0 µA VCC+0.5V<Vin≤12.6V
— — 10.0 µA 0.5V≤Vin≤VCC+0.5V
5(6, 67%<, NMI, — — 1.0 µA Vin = 0.5 to
MD0–MD2 VCC – 0.5 V
Ports 8 and 9 — — 1.0 µA Vin = 0.5 to
AVCC – 0.5 V
Leakage Ports 1 to 7 and A | ISTI | — — 1.0 µA Vin = 0.5 to
current in3- to C VCC – 0.5 V
state (off-state)
Input pull-up Ports B and C –IP 50 — 300 µA Vin = 0 V
transistor
current
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Condition
Item Symbol Min Typ Max Unit
Permissible output low Ports 3 and 5 IOL — — 10 mA
current (per pin) 5(62 — — 3.0 mA
Other output pins — — 2.0 mA
Permissible output low Total of 14 pins in ΣIOL — — 40 mA
current (total) ports 3 and 5
Total of all output pins, — — 80 mA
including the above
Permissible output high Per pin -IOH — — 2.0 mA
current
Permissible output high Total of all output pins Σ-IOH — — 25 mA
current
Notes: 1. To protect chip reliability, do not exceed the output current values in table 22-3.
2. When driving a Darlington pair or LED, always insert a current-limiting resistor in the
output line, as shown in figures 22-1 and 22-2.
2 kΩ
Port 3 or 5
Darlington pair
H8/539F
V CC
600 Ω
Port 3 or 5
LED
22.2.2 AC Characteristics
The AC characteristics of the H8/539F are described below. Bus timing parameters are listed in
table 22-4. Control signal timing parameters are listed in table 22-5. Timing parameters of the
on-chip peripheral modules are listed in table 22-6.
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
Clock cycle time tCYC 62.5 500 ns Fig. 22-4,
Fig. 22-5
Clock low pulse width tCL 20 — ns
Clock high pulse width tCH 20 — ns
Clock rise time tCr — 15 ns
Clock fall time tCf — 15 ns
Address delay time tAD — 25 ns
Address hold time tAH 10 — ns
Address strobe delay time 1 tASD1 — 25 ns
Address strobe delay time 2 tASD2 — 25 ns
Read strobe delay time 1 tRDD1 — 25 ns
Read strobe delay time 2 tRDD2 — 25 ns
Write strobe delay time 1 tWRD1 — 25 ns
Write strobe delay time 2 tWRD2 — 25 ns
Write strobe delay time 3 tWRD3 — 25 ns
Write data strobe pulse width 1 tWRW1 50 — ns
Write data strobe pulse width 2 tWRW2 170 — ns
Address setup time 1 tAS1 10 — ns
Address setup time 2 tAS2 10 — ns
Address setup time 3 tAS3 30 — ns
Read data setup time tRDS 20 — ns
Read data hold time tRDH 0 — ns
Read data access time 1 tACC1 — 60 ns
Read data access time 2 tACC2 — 120 ns
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
Write data delay time tWDD — 55 ns Fig. 22-4,
Fig. 22-5
Write data setup time tWDS 2 — ns
Write data hold time tWDH 10 — ns
Wait setup time tWTS 25 — ns Fig. 22-6
Wait hold time tWTH 10 — ns
Bus request setup time tBRQS 30 — ns Fig. 22-10
Bus acknowledge delay time 1 tBACD1 — 30 ns
Bus acknowledge delay time 2 tBACD2 — 30 ns
Bus-floating delay time tBZD — tBACD1 ns
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
5(6 setup time tRESS 200 — ns Fig. 22-7
5(6 pulse width tRESW 6.0 — tcyc
Mode programming setup time* tMDS 4.0 — tcyc
5(62 output delay time tRESD — 200 ns Fig. 22-8
R(62 output pulse width tRESOW 132 — tcyc
NMI setup time tNMIS 150 — ns Fig. 22-9
NMI hold time tNMIH 10 — ns
,540 setup time tIRQ0S 50 — ns
,541 to ,543 setup time tIRQ1S 50 — ns
,541 to ,543 hold time tIRQ1H 10 — ns
NMI pulse width (for recovery tNMIW 200 — ns
from software standby mode)
Clock oscillator settling time at tOSC1 20 — ms Fig. 22-11
reset (crystal)
Clock oscillator settling time in tOSC2 10 — ms Fig. 21-1
software standby (crystal)
External clock output settling tDEXT 500 — µs Fig. 22-12
delay time (When inputting
external clock from the EXTAL
pin)
Note:* In boot mode, the input high voltage to MD2 should satisfy the high voltage (12V) applied
criterion (VH max).
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz Test
Item Item Symbol Min Max Unit Conditions
IPU Timer output delay time tTOCD — 100 ns Fig. 22-15
Timer input setup time tTICS 50 — ns
Timer clock input setup time tTCKS 50 — ns Fig. 22-16
Timer clock pulse width tTCKW 1.5 — tCYC
SCI Input clock cycle Asyn- tSCYC 4 — tCYC Fig. 22-17
chronous
Clocked 6 — tCYC
syn-
chronous
Input clock pulse width tSCKW 0.4 0.6 tSCYC
Transmit data delay time tTXD — 100 ns Fig. 22-18
Receive data setup time tRXS 100 — ns
(clocked synchronous)
Receive data hold time tRXH 100 — ns
(clocked synchronous)
Ports Output data delay time tPWD — 50 ns Fig. 22-13
Receive data setup time tPRS 50 — ns
(clocked synchronous)
Receive data hold time tPRH 50 — ns
(clocked synchronous)
PWM output delay time tPWDD — 100 ns Fig.22-14
RL
Table 22-7 lists the A/D conversion characteristics of the H8/539F. Table 22-8 lists the
permissible signal-source impedance for the A/D converter.
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Condition
16 MHz
Item Min Typ Max Unit
Resolution 10 10 10 Bits
Conversion time — — 8.38 µs
Analog input capacitance — — 20 pF
Nonlinearity error — — ±2.0 LSB
Offset error — — ±2.0 LSB
Full-scale error — — ±2.0 LSB
Quantization error — — ±1/2 LSB
Absolute accuracy — — ±2.5 LSB
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Conditions: VCC = 4.5 to 5.5 V, AVCC = 4.5 to 5.5 V, VREF = 4.5 to 5.5 V, VSS = AVSS = 0V,
VPP = 12.0 ±0.6V, Ta = –20 to +75°C (regular specifications), Ta = –40 to 85°C (wide-range
specifications)
Test
Item Symbol Min Typ Max Unit Conditions
1, 2
Programming time* * tP — 50 1000 µs/byte
1, 3
Erase time* * tE — 1 30 s
Number of writing /
NWEC — — 100 times
erasing count
1
Verify-setup time 1* tvs1 4 — — µs
1
Verify- setup time 2* tvs2 2 — — µs
VPP enable setup time tVPS 5 — — µs
Flash-memory-read tFRS 50 — — µs VCC ≥ 4.5V Fig.22-19
4
setup time* Fig.22-20
Notes: 1. Set the times following the programming/erasing algorithm shown in section 19, "Flash
Memory."
2. The programming time is the time during which a byte is programmed or the P bit in the
flash memory control register (FLMCR) is set. It does not include the program-verify
time.
3. The erase time is the time during which all blocks (128 kbytes) are erased or the E bit in
the flash memory control register (FLMCR) is set. It does not include the prewriting time
before erasure or erase-verify time.
4. After power-on when using an external clock source, after return from standby mode, or
after clearing the VPP enable bit, make sure that this read setup time has elapsed before
reading flash memory.
φ
t Cf t Cr
t AD
A19 −A 0
t ASD1 t ASD2 t AH
AS
t AS1
t RDD1 t RDD2 t AH
RD (read)
t AS1
t ACC1 t RDS t RDH
D15 −D 0 (read)
t WRD1 t WRD2 t AH
t WRW1
HWR, LWR
(write) t AS2
t WDD t WDH
A 19 -A 0
AS
RD
(read)
t ACC2
D15 -D0
(read)
t WRD3
t WRW2
HWR, LWR
(write) t AS3
t WDS
D15 -D0
(write)
A19 − A 0
AS
RD
(read)
D15−D0
(read)
HWR, LWR
(write)
D15−D0
(write)
t WTS t WTH t WTS t WTH
WAIT
Figure 22-6 Basic Bus Cycle: Three-State Access with One Wait State
t RESS t RESS
RES
t MDS* t RESW
MD2−MD0
Note: *In boot mode, the high-level input at the MD2 pin must satisfy the high-voltage
(12 V) application criterion (VHmax).
tRESD tRESD
RESO
tRESOW
t NMIS t NMIH
NMI
t IRQ1S t IRQ1H
IRQ1−IRQ3
t IRQ0S
IRQ0
tBRQS t BRQS
BREQ
t BACD1 t BACD2
BACK
t BZD t BZD
A19-A0,
AS, RD,
HWR,
LWR
VCC
STBY
t OSC1 t OSC1
RES
4.5V
VCC
VIH
STBY
EXTAL
RES
tDEXT*
This section gives the following H8/539F I/O port input/output timing diagram:
T1 T2 T3
t PRS t PRH
Ports 1 to C
(read)
t PWD
Ports 1 to 7
and A to C
(write)
This section gives the following H8/539F PWM timer output timing diagram.
TCNT Compare-match
t PWDD
PW1 to 3
t TOCD
Output
compare* 1
t TICS
Input
capture* 2
t TCKS
TCLK1−TCLK3
t TCKW t TCKW
t SCKW
SCK1, SCK2
t scyc
t scyc
SCK1, SCK2
t TXD
TXD1, TXD2
(transmit data)
t RXS t RXH
RXD1, RXD2
(receive data)
This section gives the following H8/539F on-chip flash memory read timing diagrams:
11.4V
VPP
VCC+2V
VPPE bit
(Flash memory
control register)
tFRS
RD
(On-chip ROM read signal)
Figure 22-19 Flash Memory Read Timing (After Clearing VPPE Bit)
VIH
STBY
EXTAL
RES
tFRS
FRS**
RD
(On-chip ROM read signal)
Figure 22-20 Flash Memory Read Timing (When Using External Clock)
23.2.1 DC Characteristics
Tables 23-2 and lists the DC characteristics. Table 23-3 lists the permissible output currents.
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC), VSS
= AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Test
Item Symbol Min Typ Max Unit Conditions
Input high 5(6, 67%<, MD2– VIH VCC – 0.7 VCC + 0.3 V
voltage MD0, FEW
EXTAL VCC × 0.7 VCC + 0.3 V
Ports 8 and 9 2.2 AVCC + 0.3 V
Other input pins 2.2 VCC + 0.3 V
(except ports 4
and 5)
Input low 5(6, 67%<, VIL –0.3 0.4 V
voltage MD2–MD0, FEW
Other input –0.3 0.8 V
pins(except ports 4
and 5)
Schmitt trigger Ports 4 and 5 VT
–
1.0 2.5 V
input voltages VT
+
2.0 3.5 V
VT
+
– VT
–
0.4 V
Input leakage FWE | |in | 10 µA Vin = 0.5 to
current VCC – 0.5 V
MD2 1.0 µA Vin = 0.5 to
VCC – 0.5 V
5(6, 67%<, NMI, 1.0 µA Vin = 0.5 to
MD0–MD2 VCC – 0.5 V
Ports 8 and 9 1.0 µA Vin = 0.5 to
AVCC – 0.5 V
Leakage Ports 1 to 7 | ISTI | 1.0 µA Vin = 0.5 to
current in3- and A to C VCC – 0.5 V
state(off-state)
Input pull-up Ports B and C –IP 50 300 µA Vin = 0 V
transistor
current
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC), VSS = AVSS
= 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
Item Symbol Min Typ Max Unit
Permissible output low Ports 3 and 5 IOL 10 mA
current (per pin)
Other output pins 2.0 mA
Permissible output low Total of 14 pins in ΣIOL 40 mA
current (total) ports 3 and 5
Total of all output pins 80 mA
including the above,
Permissible output high All output pins -IOH 2.0 mA
current (per pin)
Permissible output high Total of all output pins Σ-IOH 25 mA
Current
Notes: 1. To protect chip reliability, do not exceed the output current values in table 23-3.
2. When driving a Darlington pair or LED, always insert a current-limiting resistor in the
output line, as shown in figures 23-1 and 23-2.
2 kΩ
Port 3 or 5
Darlington pair
H8/539F
V CC
600 Ω
Port 3 or 5
LED
The AC characteristics of the H8/539F are described below. Bus timing parameters are listed in
table 23-4. Control signal timing parameters are listed in table 23-5. Timing parameters of the
on-chip peripheral modules are listed in table 23-6.
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
Clock cycle time tCYC 62.5 500 ns Fig. 23-4,
Clock low pulse width tCL 20 ns Fig. 23-5
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz Test
Item Symbol Min Max Unit Conditions
Read data access time 1 tACC1 60 ns Fig. 23-4
Fig. 23-5
Read data access time 2 tACC2 120 ns
Write data delay time tWDD 55 ns
Write data setup time tWDS 2 ns
Write data hold time tWDH 10 ns
Wait setup time tWTS 25 ns Fig. 23-6
Wait hold time tWTH 10 ns
Bus request setup time tBRQS 30 ns Fig. 23-9
Bus acknowledge delay time 1 tBACD1 30 ns
Bus acknowledge delay time 2 tBACD2 30 ns
Bus-floating delay time tBZD tBACD1 ns
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
5(6 setup time tRESS 200 ns Fig. 23-7
5(6 pulse width tRESW 20 tcyc
Mode programming setup time tMDS 4.0 tcyc
NMI setup time tNMIS 150 ns Fig. 23-8
NMI hold time tNMIH 10 ns
,540 setup time tIRQ0S 50 ns
,541–3 setup time tIRQ1S 50 ns
,541–3 hold time tIRQ1H 10 ns
NMI pulse width (for recovery tNMIW 200 ns
from software standby mode)
Clock oscillator settling time at tOSC1 20 ms Fig. 23-10
reset (crystal)
Clock oscillator settling time in tOSC2 10 ms Fig. 21-1
software standby (crystal)
External clock output settling tDEXT 500 µs Fig. 23-11
delay time (When inputting
external clock from the EXTAL
pin)
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
16 MHz
Item Item Symbol Min Max Unit
IPU Timer output delay Time tTOCD 100 ns Fig. 23-14
Timer input setup Time tTICS 50 ns
Timer clock input setup time tTCKS 50 ns Fig. 23-15
Timer clock pulse Width tTCKW 1.5 tCYC
PWM output delay time tPWDD 100 ns Fig.23-13
SCI Input clock cycle Asyn- tSCYC 4 tCYC Fig. 23-16
chronous
Clocked syn- 6 tCYC
chronous
Input clock pulse Width tSCKW 0.4 0.6 tSCYC
Transmit data delay Time tTXD 100 ns Fig. 23-17
Receive data setup time (clocked tRXS 100 ns
synchronous)
Receive data hold time (clocked tRXH 100 ns
synchronous)
Ports Output data delay Time tPWD 50 ns Fig. 23-12
Receive data setup time (clocked tPRS 50 ns
synchronous)
Receive data hold time (clocked tPRH 50 ns
synchronous)
RL
Table 23-7 lists the A/D conversion characteristics of the H8/539F. Table 23-8 lists the
permissible signal-source impedance for the A/D converter.
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Condition
16 MHz
Item Min Typ Max Unit
Resolution 10 10 10 Bits
Conversion time 8.38 µs
Analog input capacitance 20 pF
Nonlinearity error ±2.0 LSB
Offset error ±2.0 LSB
Full-scale error ±2.0 LSB
Quantization error ±1/2 LSB
Absolute accuracy ±2.5 LSB
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Conditions: VCC = 4.5 to 5.5 V, AVCC = 4.5 to 5.5 V, VREF = 4.5 to 5.5 V, VSS = AVSS = 0V,
Ta = 0 to +70°C (regular specifications), Ta = 0 to 70°C (wide-range specifications)
Test
Item Symbol Min Typ Max Unit Conditions
1, 2,
Programming time* * *
4
tP 10 200 ms/32 byte
1,
Erase time* * *
3, 5
tE 100 300 ms/block
Number of writing / erasing count NWEC 100 times
Programming Wait time after SWE-bit set*
1
x 10 µs
time
Waite time after PSU-bit set*
1
y 50 µs
1,
Wait time after P-bit set* *
4
z 150 500 µs
Wait time after P-bit clear*
1
α 10 µs
Wait time after PSU-bit clear*
1
β 10 µs
Wait time after PV-bit set*
1
γ 4 µs
Wait time after H'FF dummy write*
1
ε 2 µs
Wait time after PV-bit clear*
1
η 4 µs
Maximum number of programs* *
1, 4
N 403 times
Erase time Wait time after SWE-bit set*
1
x 10 µs
Waite time after ESU-bit set*
1
y 200 µs
1,
Wait time after E-bit set* *
5
z 5 ms
Wait time after E-bit clear*
1
α 10 µs
Wait time after ESU-bit clear*
1
β 10 µs
Wait time after EV-bit set*
1
γ 20 µs
Wait time after H'FF dummy write*
1
ε 2 µs
Wait time after EV-bit clear*
1
η 5 µs
1,
Maximum number of erasures* *
5
N 60 times
Notes: 1. Make the time settings in accordance with the program/erase algorithm.
2. The programming time for 32 bytes. (Indicates the total time for which the P bit in the
flash memory control register (FLMCR) is set. The program/verify time is not included.)
3. The time required to erase one block. (Indicates the time for which the E bit in the flash
memory control register (FLMCR) is set. The erase/verify time is not included.)
φ
t Cf t Cr
t AD
A19−A0
t ASD1 t ASD2 t AH
AS
t AS1
t RDD1 t RDD2 t AH
RD (read)
t AS1
t ACC1 t RDS t RDH
D15−D0 (read)
t WRD1 t WRD2 t AH
t WRW1
HWR, LWR
(write) t AS2
t WDD t WDH
D15−D0 (write)
T1 T2 T3
A19−A0
AS
RD
(read)
t ACC2
D15−D0
(read)
t WRD3
t WRW2
HWR, LWR
(write) t AS3
t WDS
D15−D0
(write)
A19−A0
AS
RD
(read)
D15−D0
(read)
HWR, LWR
(write)
D15−D0
(write)
t WTS t WTH t WTS t WTH
WAIT
Figure 23-6 Basic Bus Cycle: Three-State Access with One Wait State
t RESS t RESS
RES
t MDS t RESW
MD2−MD0 ,
FWE*
Note: * The FWE input timing shown is for entering and exiting boot mode.
t NMIS t NMIH
NMI
t IRQ1S t IRQ1H
IRQ1−IRQ3
t IRQ0S
IRQ0
tBRQS t BRQS
BREQ
t BACD1 t BACD2
BACK
t BZD t BZD
A19−A0,
AS, RD,
HWR,
LWR
VCC
STBY
t OSC1 t OSC1
RES
4.5V
VCC
VIH
STBY
EXTAL
RES
tDEXT*
This section gives the following H8/539F I/O port input/output timing diagram:
T1 T2 T3
t PRS t PRH
Ports 1 to C
(read)
t PWD
Ports 1 to 7
and A to C
(write)
This section gives the following H8/539F PWM timer output timing diagram.
TCNT Compare-match
t PWDD
PW1 to 3
t TOCD
Output
compare* 1
t TICS
Input
capture* 2
t TCKS
TCLK1-TCLK3
t TCKW t TCKW
t SCKW
SCK1, SCK2
t scyc
t scyc
SCK1, SCK2
t TXD
TXD1, TXD2
(transmit data)
t RXS t RXH
RXD1, RXD2
(receive data)
24.2.1 DC Characteristics
Tables 24-2 and lists the DC characteristics. Table 24-3 lists the permissible output currents.
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC), VSS
= AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Test
Item Symbol Min Typ Max Unit Conditions
Input high 5(6, 67%<, VIH VCC – 0.7 VCC + 0.3 V
voltage MD2–MD0, FEW
EXTAL VCC × 0.7 VCC + 0.3 V
Ports 8 and 9 2.2 AVCC + 0.3 V
Other input pins 2.2 VCC + 0.3 V
(except ports 4
and 5)
Input low 5(6, 67%<, VIL –0.3 0.4 V
voltage MD2–MD0, FEW
Other input –0.3 0.8 V
pins(except ports 4
and 5)
Schmitt trigger Ports 4 and 5 VT
–
1.0 2.5 V
input voltages VT
+
2.0 3.5 V
VT
+
– VT
–
0.4 V
Input leakage FWE | Iin | 10 µA Vin = 0.5 to
current VCC – 0.5 V
MD2 1.0 µA Vin = 0.5 to
VCC – 0.5 V
5(6, 67%<, NMI, 1.0 µA Vin = 0.5 to
MD0–MD2 VCC – 0.5 V
Ports 8 and 9 1.0 µA Vin = 0.5 to
AVCC – 0.5 V
Leakage Ports 1 to 7 | ISTI | 1.0 µA Vin = 0.5 to
current in3- and A to C VCC – 0.5 V
state(off-state)
Input pull-up Ports B and C –IP 50 300 µA Vin = 0 V
transistor
current
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Conditions: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC), VSS = AVSS
= 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
Item Symbol Min Typ Max Unit
Permissible output low Ports 3 and 5 IOL 10 mA
current (per pin)
Other output pins 2.0 mA
Permissible output low Total of 14 pins in ΣIOL 40 mA
current (total) ports 3 and 5
Total of all output pins 80 mA
including the above,
Permissible output high All output pins -IOH 2.0 mA
current (per pin)
Permissible output high Total of all output pins Σ-IOH 25 mA
Current
Notes: 1. To protect chip reliability, do not exceed the output current values in table 24-3.
2. When driving a Darlington pair or LED, always insert a current-limiting resistor in the
output line, as shown in figures 24-1 and 24-2.
2 kΩ
Port 3 or 5
Darlington pair
H8/539F
V CC
600 Ω
Port 3 or 5
LED
The AC characteristics of the H8/539F are described below. Bus timing parameters are listed in
table 24-4. Control signal timing parameters are listed in table 24-5. Timing parameters of the
on-chip peripheral modules are listed in table 24-6.
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V,
Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
Clock cycle time tCYC 62.5 500 ns Fig. 24-4,
Clock low pulse width tCL 15 ns Fig. 24-5
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V,
Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
Read data access time 1 tACC1 30 ns Fig. 24-4
Fig. 24-5
Read data access time 2 tACC2 90 ns
Write data delay time tWDD 55 ns
Write data setup time tWDS 2 ns
Write data hold time tWDH 10 ns
Wait setup time tWTS 40 ns Fig. 24-6
Wait hold time tWTH 10 ns
Bus request setup time tBRQS 30 ns Fig. 24-9
Bus acknowledge delay time 1 tBACD1 30 ns
Bus acknowledge delay time 2 tBACD2 30 ns
Bus-floating delay time tBZD tBACD1 ns
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
Condition
16 MHz
Test
Item Symbol Min Max Unit Conditions
5(6 setup time tRESS 200 ns Fig. 24-7
5(6 pulse width tRESW 20 tcyc
Mode programming setup time tMDS 4.0 tcyc
NMI setup time tNMIS 150 ns Fig. 24-8
NMI hold time tNMIH 10 ns
,540 setup time tIRQ0S 50 ns
,541 to ,543 setup time tIRQ1S 50 ns
,541 to ,543 hold time tIRQ1H 10 ns
NMI pulse width (for recovery tNMIW 200 ns
from software standby mode)
Clock oscillator settling time at tOSC1 20 ms Fig. 24-10
reset (crystal)
Clock oscillator settling time in tOSC2 10 ms Fig. 21-1
software standby (crystal)
External clock output settling tDEXT 500 µs Fig. 24-11
delay time (When inputting
external clock from the EXTAL
pin)
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10%, VSS = AVSS = 0 V, Ta
= –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range specifications)
16 MHz
Item Item Symbol Min Max Unit
IPU Timer output delay Time tTOCD 100 ns Fig. 24-14
Timer input setup Time tTICS 50 ns
Timer clock input setup time tTCKS 50 ns Fig. 24-15
Timer clock pulse Width tTCKW 1.5 tCYC
PWM output delay time tPWDD 100 ns Fig.24-13
SCI Input clock cycle Asyn- tSCYC 4 tCYC Fig. 24-16
chronous
Clocked syn- 6 tCYC
chronous
Input clock pulse Width tSCKW 0.4 0.6 tSCYC
Transmit data delay Time tTXD 100 ns Fig. 24-17
Receive data setup time (clocked tRXS 100 ns
synchronous)
Receive data hold time (clocked tRXH 100 ns
synchronous)
Ports Output data delay Time tPWD 50 ns Fig. 24-12
Receive data setup time (clocked tPRS 50 ns
synchronous)
Receive data hold time (clocked tPRH 50 ns
synchronous)
RL
Table 24-7 lists the A/D conversion characteristics of the H8/539F. Table 24-8 lists the
permissible signal-source impedance for the A/D converter.
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Condition
16 MHz
Item Min Typ Max Unit
Resolution 10 10 10 Bits
Conversion time 8.38 µs
Analog input capacitance 20 pF
Nonlinearity error ±2.0 LSB
Offset error ±2.0 LSB
Full-scale error ±2.0 LSB
Quantization error ±1/2 LSB
Absolute accuracy ±2.5 LSB
Condition: VCC = 5.0 V ±10%, AVCC = 5.0 V ±10%, VREF = 5.0 V ±10% (VREF ≤ AVCC),
VSS = AVSS = 0 V, Ta = –20 to +75°C (regular specifications), Ta = –40 to +85°C (wide-range
specifications)
Conditions: VCC = 4.5 to 5.5 V, AVCC = 4.5 to 5.5 V, VREF = 4.5 to 5.5 V, VSS = AVSS = 0V,
Ta = 0 to +70°C (regular specifications), Ta = 0 to 70°C (wide-range specifications)
Test
Item Symbol Min Typ Max Unit Conditions
1, 2,
Programming time* * *
4
tP 10 200 ms/32 byte
1,
Erase time* * *
3, 5
tE 100 300 ms/block
Number of writing / erasing count NWEC 100 times
Programming Wait time after SWE-bit set*
1
x 10 µs
time
Waite time after PSU-bit set*
1
y 50 µs
1,
Wait time after P-bit set* *
4
z 200 µs
Wait time after P-bit clear*
1
α 10 µs
Wait time after PSU-bit clear*
1
β 10 µs
Wait time after PV-bit set*
1
γ 4 µs
Wait time after H'FF dummy write*
1
ε 2 µs
Wait time after PV-bit clear*
1
η 4 µs
1,
Maximum number of programs* *
4
N 1000 times
Erase time Wait time after SWE-bit set*
1
x 10 µs
Waite time after ESU-bit set*
1
y 200 µs
1,
Wait time after E-bit set* *
5
z 5 ms
Wait time after E-bit clear*
1
α 10 µs
Wait time after ESU-bit clear*
1
β 10 µs
Wait time after EV-bit set*
1
γ 20 µs
Wait time after H'FF dummy write*
1
ε 2 µs
Wait time after EV-bit clear*
1
η 5 µs
Maximum number of erasures* *
1, 5
N 60 times
Notes: 1. Make the time settings in accordance with the program/erase algorithm.
2. The programming time for 32 bytes. (Indicates the total time for which the P bit in the
flash memory control register (FLMCR) is set. The program/verify time is not included.)
3. The time required to erase one block. (Indicates the time for which the E bit in the flash
memory control register (FLMCR) is set. The erase/verify time is not included.)
4. To specify the programming time maximum value (tP(max)) in the 32-byte programming
flow, set the maximum number of writes (N) to the maximum value (403).
Also, the wait time after P bit setting (z) is switched based on the number of writes as
shown below.
If the number of writes counter is at 1 to 4, z = 150 µs.
If the number of writes counter is at 5 to 403, z = 500 µs.
5. Erase time maximum value (tE(max)) = wait time after E bit setting (z) x maximum
number of erases (N)
φ
t Cf t Cr
t AD
A19−A0
t ASD1 t ASD2 t AH
AS
t AS1
t RDD1 t RDD2 t AH
RD (read)
t AS1
t ACC1 t RDS t RDH
D15−D0 (read)
t WRD1 t WRD2 t AH
t WRW1
HWR, LWR
(write) t AS2
t WDD t WDH
D15−D0 (write)
A19−A0
AS
RD
(read)
t ACC2
D15−D0
(read)
t WRD3
t WRW2
HWR, LWR
(write) t AS3
t WDS
D15−D0
(write)
A19−A0
AS
RD
(read)
D15−D0
(read)
HWR, LWR
(write)
D15−D0
(write)
t WTS t WTH t WTS t WTH
WAIT
Figure 24-6 Basic Bus Cycle: Three-State Access with One Wait State
t RESS t RESS
RES
t MDS t RESW
MD2−MD0 ,
FWE*
Note: * The FWE input timing shown is for entering and exiting boot mode.
t NMIS t NMIH
NMI
t IRQ1S t IRQ1H
IRQ1−IRQ3
t IRQ0S
IRQ0
tBRQS t BRQS
BREQ
t BACD1 t BACD2
BACK
t BZD t BZD
A19−A0,
AS, RD,
HWR,
LWR
VCC
STBY
t OSC1 t OSC1
RES
4.5V
VCC
VIH
STBY
EXTAL
RES
tDEXT*
This section gives the following H8/539F I/O port input/output timing diagram:
T1 T2 T3
t PRS t PRH
Ports 1 to C
(read)
t PWD
Ports 1 to 7
and A to C
(write)
This section gives the following H8/539F PWM timer output timing diagram.
TCNT Compare-match
t PWDD
PW1 to 3
t TOCD
Output
compare* 1
t TICS
Input
capture* 2
t TCKS
TCLK1-TCLK3
t TCKW t TCKW
t SCKW
SCK1, SCK2
t scyc
t scyc
SCK1, SCK2
t TXD
TXD1, TXD2
(transmit data)
t RXS t RXH
RXD1, RXD2
(receive data)
↔
MOV:G B/W 0
Rs → (EAd)
#IMM → (EAd)
#IMM → Rd −
↔ ↔
↔ ↔
MOV:E (short format) B 0
MOV: F @(d:8,FP) → Rd B/W 0 −
Data transfer instructions
↔ ↔ ↔
↔ ↔ ↔
MOV:I (short format) W 0
MOV:L (@aa:8) → Rd (short format) B/W 0 −
MOV:S Rs → (@aa:8) (short format) B/W 0 −
LDM @SP+ → Rn (register list) W − − − −
STM Rn (register list) → @−SP W − − − −
XCH Rs ↔ Rd W − − − −
Rd (upper byte) ↔ Rd (lower byte) −
↔
SWAP B 0
(MOVTPE) Not available in H8/539F
(MOVFPE) Not available in H8/539F
Rd+ (EAs) → Rd
↔ ↔
↔ ↔
↔ ↔
↔ ↔
ADD:G B/W
ADD:Q (EAd) +#IMM → (EAd) B/W
(#IMM = ±1, ±2) (short format)
ADDS Rd+ (EAs) → Rd B/W − − − −
(Rd is always word size)
Rd+ (EAs) +C → Rd
↔
↔ ↔ ↔
↔ ↔ ↔
ADDX B/W
Arithmetic instructions
SUB B/W
SUBS Rd− (EAs) → Rd B/W − − − −
Rd− (EAs) − C → Rd
↔
↔ ↔ ↔
↔ ↔
SUBX B/W
DSUB (Rd) 10− (Rs) 10−C → (Rd) 10 B − −
Rd × (EAs) → Rd 8×8
↔
MULXU B/W 0 0
(unsigned) 16 × 16
Rd ÷ (EAs) → Rd 16 ÷ 8
↔
DIVXU B/W 0
(unsigned) 32 ÷16
Rd − (EAs), set CCR flags
↔
CMP:G B/W
(EAd) − #IMM, set CCR flags
↔ ↔ ↔
↔ ↔ ↔ ↔ ↔ ↔
↔ ↔
↔ ↔
CMP:E (short format) B
CMP:I Rd − #IMM, set CCR flags (short format) W
Arithmetic instructions
↔ ↔
TST B/W 0 0
0− (EAd) → (EAd)
↔
NEG B/W 0
CLR 0 → (EAd) B/W 0 1 0 0
(EAd) − 0, set CCR flags
↔
TAS B 0 0
(1) 2 → (<bit 7> of <EAd>)
↔
SHAL MSB LSB B/W
C 0
↔
SHAR MSB LSB B/W 0
0
↔
SHLL B/W 0
MSB LSB
C 0
↔
Shift instructions
SHLR B/W 0 0
MSB LSB
0 C
↔
↔
ROTL MSB LSB B/W 0
C
↔
↔ ↔ ↔ ↔
↔ ↔ ↔ ↔ ↔
AND B/W 0
OR Rd ∨ (EAs) → Rd B/W 0 −
XOR Rd ⊕ (EAs) → Rd B/W 0 −
NOT ¬ (EAd) → (EAd) B/W 0 −
BSET ¬ (<Bit No.> of <EAd>) → Z B/W − − −
1 → (<Bit No.> of <EAd>)
BCLR ¬ (<Bit No.> of <EAd>) → Z − − −
↔
B/W
0 → (<Bit No.> of <EAd>)
¬ (<Bit No.> of <EAd>) → Z − − −
↔ ↔
BTST B/W
BNOT ¬ (<Bit No.> of <EAd>) → Z B/W − − −
→ (<Bit No.> of <EAd>)
Bcc If condition is true then − − − − −
PC + disp → PC
else next;
PRTS @SP + → CP − − − − −
@SP + → PC
RTD @SP + → PC − − − − −
SP + #IMM → SP
PRTD @SP + → CP − − − − −
@SP + → PC
SP + #IMM → SP
SCB If condition is true then next; − − − − −
SCB/F else Rn − 1 → Rn;
SCB/NE If Rn = −1 then next
SCB/EQ else PC + disp → PC;
@SP + → SR −
↔
RTE
(If Max. mode then @SP + → CP)
@SP + → PC
LINK FP (R6) → @ − SP − − − − −
SP → FP (R6)
SP + #IMM → SP
UNLK FP (R6) → SP − − − − −
@SP + → FP
SLEEP Normal operating mode → power-down state − − − − −
LDC (EAs) → CR B/W*
STC CR → (EAd) B/W* − − − −
ANDC CR ∧ #IMM → CR B/W*
ORC CR ∨ #IMM → CR B/W*
XORC CR ⊕ #IMM → CR B/W*
NOP PC + 1 → PC − − − − −
How to Read Tables A-1 (a) to (d): The general format consists of an effective address (EA)
field followed by an operation code (OP) field.
1 2 3 4 5 6
Data (low)
3
dispL
Effective Address (EA) Field
Data (high)
Effective
Address
2
address (EA)
dispH
Data
disp
field
Operation code
0000Sz101
0001Sz101
00000100
00001100
1010Szrrr
1101Szrrr
1110Szrrr
@(d:16,Rn) 1111Szrrr
1011Szrrr
1100Szrrr
(OP) field
1
Addres-
sing Mode
@(d:8,Rn)
@aa:16
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Instruction
Rn
4 5 6
MOV:G.B <EAs>,Rd 2 2 3 4 2 2 3 4 3 10000rdrdrd
MOV:G.W <EAs>,Rd 2 2 3 4 2 2 3 4 4 10000rdrdrd
Data transfer
In special-format instructions the operation code field precedes the effective address field.
Note: * Do not use combinations marked as disallowed, since they may cause incorrect operation.
R7 R6 R5 R4 R3 R2 R1 R0
• #VEC: four bits specifying a vector number from 0 to 15. These vector numbers designate
vector addresses as follows:
Vector Address
#VEC Minimum Mode Maximum Mode
0 H'0020-H'0021 H'0040-H'0043
1 H'0022-H'0023 H'0044-H'0047
2 H'0024-H'0025 H'0048-H'004B
3 H'0026-H'0027 H'004C-H'004F
4 H'0028-H'0029 H'0050-H'0053
5 H'002A-H'002B H'0054-H'0057
6 H'002C-H'002D H'0058-H'005B
7 H'002E-H'002F H'005C-H'005F
8 H'0030-H'0031 H'0060-H'0063
9 H'0032-H'0033 H'0064-H'0067
A H'0034-H'0035 H'0068-H'006B
B H'0036-H'0037 H'006C-H'006F
C H'0038-H'0039 H'0070-H'0073
D H'003A-H'003B H'0074-H'0077
E H'003C-H'003D H'0078-H'007B
F H'003E-H'003F H'007C-H'007F
Data (low)
3
dispL
Effective Address (EA) Field
Data (high)
Address
2
dispH
Data
disp
0000Sz101
0001Sz101
00000100
00001100
1010Szrrr
1101Szrrr
1110Szrrr
@(d:16,Rn) 1111Szrrr
1011Szrrr
1100Szrrr
1
Addres-
sing Mode
@(d:8,Rn)
@aa:16
Operation Code (OP) Field
@aa:8
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Instruction
Rn
4 5 6
MOV:G.B <EAs>,Rd 2 2 3 4 2 2 3 4 3 10000rdrdrd
MOV:G.W <EAs>,Rd 2 2 3 4 2 2 3 4 4 10000rdrdrd
MOV:G.B Rs,<EAd> 2 3 4 2 2 3 4 10010rsrsrs
MOV:G.W Rs,<EAd> 2 3 4 2 2 3 4 10010rsrsrs
MOV:G.B #xx:8,<EAd> 3 4 5 3 3 4 5 00000110 Data
MOV:G.W #xx:8,<EAd> 3 4 5 3 3 4 5 00000110 Data
Data transfer
Data (low)
3
dispL
Effective Address (EA) Field
Data (high)
Address
2
dispH
Data
disp
0000Sz101
0001Sz101
00000100
00001100
1010Szrrr
1101Szrrr
1110Szrrr
@(d:16,Rn) 1111Szrrr
1011Szrrr
1100Szrrr
1
Addres-
sing Mode
@(d:8,Rn)
@aa:16
Operation Code (OP) Field
@aa:8
#xx:16
@Rn+
@-Rn
#xx:8
@Rn
Instruction
Rn
4 5 6
DADD.B Rs,Rd 3 00000000 10100rdrdrd
SUB.B <EAs>,Rd 2 2 3 4 2 2 3 4 3 00110rdrdrd
SUB.W <EAs>,Rd 2 2 3 4 2 2 3 4 4 00110rdrdrd
SUBS.B <EAs>,Rd 2 2 3 4 2 2 3 4 3 00111rdrdrd
SUBS.W <EAs>,Rd 2 2 3 4 2 2 3 4 4 00111rdrdrd
SUBX.B <EAs>,Rd 2 2 3 4 2 2 3 4 3 10110rdrdrd
SUBX.W <EAs>,Rd 2 2 3 4 2 2 3 4 4 10110rdrdrd
DSUB.B Rs,Rd 3 00000000 10110rdrdrd
MULXU.B <EAs>,Rd 2 2 3 4 2 2 3 4 3 10101rdrdrd
MULXU.W <EAs>,Rd 2 2 3 4 2 2 3 4 4 10101rdrdrd
Arithmetic operations
Data (low)
3
dispL
Effective Address (EA) Field
Data (high)
Address
2
dispH
Data
disp
0000Sz101
0001Sz101
00000100
00001100
1010Szrrr
1101Szrrr
1110Szrrr
@(d:16,Rn) 1111Szrrr
1011Szrrr
1100Szrrr
1
Addres-
sing Mode
@(d:8,Rn)
@aa:16
Operation Code (OP) Field
@aa:8
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Instruction
Rn
4 5 6
SHAL.B <EAd> 2 2 3 4 2 2 3 4 00011000
SHAL.W <EAd> 2 2 3 4 2 2 3 4 00011000
SHAR.B <EAd> 2 2 3 4 2 2 3 4 00011001
SHAR.W <EAd> 2 2 3 4 2 2 3 4 00011001
SHLL.B <EAd> 2 2 3 4 2 2 3 4 00011010
SHLL.W <EAd> 2 2 3 4 2 2 3 4 00011010
SHLR.B <EAd> 2 2 3 4 2 2 3 4 00011011
Shift
Data (low)
3
dispL
Effective Address (EA) Field
Data (high)
Address
2
dispH
Data
disp
0000Sz101
0001Sz101
00000100
00001100
1010Szrrr
1101Szrrr
1110Szrrr
@(d:16,Rn) 1111Szrrr
1011Szrrr
1100Szrrr
1
Addres-
sing Mode
@(d:8,Rn)
@aa:16
Operation Code (OP) Field
@aa:8
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Instruction
Rn
4 5 6
BSET.B #xx,<EAd> 2 2 3 4 2 2 3 4 1100 data
BSET.W #xx,<EAd> 2 2 3 4 2 2 3 4 1100 data
BSET.B Rs,<EAd> 2 2 3 4 2 2 3 4 01001rs rsrs
BSET.W Rs,<EAd> 2 2 3 4 2 2 3 4 01001rsrsrs
BCLR.B #xx,<EAd> 2 2 3 4 2 2 3 4 1101 data
BCLR.W #xx,<EAd> 2 2 3 4 2 2 3 4 1101 data
Bit operations
Machine-Language Code
Byte
Instruction Length 1 2 3 4
MOV:E.B #xx:8, Rd 2 01010rdrdrd Data
MOV:I.W #xx:16, Rd 3 01011rdrdrd Data (high) Data (low)
MOV:L.B @aa:8, Rd 2 01100rdrdrd Address (low)
MOV:L.W @aa:8, Rd 2 01101rdrdrd Address (low)
MOV:S.B Rs, @aa:8 2 01110rsrsrs Address (low)
MOV:S.W Rs, @aa:8 2 01111rsrsrs Address (low)
MOV:F.B @(d:8,R6), Rd 2 10000rdrdrd disp
MOV:F.W @(d:8,R6), Rd 2 10001rdrdrd disp
MOV:F.B Rs, @(d:8, R6) 2 10010rsrsrs disp
MOV:F.W Rs, @(d:8, R6) 2 10011rsrsrs disp
CMP:E #xx8, Rd 2 01000rdrdrd Data
CMP:I #xx16, Rd 3 01001rdrdrd Data (high) Data (low)
Machine-Language Code
Byte
Instruction Length 1 2 3 4
Bcc d:8 BRA (BT) 2 00100000 disp
BRN (BF) 00100001 disp
BHI 00100010 disp
BLS 00100011 disp
BCC (BHS) 00100100 disp
BCS (BLO) 00100101 disp
BNE 00100110 disp
BEQ 00100111 disp
BVC 00101000 disp
BVS 00101001 disp
BPL 00101010 disp
BMI 00101011 disp
BGE 00101100 disp
BLT 00101101 disp
BGT 00101110 disp
BLE 00101111 disp
Bcc d:16 BRA (BT) 3 00110000 disp H disp L
BRN (BF) 00110001 disp H disp L
BHI 00110010 disp H disp L
BLS 00110011 disp H disp L
BCC (BHS) 00110100 disp H disp L
BCS (BLO) 00110101 disp H disp L
BNE 00110110 disp H disp L
BEQ 00110111 disp H disp L
BVC 00111000 disp H disp L
BVS 00111001 disp H disp L
BPL 00111010 disp H disp L
BMI 00111011 disp H disp L
BGE 00111100 disp H disp L
Machine-Language Code
Byte
Instruction Length 1 2 3 4
Bcc d:16 BLT 3 00111101 disp H disp L
BGT 00111110 disp H disp L
BLE 00111111 disp H disp L
JMP @Rn 2 00010001 11010rrr
JMP @aa:16 3 00010000 Address (high) Address (low)
JMP @(d:8, Rn) 3 00010001 11100rrr disp
JMP @(d:16, Rn) 4 00010001 11110rrr disp H disp L
BSR d:8 2 00001110 disp
BSR d:16 3 00011110 disp H disp L
JSR @Rn 2 00010001 11011rrr
JSR @aa:16 3 00011000 Address (high) Address (low)
JSR @(d:8, Rn) 3 00010001 11101rrr disp
JSR @(d:16, Rn) 4 00010001 11111rrr disp H disp L
RTS 1 00011001
RTD #xx:8 2 00010100 Data
RTD #xx:16 3 00011100 Data (high) Data (low)
SCB/cc Rn,disp SCB/F 3 00000001 10111rrr disp
SCB/NE 00000110 10111rrr disp
SCB/EQ 00000111 10111rrr disp
PJMP @aa:24 4 00010011 Page Address (high) Address (low)
PJMP @Rn 2 00010001 11000rrr
PJSR @aa:24 4 00000011 Page Address (high) Address (low)
PJSR @Rn 2 00010001 11001rrr
PRTS 2 00010001 00011001
PRTD #xx:8 3 00010001 00010100 Data
PRTD #xx:16 4 00010001 00011100 Data (high) Data (low)
Machine-Language Code
Byte
Instruction Length 1 2 3 4
TRAPA #xx 2 00001000 0001 #VEC
TRAP/VS 1 00001001
PTE 1 00001010
LINK FP,#xx:8 2 00010111 Data
LINK FP,#xx:16 3 00011111 Data (high) Data (low)
UNLK FP 1 00001111
SLEEP 1 00011010
NOP 1 00000000
HI 0 1 2 3 4 5 6 7 8 9 A B C D E F
NOP SCB/F LDM PJSR #xx:8 @aa:8.B SCB/NE SCB/EQ TRAPA TRAP/VS RTE #xx:16 @aa:8.W BSR UNLK
0
Table A-6 @aa:24 Table A-5 Table A-4 Table A-6 Table A-6 Table A-5 Table A-4 d:8
JMP Table A-6* STM PJMP RTD @aa:16.B LINK JSR RTS SLEEP RTD @aa:16.W BSR LINK
1
@aa:24 #xx:8 Table A-4 #xx:8 #xx:16 Table A-4 d:16 #xx:16
BRA BRN BHI BLS Bcc BCS BNE BEQ BVC BVS BPL BMI BGE BLT BGT BLE
2
d:8
BRA BRN BHI BLS Bcc BCS BNE BEQ BVC BVS BPL BMI BGE BLT BGT BLE
3
d:16
Note: * References to tables A-3 to A-6 indicate the table giving the second or a subsequent byte of the machine-language code.
H'11 is the first byte of the machine-language code of the following instructions:
JMP, JSR, PJMP, and PJSR in register indirect addressing mode;
JMP and JSR in register indirect addressing mode with displacement;
PRTS and PRTD.
effective adress (EA) and operation code (OP) fields but not the effective address extension.
Tables A-2 to A-6 show a map of the machine-language instruction codes. The map includes the
Table A-3 Second Byte of Axxx Instruction Codes
LO
HI 0 1 2 3 4 5 6 7 8 9 A B C D E F
Table A-6* ADD:Q ADD:Q ADD:Q ADD:Q
0 #2
#1 #−1 #−2
SWAP EXTS EXTU CLR NEG NOT TST TAS SHAL SHAR SHLL SHLR ROTL ROTR ROTXL ROTXR
1
ADD ADDS
2
R0 R1 R2 R3 R4 R5 R6 R7 R0 R1 R2 R3 R4 R5 R6 R7
SUB SUBS
3
OR BSET (register indirect specification of bit number)
4
8 MOV LDC
9 XCH STC
A ADDX MULXU
Rev. 3.0, 02/99, page 771 of 904
B SUBX DIVXU
Note: * Prefix code of the DADD and DSUB instructions. Table A-6 gives the third byte of the instruction code.
Rev. 3.0, 02/99, page 772 of 904 Table A-4 Second Byte of 05xx, 15xx, 0Dxx, 1Dxx, Bxxx, Cxxx, Dxxx, Exxx, and Fxxx Instruction Codes
LO
HI 0 1 2 3 4 5 6 7 8 9 A B C D E F
Table A-6* CMP CMP MOV MOV ADD:Q ADD:Q ADD:Q ADD:Q
0 #1 #2
#xx:8 #xx:16 #xx:8 #xx:16 #−1 #−2
CLR NEG NOT TST TAS SHAL SHAR SHLL SHLR ROTL ROTR ROTXL ROTXR
1
ADD ADDS
2
R0 R1 R2 R3 R4 R5 R6 R7 R0 R1 R2 R3 R4 R5 R6 R7
SUB SUBS
3
OR BSET (register indirect specification of bit number)
4
AND BCLR (register indirect specification of bit number)
5
XOR BNOT (register indirect specification of bit number)
6
7 CMP BTST (register indirect specification of bit number)
A ADDX MULXU
B SUBX DIVXU
Note: * Prefix code of the DADD and DSUB instructions. Table A-6 gives the third byte of the instruction code.
Table A-5 Second Byte of 04xx and 0Cxx Instruction Codes
LO
HI 0 1 2 3 4 5 6 7 8 9 A B C D E F
ADD ADDS
2
R0 R1 R2 R3 R4 R5 R6 R7 R0 R1 R2 R3 R4 R5 R6 R7
SUB SUBS
3
OR ORC
4
5 AND ANDC
XOR XORC
6
7 CMP
8 MOV LDC
A ADDX MULXU
Rev. 3.0, 02/99, page 773 of 904
B SUBX DIVXU
F
Rev. 3.0, 02/99, page 774 of 904 Table A-6 Second or Third Byte of 11xx, 01xx, 06xx, 07xx, and xx00xx Instruction Codes
LO
HI 0 1 2 3 4 5 6 7 8 9 A B C D E F
0
PRTD PRTS PRTD
1
#xx:8 #xx:16
7
(MOVFPE)*
8
R0 R1 R2 R3 R4 R5 R6 R7
9 (MOVTPE)*
A DADD
B DSUB SCB
R0 R1 R2 R3 R4 R5 R6 R7
C PJMP @Rn PJSR @Rn
@(d:16,Rn)
I is the total number of bytes
@(d:8,Rn)
written or read when the operand
@aa:16
@aa:8
#xx:16
@Rn+
@−Rn
is in memory
#xx:8
@Rn
Rn
Instruction I K 1 1 2 3 1 1 2 3 2 3
J
ADD.B 1 1 2 5 5 6 5 6 5 6 3
ADD.W 2 1 2 5 5 6 5 6 5 6 4
ADD:Q.B 2 1 2 7 7 8 7 8 7 8
ADD:Q.W 4 1 2 7 7 8 7 8 7 8
DADD 2 4
Formula
Assembler Notation (Value in Table
Operand Start A-7) + (Value in Execution
Read/Write Address Address Code Mnemonic Table A-8 (b)) States
16-bit-bus, Even H'0100 D821 ADD @R0,R1 5+1 6
2-state-
Odd H'0101 D821 ADD @R0,R1 5+0 5
access area
or general
register
Formula
Branch Assembler Notation (Value in Table
Operand destination A-7) + (Value in Execution
Read/Write Address Address Code Mnemonic Table A-8 (a)) + 2I States
On-chip Even H'FC00 11D8 JSR @R0 9+0+2×2 13
supporting
Odd H'FC01 11D8 JSR @R0 9+1+2×2 14
module or
8-bit-bus,
3-state-
access area
(word)
Formula
Assembler Notation
Operand (Value in Table Execution
Read/Write Address Code Mnemonic A-7) + 2 (J + K) States
16-bit-bus, H'9002 D821 ADD @R0,R1 5 + 2 × (1 + 1) 9
2-state-access
area or general
register
Formula
(Value in Table
Assembler Notation A-7) + (Value in
Operand Start Table A-8 (b)) + Execution
Read/Write Address Address Code Mnemonic (J + K)/2 States
16-bit-bus, Even H'0100 D821 ADD @R0,R1 5 + 1 + (1 + 1)/2 7
2-state-
Odd H'0101 D821 ADD @R0,R1 5 + 0 + (1 + 1)/2 6
access area
or general
register
Addressing Mode
@(d:16,Rn)
@(d:8,Rn)
@aa:16
@aa:8
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Rn
Instruction I K 1 1 2 3 1 1 2 3 2 3
J
ADD:G.B <EAs>,Rd 1 1 2 5 5 6 5 6 5 6 3
ADD:G.W <EAs>,Rd 2 1 2 5 5 6 5 6 5 6 4
ADD:Q.B #xx, <EAd> 2 1 2 7 7 8 7 8 7 8
ADD:Q.W #xx, <EAd> 4 1 2 7 7 8 7 8 7 8
ADDS.B <EAs>, Rd 1 1 3 5 5 6 5 6 5 6 3
ADDS.W <EAs>, Rd 2 1 3 5 5 6 5 6 5 6 4
ADDX.B <EAs>, Rd 1 1 2 5 5 6 5 6 5 6 3
ADDX.W <EAs>, Rd 2 1 2 5 5 6 5 6 5 6 4
AND.B <EAs>, Rd 1 1 2 5 5 6 5 6 5 6 3
AND.W <EAs>, Rd 2 1 2 5 5 6 5 6 5 6 4
ANDC #xx,CR 1 5 9
BCLR.B #xx, <EAd> * 2 1 4 7 7 8 7 8 7 8
BCLR.W #xx, <EAd> * 4 1 4 7 7 8 7 8 7 8
BNOT.B #xx, <EAd> * 2 1 4 7 7 8 7 8 7 8
BNOT.W #xx, <EAd> * 4 1 4 7 7 8 7 8 7 8
BSET.B #xx, <EAd> * 2 1 4 7 7 8 7 8 7 8
BSET.W #xx, <EAd> * 4 1 4 7 7 8 7 8 7 8
BTST.B #xx, <EAd> * 1 1 3 5 5 6 5 6 5 6
BTST.W #xx, <EAd> * 2 1 3 5 5 6 5 6 5 6
CLR.B <EAd> 1 1 2 5 5 6 5 6 5 6
CLR.W <EAd> 2 1 2 5 5 6 5 6 5 6
CMP:G.B <EAs>,Rd 1 1 2 5 5 6 5 6 5 6 3
CMP:G.W <EAs>,Rd 2 1 2 5 5 6 5 6 5 6 4
CMP:G.B #xx:8, <EA> 1 2 6 6 7 6 7 6 7
CMP:G.B #xx:16, <EA> 2 3 7 7 8 7 8 7 8
Note: * Rs can also be specified for the source operand.
Addressing Mode
@(d:16,Rn)
@(d:8,Rn)
@aa:16
@aa:8
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Rn
Instruction I K 1 1 2 3 1 1 2 3 2 3
J
CMP:E #xx:8,Rd 0 2
CMP:I #xx:16,Rd 0 3
DADD Rs,Rd 2 4
DIVXU.B <EAs>,Rd 1 1 20 23 23 24 23 24 23 24 21
DIVXU.W <EAs>,Rd 2 1 26 29 29 30 29 30 29 30 28
DSUB Rs,Rd 2 4
EXTS Rd 1 3
EXTU Rd 1 3
LDC.B <EAs>,CR 1 1 3 6 6 7 6 7 6 7 4
LDC.W <EAs>,CR 2 1 4 7 7 8 7 8 7 8 6
MOV:G.B 1 1 2 5 5 6 5 6 5 6 3
MOV:G.W 2 1 2 5 5 6 5 6 5 6 4
MOV:G.B #xx:8,<EAd> 1 2 7 7 8 7 8 7 8
MOV:G.W #xx:16,<EAd> 2 3 8 8 9 8 9 8 9
MOV:E #xx:8,Rd 0 2
MOV:I #xx:16,Rd 0 3
MOV:L.B @aa:8,Rd 1 0 5
MOV:L.W @aa:8,Rd 2 0 5
MOV:S.B Rs,@aa:8 1 0 5
MOV:S.W Rs,@aa:8 2 0 5
MOV:F.B @(d:8,R6),Rd 1 0 5
MOV:F.W @(d:8,R6),Rd 2 0 5
MOV:F.B Rs,@(d:8,R6) 1 0 5
MOV:FW Rs,@(d:8,R6) 2 0 5
Addressing Mode
@(d:16,Rn)
@(d:8,Rn)
@aa:16
@aa:8
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Rn
Instruction I K 1 1 2 3 1 1 2 3 2 3
J
(MOVFPE <EAs>,Rd)* 0 2 13 13 14 13 14 13 14
20 20 21 20 21 20 21
(MOVTPE Rs,<EA>)* 0 2 13 13 14 13 14 13 14
20 20 21 20 21 20 21
MULXU.B <EAs>,Rd 1 1 16 19 19 20 19 20 19 20 18
MULXU.W <EAs>,Rd 2 1 23 25 25 26 25 26 25 26 25
NEG.B <EAd> 2 1 2 7 7 8 7 8 7 8
NEG.W <EAd> 4 1 2 7 7 8 7 8 7 8
NOT.B <EAd> 2 1 2 7 7 8 7 8 7 8
NOT.W <EAd> 4 1 2 7 7 8 7 8 7 8
OR.B <EAs>,Rd 1 1 2 5 5 6 5 6 5 6 3
OR.W <EAs>,Rd 2 1 2 5 5 6 5 6 5 6 4
ORC #xx,CR 1 5 9
ROTL.B <EAd> 2 1 2 7 7 8 7 8 7 8
ROTL.W <EAd> 4 1 2 7 7 8 7 8 7 8
ROTR.B <EAd> 2 1 2 7 7 8 7 8 7 8
ROTR.W <EAd> 4 1 2 7 7 8 7 8 7 8
ROTXL.B <EAd> 2 1 2 7 7 8 7 8 7 8
ROTXL.W <EAd> 4 1 2 7 7 8 7 8 7 8
ROTXR.B <EAd> 2 1 2 7 7 8 7 8 7 8
ROTXR.W <EAd> 4 1 2 7 7 8 7 8 7 8
SHAL.B <EAd> 2 1 2 7 7 8 7 8 7 8
SHAL.W <EAd> 4 1 2 7 7 8 7 8 7 8
SHAR.B <EAd> 2 1 2 7 7 8 7 8 7 8
SHAR.W <EAd> 4 1 2 7 7 8 7 8 7 8
SHILL.B <EAd> 2 1 2 7 7 8 7 8 7 8
SHLL.W <EAd> 4 1 2 7 7 8 7 8 7 8
Note: * Not available in the H8/539F.
Addressing Mode
@(d:16,Rn)
@(d:8,Rn)
@aa:16
@aa:8
#xx:16
@Rn+
@−Rn
#xx:8
@Rn
Rn
Instruction I K 1 1 2 3 1 1 2 3 2 3
J
SHLR.B <EAd> 2 1 2 7 7 8 7 8 7 8
SHLR.W <EAd> 4 1 2 7 7 8 7 8 7 8
STC.B CR,<EAd> 1 1 4 7 7 8 7 8 7 8
STC.W CR,<EAd> 2 1 4 7 7 8 7 8 7 8
SUB.B <EAs>,Rd 1 1 2 5 5 6 5 6 5 6 3
SUB.W <EAs>,Rd 2 1 2 5 5 6 5 6 5 6 4
SUBS.B <EAs>,Rd 1 1 3 5 5 6 5 6 5 6 3
SUBS.W <EAs>,Rd 2 1 3 5 5 6 5 6 5 6 4
SUBX.B <EAs>,Rd 1 1 2 5 5 6 5 6 5 6 3
SUBX.W <EAs>,Rd 2 1 2 5 5 6 5 6 5 6 4
SWAP Rd 1 3
TAS <EAd> 2 1 4 7 7 8 7 8 7 8
TST.B <EAd> 1 1 2 5 5 6 5 6 5 6
TST.W <EAd> 2 1 2 5 5 6 5 6 5 6
XCH Rs,Rd 1 4
XOR.B <EAs>,Rd 1 1 2 5 6 5 5 6 5 6 3
XOR.W <EAs>,Rd 2 1 2 5 6 5 5 6 5 6 4
XORC #xx,CR 1 5 9
*
6
DIVXU.B zero divide, minimum mode 1 20 23 23 24 23 24 23 24 21
7
10
DIVXU.B zero divide, maximum mode 1 25 28 28 29 28 29 28 29 21
11
6
DIVXU.W zero divide, minimum mode 1 20 23 23 24 23 24 23 24 27
8
10
DIVXU.W zero divide, maximum mode 1 25 28 28 29 28 29 28 29 27
12
DIVXU.B overflow 1 1 8 11 11 12 11 12 11 12 9
DIVXU.W overflow 2 1 8 11 11 12 11 12 11 12 10
Note: * Register operand or immediate data
Memory operand
BSR,JMP,JSR,RTS,RTD,RTE, Even 0
TRAPA,PJMP,PJSR,PRTS,PRTD Odd 1
Even 0
Bcc,SCB,TRAP/VS (if branch is taken)
Odd 1
Table A-8 (b) Correction Values (General Instructions, for Each Addressing Mode)
A.5.1 Features
• General-register architecture
• Highly orthogonal instruction set
• 1.5-address instructions
• C-oriented instruction set
The H8/500 CPU instruction set consists of 63 instructions. Table A-9 classifies the instruction
set.
Number of
Type Instructions Instructions
Data transfer MOV LDM STM XCH SWAP MOVTPE MOVFPE 7
Arithmetic operations ADD SUB ADDS SUBS ADDX SUBX DADD DSUB 17
MULXU DIVXU CMP EXTS EXTU TST NEG CLR
TAS
Logic operations AND OR XOR NOT 4
Shift SHAL SHAR SHLL SHLR ROTL ROTR ROTXL 8
ROTXR
Bit manipulation BSET BCLR BTST BNOT 4
Branch Bcc* JMP PJMP BSR JSR PJSR RTS PRTS RTD 11
PRTD SCB(/F/NE/EQ)
System control TRAPA TRAP/VS RTE SLEEP LDC STC ANDC ORC 12
XORC NOP LINK UNLK
Note: * Bcc is the generic designation for a conditional branch instruction.
There are two kinds of basic instruction format, general and special.
(1) General Format: This format consists of an effective address (EA) field, an effective address
extension field, and an operation code (OP) field. The effective address is placed before the
operation code because this results in faster execution of the instruction. Table A-10 describes the
three fields of the general instruction format.
1 0 1 0 0 r r r 0 0 0 0 0 0 0 0 1 0 1 0 0 r r r
(2) Special Format: In this format the operation code comes first, followed by the effective
address field and effective address extension. This format is used in branching instructions,
system control instructions, and some short-format instructions that can be executed faster if the
operation is specified before the operand. Table A-11 describes the three fields of the special
instruction format.
There are seven data transfer instructions. The function of each instruction is described next.
(1) MOV Instruction: Transfers data between two general registers, or between a general register
and memory. Can also transfer immediate data to a general register or memory.
Rs
(EAd)
Instructions and Operand Sizes: The following table lists the possible combinations.
Size
Instruction B/W B W
MOV:G O
MOV:E O
MOV:F O
MOV:I O
MOV:L O
MOV:S O
B: Byte
W: Word
R0
R1
SP
R2 R0
R3 R1
R2
(Old SP)
Instructions and Operand Sizes: The operand size is always word size.
(3) STM Instruction (W): Saves data onto the stack. Multiple registers can be saved
simultaneously.
R0 SP
R1
R2 R0
R3 R1
R2
(Old SP)
Instructions and Operand Sizes: The operand size is always word size.
Operation: Rs → Rd, Rd → Rs
Registers (CPU)
R0 A R0 B
R1 R1
R2 B R2 A
R3 R3
Instructions and Operand Sizes: The operand size is always word size.
(5) SWAP Instruction (B): Exchanges data between the upper and lower bytes of a general
register.
Registers (CPU)
R0 A B R0 B A
R1 R1
R2 R2
R3 R3
Example: SWAP R0
Instructions and Operand Sizes: The operand size is always byte size.
Operation: Rn → (EAd)
Rs
(EAd)
Instructions and Operand Sizes: The operand size is always byte size.
Operation: (EAs) → Rd
Rd
(EAs)
Instructions and Operand Sizes: The operand size is always byte size.
There are 17 arithmetic instructions. The function of each instruction is described next.
These instructions perform addition and subtraction on data in two general registers, data in a
general register and memory, data in a general register and immediate data, or data in memory and
immediate data.
Registers (CPU)
Rd A
ALU A+1
Instructions and Operand Sizes: Byte or word operand size can be selected.
These instructions perform addition and subtraction with carry on data in two general registers,
data in a general register and memory, or data in a general register and immediate data.
Registers (CPU)
Rd A
CCR C 1
ALU A+1+C
Instructions and Operand Sizes: Byte or word operand size can be selected.
These instructions perform decimal addition and subtraction on data in two general registers.
Registers (CPU)
Rd A
Rs B
CCR C
ALU (A + B + C) 10
Instructions and Operand Sizes: The operand size is always byte size.
Operation: Rd × (EAs) → Rd
Registers (CPU)
Rd A Rd Result
Rs B Rs B
<After execution>
ALU A× B
Instructions and Operand Sizes: Byte or word operand size can be selected.
(10) DIVXU Instruction (B/W): Performs 16-bit ÷ 8-bit or 32-bit ÷ 16-bit unsigned division on
data in a general register and data in another general register or memory, or on data in a general
register and immediate data.
Operation: Rd ÷ (EAs) → Rd
Rd A Rd
Rs B Rs B
<After execution>
ALU A÷ B
Instructions and Operand Sizes: Byte or word operand size can be selected.
Registers (CPU)
Rd A Left unchanged
Rs B
Instructions and Operand Sizes: The following table lists the possible combinations.
Size
Instruction B/W B W
CMP:G O
CMP:E O
CMP:I O
B: Byte
W: Word
Registers (CPU)
15 87 0
R0 Don't care 1 0 1 1 0 1 0 1
(Before execution)
15 87 0
R0 1 1 1 1 1 1 1 1 1 0 1 1 0 1 0 1
(After execution) Sign extension
Example: EXTS R0
Instructions and Operand Sizes: The operand size is always byte size.
(13) EXTU Instruction (B): Converts byte data in a general register to word data by padding with
zero bits.
Registers (CPU)
15 87 0
R0 Don't care 1 0 1 1 0 1 0 1
(Before execution)
15 87 0
R0 0 0 0 0 0 0 0 0 1 0 1 1 0 1 0 1
Example: EXTU R0
Instructions and Operand Sizes: The operand size is always byte size.
Operation: (EAd) − 0
Registers (CPU)
R0 A Left unchanged
Example: TST.W R0
Instructions and Operand Sizes: Byte or word operand size can be selected.
(15) NEG Instruction (B/W): Obtains the two's complement of general register or memory
contents.
Registers (CPU)
R0 A R0 2's complement
0
<After execution>
ALU 0−A
Example: NEG.W R0
Instructions and Operand Sizes: Byte or word operand size can be selected.
Operation: 0 → (EAd)
Registers (CPU)
15 0
R0 Don't care
(before execution)
15 0
R0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Example: CLR.W R0
Instructions and Operand Sizes: Byte or word operand size can be selected.
(17) TAS Instruction (B): Tests general register or memory contents, then sets the most
significant bit (bit 7) to 1.
Registers (CPU)
R0 A
15 87 0
R0 Don't care 1 * * * * * * *
(after execution) Set to 1
Example: TAS R0
Instructions and Operand Sizes: The operand size is always byte size.
There are four logic instructions. The function of each instruction is described next.
(1) AND Instruction (B/W): Performs a logical AND operation on a general register and another
general register, memory, or immediate data.
Operation: Rd ∧ (EAs) → Rd
Rd A Rd
Rs B Rs B
<After execution>
ALU A∧B
Instructions and Operand Sizes: Byte or word operand size can be selected.
(2) OR Instruction (B/W): Performs a logical OR operation on a general register and another
general register, memory, or immediate data.
Operation: Rd ∨ (EAs) → Rd
Registers (CPU)
Rd A Rd Result
Rs B Rs B
Instructions and Operand Sizes: Byte or word operand size can be selected.
Operation: Rd ⊕ (EAs) → Rd
Registers (CPU)
Rd A Rd Result
Rs B Rs B
<After execution>
ALU A + B
Instructions and Operand Sizes: Byte or word operand size can be selected.
(4) NOT Instruction (B/W): Takes the one's complement of general register or memory contents.
Registers (CPU)
Rd A Rd 1's complement
Example: NOT.W Rd
Instructions and Operand Sizes: Byte or word operand size can be selected.
There are eight shift instructions. The function of each instruction is described next.
These instructions perform an arithmetic shift operation on general register or memory contents.
MSB LSB
C (CCR) (0)2
Example: SHAL.W Rd
MSB LSB
C(CCR)
Example: SHAR.W Rd
Instructions and Operand Sizes: Byte or word operand size can be selected.
These instructions perform a logic shift operation on general register or memory contents.
MSB LSB
C (CCR) (0)2
Example: SHLL.W Rd
MSB LSB
(0)2 C(CCR)
Example: SHLR.W Rd
Instructions and Operand Sizes: Byte or word operand size can be selected.
MSB LSB
C (CCR)
Example: ROTL.W Rd
MSB LSB
C(CCR)
Example: ROTR.W Rd
Instructions and Operand Sizes: Byte or word operand size can be selected.
These instructions rotate general register or memory contents through the carry bit.
MSB LSB
C (CCR)
Example: ROTXL .W Rd
MSB LSB
C (CCR)
Example: ROTXR.W Rd
Instructions and Operand Sizes: Byte or word operand size can be selected.
There are four bit manipulation instructions. The function of each instruction is described next.
(1) BSET Instruction (B/W): Tests a specified bit in a general register or memory, then sets the
bit to 1. The bit is specified by immediate data or a bit number in a general register.
Registers (CPU)
14 14
R1 A R1 1
1 <After execution>
ALU ¬A Z (CCR)
Instructions and Operand Sizes: Byte or word operand size can be selected.
Registers (CPU)
14 14
R1 A R1 0
0 <After execution>
ALU ¬A Z (CCR)
Instructions and Operand Sizes: Byte or word operand size can be selected.
(3) BNOT Instruction (B/W): Tests a specified bit in a general register or memory, then inverts
the bit. The bit is specified by immediate data or a bit number in a general register.
Registers (CPU) ¬A
14 14
R1 A R1
<After execution>
ALU ¬A Z (CCR)
Instructions and Operand Sizes: Byte or word operand size can be selected.
Registers (CPU)
14
R1 A Left unchanged
ALU ¬A Z (CCR)
Instructions and Operand Sizes: Byte or word operand size can be selected.
There are 11 branch instructions. The function of each instruction is described next.
Start of next
instruction
BRA
BRA instruction
disp
Old PC
disp
PC + disp → PC
LABEL New PC
Start
instruction
Example: BRA LABEL
Operation: <EA> → PC
JMP
JMP instruction
@LABEL:16
Start of
instruction @LABEL: 16 → PC
LABEL New PC
Addressing of Branch Destination: Register indirect, register indirect with eight-bit or 16-bit
displacement, or 16-bit direct addressing.
PJMP
PJMP instruction
@R2
R2 High
R3 Low
Start of
instruction R3→PC R2→CP
New CP, PC
Start of next
instruction BSR
BSR instruction
disp
Old PC
disp
PC + disp → PC
LABEL New PC
New SP
Start of Old PC
instruction Old SP
Addressing of Branch Destination: Register indirect, register indirect with eight-bit or 16-bit
displacement, or 16-bit direct addressing.
New CP, PC
Start of
New TP:SP
instruction Old PC
Old PC
Old TP:SP
Operation: @SP+ → PC
RTS Old PC
Old SP
New PC
New SP
Example: RTS
Old TP:SP
New CP
New PC
New TP:SP
Example: PRTS
RTD Old PC
#xx:8
Old SP
New PC
SP+#xx:8
New SP
RTD can return from a subroutine called by a BSR or JSR instruction. The stack-pointer
adjustment is specified by eight-bit or 16-bit immediate data.
Note: The immediate data must have an even value. If the stack pointer is set to an odd address,
an address error will occur when the stack is accessed.
Old SP
New CP
New PC
SP+#xx:8
New SP
PRTD can return from a subroutine called by a BSR or JSR instruction. The stack-pointer
adjustment is specified by eight-bit or 16-bit immediate data.
Note: The immediate data must have an even value. If the stack pointer is set to an odd address,
an address error will occur when the stack is accessed.
Start of next
instruction SCB/F SCB/F
instruction
disp
Old PC
disp
PC+disp → PC
Start of instruction −1 1
R2−1
= end of loop
Description
Instruction Function Condition
SCB/F False −
SCB/NE Not Equal Z=0
SCB/EQ Equal Z=1
There are 12 system control instructions. The function of each instruction is described next.
H'0028 PCH
TRAPA #4 vector
H'0029 PCL
New PC
Start of
New SP
instruction Old SR SR
Old PC
Old SP
Example: TRAPA #4
H'0008 PCH
TRAP/VS vector
H'0009 PCL
Start of next
instruction TRAPA
Old PC
New PC
Start of New SP
instruction Old SR SR
Old PC (V = 1)
Old SP
Example: TRAP/VS
H'0028 PCH
TRAPA #4 vector
H'0029 PCL
RTE
Old SP
New SR SR
New PC
New SP
Example: RTE
LINK
LINK instruction
disp
Old SP + #IMM → SP
R6 Old FP
New SP Area C (FP − 6) R7 Old SP
Stack frame
Area B (FP − 4) created by
Area A (FP − 2) LINK <Before execution>
New FP Old FP instruction
Old SP Data 1 R6 New FP
Old FP Initial SP (= FP) R7 New SP
Initial SP Return PC
(= FP) <After execution>
@SP+ → FP
R6 Old FP
Old SP Area C (FP − 6) R7 Old SP
Stack frame
Area B (FP − 4) released
Area A (FP − 2) by UNLK <Before execution>
Example: UNLK FP
(7) LDC Instruction (B/W): Moves immediate data or general register or memory contents into a
specified control register.
Operation: (EAs) → CR
CP
R1 DP
TP
Instructions and Operand Sizes: The operand size depends on the control register.
Operation: CR → (EAd)
CP
R1 DP DP
TP
Instructions and Operand Sizes: The operand size depends on the control register.
(9) ANDC Instruction (B/W): Logically ANDs a control register with immediate data.
Operation: CR ∧ #IMM → CR
R1 SR
ALU SR ∧ R1
Instructions and Operand Sizes: The operand size depends on the control register.
Operation: CR ∨ #IMM → CR
R1 SR
ALU SR ∨ R1
Instructions and Operand Sizes: The operand size depends on the control register.
(11) XORC Instruction (B/W): Logically exclusive-ORs a control register with immediate data.
Operation: CR ⊕ #IMM → CR
R1 SR
ALU SR + R1
Instructions and Operand Sizes: The operand size depends on the control register.
Operation: PC + 1 → PC
The ADD, CMP, and MOV instructions have special short formats. The short formats are a byte
shorter than the corresponding general formats, and most of them execute one state faster. Table
A-12 lists these short formats together with the equivalent general formats.
Initial Value
Register
Minimum Mode Maximum Mode
15 0
R0
R1
R2
R3 Undetermined Undetermined
R4
R5
R6 (FP)
R7 (SP)
15 0
Loaded from Loaded from
PC vector table vector table
SR
H'070* H'070*
CCR
7 0
CP CP: loaded from
vector table
DP Undetermined
DP, EP, and TP:
EP
undetermined
TP
7 0
BR Undetermined Undetermined
H'FE80 Port 1 P1DDR P17DDR P16DDR P15DDR P14DDR P13DDR P12DDR P11DDR P10DDR H'00
H'FE81 Port 2 P2DDR P27DDR P26DDR P25DDR P24DDR P23DDR P22DDR P21DDR P20DDR H'00
H'FE82 Port 1 P1DR P17 P16 P15 P14 P13 P12 P11 P10 H'00
H'FE83 Port 2 P2DR P27 P26 P25 P24 P23 P22 P21 P20 H'00
H'FE84 Port 3 P3DDR P35DDR P34DDR P33DDR P32DDR P31DDR P30DDR H'C0
H'FE85 Port 4 P4DDR P47DDR P46DDR P45DDR P44DDR P43DDR P42DDR P41DDR P40DDR H'00
H'FE86 Port 3 P3DR P35 P34 P33 P32 P31 P30 H'C0
H'FE87 Port 4 P4DR P47 P46 P45 P44 P43 P42 P41 P40 H'00
H'FE88 Port 5 P5DDR P57DDR P56DDR P55DDR P54DDR P53DDR P52DDR P51DDR P50DDR H'00
H'FE8A Port 5 P5DR P57 P56 P55 P54 P53 P52 P51 P50 H'00
H'FE8C Port 7 P7DDR P77DDR P76DDR P75DDR P74DDR P73DDR P72DDR P71DDR P70DDR H'00
H'FE8D H'FF
H'FE8E Port 7 P7DR P77 P76 P75 P74 P73 P72 P71 P70 H'00
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FE90 H'FF
H'FE91 Port A PADDR PA6DDR PA5DDR PA4DDR PA3DDR PA2DDR PA1DDR PA0DDR H'80
H'FE92 Port 9 P9DR P97 P96 P95 P94 P93 P92 P91 P90 Undeter-
mined
H'FE93 Port A PADR PA6 PA5 PA4 PA3 PA2 PA1 PA0 H'80
H'FE94 Port B PBDDR PB7DDR PB6DDR PB5DD PB4DDR PB3DDR PB2DDR PB1DDR PB0DDR H'00
R
H'FE95 Port C PCDDR PC7DDR PC6DDR PC5DD PC4DDR PC3DDR PC2DDR PC1DDR PC0DDR H'00
R
H'FE96 Port B PBDR PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 H'00
H'FE97 Port C PCDR PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 H'00
H'FE98 Port B PBPCR PB7PON PB6PON PB5PON PB4PON PB3PON PB2PON PB1PON PB0PON H'00
H'FE99 Port C PCPCR PC7PON PC6PON PC5PON PC4PON PC3PON PC2PON PC1PON PC0PON H'00
H'FE9B H'FF
H'FE9C H'FF
H'FE9D H'FF
H'FE9E H'FF
H'FE9F H'FF
(continued on next page)
Note: * Initialized to H'FF in standby mode.
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEA0 A/D ADDR0H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA2 ADDR1H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA4 ADDR2H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA6 ADDR3H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA8 ADDR4H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEAA ADDR5H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEAC ADDR6H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEAE ADDR7H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEB0 A/D ADDR8H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB2 ADDR9H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB4 ADDRAH AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB6 ADDRBH AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB8 ADCSR ADF ADIE ADM1 ADM0 CH3 CH2 CH1 CH0 H'00
H'FEBA H'FF
H'FEBB H'FF
H'FEBC H'FF
H'FEBD H'FF
H'FEBE H'FF
H'FEBF H'FF
(continued on next page)
Legend
A/D: A/D converter
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEC0 SCI3 SMR C/$ CHR PE O/( STOP MP CKS1 CKS0 H'00
H'FEC4 SSR TDRE RDRF ORER FER PER TEND MPB MPBT H'84F
H'FEC6 H'FF
H'FEC7 Undeter-
mined
H'FEC8 SCI1 SMR C/$ CHR PE O/( STOP MP CKS1 CKS0 H'00
H'FECC SSR TDRE RDRF ORER FER PER TEND MPB MPBT H'84
H'FECE H'FF
H'FECF Undeter-
mined
(continued on next page)
Legend
SCI1: Serial communication interface 1
SCI3: Serial communication interface 3
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FED0 SCI2 SMR C/$ CHR PE O/( STOP MP CKS1 CKS0 H'00
H'FED4 SSR TDRE RDRF ORER FER PER TEND MPB MPBT H'84
H'FED6 H'FF
H'FED7 Undeter-
mined
H'FED8 H'FF
H'FED9 H'FF
H'FEDA Port A PACR TXD3E RXD3E SCK3E PW3E PW2E PW1E H'90
H'FEDD H'FF
H'FEDF BSC BCR BCRE 0P3T P9AE EXIOP PCRE PBCE P12E H'3F*
(continued on next page)
Legend
SCI2: Serial communication interface 2
INTC: Interrupt controller
BSC: Bus controller
A/D: A/D converter
Note: * Initial value in modes 5 and 6. In modes 1 to 4 and mode 7 the initial value is H'BF.
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEE0 Flash FLMCR VPP VPPE EV PV E P H'00*
memory
H'FEE1 H'FF
H'FEE2 EBR1 LB7 LB6 LB5 LB4 LB3 LB2 LB1 LB0 H'00
H'FEE3 EBR2 SB7 SB6 SB5 SB4 SB3 SB2 SB1 SB0 H'00
H'FEE4 H'FF
H'FEE5 H'FF
H'FEE6 H'FF
H'FEE7 H'FF
H'FEE8 H'FF
H'FEE9 H'FF
H'FEEA H'FF
H'FEEB H'FF
H'FEEE H'FF
H'FEEF H'FF
(continued on next page)
Note: * When 12 V is being applied to the VPP pin, the initial value is H'80.
Bit Names
Address Module Register Initial
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Name Name Value
H'FEF0 PWM1 TCR OE OS CKS2 CKS1 CKS0 H'38
H'FEF3 H'FF
H'FEF7 H'FF
H'FEFB H'FF
H'FEFC H'FF
H'FEFD H'FF
H'FEFE H'FF
H'FEFF H'FF
(continued on next page)
Legend
PWM1: Pulse width modulation timer 1
PWM2: Pulse width modulation timer 2
PWM3: Pulse width modulation timer 3
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF00 INTC IPRA 0 0 H'00
H'FF07 Undeter-
mined
H'FF0E Undeter-
mined
H'FF0F Undeter-
mined
(continued on next page)
Legend
INTC: Interrupt controller
DTC: Data transfer controller
Bit Names
Address Module Register Initial
Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Name Name Value
1
H'FF10 WDT (TCSR)* OVF WT/,7 TME CKS2 CKS1 CKS0 H'18
1
H'FF11 TCNT* H'00
H'FF12 H'FF
H'FF13 H'FF
H'FF18 H'FF
Notes: 1. These registers are write-protected by a password. See section 13.2.4 , "Notes on
Register Access" for details.
2. Initial value in modes 5 and 6. In modes 1 to 4 and mode 7 the initial value is H'EE.
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF20 IPU T1CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 1
H'FF21 T1CRL CCLR2 CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'80
H'FF24 T1OERA DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF25 TMDRA MD6-7 MD4-7 MD3-5 MD2-6 SYNC3 SYNC2 SYNC1 SYNC0 H'00
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF30 IPU TSTR STR7 STR6 STR5 STR4 STR3 STR2 STR1 H'80
Channel 1
H'FF31 T1CRA IEG41 IEG40 IEG31 IEG30 H'F0
H'FF34 T1OERB DOE41 DOE40 DOE31 DOE30 GOE41 GOE40 GOE31 GOE30 H'00
H'FF36 H'FF
H'FF37 H'FF
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF40 IPU T2CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 2
H'FF41 T2CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF44 T2OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF45 H'FF
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF50 IPU T3CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 3
H'FF51 T3CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF54 T3OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF55 H'FF
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF60 IPU T4CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 3
H'FF61 T4CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF64 T4OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF65 H'FF
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF70 IPU T5CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 5
H'FF71 T5CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF74 T5OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF75 H'FF
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF80 IPU T6CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 6
H'FF81 T6CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF85 H'FF
H'FF8C H'FF
H'FF8D H'FF
H'FF8E H'FF
H'FF8F H'FF
(continued on next page)
Legend
IPU: 16-bit integrated timer pulse unit
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF90 IPU T7CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 7
H'FF91 T7CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF95 H'FF
H'FF9C H'FF
H'FF9D H'FF
H'FF9E H'FF
H'FF9F H'FF
(continued on next page)
Legend
IPU: 16-bit integrated timer pulse unit
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FFA0 MULT MLTCR CLR S_ON SIGN MUL MAC H'38
H'FFA4 H'FF
H'FFA5 H'FF
H'FFA6 H'FF
H'FFA7 H'FF
H'FFA8 H'FF
H'FFA9 H'FF
H'FFAA H'FF
H'FFAB H'FF
H'FFAC H'FF
H'FEED H'FF
H'FFAE H'FF
H'FFAF H'FF
(continued on next page)
Legend
MULT: Multiplier
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FFB0 MULT CA H'00
H'FFB2 CB H'00
H'FFB4 CC H'00
H'FFB6 XH Undeter-
mined
H'FFB8 H Undeter-
mined
H'FFBA L Undeter-
mined
H'FFBC MR H'00
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FE80 Port 1 P1DDR P17DDR P16DDR P15DDR P14DDR P13DDR P12DDR P11DDR P10DDR H'00
H'FE81 Port 2 P2DDR P27DDR P26DDR P25DDR P24DDR P23DDR P22DDR P21DDR P20DDR H'00
H'FE82 Port 1 P1DR P17 P16 P15 P14 P13 P12 P11 P10 H'00
H'FE83 Port 2 P2DR P27 P26 P25 P24 P23 P22 P21 P20 H'00
H'FE84 Port 3 P3DDR P35DDR P34DDR P33DDR P32DDR P31DDR P30DDR H'C0
H'FE85 Port 4 P4DDR P47DDR P46DDR P45DDR P44DDR P43DDR P42DDR P41DDR P40DDR H'00
H'FE86 Port 3 P3DR P35 P34 P33 P32 P31 P30 H'C0
H'FE87 Port 4 P4DR P47 P46 P45 P44 P43 P42 P41 P40 H'00
H'FE88 Port 5 P5DDR P57DDR P56DDR P55DDR P54DDR P53DDR P52DDR P51DDR P50DDR H'00
H'FE8A Port 5 P5DR P57 P56 P55 P54 P53 P52 P51 P50 H'00
H'FE8C Port 7 P7DDR P77DDR P76DDR P75DDR P74DDR P73DDR P72DDR P71DDR P70DDR H'00
H'FE8D H'FF
H'FE8E Port 7 P7DR P77 P76 P75 P74 P73 P72 P71 P70 H'00
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FE90 H'FF
H'FE91 Port A PADDR PA6DDR PA5DDR PA4DDR PA3DDR PA2DDR PA1DDR PA0DDR H'80
H'FE92 Port 9 P9DR P97 P96 P95 P94 P93 P92 P91 P90 Undeter-
mined
H'FE93 Port A PADR PA6 PA5 PA4 PA3 PA2 PA1 PA0 H'80
H'FE94 Port B PBDDR PB7DDR PB6DDR PB5DDR PB4DDR PB3DDR PB2DDR PB1DDR PB0DDR H'00
H'FE95 Port C PCDDR PC7DDR PC6DDR PC5DDR PC4DDR PC3DDR PC2DDR PC1DDR PC0DDR H'00
H'FE96 Port B PBDR PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 H'00
H'FE97 Port C PCDR PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0 H'00
H'FE98 Port B PBPCR PB7PON PB6PON PB5PON PB4PON PB3PON PB2PON PB1PON PB0PON H'00
H'FE99 Port C PCPCR PC7PON PC6PON PC5PON PC4PON PC3PON PC2PON PC1PON PC0PON H'00
H'FE9B H'FF
H'FE9C H'FF
H'FE9D H'FF
H'FE9E H'FF
H'FE9F H'FF
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEA0 A/D ADDR0H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA2 ADDR1H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA4 ADDR2H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA6 ADDR3H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEA8 ADDR4H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEAA ADDR5H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEAC ADDR6H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEAE ADDR7H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEB0 A/D ADDR8H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB2 ADDR9H AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB4 ADDRAH AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB6 ADDRBH AD9 AD8 AD7 AD6 AD5 AD4 AD3 AD2 H'00
H'FEB8 ADCSR ADF ADIE ADM1 ADM0 CH3 CH2 CH1 CH0 H'00
H'FEBA H'FF
H'FEBB H'FF
H'FEBC H'FF
H'FEBD H'FF
H'FEBE H'FF
H'FEBF H'FF
(continued on next page)
Legend
A/D: A/D converter
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEC0 SCI3 SMR C/$ CHR PE O/( STOP MP CKS1 CKS0 H'00
H'FEC4 SSR TDRE RDRF ORER FER PER TEND MPB MPBT H'84F
H'FEC6 H'FF
H'FEC7 Undeter-
mined
H'FEC8 SCI1 SMR C/$ CHR PE O/( STOP MP CKS1 CKS0 H'00
H'FECC SSR TDRE RDRF ORER FER PER TEND MPB MPBT H'84
H'FECE H'FF
H'FECF Undeter-
mined
(continued on next page)
Legend
SCI1: Serial communication interface 1
SCI3: Serial communication interface 3
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FED0 SCI2 SMR C/$ CHR PE O/( STOP MP CKS1 CKS0 H'00
H'FED4 SSR TDRE RDRF ORER FER PER TEND MPB MPBT H'84
H'FED6 H'FF
H'FED7 Undeter-
mined
H'FED8 H'FF
H'FED9 H'FF
H'FEDA Port A PACR TXD3E RXD3E SCK3E PW3E PW2E PW1E H'90
H'FEDD H'FF
H'FEDF BSC BCR BCRE 0P3T P9AE EXIOP PCRE PBCE P12E H'3F*
(continued on next page)
Legend
SCI2: Serial communication interface 2
INTC: Interrupt controller
BSC: Bus controller
A/D: A/D converter
Note: * Initial value in modes 5 and 6. In modes 1 to 4 and mode 7 the initial value is H'BF.
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEE0 Flash FLMCR FWE SWE ESU PSU EV PV E P H'00*
memory
H'FEE1 H'FF
H'FEE2 EBR1 EB7 EB6 EB5 EB4 EB3 EB2 EB1 EB0 H'00
H'FEE3 H'FF
H'FEE4 H'FF
H'FEE5 H'FF
H'FEE6 H'FF
H'FEE7 H'FF
H'FEE8 H'FF
H'FEE9 H'FF
H'FEEA H'FF
H'FEEB H'FF
H'FEEE H'FF
H'FEEF H'FF
(continued on next page)
Note: * When a high level is being applied to the FWE to the FWE pin, the initial value is H'80
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FEF0 PWM1 TCR OE OS CKS2 CKS1 CKS0 H'38
H'FEF3 H'FF
H'FEF7 H'FF
H'FEFB H'FF
H'FEFC H'FF
H'FEFD H'FF
H'FEFE H'FF
H'FEFF H'FF
(continued on next page)
Legend
PWM1: Pulse width modulation timer 1
PWM2: Pulse width modulation timer 2
PWM3: Pulse width modulation timer 3
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF00 INTC IPRA 0 0 H'00
H'FF07 Undeter-
mined
H'FF0E Undeter-
mined
H'FF0F Undeter-
mined
(continued on next page)
Legend
INTC: Interrupt controller
DTC: Data transfer controller
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
1
H'FF10 WDT (TCSR)* OVF WT/,7 TME CKS2 CKS1 CKS0 H'18
1
H'FF11 TCNT* H'00
H'FF12 H'FF
H'FF13 H'FF
H'FF18 H'FF
Notes: 1. These registers are write-protected by a password. See section 13.2.4 , "Notes on
Register Access" for details.
2. Initial value in modes 5 and 6. In modes 1 to 4 and mode 7 the initial value is H'EE.
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF20 IPU T1CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 1
H'FF21 T1CRL CCLR2 CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'80
H'FF24 T1OERA DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF25 TMDRA MD6-7 MD4-7 MD3-5 MD2-6 SYNC3 SYNC2 SYNC1 SYNC0 H'00
Bit Names
Address Module Register Initial
Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF30 IPU TSTR STR7 STR6 STR5 STR4 STR3 STR2 STR1 H'80
Channel 1
H'FF31 T1CRA IEG41 IEG40 IEG31 IEG30 H'F0
H'FF34 T1OERB DOE41 DOE40 DOE31 DOE30 GOE41 GOE40 GOE31 GOE30 H'00
H'FF36 H'FF
H'FF37 H'FF
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF40 IPU T2CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 2
H'FF41 T2CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF44 T2OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF45 H'FF
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF50 IPU T3CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 3
H'FF51 T3CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF54 T3OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF55 H'FF
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF60 IPU T4CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 4
H'FF61 T4CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF64 T4OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF65 H'FF
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF70 IPU T5CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 5
H'FF71 T5CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF74 T5OER DOE21 DOE20 DOE11 DOE10 GOE21 GOE20 GOE11 GOE10 H'00
H'FF75 H'FF
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF80 IPU T6CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 6
H'FF81 T6CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF85 H'FF
H'FF8C H'FF
H'FF8D H'FF
H'FF8E H'FF
H'FF8F H'FF
(continued on next page)
Legend
IPU: 16-bit integrated timer pulse unit
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FF90 IPU T7CRH CKEG1 CKEG0 TPSC3 TPSC2 TPSC1 TPSC0 H'C0
Channel 7
H'FF91 T7CRL CCLR1 CCLR0 IEG21 IEG20 IEG11 IEG10 H'C0
H'FF95 H'FF
H'FF9C H'FF
H'FF9D H'FF
H'FF9E H'FF
H'FF9F H'FF
(continued on next page)
Legend
IPU: 16-bit integrated timer pulse unit
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FFA0 MULT MLTCR CLR S_ON SIGN MUL MAC H'38
H'FFA4 H'FF
H'FFA5 H'FF
H'FFA6 H'FF
H'FFA7 H'FF
H'FFA8 H'FF
H'FFA9 H'FF
H'FFAA H'FF
H'FFAB H'FF
H'FFAC H'FF
H'FEED H'FF
H'FFAE H'FF
H'FFAF H'FF
(continued on next page)
Legend
MULT: Multiplier
Bit Names
Address Module Register Initial
(low) Name Name Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Value
H'FFB0 MULT CA H'00
H'FFB2 CB H'00
H'FFB4 CC H'00
H'FFB6 XH Undeter-
mined
H'FFB8 H Undeter-
mined
H'FFBA L Undeter-
mined
H'FFBC MR H'00
Table D-2 IPU and P3DDR Settings and Selected Functions of P31 /T1OC2
Table D-3 IPU and P3DDR Settings and Selected Functions of P32 /T1OC3
Table D-4 IPU and P3DDR Settings and Selected Functions of P33 /T1OC4
Table D-5 IPU and P3DDR Settings and Selected Functions of P34 /T2OC1
Table D-8 IPU and P4DDR Settings and Selected Functions of P41 /T4IOC2
Table D-9 IPU and P4DDR Settings and Selected Functions of P42 /T5IOC1
Table D-11 IPU and P4DDR Settings and Selected Functions of P44 /T6IOC1
Table D-12 IPU and P4DDR Settings and Selected Functions of P45 /T6IOC2
Table D-13 IPU and P4DDR Settings and Selected Functions of P46 /T7IOC1
Table D-16 IPU and P5DDR Settings and Selected Functions of P51 /T1IOC2
Table D-18 IPU and P5DDR Settings and Selected Functions of P53 /T1IOC4
Table D-19 IPU and P5DDR Settings and Selected Functions of P54 /T2IOC1
Table D-20 IPU and P5DDR Settings and Selected Functions of P55 /T2IOC2
Table D-22 IPU and P5DDR Settings and Selected Functions of P57 /T3IOC2
PW3E (P67CR) 0 1
OE (TCR: PWM3) * 0 1
IRQ2E (IRQCR) 0 1 0 1 0 1
P61DDR 0 1 0 1 0 1 0 1 0 1 0 1
Selected function P60 P60 IRQ2 input P60 P60 IRQ2 input PW3 output PW3 output
input output input output and IRQ2
P60 P60 P60 P60
port port port port input
input output input output
port port port port
,543
Table D-24 IRQCR and P6DDR Settings and Selected Functions of P6 1/,54
IRQ3E (IRQCR) 0 1
P61DDR 0 1 0 1
Selected function P61 input port P61 output port P61 input port P61 output port
IRQ3 input
Table D-25 IPU and P6DDR Settings and Selected Functions of P62 /TCLK1
Table D-26 IPU and P6DDR Settings and Selected Functions of P63 /TCLK2
IRQ0E (IRQCR) 0 1
P70DDR 0 1 0 1
Selected function P70 input port P70 output port P70 input port P70 output port
IRQ0 input
Table D-29 IRQCR and A/D Converter, and P7DDR Settings and Selected Functions of
,541/$'75*
P71/,54 $'75*
Table D-30 SCI1 and P7DDR Settings and Selected Functions of P72 /TXD1
TE (SCR: SCI1) 0 1
P72DDR 0 1 0 1
Selected function P72 input port P72 output port TXD1 output
RE (SCR: SCI1) 0 1
P73DDR 0 1 0 1
Selected function P73 input port P73 output port RXD1 input
Table D-32 SCI2 and P7DDR Settings and Selected Functions of P74 /TXD2
TE (SCR: SCI2) 0 1
P74DDR 0 1 0 1
Selected function P74 input port P74 output port TXD2 output
Table D-33 SCI2 and P7DDR Settings and Selected Functions of P75 /RXD2
RE (SCR: SCI2) 0 1
P75DDR 0 1 0 1
Selected function P75 input port P75 output port RXD2 input
Table D-34 P67CR, PWM1, SCI1, and P7DDR Settings and Selected Functions of
P76/SCK1/PW1
PW1E (P67CR) 0 1
OE (TCR: PWM1) * 0 1
C/A (SMR: SCI1) 0 1 * *
CKE1 (SMR: SCI1) 0 1 0 1 0 1 0 1
CKE0 (SMR: SCI1) 0 1 * * * * * * *
P76DDR 0 1 * * * * 0 1 0 1 * *
Selected function P76 P76 SCK1 SCK1 SCK1 SCK1 P76 P76 P76 P76 PW1 PW1
input output output input output input input output input output output output
port port port port port port and
and and SCK1
SCK1 SCK1 input
input input
PW2E (P67CR) 0 1
OE (TCR: PWM2) * 0 1
C/A (SMR: SCI2) 0 1 * *
CKE1 (SMR: SCI2) 0 1 0 1 0 1 0 1
CKE0 (SMR: SCI2) 0 1 * * * * * * *
P77DDR 0 1 * * * * 0 1 0 1 * *
Selected function P77 P77 SCK2 SCK2 SCK2 SCK2 P77 P77 P77 P77 PW2 PW2
input output output input output input input output input output output output
port port port port port port and
and and SCK2
SCK7 SCK7 input
input input
Table D-38 Operating Mode, PACR, IPU, PWM3, and PADDR Settings, and Selected
Functions of PA2/A18/T5OC1/PW3
Table D-39 (2) Operating Mode, PACR, IPU, SCI3, and PADDR Settings, and Selected
Functions of PA3/A19/T5OC2/SCK3
Table D-40 Operating Mode, WCR and PADDR Settings, and Selected Functions of
:$,7
PA4/:$,7
Table D-41 (2) Operating Mode, PACR, BRCR, IPU, SCI3, and PADDR Settings, and
%5(4/RXD
%5(4
Selected Functions of PA5/T3OC1/%5(4 3
Table D-42 (2) Operating Mode, PACR, BRCR, IPU, SCI3, and PADDR Settings, and
%$&./TXD
%$&.
Selected Functions of PA6/T3OC2/%$&. 3
Port 1
Modes 1 to 6
Write to P1DDR
Write to P1DR
Read P1DR
Read external
address
Write to external
address
Read/write
control Reset
CLR
Q D
P1nDDR
CK
Input multiplexer
Write to P2DR
Read P2DR
Read external
address
Write to external
address
Read/write
control Reset
CLR
Q D
P2nDDR
CK
Input multiplexer
Write to P3DR
Port 3 direction Read P3DR
control
Reset
CLR
Q D
P3nDDR
Output multiplexer
CLR
P3n Q D
P3nDR
CK
(n = 0−5)
Input multiplexer
IPU input
capture enable
Port 4 direction
control Write to P4DDR
Write to P4DR
Read P4DR
Reset
CLR
Q D
P4nDDR
Output multiplexer
CLR
P4n Q D
P4nDR
CK
(n = 0−7)
Input multiplexer
IPU compare match output (T4IOC1,T4IOC2 ,
T5IOC1, T5IOC2 , T6IOC1, T6IOC2 ,
T7IOC1, T7IOC2 )
IPU input capture (T4IOC1 ,T4IOC2 ,
T5IOC1, T5IOC2 , T6IOC1, T6IOC2 ,
T7IOC1, T7IOC2 )
IPU input
capture enable
Port 5 direction
control Write to P5DDR
Write to P5DR
Read P5DR
Reset
CLR
Q D
P5nDDR
Output multiplexer
CLR
P5n Q D
P5nDR
CK
(n = 0−7)
Input multiplexer
IPU compare match output
(T1IOC1 to T1IOC4 , T2IOC1 ,
T2IOC 2 , T3IOC1 , T3IOC2 )
IPU input capture
(T1IOC1 to T1IOC4 , T2IOC1 ,
T2IOC , T3IOC1 , T3IOC 2 )
Write P6DDR
Write P6DR
Port 6 direction Read P6DR
control
IRQ2 input
enable
CLR
Q D
P60DDR
Output multiplexer
CLR
P60 Q D
P60DR
CK
Input multiplexer
PW3 output
Edge detector
IRQ2 input
Write to P6DDR
Write to P6DR
Read P6DR
Reset
CLR
Q D
P6nDDR
CLR
P61 Q D
P6nDR
CK
Input multiplexer
Edge detector
IRQ3 input
Write to P6DDR
Write to P6DR
Read P6DR
Reset
CLR
Q D
P6nDDR
CLR
P6n Q D
P6nDR
CK
(n = 2−4)
Input multiplexer
Write to P7DDR
Write to P7DR
Read P7DR
Reset
CLR
Q D
P70DDR
CLR
P70 Q D
P70DR
CK
Input multiplexer
IRQ0 input
Write to P7DDR
Write to P7DR
Read P7DR
Reset
CLR
Q D
P71DDR
CLR
P71 Q D
P71DR
CK
Input multiplexer
IRQ1 input
ADTRG input
Edge detector
Reset
CLR
Q D
P7nDDR
Output multiplexer
CLR
P7n Q D
P7nDR
CK
(n = 2, 4)
Input multiplexer
SCI transmit data output
(TXD1, TXD2)
Reset
CLR
Q D
P7nDDR
CLR
P7n Q D
P7nDR
CK
(n = 3, 5)
Input multiplexer
Port 7 direction
control SCI serial clock
input enable
CLR
Q D
P7nDDR
Output
multiplexer
CLR
P7n Q D
P7nDR
CK
(n = 6, 7)
Input multiplexer
SCI serial clock output
(SCK1, SCK2)
(n = 0−3)
Port 9
A/D converter
input sampling
Read P9DR
P9n
(n = 0−7)
Mode 1, 2, 6, or 7
Mode 4
Port A direction
control Mode 3 or 5
Bus released
PADDR write
PADR write
PADR read
Reset
CLR
Q D
PAnDDR
Input multiplexer
Mode 1, 2, 6, or 7
Mode 4
Port A direction
controller Mode 3 or 5
Bus release
CLR
Q D
PAnDDR
Input multiplexer
Write to PADDR
Port A direction Write to PADR
control Read PADR
Reset
CLR
Q D
PA4DDR
CK
Input multiplexer
WAIT input
Modes 1 to 6
Bus release enable
CLR
Q D
PA5DDR
CK
Input multiplexer
BREQ input
Modes 1 to 6
Bus release enable
Port A direction
control
IPU output enable (T3OC2)
TXD3 enable
TXD3 output enable
Write to PADDR
Write to PADR
Read PADR
Reset
CLR
Q D
PA6DDR
CK
Input multiplexer
BACK output
Mode 1, 3, 5, or 6
Software standby
mode
Mode 2 or 4
Bus released
Mode 7
Write to PBPCR
Port B direction Write to PBDDR
control
Write to PBDR
Read PBDR
Reset
CLR
Q D
Input pull-up control PBnPCR
CK
CLR
Q D
PBnDDR
CK
Input multiplexer
Mode 1, 3, 5, or 6
Software standby
mode
Mode 2 or 4
Bus released
Mode 7
Write to PBCPCR
Port C direction Write to PCDDR
control
Write to PCDR
Read PCDR
Reset
CLR
Q D
Input pull-up control PCnPCR
CK
CLR
Q D
PCnDDR
CK
Input multiplexer
H'0000 H'0000
Vector table Vector table
H'00FF H'00FF
H'0100 H'0100
On-chip ROM
External (16 kbytes)
memory space
H'3FFF
H'4000 External
H'EE7F H'EE7F memory space
H'EE80 H'EE80
On-chip RAM On-chip RAM
H'FE7F (4 kbytes) H'FE7F (4 kbytes)
H'FE80 On-chip registers H'FE80 On-chip registers
(384 bytes) (384 bytes)
H'FFFF H'FFFF
Program
Execution
Hardware Software Bus Mode
Standby Standby Sleep Release (normal
Pin Name Mode Reset Mode Mode Mode Mode operation)
φ Clock T H Clock Clock Clock
output output output output
5', $6, 1−6 H T T H T 5', $6,
+:5, /:5 +:5, /:5
7 H T T H H
P17−P10 1−6 T T T T T D15−D8
7 keep keep keep I/O port
P27−P20 1, 3−5, 6 T T T T T D7−D0
2, 7 keep keep keep I/O port
P35−P30
1
1−7 T T keep* keep keep I/O port
P47−P40
P57−P50
P64−P60
P77−P70
P84−P80 1−7 T T T T T Input port
P97−P90
PA6−PA4
2 3 4
1−7 T T keep* keep* keep* I/O port or
control
input/output
PA3−PA0 3, 5 L T T L T A19−A16
1
1, 2, 4, 6, 7 T keep* keep keep I/O port
PB7–PB0 1, 3, 5, 6 L T T L T A15−A0
PC7–PC0
2, 4, 7 T keep keep keep I/O port
Legend
H: High, L: Low, T: High-impedance state
keep: Input pins are in the high-impedance state; output pins maintain their previous state.
Notes: 1. The on-chip supporting modules are reset, so these pins become input or output pins
according to their DDR and DR bits.
2. If PA5 is set for %$&. output, it goes to the high-impedance state.
3. %5(4 can be received, and %$&. is high.
Rev. 3.0, 02/99, page 897 of 904
4. %$&. is low.
5. In modes 5 and 6, the external bus space has a 16-bit bus width, but an 8-bit bus width
is set after a reset. In this case, the upper half of the data bus (D15 to D8) is enabled,
and the lower half (D7 to D0) is disabled. After the BCRE bit in the bus control register
(BCR) has been set to 1 by software, the bus width can be changed to 16 bits (D15 to
D0) by a byte area top register (ARBT) setting. In modes 1, 3, and 4, the external bus
space has a 16-bit bus width (D15 to D0) after a reset, but this can be changed to 8 bits
by an ARBT setting. In this case, the upper half of the data bus (D15 to D8) is enabled,
and the lower half (D7 to D0) is disabled. For details of the settings, see section 16, Bus
Controller.
RES
Internal reset
signal
A15−A0 H'0000
AS, RD
LWR, HWR
High impedance
D15−D0
High impedance
I/O ports
1.5φ
RES
Internal reset
signal
High impedance
A15−A0
AS, RD
HWR
High impedance
D15−D8
High impedance
I/O ports
RES
Internal reset
signal
A19−A0 H'0000
AS, RD
LWR, HWR
High impedance
D15−D0
High impedance
I/O ports
1.5φ
RES
Internal reset
signal
High impedance
A19−A0
AS, RD
LWR, HWR
High impedance
D15−D0
High impedance
I/O ports
RES
Internal reset
signal
High impedance
I/O ports
Unit: mm
23.2 ± 0.3
20
84 57
85 56
23.2 ± 0.3
0.65
112 29
1 28
*0.32 ± 0.08
3.05 Max
*0.17 ± 0.05
0.15 ± 0.04
1.23 1.6
0° – 8°
0.10 +0.15
–0.10
0.8 ± 0.3
0.10