The H8/532 is a high-performance single-chip Hitachi-original microcomputer, featuring a highspeed CPU with 16-bit internal data paths and a full complement of on-chip supporting modules.
The H8/532 is an ideal microcontroller for a wide variety of medium-scale devices, including both
office and industrial equipment and consumer products.
Its highly orthogonal instruction set is designed for fast execution of programs coded in the highlevel C language.
On-chip facilities include large RAM and ROM memories, numerous timers, serial I/O, an A/D
converter, I/O ports, and other functions for compact implementation of high-performance
application systems.
The H8/532 is available in both a ZTAT version* with on-chip PROM, ideal for the early stages
of production or for products with frequently-changing specifications, and a masked-ROM version
suitable for volume production.
This manual gives a hardware description of the H8/532. For details of the instruction set, refer to
the H8/500 Series Programming Manual, which applies to all chips in the H8/500 Series.
* ZTAT (Zero Turn-Around Time) is a registered trademark of Hitachi, Ltd.
4.7Trap Instructions and Zero Divide ·······················································································92
4.8Cases in Which Exception Handling is Deferred ·································································92
4.8.1 Instructions that Disable Interrupts ···········································································92
4.8.2 Disabling of Exceptions Immediately after a Reset ··················································93
4.8.3 Disabling of Interrupts after a Data Transfer Cycle ··················································93
4.9Stack Status after Completion of Exception Handling ························································94
4.9.1 PC Value Pushed on Stack for Trace,
Interrupts, Trap Instructions, and Zero Divide Exceptions ·······································96
4.9.2 PC Value Pushed on Stack for Address Error and Invalid
Instruction Exceptions ······························································································96
4.10 Notes on Use of the Stack ····································································································96
10.2.2 Output Compare Registers A and B (OCRA and OCRB) - H'FF94
and H'FF96, H'FFA4 and H'FFA6, H'FFB4 and H'FFB6 ·······································182
A.4.1 Calculation of Instruction Execution States ····························································358
A.4.2 Tables of Instruction Execution Cycles ··································································359
Appendix B Register Field
B.1Register Addresses and Bit Names ····················································································367
B.2Register Descriptions ·········································································································372
Appendix C I/O Port Schematic Diagrams
C.1Schematic Diagram of Port 1 ·····························································································407
C.2Schematic Diagram of Port 2 ·····························································································413
C.3Schematic Diagram of Port 3 ·····························································································414
C.4Schematic Diagram of Port 4 ·····························································································415
C.5Schematic Diagram of Port 5 ·····························································································416
C.6Schematic Diagram of Port 6 ·····························································································417
C.7Schematic Diagram of Port 7 ·····························································································418
C.8Schematic Diagram of Port 8 ·····························································································423
C.9Schematic Diagram of Port 9 ·····························································································424
Appendix D Memory Map ·································································································429
Appendix E Pin State
E.1Port State of Each Pin State ·······························································································431
E.2Pin Stattus in the Reset State ······························································································434
Appendix F
Timing of Entry to and Recovery from Hardware Standby Mode
········449
Appendix G Package Dimensions ····················································································451
Figures
1-1Block Diagram ···················································································································4
1-2Pin Arrangement (CP-84, Top View) ·················································································5
1-3Pin Arrangement (CG-84, Top View) ················································································6
1-4Pin Arrangement (FP-80A, Top View) ··············································································7
2-1Address Space in Each Mode ··························································································26
2-2Map of Page 0 ··················································································································28
3-1CPU Operating Modes ·····································································································32
3-2Registers in the CPU ········································································································33
3-3Stack Pointer ····················································································································34
3-4Combinations of Page Registers with Other Registers ····················································38
3-5Short Absolute Addressing Mode and Base Register ······················································39
3-6On-Chip Memory Access Timing ····················································································64
3-7Pin States during Access to On-Chip Memory ································································65
3-8Register Field Access Timing ··························································································66
3-9Pin States during Register Field Access ··········································································67
3-10 (a) External Access Cycle (Read Access) ·············································································68
3-10 (b) External Access Cycle (Write Access) ············································································69
3-11 Operating States ···············································································································70
3-12State Transitions ··············································································································71
3-13Bus-Right Release Cycle (During On-chip Memory Access Cycle) ·······························73
3-14Bus-Right Release Cycle (During External Access Cycle) ·············································74
3-15Bus-Right Release Cycle (During Internal CPU Operation) ···········································75
4-1Types of Factors Causing Exception Handling ································································83
4-2Reset Vector ·····················································································································86
4-3Reset Sequence (Minimum Mode, On-Chip Memory) ···················································87
4-4Reset Sequence (Maximum Mode, External Memory) ···················································88
4-5Interrupt Sources (and Number of Interrupt Types) ························································91
5-1Interrupt Controller Block Diagram ················································································98
5-2Interrupt Handling Flowchart ························································································106
5-3 (a) Stack before and after Interrupt Exception-Handling (Minimum Mode) ······················107
5-3 (b) Stack before and after Interrupt Exception-Handling (Maximum Mode) ·····················108
5-4Interrupt Sequence (Minimum Mode, On-Chip Memory) ············································109
5-5Interrupt Sequence (Maximum Mode, External Memory) ············································110
6-1Block Diagram of Data Transfer Controller ··································································114
6-2Flowchart of Data Transfer Cycle ··················································································119
6-3DTC Vector Table ··········································································································120
6-4DTC Vector Table Entry ································································································121
6-5Order of Register Information ·······················································································122
6-6Use of DTC to Receive Data via Serial Communication Interface ·······························126
7-1Block Diagram of Wait-State Controller ·······································································128
7-2Programmable Wait Mode ·····························································································131
7-3Pin Wait Mode ···············································································································132
7-4Pin Auto-Wait Mode ······································································································133
8-1Block Diagram of Clock Pulse Generator ·····································································135
8-2Connection of Crystal Oscillator (Example) ·································································136
8-3Crystal Oscillator Equivalent Circuit ·············································································136
8-4Notes on Board Design around External Crystal ···························································137
8-5External Clock Input (Example) ····················································································137
8-6Phase Relationship of ø Clock and E clock ···································································138
9-1Pin Functions of Port 1 ··································································································142
9-2Pin Functions of Port 2 ··································································································148
9-3Port 2 Pin Functions in Expanded Modes ······································································150
9-4Port 2 Pin Functions in Single-Chip Mode ····································································151
9-5Pin Functions of Port 3 ··································································································151
9-6Port 3 Pin Functions in Expanded Modes ······································································153
9-7Port 3 Pin Functions in Single-Chip Mode ····································································154
9-8Pin Functions of Port 4 ··································································································154
9-9Port 4 Pin Functions in Expanded Modes ······································································156
9-10Port 4 Pin Functions in Single-Chip Mode ····································································157
9-11Pin Functions of Port 5 ··································································································157
9-12Port 5 Pin Functions in Modes 1 and 3 ··········································································159
9-13Port 5 Pin Functions in Modes 2 and 4 ··········································································160
9-14Port 5 Pin Functions in Single-Chip Mode ····································································160
9-15Pin Functions of Port 6 ··································································································164
9-16Port 6 Pin Functions in Mode 3 ·····················································································166
9-17Port 6 Pin Functions in Mode 4 ·····················································································166
9-18Port 6 Pin Functions in Modes 7, 2, and 1 ·····································································167
9-19Pin Functions of Port 7 ··································································································168
9-20Pin Functions of Port 8 ··································································································172
9-21Pin Functions of Port 9 ··································································································173
10-1Block Diagram of 16-Bit Free-Running Timer ·····························································178
10-2 (a) Write Access to FRC (When CPU Writes H'AA55) ·····················································189
10-2 (b) Read Access to FRC (When FRC Contains H'AA55) ···················································190
10-3Increment Timing for External Clock Input ··································································191
10-4Setting of Output Compare Flags ··················································································192
10-5Timing of Output Compare A ························································································192
10-6Clearing of FRC by Compare-Match A ·········································································193
10-7Input Capture Timing (Usual Case) ···············································································193
10-8Input Capture Timing (1-State Delay) ···········································································194
10-9Setting of Input Capture Flag ························································································194
10-10Setting of Overflow Flag (OVF) ····················································································195
10-11Square-Wave Output (Example) ····················································································200
10-12FRC Write-Clear Contention ·························································································201
10-13FRC Write-Increment Contention ·················································································202
10-14Contention between OCR Write and Compare-Match ··················································203
11-1Block Diagram of 8-Bit Timer ·······················································································208
11-2Count Timing for External Clock Input ·········································································215
11-3Setting of Compare-Match Flags ···················································································216
11-4Timing of Timer Output ·································································································216
11-5Timing of Compare-Match Clear ··················································································217
11-6Timing of External Reset ·······························································································217
11-7Setting of Overflow Flag (OVF) ····················································································218
11-8Example of Pulse Output ·······························································································219
11-9TCNT Write-Clear Contention ······················································································220
11-10TCNT Write-Increment Contention ··············································································221
11-11Contention between TCOR Write and Compare-Match ···············································222
12-1Block Diagram of PWM Timer ·····················································································228
12-2PWM Timing ·················································································································233
13-1Block Diagram of Timer Counter ··················································································236
13-2Writing to TCNT and TCSR ··························································································239
13-3Operation in Watchdog Timer Mode ·············································································241
13-4Operation in Interval Timer Mode ·················································································242
13-5Setting of OVF Bit ·········································································································243
13-6TCNT Write-Increment Contention ··············································································244
14-1Block Diagram of Serial Communication Interface ······················································246
14-2Data Format in Asynchronous Mode ·············································································260
14-3Phase Relationship between Clock Output and Transmit Data ·····································261
14-4Data Format in Synchronous Mode ···············································································265
14-5Sampling Timing (Asynchronous Mode) ······································································271
15-1Block Diagram of A/D Converter ··················································································274
15-2Read Access to A/D Data Register (When Register Contains H'AA40) ·······················280
15-3A/D Operation in Single Mode (When Channel 1 is Selected) ·····································283
15-4A/D Operation in Scan Mode (When Channels 0 to 2 are Selected) ·····························286
15-5A/D Conversion Timing ·································································································288
16-1Block Diagram of On-Chip RAM ·················································································291
17-1Block Diagram of On-Chip ROM ·················································································296
17-2Socket Adapter Pin Arrangements ·················································································298
17-3Memory Map in PROM Mode ·······················································································299
17-4High-Speed Programming Flowchart ············································································300
17-5PROM Write/Verify Timing ··························································································302
17-6Recommended Screening Procedure ·············································································303
18-1NMI Timing of Software Standby Mode (Application Example) ·································311
18-2Hardware Standby Sequence ·························································································313
19-1Execution Cycle of Instruction Synchronized with E Clock in Expanded Modes
19-2Execution Cycle of Instruction Synchronized with E Clock in Expanded Modes
(Minimum Synchronization Delay) ···············································································317
20-1Example of Circuit for Driving a Darlington Transistor Pair ········································322
20-2Example of Circuit for Driving an LED ········································································322
20-3Output Load Circuit ·······································································································325
20-4Basic Bus Cycle (without Wait States) in Expanded Modes ·········································327
20-5Basic Bus Cycle (with 1 Wait State) in Expanded Modes ·············································328
20-6Bus Cycle Synchronized with E Clock ··········································································329
20-7Reset Input Timing········································································································ 330
20-8Interrupt Input Timing ···································································································330
20-9NMI Pulse Width (for Recovery from Software Standby Mode) ··································330
20-10Bus Release State Timing ······························································································331
20-11E Clock Timing ··············································································································331
20-12Clock Oscillator Stabilization Timing ···········································································332
20-13I/O Port Input/Output Timing ························································································333
20-14Free-Running Timer Input/Output Timing ····································································334
20-15External Clock Input Timing for Free-Running Timers ················································334
20-168-Bit Timer Output Timing ····························································································335
20-178-Bit Timer Clock Input Timing ····················································································335
20-188-Bit Timer Reset Input Timing ····················································································335
20-19PWM Timer Output Timing ··························································································336
20-20SCI Input Clock Timing ································································································336
20-21SCI Input/Output Timing (Synchronous Mode) ····························································336
C-1 (a) Schematic Diagram of Port 1, Pin P10 ··········································································407
C-1 (b) Schematic Diagram of Port 1, Pin P11 ··········································································407
C-1 (c) Schematic Diagram of Port 1, Pin P12 ···········································································408
C-1 (d) Schematic Diagram of Port 1, Pin P13 ··········································································409
C-1 (e) Schematic Diagram of Port 1, Pin P14 ···········································································410
C-1 (f) Schematic Diagram of Port 1, Pins P15 and P16 ···························································411
C-1 (g) Schematic Diagram of Port 1, Pin P17 ··········································································412
C-2Schematic Diagram of Port 2 ·························································································413
C-3Schematic Diagram of Port 3 ·························································································414
C-4Schematic Diagram of Port 4 ·························································································415
C-5Schematic Diagram of Port 5 ·························································································416
C-6Schematic Diagram of Port 6 ·························································································417
C-7 (a) Schematic Diagram of Port 7, Pin P70 ··········································································418
C-7 (b) Schematic Diagram of Port 7, Pins P71 and P72 ···························································419
C-7 (c) Schematic Diagram of Port 7, Pin P73 ··········································································420
C-7 (d) Schematic Diagram of Port 7, Pins P74, P75 and P76 ····················································421
C-7 (e) Schematic Diagram of Port 7, Pin P77 ··········································································422
C-8Schematic Diagram of Port 8 ·························································································423
C-9 (a) Schematic Diagram of Port 9, Pins P90 and P91 ···························································424
C-9 (b) Schematic Diagram of Port 9, Pins P92, P93 and P94 ····················································425
C-9 (c) Schematic Diagram of Port 9, Pin P95 ··········································································426
C-9 (d) Schematic Diagram of Port 9, Pin P96 ··········································································427
C-9 (e) Schematic Diagram of Port 9, Pin P97 ··········································································428
E-1Reset during Memory Access (Mode 1) ········································································435
E-2Reset during Memory Access (Mode 1) ········································································436
E-3Reset during Memory Access (Mode 2) ········································································438
E-4Reset during Memory Access (Mode 2) ········································································439
E-5Reset during Memory Access (Mode 3) ········································································441
E-6Reset during Memory Access (Mode 3) ········································································442
E-7Reset during Memory Access (Mode 4) ········································································444
E-8Reset during Memory Access (Mode 4) ········································································445
E-9Reset during Memory Access (Mode 7) ········································································446
E-10Reset during Memory Access (Mode 7) ········································································447
G-1Package Dimensions (CP-84) ························································································451
G-2Package Dimensions (CG-84) ·······················································································451
G-3Package Dimensions (FP-80A) ······················································································452
Tables
1-1Features ······························································································································2
1-2Pin Arrangements in Each Operating Mode (CP-84, CG-84) ···········································8
1-3Pin Arrangements in Each Operating Mode (FP-80A) ····················································12
1-4Pin Functions ···················································································································16
2-1Operating Modes ·············································································································23
2-2Mode Control Register ····································································································29
3-1Interrupt Mask Levels ······································································································36
3-2Interrupt Mask Bits after an Interrupt is Accepted ··························································36
3-3Initial Values of Registers ································································································41
3-4General Register Data Formats ························································································42
3-5Data Formats in Memory ·································································································43
3-6Data Formats on the Stack ·······························································································44
3-7Addressing Modes ···········································································································46
3-8Effective Address Calculation ·························································································47
3-9Instruction Classification ·································································································50
3-10Data Transfer Instructions ·······························································································52
3-11Arithmetic Instructions ····································································································53
3-12Logic Operation Instructions ···························································································54
3-13Shift Instructions ··············································································································55
3-14Bit-Manipulation Instructions ··························································································56
3-15Branching Instructions ·····································································································57
3-16System Control Instructions ····························································································59
3-17Short-Format Instructions and Equivalent General Formats ···········································62
4-1 (a) Exceptions and Their Priority ··························································································81
4-1 (b) Instruction Exceptions ······································································································81
4-2Exception Vector Table ····································································································84
4-3Stack after Exception Handling Sequence ·······································································94
5-1Interrupt Controller Registers ··························································································99
5-2Interrupts, Vectors, and Priorities ··················································································102
5-3Assignment of Interrupt Priority Registers ····································································103
5-4Number of States before Interrupt Service ····································································111
6-1Internal Control Registers of the DTC ···········································································114
6-2Data Transfer Enable Registers ·····················································································115
6-3Assignment of Data Transfer Enable Registers ·····························································117
6-4Addresses of DTC Vectors ·····························································································121
6-5Number of States per Data Transfer ··············································································123
6-6Number of States before Interrupt Service ····································································124
6-7DTC Control Register Information Set in RAM ···························································125
7-1Register Configuration ···································································································128
7-2Wait Modes ····················································································································130
8-1External Crystal Parameters ··························································································136
9-1Input/Output Port Summary ··························································································140
9-2Port 1 Registers ··············································································································142
9-3Port 1 Pin Functions in Expanded Modes ······································································145
9-4Port 1 Pin Functions in Single-Chip Modes ··································································147
9-5Port 2 Registers ··············································································································149
9-6Port 3 Registers ··············································································································152
9-7Port 4 Registers ··············································································································155
9-8Port 5 Registers ··············································································································158
9-9Status of MOS Pull-Ups for Port 5 ················································································161
9-10Port 6 Registers ··············································································································164
9-11Status of MOS Pull-Ups for Port 5 ················································································167
9-12Port 7 Registers ··············································································································168
9-13Port 7 Pin Functions ·······································································································170
9-14Port 8 Registers ··············································································································172
9-15Port 9 Registers ··············································································································173
9-16Port 9 Pin Functions ·······································································································175
10-1Input and Output Pins of Free-Running Timer Module ················································179
10-2Register Configuration ···································································································180
10-3Free-Running Timer Interrupts ······················································································195
10-4Synchronization by Writing to FRCs ············································································196
10-5Effect of Changing Internal Clock Sources ···································································204
11-1Input and Output Pins of 8-Bit Timer ············································································209
11-28-Bit Timer Registers ·····································································································209
11-38-Bit Timer Interrupts ····································································································218
11-4Priority Order of Timer Output ······················································································223
11-5Effect of Changing Internal Clock Sources ···································································223
12-1Output Pins of PWM Timer Module ·············································································228
12-2PWM Timer Registers ···································································································229
12-3PWM Timer Parameters for 10MHz System Clock ······················································232
13-1Register Configuration ···································································································236
13-2Read Addresses of TCNT and TCSR ············································································240
14-1SCI Input/Output Pins ····································································································247
14-2SCI Registers ·················································································································247
14-3Examples of BRR Settings in Asynchronous Mode (1) ················································255
14-3Examples of BRR Settings in Asynchronous Mode (2) ················································256
14-3Examples of BRR Settings in Asynchronous Mode (3) ················································256
14-3Examples of BRR Settings in Asynchronous Mode (4) ················································257
14-4Examples of BRR Settings in Synchronous Mode ························································258
14-5Communication Formats Used by SCI ··········································································259
14-6SCI Clock Source Selection ···························································································259
14-7Data Formats in Asynchronous Mode ···········································································261
14-8Receive Errors ················································································································264
14-9SCI Interrupts ·················································································································269
14-10SSR Bit States and Data Transfer When Multiple Receive Errors Occur ·····················270
15-1A/D Input Pins ···············································································································275
15-2A/D Registers ·················································································································275
15-3Assignment of Data Registers to Analog Input Channels ·············································276
15-4A/D Conversion Time (Single Mode) ············································································288
16-1RAM Control Register ···································································································292
17-1ROM Usage in Each MCU Mode ··················································································295
17-2Selection of PROM Mode ······························································································296
17-3Socket Adapter ···············································································································297
17-4Selection of Sub-Modes in PROM Mode ······································································299
17-5DC Characteristics
18-1Power-Down State ·········································································································307
18-2Software Standby Control Register ···············································································309
20-1Absolute Maximum Ratings ··························································································319
20-2DC Characteristics ·········································································································320
20-3Allowable Output Current Sink Values ·········································································321
20-4Bus Timing ····················································································································322
20-5Control Signal Timing ···································································································324
20-6Timing Conditions of On-Chip Supporting Modules ····················································325
20-7A/D Converter Characteristics ·······················································································326
A-1 (a) Machine Language Coding [General Format] ·······························································346
A-1 (b) Machine Language Coding [Special Format: Short Format] ·········································350
A-1 (c) Machine Language Coding [Special Format: Branch Instructions] ······························351
A-1 (d) Machine Language Coding [Special Format: System Control Instructions] ·················352
A-2Operation Codes in Byte 1 ·····························································································353
A-3Operation Codes in Byte 2 (Axxx) ················································································354
A-4Operation Codes in Byte 2 (05xx, 15xx, 0Dxx, 1Dxx, Bxxx, Cxxx, Dxxx,
Exxx, Fxxx) ···················································································································355
A-5Operation Codes in Byte 2 (04xx, 0Cxx) ······································································356
A-6Operation Codes in Bytes 2 and 3 (11xx, 01xx, 06xx, 07xx, xx00xx) ··························357
A-7Instruction Execution Cycles (1) ···················································································361
A-7Instruction Execution Cycles (2) ····················································································362
A-7Instruction Execution Cycles (3) ····················································································363
A-7Instruction Execution Cycles (4) ····················································································364
A-7Instruction Execution Cycles (5) ····················································································365
A-7Instruction Execution Cycles (6) ····················································································366
A-8 (a) Adjusted Value (Branch Instruction) ·············································································366
A-8 (b) Adjusted Value (Other Instructions by Addressing Modes) ··········································366
C-1 (a) Port 1 Port Read (Pin P10) ·····························································································407
C-1 (b) Port 1 Port Read (Pin P11) ·····························································································408
C-1 (c) Port 1 Port Read (Pin P12) ·····························································································408
C-1 (d) Port 1 Port Read (Pin P13) ·····························································································409
C-1 (e) Port 1 Port Read (Pin P14) ·····························································································410
C-1 (f) Port 1 Port Read (Pins P15, P16) ····················································································411
C-1 (g) Port 1 Port Read (Pin P17) ·····························································································412
C-2Port 2 Port Read ·············································································································413
C-3Port 3 Port Read ·············································································································414
C-4Port 4 Port Read ·············································································································415
C-5Port 5 Port Read ·············································································································416
C-6Port 6 Port Read ·············································································································417
C-7 (a) Port 7 Port Read (Pin P70) ·····························································································418
C-7 (b) Port 7 Port Read (Pins P71, P72) ····················································································419
C-7 (c) Port 7 Port Read (Pin P73) ·····························································································420
C-7 (d) Port 7 Port Read (Pins P74–P76) ····················································································421
C-7 (e) Port 7 Port Read (Pin P77) ·····························································································422
C-9 (a) Port 9 Port Read (Pins P90, P91) ····················································································424
C-9 (b) Port 9 Port Read (Pins P92–P94) ····················································································425
C-9 (c) Port 9 Port Read (Pin P95) ·····························································································426
C-9 (d) Port 9 Port Read (Pin P96) ·····························································································427
C-9 (e) Port 9 Port Read (Pin P97) ·····························································································428
E-1Port State ························································································································431
E-2Pull-up MOS State ·········································································································433
Section 1 Overview
1.1 Features
The H8/532 is an original Hitachi CMOS microcomputer unit (MCU) comprising a highperformance CPU core plus a full range of supporting functions—an entire system integrated onto
a single chip.
The 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 access
to on-chip 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 conversion, and I/O ports. An on-chip data transfer controller (DTC) can transfer data
in either direction between memory and I/O independently of the CPU.
For the on-chip ROM, a choice is offered between masked ROM and programmable ROM
(PROM). The PROM version can be programmed by the user with a general-purpose PROM
writer.
Table 1-1 lists the main features of the H8/532 chip.
1
Table 1-1 Features
FeatureDescription
CPUGeneral-register machine
• Eight 16-bit general registers
• Five 8-bit and two 16-bit control registers
High speed
• Maximum mode: up to 1M-byte address space
Highly orthogonal instruction set
• Addressing modes and data size can be specified independently for
each instruction
1.5 Addressing modes
• Register-register operations
• Register-memory operations
Instruction set optimized for C language
• Special short formats for frequently-used instructions and addressing modes
Memory• 1K-Byte high-speed RAM on-chip
• 32K-Byte programmable or masked ROM on-chip
16-Bit free-Each channel provides:
running • 1 free-running counter (which can count external events)
timer (FRT)• 2 output-compare registers
(3 channels)• 1 input capture register
8-Bit timer• One 8-bit up-counter (which can count external events)
(1 channel)• 2 time constant registers
PWM timer • Generates pulses with any duty ratio from 0 to 100%
(3 channels)• Resolution: 1/250
Watchdog • An overflow generates a nonmaskable interrupt
timer (WDT)• Can also be used as an interval timer
(1 channel)
2
Table 1-1 Features (cont)
FeatureDescription
Serial com-• Asynchronous or synchronous mode (selectable)
munication• Full duplex: can send and receive simultaneously
interface (SCI)• Built-in baud rate generator
A/D converter • 10-Bit resolution
• 8 channels, controllable in single mode or scan mode (selectable)
• Sample-and-hold function
I/O ports• 57 Input/output pins (six 8-bit ports, one 5-bit port, one 4-bit port)
• 8 Input-only pins (one 8-bit port)
• Memory-mapped I/O
Interrupt • 3 external interrupt pins (NMI, IRQ
controller• 19 internal interrupts
(INTC)• 8 priority levels
Data transfer Performs bidirectional data transfer between memory and I/O independently
controller (DTC) of the CPU
Wait-state Can insert wait states in access to external memory or I/O
controller (WSC)
Operating 5 MCU operating modes
modes• Expanded minimum modes, supporting up to 64k bytes external memory
with or without using on-chip ROM (Modes 1 and 2)
• Expanded maximum modes, supporting up to 1M byte external memory
with or without using on-chip ROM (Modes 3 and 4)
• Single-chip mode (Mode 7)
3 power-down modes
• Sleep mode
• Software standby mode
• Hardware standby mode
Other features• E clock output available
Figure 1-2 shows the pin arrangement of the CP-84 package. Figure 1-3 shows the pin
arrangement of the CG-84 package. Figure 1-4 shows the pin arrangement of the FP-80A package.
Notes: 1. For the PROM mode, see section 17, “ROM.”
2. Pins marked NC should be left unconnected.
15
Pin Functions: Table 1-4 gives a concise description of the function of each pin.
Table 1-4 Pin Functions
Pin No.
CP-84,
TypeSymbol CG-84 FP-80AI/O Name and Function
PowerV
ClockXTAL170ICrystal: Connected to a crystal oscillator.
System BACK574OBus Request Acknowledge: Indicates
controlthat the bus right has been granted to an external
CC16, 555, 42IPower: Connected to the power supply (+5V).
Connect both V
CC pins to the system power
supply (+5V). The chip will not operate if either pin
is left unconnected.
V
SS2, 2412, 29IGround: Connected to ground (0V).
41, 4271Connect all V
64, 83supply (0V). The chip will not operate if any V
SS pins to the system power
SS
pin is left unconnected.
The crystal frequency should be double the desired
ø clock frequency.
If an external clock is input at the EXTAL pin, leave
the XTAL pin unconnected.
EXTAL8469IExternal Crystal: Connected to a crystal
oscillator or external clock. The frequency of the
external clock should be double the desired ø clock
frequency. See section 8.2, “Oscillator Circuit” for
examples of connections to a crystal and external
clock.
ø 372OSystem Clock: Supplies the ø clock to peripheral
devices.
E473OEnable Clock: Supplies an E clock to E clock based
peripheral devices.
device. Notifies an external device that issued a
BREQ signal that it now has control of the bus.
16
Table 1-4 Pin Functions (cont)
Pin No.
CP-84,
TypeSymbol CG-84 FP-80AI/O Name and Function
System BREQ675IBus Request: Sent by an external device to the
controlH8/532 chip to request the bus right.
STBY209IStandby: A transition to the hardware standby
mode (a power-down state) occurs when a Low
input is received at the STBY pin.
RES2110IReset: A Low input causes the H8/532 chip to
reset.
Address A
bus40 – 33 28 – 21
Data bus D
BusWAIT776IWait: Requests the CPU to insert one or more Tw
controlstates when accessing an off-chip address.
The inputs at these pins are latched in mode select
bits 2 to 0 (MDS2 – MDS0) of the mode control
register (MDCR) on the rising edge of the RES
signal.
18
Table 1-4 Pin Functions (cont)
Pin No.
CP-84,
TypeSymbol CG-84 FP-80A I/OName and Function
16-Bit free- FTOA
runningFTOA
timer (FRT) FTOA
8-BitTMO1079O8-bit Timer Output: Compare-match output pin
timerfor the 8-bit timer.
PWMPW
timerPW
16350OFRT Output Compare A (channels 1, 2, and 3):
27561Output pins for the output compare A function
37662of the free-running timer channels 1, 2, and 3.
16047OFRT Output Compare B (channels 1, 2, and 3):
FTOB
FTOB
26148Output pins for the output compare B function
FTOB
36249of the free-running timer channels 1, 2, and 3.
FTCI
16047IFRT Counter Clock Input (channels 1, 2, and 3):
FTCI
26148External clock input pins for the free-running
FTCI
36249counters (FRCs) of free-running timer channels 1,
2, and 3.
15744IFRT Input Capture (channels 1, 2, and 3):
FTI
FTI
25845Input capture pins for free-running timer
FTI
35946channels 1, 2, and 3.
TMCI5643I8-bit Timer Clock Input: External
clock input pin for the 8-bit timer counter.
TMRI5946I8-bit Timer Counter Reset Input: A high input
Serial com- TXD8066OTransmit Data: Data output pins for the
municationserial communication interface.
interface
signalsRXD8167IReceive Data: Data input pins for the
serial communication interface.
SCK8268I/O Serial Clock: Input/output pin for the
serial interface clock.
A/DAN
converter
ParallelP1
I/Odirection of each bit is determined by the port 1
7 – AN0 73 – 6659 – 52 IAnalog Input: Analog signal input pins.
AV
CC*7460IAnalog Reference Voltage: Reference voltage
and power supply pin for the A/D converter.
AV
SS*6551IAnalog Ground: Ground pin for the A/D
converter.
7 – P10 10 – 379 – 72I/O Port 1: An 8-bit input/output port. The
data direction register (P1DDR).
P2
4 – P20 15 – 114 – 1,I/O Port 2: A 5-bit input/output port. The
80direction of each bit is determined by the port 2
data direction register (P2DDR).
P3
7 – P30 32 – 2520 – 13 I/O Port 3: An 8-bit input/output port. The
direction of each bit is determined by the port 3
data direction register (P3DDR).
P4
7 – P40 40 – 3328 – 21 I/O Port 4: An 8-bit input/output port. The
direction of each bit is determined by the port 4
data direction register (P4DDR). These pins
can drive LED indicators.
* When A/D converter is not used, AV
connected to GND.
CC should be connected to VCC, and AVSS should be
20
Table 1-4 Pin Functions (cont)
Pin No.
CP-84,
TypeSymbolCG-84FP-80A I/O Name and Function
ParallelP5
I/Oeach bit is determined by the port 5 data direction
7 – P50 50 – 43 37 – 30 I/O Port 5: An 8-bit input/output port. The direction of
register (P5DDR). These pins have built-in MOS
input pull-ups.
P6
3 – P60 54 – 51 41 – 38 I/O Port 6: A 4-bit input/output port. The direction of
each bit is determined by the port 6 data direction
register (P6DDR). These pins have built-in MOS
input pull-ups.
P7
7 – P70 63 – 56 50 – 43 I/O Port 7: An 8-bit input/output port. The direction of
each bit is determined by the port 7 data direction
register (P7DDR). These pins have Schmitt inputs.
P8
7 – P80 73 – 66 59 – 52 IPort 8: An 8-bit input port
P9
7 – P90 82 – 75 68 – 61 I/O Port 9: An 8-bit input/output port. The direction of
each bit is determined by the port 9 data direction
register (P9DDR).
21
Section 2 MCU Operating Modes and Address Space
2.1 Overview
The H8/532 microcomputer unit (MCU) operates in five modes numbered 1, 2, 3, 4, and 7. The
mode is selected by the inputs at the mode pins (MD2 to MD0) at the instant when the chip comes
out of a reset. As indicated in table 2-1, the MCU mode determines the size of the address space,
the usage of on-chip ROM, and the operating mode of the CPU. The MCU mode also affects the
functions of I/O pins.
Table 2-1 Operating Modes
MD2 MD1 MD0MCU ModeAddress SpaceOn-Chip ROM CPU Mode
Modes 1 to 4 are referred to as “expanded” because they permit access to off-chip memory and
peripheral addresses. The expanded minimum modes (modes 1 and 2) support a maximum
address space of 64K bytes. The expanded maximum modes (modes 3 and 4) support a maximum
address space of 1M byte.
Interrupt service is slightly slower in the expanded maximum modes than in the other modes
because the CPU has to save its code page register.
The H8/532 cannot be set to modes 0, 5, and 6. The mode pins should never be set to these
values.
23
2.2 Mode Descriptions
The five MCU modes are described below. For further information on the I/O pin functions in
each mode, see section 9, “I/O Ports.”
Mode 1 (Expanded Minimum Mode): Mode 1 supports a maximum 64K-byte address space
which does not include any on-chip ROM. Ports 1 to 5 are used for bus lines and bus control
signals as follows:
Control signals: Ports 1* and 2
Data bus:Port 3
Address bus:Ports 4 and 5
* The functions of individual pins of port 1 are software-selectable.
Mode 2 (Expanded Minimum Mode): Mode 2 supports a maximum 64K-byte address space of
which the first 32K bytes are in on-chip ROM. Ports 1 to 5 are used for bus lines and bus control
signals as follows:
Control signals: Ports 1* and 2
Data bus:Port 3
Address bus:Ports 4 and 5*
* The functions of individual pins in ports 1 and 5 are software-selectable.
Note: In mode 2, port 5 is initially a general-purpose input port. Software must change it to
output before using it for the address bus. See section 9.6, “Port 5” for details. The following
instruction makes all pins of port 5 into output pins:
MOV.B #H'FF, @H'FF88*
* H'xx or H'xxxx express the hexadecimal number.
Mode 3 (Expanded Maximum Mode): Mode 3 supports a maximum 1M-byte address space
which does not include any on-chip ROM. Ports 1 to 6 are used for bus lines and bus control
signals as follows:
Control signals: Ports 1* and 2
Data bus:Port 3
Address bus:Ports 4, 5, and 6
* The functions of individual pins of port 1 are software-selectable.
24
Mode 4 (Expanded Maximum Mode): Mode 4 supports a maximum 1M-byte address space of
which the first 32K bytes are in on-chip ROM. Ports 1 to 6 are used for bus lines and bus control
signals as follows:
Control signals: Ports 1* and 2
Data bus:Port 3
Address bus:Ports 4, 5*, and 6*
* The functions of individual pins in ports 1, 5, and 6 are software-selectable.
Note: In mode 4, ports 5 and 6 are initially general-purpose input ports. Software must change
them to output before using them for the address bus. See section 9.6, “Port 5” and 10.7, “Port 6”
for details. The following instruction sets all pins of ports 5 and 6 to output:
MOV.W #H'FFFF, @H'FF88
Mode 7 (Single-Chip Mode): In this mode all memory is on-chip, in 32K bytes of ROM and 1K
byte of RAM. It is not possible to access off-chip addresses.
The single-chip mode provides the maximum number of ports. All the pins associated with the
address and data buses in the expanded modes are available as general-purpose input/output ports
in the single-chip mode.
2.3 Address Space Map
2.3.1 Page Segmentation
The H8/532’s address space is segmented into 64K-byte pages. In the single-chip mode and
expanded minimum modes there is just one page: page 0. In the expanded maximum modes there
can be up to 16 pages. Figure 2-1 shows the address space in each mode and indicates which parts
are on- and off-chip.
25
On-chipOn- or off-chip (selectable)Off-chip
AddressMode 1Mode 2Mode 3Mode 4Mode 7
H'00000
Page 0
H'0FFFF
H'10000
Page 1
H'1FFFF
H'F0000
Page 15
H'FFFFF
Expanded minimum modesExpanded maximum modesSingle-chip mode
Figure 2-1 Address Space in Each Mode
26
2.3.2 Page 0 Address Allocations
The high and low address areas in page 0 are reserved for registers and vector tables.
Vector Tables: The low address area contains the exception vector table and DTC vector table.
The CPU accesses the exception vector table to obtain the addresses of user-coded exceptionhandling routines. The DTC vector table contains pointers to tables of register information used
by the on-chip chip data transfer controller. The size of these tables depends on the CPU
operating mode. Details are given in section 4.1.3, “Exception Factors and Vector Table,” section
5.2.3, “Interrupt Vector Table,” and section 6.3.2, “DTC Vector Table.”
In modes 2 and 4 the vector tables are located in on-chip ROM. In modes 1, 3, and 7 the vector
tables are in external memory.
Register Field: The highest 128 addresses in page 0 (addresses H'FF80 to H'FFFF) belong to
control, status, and data registers used by the I/O ports and on-chip supporting modules. Program
code cannot be located at these addresses.
The CPU accesses addresses in this register field like other addresses in the address space. By
reading and writing at these addresses the CPU controls the on-chip supporting modules and
communicates via the I/O ports. A complete map of the register field is given in appendix B.
On-Chip RAM: One of the control registers in the register field is a RAM control register
(RAMCR) containing a RAM enable bit (RAME) that enables or disables the 1-kbyte on-chip
RAM. When this bit is set to “1” (its default value), addresses H'FFB0 to H'FF7F are located onchip. When this bit is cleared to “0,” these addresses are located in external memory and the onchip RAM is not used. See section 16, “RAM” for further information.
The RAME bit is bit 7 at address H'FFF9.
Coding Example:
To enable on-chip RAM: BSET.B #7, @H'FFF9
To disable on-chip RAM: BCLR.B #7, @H'FFF9
Note: If on-chip RAM is disabled in the single-chip mode, access to addresses H'FFB0 to H'FF7F
causes an address error.
27
Figure 2-2 is a map of page 0 of the address space.
On-chip RAM (when enabled)
H'0000
Exception vector table
DTC vector table
H'7FFF
H'8000
H'FB80
H'FF80
H'FFFF
On-chip register field
On-chip ROM
(modes 2, 4, and 7)
or external memory
(modes 1 and 3)
Figure 2-2 Map of Page 0
28
2.4 Mode Control Register (MDCR)
Another control register in the register field in page 0 is the mode control register (MDCR). The
inputs at the mode pins are latched in this register on the rising edge of the signal. The mode
control register can be read by the CPU, but not written. Table 3-2 lists the attributes of this
register.
Table 2-2 Mode Control Register
NameAbbreviationRead/WriteAddress
Mode control registerMDCRRead onlyH'FFFA
The bit configuration of this register is shown below.
Bit76543210
—————MDS2MDS1MDS0
Initial value11000***
Read/Write—————R R R
* Initialized according to MD2 to MD0.
Bits 7 and 6—Reserved: These bits cannot be modified and are always read as “1.”
Bits 5 to 3—Reserved: These bits cannot be modified and are always read as “0.”
Bits 2 to 0—Mode Select 2 to 0 (MDS2 to MDS0): These bits indicate the values of the mode
pins (MD2 to MD0) latched on the rising edge of the signal. MDS2 corresponds to MD2, MDS1
to MD1, and MDS0 to MD0. These bits can be read but not written.
Coding Example: To test whether the MCU is operating in mode 1:
CMP:G.B #H'C1, @H'FFFA
The comparison is with H'C1 instead of H'01 because bits 7 and 6 are always read as “1.”
29
Section 3 CPU
3.1 Overview
The H8/532 chip has the H8/500 Family CPU: a high-speed central processing unit designed for
realtime control of a wide range of medium-scale office and industrial equipment. Its Hitachioriginal architecture features eight 16-bit general registers, internal 16-bit data paths, and an
optimized instruction set.
Section 3 summarizes the CPU architecture and instruction set.
3.1.1 Features
The main features of the H8/500 CPU are listed below.
• General-register machine
— Eight 16-bit general registers
— Seven control registers (two 16-bit registers, five 8-bit registers)
• High speed: maximum 10MHz
At 10MHz a register-register add operation takes only 200ns.
• Address space managed in 64k-byte pages, expandable to 1M byte*
Page registers make four pages available simultaneously: a code page, stack page, data page,
and extended page.
• Two CPU operating modes:
— Minimum mode: Maximum 64k-byte address space
— Maximum mode: Maximum 1M-byte address space*
• Highly orthogonal instruction set
Addressing modes and data sizes can be specified independently within each instruction.
• 1.5 Addressing modes
Register-register and register-memory operations are supported.
• Optimized for efficient programming in C language
In addition to the general registers and orthogonal instruction set, the CPU has special short
formats for frequently-used instructions and addressing modes.
* The CPU architecture supports up to 16M bytes of external memory, but the H8/532 chip has
only enough address pins to address 1M byte.
31
3.1.2 Address Space
The address space size depends on the operating mode.
The H8/532 MCU has five operating modes, which are selected by the input to the mode pins
(MD2 to MD0) when the chip comes out of a reset. The CPU, however, has only two operating
modes. The MCU operating mode determines the CPU operating mode, which in turn determines
the maximum address space size as indicated in figure 3-1.
CPU operating mode
Minimum mode
Maximum mode
Maximum address space: 64 k
bytes Hightest address: H'FFFF
Maximum address space: 1 M byte
Hightest address: H'FFFFF
Figure 3-1 CPU Operating Modes
32
3.1.3 Register Configuration
TI2 I1 I0NZVC
Figure 3-2 shows the register structure of the CPU. There are two groups of registers: the general
registers (Rn) and control registers (CR).
All eight of the 16-bit 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.
R6 and R7, in addition to functioning as general registers, have special assignments.
R7 is the stack pointer, used implicitly in exception handling and subroutine calls. It can be
designated by the name SP, which is synonymous with R7. As indicated in figure 3-3, it points to
the top of the stack. It is also used implicitly by the LDM and STM instructions, which load and
store multiple registers from and to the stack and pre-decrement or post-increment R7 accordingly.
R6 functions as a frame pointer (FP). The LINK and UNLK use R6 implicitly to reserve or
release a stack frame.
Figure 3-3 Stack Pointer
34
3.2.2 Control Registers
The CPU control registers (CR) include a 16-bit program counter (PC), a 16-bit status register
(SR), four 8-bit page registers, and one 8-bit base register (BR).
Program Counter (PC): This 16-bit register indicates the address of the next instruction the
CPU will execute.
Status Register (SR): This 16-bit register contains internal status information. The lower half of
the status register is referred to as the condition code register (CCR): it can be accessed as a
separate condition code byte.
CCR
Bit 1514131211109876543210
T————I2I1I0————N Z V C
Bit 15—Trace (T): When this bit is set to “1,” the CPU operates in trace mode and generates a
trace exception after every instruction. See section 4.4, “Trace” for a description of the trace
exception-handling sequence.
When the value of this bit is “0,” instructions are executed in normal continuous sequence. This
bit is cleared to “0” at a reset.
Bits 14 to 11—Reserved: These bits cannot be modified and are always read as “0.”
Bits 10 to 8—Interrupt Mask (I2, I1, I0): These bits indicate the interrupt request mask level
(0 to 7). As shown in table 3-1, an interrupt request is not accepted unless it has a higher level
than the value of the mask. A nonmaskable interrupt (NMI), which has level 8, is accepted at any
mask level. After an interrupt is accepted, I2, I1, and I0 are changed to the level of the interrupt.
Table 3-2 indicates the values of the I bits after an interrupt is accepted.
A reset sets all three of bits (I2, I1, and I0) to “1,” masking all interrupts except NMI.
35
Table 3-1 Interrupt Mask Levels
MaskMask Bits
PriorityLevelI2I1I0Interrupts Accepted
High7111NMI
6110Level 7 and NMI
5101Levels 6 to 7 and NMI
4100Levels 5 to 7 and NMI
3011Levels 4 to 7 and NMI
2010Levels 3 to 7 and NMI
1001Levels 2 to 7 and NMI
Low0000Levels 1 to 7 and NMI
Table 3-2 Interrupt Mask Bits after an Interrupt is Accepted
Level of Interrupt AcceptedI2I1I0
NMI (8)111
7111
6110
5101
4100
3011
2010
1001
36
Bits 7 to 4—Reserved: These bits cannot be modified and are always read as “0.”
Bit 3—Negative (N): This bit indicates the most significant bit (sign bit) of the result of an
instruction.
Bit 2—Zero (Z): This bit is set to “1” to indicate a zero result and cleared to “0” to indicate a
nonzero result.
Bit 1—Overflow (V): This bit is set to “1” when an arithmetic overflow occurs, and cleared to
“0” at other times.
Bit 0—Carry (C): This bit is set to “1” when a carry or borrow occurs at the most significant bit,
and is cleared to “0” (or left unchanged) 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.
Page Registers: The code page register (CP), data page register (DP), extended page register
(EP), and stack page register (TP) are 8-bit registers that are used only in the maximum mode. No
use of their contents is made in the minimum mode.
In the maximum mode, the page registers combine with the program counter and general registers
to generate 24-bit effective addresses as shown in figure 3-4, thereby expanding the program area,
data area, and stack area.
37
Page register
PC or general register
8 Bits16 Bits
CP
DP
EP
TP
PC
R0
R1
R2
R3
@ aa : 16
R4
R5
R6
R7
24 Bits (effective address)
Figure 3-4 Combinations of Page Registers with Other Registers
Code Page Register (CP): The code page register and the program counter combine to generate
a 24-bit program code address. In the maximum mode, the code page register is initialized at a
reset to a value loaded from the vector table, and both the code page register and program counter
38
are saved and restored in exception handling.
Data Page Register (DP): The data page register combines with general registers R0 to R3 to
generate a 24-bit effective address. The data page register contains the upper 8 bits of the address.
It is used to calculate effective addresses in the register indirect addressing mode using R0 to R3,
and in the 16-bit absolute addressing mode (@aa:16).
The data page register is rewritten by the LDC instruction.
Extended Page Register (EP): The extended page register combines with general register R4 or
R5 to generate a 24-bit operand address. The extended page register contains the upper 8 bits of
the address. It is used to calculate effective addresses in the register indirect addressing mode
using R4 or R5.
The extended page can be used as an additional data page.
Stack Page Register (TP): The stack page register combines with R6 (FP) or R7 (SP) to
generate a 24-bit stack address. The stack page register contains the upper 8 bits of the address. It
is used to calculate effective addresses in the register indirect addressing mode using R6 or R7, in
exception handling, and subroutine calls.
Base Register (BR): This 8-bit register stores the base address used in the short absolute
addressing mode (@aa:8). In this addressing mode a 16-bit effective address in page 0 is
generated by using the contents of the base register as the upper 8 bits and an address given in the
instruction code as the lower 8 bits. See figure 3-5.
In the short absolute addressing mode the address is always located in page 0.
8 Bits8 Bits
BR@ aa : 8
16 Bits (effective address)
Figure 3-5 Short Absolute Addressing Mode and Base Register
39
3.2.3 Initial Register Values
When the CPU is reset, its internal registers are initialized as shown in table 3-3. Note that the
stack pointer (R7) and base register (BR) are not initialized to fixed values. Also, of the page
registers used in maximum mode, only the code page register (CP) is initialized; the other three
page registers come out of the reset state with undetermined values.
Accordingly, in the minimum mode the first instruction executed after a reset should initialize the
stack pointer. The base register must also be initialized before the short absolute addressing mode
(@aa:8) is used.
In the maximum mode, the first instruction executed after a reset should initialize the stack page
register (TP) and the next instruction should initialize the stack pointer. Later instructions should
initialize the base register and the other page registers as necessary.
40
Table 3-3 Initial Values of Registers
Initial Value
RegisterMinimum ModeMaximum Mode
General registers
150UndeterminedUndetermined
R7 – R0
Control registers
150Loaded from vector tableLoaded from vector table
The H8/500 can process 1-bit data, 4-bit BCD data, 8-bit (byte) data, 16-bit (word) data, and 32bit (longword) data.
• Bit manipulation instructions operate on 1-bit data.
• Decimal arithmetic instructions operate on 4-bit BCD data.
• Almost all instructions operate on byte and word data.
• Multiply and divide instructions operate on longword data.
3.3.1 Data Formats in General Registers
Data of all the sizes above can be stored in general registers as shown in table 3-4.
41
Bit data locations are specified by bit number. Bit 15 is the most significant bit. Bit 0 is the least
significant bit. BCD and byte data are stored in the lower 8 bits of a general register. Word data
use all 16 bits of a general register. Longword data use two general registers: 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 affect the upper 8 bits of the register.
Table 3-4 General Register Data Formats
Data TypeRegister No.Data Structure
1-Bit
Rn
150
1514131211109876543210
BCD
1587430
Rn
Don’t-careUpper digitLower digit
Byte
158 70
Rn
Don’t-careMSBLSB
Word
150
Rn
Longword
Rn*
MSBLSB
3116
MSBUpper 16 bits
Rn+1*
150
* For longword data n must be even (0, 2, 4, or 6).
3.3.2 Data Formats in Memory
Lower 16 bitsLSB
Table 3-5 indicates the data formats in memory.
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 8 bits of word data are stored in
address n (where n is an even number); the lower 8 bits are stored in address n+1.
42
Table 3-5 Data Formats in Memory
7
6543 2107
15141312111098
6543210
MSBLSB
MSB
LSB
Upper 8 bits
Lower 8 bits
Address n
Even address
Odd address
Address n
Even address
Odd address
70
Data TypeData Format
1-Bit (in byte
operand data)
1-Bit (in word
operand data)
Byte
Word
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 postincrement 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. An
address error will therefore occur if the stack pointer indicates an odd address. Programs should
be coded so that the stack pointer always indicates an even address.
There are two basic CPU instruction formats: the general format and the special format.
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.
• Effective address field:One byte containing information used to calculate the effective
address of an operand.
• Effective address extension:Zero to two bytes containing a displacement value, immediate
data, or an absolute address. The size of the effective address
extension is specified in the effective address field.
• Operation code: Defines the operation to be carried out on the operand located at
the address calculated from the effective address information.
Some instructions (DADD, DSUB, MOVFPE, MOVTPE) have
an extended format in which the operand code is preceded by a
one-byte prefix code.
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 other instructions that can be executed faster if the operation is specified
before the operand.
• Operation code: One or two bytes defining the operation to be performed by the instruction.
• Effective address field and effective address extension: Zero to three bytes containing
information used to calculate an effective address.
3.4.2 Addressing Modes
The CPU supports 7 addressing modes: (1) register direct; (2) register indirect; (3) register
indirect with displacement; (4) register indirect with pre-decrement or post-increment; (5)
immediate; (6) absolute; and (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 field. The effectiveaddress extension, if present, contains a displacement, immediate data, or an absolute address.
Table 3-7 indicates how the addressing mode is specified in the effective address field.
45
Table 3-7 Addressing Modes
No.Addressing ModeMnemonicEA FieldEA Extension
1Register directRn1 0 1 0 Sz r r rNone
*1 *2
2Register indirect@Rn1 1 0 1 Sz r r rNone
3Register indirect@(d:8,Rn)1 1 1 0 Sz r r r Displacement (1 byte)
with displacement
@(d:16,Rn)1 1 1 1 Sz r r r Displacement (2 bytes)
4Register indirect @–Rn1 0 1 1 Sz r r r
with pre-decrementNone
Register indirect @Rn+1 1 0 0 Sz r r r
with post-increment
#xx:16—Operand is 2-byte EA
00001100extension data.
7PC-relative8 Bits
disp:815023150
1
No EA codePCCP
Specified in OP code
150
⊕
Displacement with
sign extension
*
Result
disp:1616 Bits23150
No EA code150CP
Specified in OP codePC
150
Displacement
Notes: * 1 The page register is ignored in minimum mode.
* 2 The page register used in addressing modes 2, 3, and 4 depends on the general register :
DP for R0, R1, R2, or R3; EP for R4 or R5; TP for R6 or R7.
* 3 Decrement by –1 for a byte operand, and by –2 for a word operand.
* 4 The pre-decrement or post-increment is always ±2 when R7 is specified, even if the
operand is byte size.
* 5 The drawing below shows what happens when the @-SP and @ SP+ addressing
modes are used to save and restore the stack pointer.
48
⊕
1
*
Result
SP
Old SP-2 (upper byte)
Old SP-2 (lower byte)
MOV.W SP, @–SPMOV.W @SP+.SP
SPSP
49
3.5 Instruction Set
3.5.1 Overview
The main features of the CPU instruction set are:
• A general-register architecture.
• Orthogonality. Addressing modes and data sizes can be specified independently in each instruction.
• 1.5 addressing modes (supporting register-register and register-memory operations)
• Affinity for high-level languages, particularly C, with short formats for frequently-used
instructions and addressing modes.
• Standard mnemonics, common throughout the H Series.
The CPU instruction set includes 63 types of instructions, listed by function in table 3-9.
Table 3-9 Instruction Classification
FunctionInstructionsTypes
Data transferMOV, LDM, STM, XCH, SWAP, MOVTPE, MOVFPE7
System controlTRAPA, TRAP/VS, RTE, SLEEP, LDC, STC, ANDC,12
ORC, XORC, NOP, LINK, UNLK
Total63
* Bcc is a conditional branch instruction in which cc represents a condition code.
Tables 3-10 to 3-16 give a concise summary of the instructions in each functional category. The
MOV, ADD, and CMP instructions have special short formats, which are listed in table 3-17. For
detailed descriptions of the instructions, refer to the H8/500 Series Programming Manual.
The notation used in tables 3-10 to 3-17 is defined below.
50
Operation Notation
RdGeneral register (destination)
RsGeneral register (source)
RnGeneral register
(EAd)Destination operand
(EAs)Source operand
CCRCondition code register
NN (negative) bit of CCR
ZZ (zero) bit of CCR
VV (overflow) bit of CCR
CC (carry) bit of CCR
CRControl register
PCProgram counter
CPCode page register
SPStack pointer
FPFrame pointer
#IMMImmediate data
dispDisplacement
+Addition
–Subtraction
×Multiplication
÷Division
∧AND logical
∨OR logical
⊕Exclusive OR logical
→Move
↔Exchange
¬Not
51
3.5.2 Data Transfer Instructions
Table 3-10 describes the seven data transfer instructions.
Table 3-10 Data Transfer Instructions
InstructionSize*Function
DataMOV(EAs) → (EAd), #IMM → (EAd)
transferMOV:GB/WMoves data between two general registers, or between
MOV:EBa general register and memory, or moves immediate data
MOV:IWto a general register or memory.
MOV:FB/W
MOV:LB/W
MOV:SB/W
LDMWStack → Rn (register list)
Pops data from the stack to one or more registers.
STMWRn (register list) → stack
Pushes data from one or more registers onto the stack.
XCHWRs ↔ Rd
Exchanges data between two general registers.
SWAPBRd (upper byte) ↔ Rd (lower byte)
Exchanges the upper and lower bytes in a general register.
MOVTPEBRn → (EAd)
Transfers data from a general register to memory in
synchronization with the E clock.
MOVFPEB(EAs) → Rd
Transfers data from memory to a general register in
synchronization with the E clock.
Note: B—byte; W—word
52
3.5.3 Arithmetic Instructions
Table 3-11 describes the 17 arithmetic instructions.
Table 3-11 Arithmetic Instructions
InstructionSizeFunction
ArithmeticADDRd ± (EAs) → Rd, (EAd) ± #IMM → (EAd)
operationsADD:GB/WPerforms addition or subtraction on data in a general
ADD:QB/Wregister and data in another general register or memory, or
SUBB/Won immediate data and data in a general register or memory.
ADDSB/W
SUBSB/W
ADDXB/WRd ± (EAs) ± C → Rd
SUBXB/WPerforms addition or subtraction with carry or borrow on
data in a general register and data in another general
register or memory, or on immediate data and data in a
general register or memory.
DADDB(Rd)
DSUBBPerforms decimal addition or subtraction on data in two
MULXUB/WRd × (EAs) → Rd
DIVXUB/WRd ÷ (EAs) → Rd
CMPRn – (EAs), (EAd) – #IMM
CMP:GB/WCompares data in a general register with data in another
CMP:EBgeneral register or memory, or with immediate data, or
CMP:IWcompares immediate data with data in memory.
Note: B—byte; W—word
10 ± (Rs)10 ±C → (Rd)10
general registers.
Performs 8-bit × 8-bit or 16-bit × 16-bit unsigned
multiplication on data in a general register and data in
another general register or memory, or on data in a
general register and immediate data.
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.
53
Table 3-11 Arithmetic Instructions (cont)
InstructionSizeFunction
ArithmeticEXTSB(<bit 7> of <Rd>) → (<bits 15 to 8> of <Rd>)
operationsConverts byte data in a general register to word data by
extending the sign bit.
EXTUB0 → (<bits 15 to 8> of <Rd>)
Converts byte data in a general register to word data by
padding with zero bits.
TSTB/W(EAd) – 0
Compares general register or memory contents with 0.
NEGB/W0 – (EAd) → (EAd)
Obtains the two’s complement of general register or
memory contents.
CLRB/W0 → (EAd)
Clears general register or memory contents to 0.
TASB(EAd) — 0, (1)
Tests general register or memory contents, then sets the
most significant bit (bit 7) to “1.”
Note: B—byte; W—word
2 → (<bit 7> of <EAd>)
3.5.4 Logic Operations
Table 3-12 lists the four instructions that perform logic operations.
Table 3-12 Logic Operation Instructions
InstructionSizeFunction
LogicalANDB/WRd∧(EAs) → Rd
operationsPerforms a logical AND operation on a general register
and another general register, memory, or immediate data.
ORB/WRd∨(EAs) → Rd
Performs a logical OR operation on a general register and
another general register, memory, or immediate data.
XORB/WRd⊕(EAs) → Rd
Performs a logical exclusive OR operation on a general register
and another general register, memory, or immediate data.
NOTB/W¬ (EAd) → (EAd)
Obtains the one’s complement of general register or memory
contents.
Note: B—byte; W—word
54
3.5.5 Shift Operations
Table 3-13 lists the eight shift instructions.
Table 3-13 Shift Instructions
InstructionSizeFunction
ShiftSHALB/W(EAd) shift → (EAd)
operationsSHARB/WPerforms an arithmetic shift operation on general register
or memory contents.
SHLLB/W(EAd) shift → (EAd)
SHLRB/WPerforms a logical shift operation on general register or
memory contents.
ROTLB/W(EAd) shift → (EAd)
ROTRB/WRotates general register or memory contents.
ROTXLB/W(EAd) rotate through carry → (EAd)
ROTXRB/WRotates general register or memory contents through the
C (carry) bit.
Note: B—byte; W—word
55
3.5.6 Bit Manipulations
Table 3-14 describes the four bit-manipulation instructions.
Table 3-14 Bit-Manipulation Instructions
InstructionSizeFunction
BitBSETB/W¬ (<bit-No.> of <EAd>) → Z,
manipu-1 → (<bit-No.> of <EAd>)
lationsTests a specified bit in a general register or memory, then
sets the bit to “1.” The bit is specified by a bit number
given in immediate data or a general register.
BCLRB/W¬ (<bit-No.> of <EAd>) → Z,
0 → (<bit-No.> of <EAd>)
Tests a specified bit in a general register or memory, then
clears the bit to “0.” The bit is specified by a bit number
given in immediate data or a general register.
BNOTB/W¬ (<bit-No.> of <EAd>) → Z,
→ (<bit-No.> of <EAd>)
Tests a specified bit in a general register or memory, then
inverts the bit. The bit is specified by a bit number given
in immediate data or a general register.
BTSTB/W¬ (<bit-No.> of <EAd>) → Z
Tests a specified bit in a general register or memory. The
bit is specified by a bit number given in immediate data or
a general register.
Note: B—byte; W—word
56
3.5.7 Branching Instructions
Table 3-15 describes the 11 branching instructions.
Table 3-15 Branching Instructions
InstructionSizeFunction
BranchBcc—Branches if condition cc is true.
MnemonicDescriptionCondition
BRA (BT)Always (true)True
BRN (BF)Never (false)False
BHIHighC ∨ Z = 0
BLSLow or SameC ∨ Z = 1
BCC (BHS)Carry Clear C = 0
JMP—Branches unconditionally to a specified address in the same page.
PJMP—Branches unconditionally to a specified address in a specified page.
BSR—Branches to a subroutine at a specified address in the same page.
JSR—Branches to a subroutine at a specified address in the same page.
PJSR—Branches to a subroutine at a specified address in a specified page.
RTS—Returns from a subroutine in the same page.
57
Table 3-15 Branching Instructions (cont)
InstructionSizeFunction
BranchPRTS—Returns from a subroutine in a different page.
RTD—Returns from a subroutine in the same page and adjusts
the stack pointer.
PRTD—Returns from a subroutine in a different page and adjusts
the stack pointer.
SCB/F—Controls a loop using a loop counter and/or a specified
SCB/NE—termination condition.
SCB/EQ—
58
3.5.8 System Control Instructions
Table 3-16 describes the 12 system control instructions.
Table 3-16 System Control Instructions
InstructionSizeFunction
SystemTRAPA—Generates a trap exception with a specified vector number.
controlTRAP/VS—Generates a trap exception if the V bit is set to “1” when
the instruction is executed.
RTE—Returns from an exception-handling routine.
LINK—FP → @–SP; SP → FP; SP + #IMM → SP
Creates a stack frame.
UNLK—FP → SP; @SP+ → FP
Deallocates a stack frame created by the LINK instruction.
SLEEP—Causes a transition to the power-down state.
LDCB/W*(EAs) → CR
Moves immediate data or general register or memory
contents to a specified control register.
STCB/W*CR → (EAd)
Moves control register data to a specified general register
or memory location.
ANDCB/W*CR ∧ #IMM → CR
Logically ANDs a control register with immediate data.
ORCB/W*CR ∨ #IMM → CR
Logically ORs a control register with immediate data.
XORCB/W*CR ⊕ #IMM → CR
Logically exclusive-ORs a control register with immediate
data.
NOP—PC + 1 → PC
No operation. Only increments the program counter.
* The size depends on the control register.
When using the LDC and STC instructions to stack and unstack the BR, CCR, TP, DP, and EP
control registers in the H8/500 family, note the following point.
H8/500 hardware does not permit byte access to the stack. If the LDC.B or STC.B assembler
mnemonic is coded with the @R7 + (@SP+) or @–R7 (@–SP) addressing mode, the stackpointer addressing mode takes precedence and hardware automatically performs word access.
59
Specifically, the LDC.B and STC.B instructions are executed as follows.
EP
a
DP
b
Old SP – 2
Before execution
Old SP – 1
Old SP
New SP
After execution
New SP + 1
New SP + 2
a
b
EP
a
DP
b
Old SP
After execution
Old SP + 1
Old SP + 2
New SP – 2
Before execution
New SP – 1
New SP
a
b
EP
a
DP
b
CCR
a
Old SP – 2
Before execution
Old SP – 1
Old SP
New SP
After execution
New SP + 1
New SP + 2
a
b
The following applies only to the stack-pointer addressing modes. In addressing modes that do not
use the stack pointer, byte data access is performed as specified by the assembler mnemonic.
(1)STC.B EP, @–SP
When word data access is applied to EP, both EP and DP are accessed. This instruction
stores EP at address SP (old) –2, and DP at address SP (old) –1.
(2)LDC.B @SP+, EP
When word data access is applied to EP, both EP and DP are accessed. This instruction
loads EP from address SP (old), and DP from address SP (old) +1, updating the DP value as
well as the EP value.
(3)STC.B CCR, @–SP
When word data access is applied to CCR, only CCR is accessed. This instruction stores
identical CCR contents at both address SP (old) –2 and address SP (old) –1.
60
(4)LDC.B @SP+, CCR
CCR
Old SP
After execution
Old SP + 1
Old SP + 2
New SP – 2
Before execution
New SP – 1
New SP
a
b
CCR
b
When word data access is applied to CCR, only CCR is accessed. This instruction loads
CCR from address SP (old) +1. Note that the value in address SP (old) is not loaded.
BR, DP, and TP are accessed in the same way as CCR. When DP is specified, both EP and
DP are accessed, but when CCR, BR, DP, or TP is specified, only the specified register is
accessed.
61
3.5.9 Short-Format Instructions
The ADD, CMP, and MOV instructions have special short formats. Table 3-17 lists these short
formats together with the equivalent general formats.
The short formats are a byte shorter than the corresponding general formats, and most of them
execute one state faster.
Table 3-17 Short-Format Instructions and Equivalent General Formats
Notes: * 1 The ADD:Q instruction accepts other destination operands in addition to a general
* 2 Number of execution states for access to on-chip memory.
*
register, but the immediate data value (#xx) is limited to ±1 or ±2.
22 ADD:G #xx:8,Rd33
*
Format InstructionLengthStates
2
*
3.6 Operating Modes
The CPU operates in one of two modes: the minimum mode or the maximum mode.
These modes are selected by the mode pins (MD2 to MD0 ).
3.6.1 Minimum Mode
The minimum mode supports a maximum address space of 64k bytes. The page registers are
ignored. Instructions that branch across page boundaries (PJMP, PJSR, PRTS, PRTD) are invalid.
62
3.6.2 Maximum Mode
In the maximum mode the page registers are valid, expanding the maximum address space to 1M
byte.
The address space is divided into 64k-byte pages. The pages are separate; it is not possible to
move continuously across a page boundary.
It is possible to move from one page to another with branching instructions (PJMP, PJSR, PRTS,
PRTD). The TRAPA instruction and branches to interrupt-handling routines can also jump across
page boundaries. It is not necessary for a program to be contained in a single 64k-byte page.
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 2, “MCU Operating Modes and
Address Space.”
3.7 Basic Operational Timing
3.7.1 Overview
The CPU operates on a system clock (ø) which is created by dividing an oscillator frequency
(fosc) by two. One period of the system clock is referred to as a “state.” The CPU accesses
memory in a cycle consisting of 2 or 3 states. The CPU uses different methods to access on-chip
memory, the on-chip register field, and external devices.
Access to On-Chip Memory (RAM, ROM): For maximum speed, access to on-chip memory
(RAM, ROM) is performed in two states, using a 16-bit-wide data bus.
Figure 3-6 shows the on-chip memory access cycle. Figure 3-7 indicates the pin states. The bus
control signals output from the H8/532 chip go to the nonactive state during the access.
Access to On-Chip Register Field (Addresses H'FF80 to H'FFFF): The access cycle consists
of three states. The data bus is 8 bits wide.
Figure 3-8 shows the on-chip supporting module access cycle. Figure 3-9 indicates the pin states.
63
Access to External Devices: The access cycle consists of three states. The data bus is 8 bits
T state
Memory cycle
1T state2
ø
Internal address bus
Internal Read signal
Internal data bus
(Read access)
Internal Write signal
Read data
Address
Write data
Internal data bus
(Write access)
wide. Figure 3-10 (a) and (b) shows the external access cycle. Additional wait states (Tw) can be
inserted by the wait-state controller (WSC).
3.7.2 On-Chip Memory Access Cycle
Figure 3-6 On-Chip Memory Access Timing
64
3.7.3 Pin States during On-Chip Memory Access
T state1T state2
ø
A to A
R/W (write access)
190
AS, DS, RD, WR
D to D 70
R/W (read access)
“High”
High-impedance
Figure 3-7 Pin States during Access to On-Chip Memory
65
3.7.4 Register Field Access Cycle (Addresses H'FF80 to H'FFFF)
T state
Memory cycle
1T state2T state3
Address
Read data
ø
Internal address bus
Internal Read signal
Internal Write signal
Internal data bus
(write access)
Internal data bus
(read access)
Write data
Figure 3-8 Register Field Access Timing
66
3.7.5 Pin States during Register Field Access (Addresses H'FF80 to H'FFFF)
T state1T state2T state3
“High”
ø
A to A
R/W (read access)
190
AS, DS, RD, WR
D to D 70
R/W (write access)
High-impedance
Figure 3-9 Pin States during Register Field Access
The CPU has five states: the program execution state, exception-handling state, bus-released state,
reset state, and power-down state. The power-down state is further divided into the sleep mode,
software standby mode, and hardware standby mode. Figure 3-11 summarizes these states, and
figure 3-12 shows a map of the state transitions.
69
StateProgram execution state
The CPU executes program instructions in sequence.
Exception-handling state
A transient state in which the CPU executes a hardware
sequence (saving the program counter and status register,
fetching a vector from the vector table, etc.) triggered by a reset,
interrupt, or other exception.
Bus-released state
The state in which the CPU has released the external bus in
response to a bus request signal from an external device, and
is waiting for the bus to be returned.
Reset state
The state in which the CPU and all on-chip supporting
modules have been initialized and are stopped.
Power-down state
A state in which some
or all of the clock
signals are stopped to
conserve power.
Sleep mode
Software standby mode
Hardware standby mode
Figure 3-11 Operating States
70
BREQ = “0”
BREQ = “0”
BREQ = “1”
Bus-released state
End of
exception
handling
Request
for exception
handling
SLEEP
instruction
with standby
flag set
SLEEP
instruction
Interrupt request
NMI
Program execution state
Exception-handling
state
Sleep mode
Software standby mode
Hardware standby mode
Reset state
*
STBY = “1”, RES = “0”
RES = “1”
*From any state except the hardware standby mode, a transition to the reset state occurs
whenever RES goes Low.
*A transition to the hardware standby mode from any state occurs when STBY goes Low.
BREQ = “1”
1*2
1
2
3.8.2 Program Execution State
In this state the CPU executes program instructions in normal sequence.
Figure 3-12 State Transitions
3.8.3 Exception-Handling State
The exception-handling state is a transient state that occurs when the CPU alters the normal
program flow due to an interrupt, trap instruction, address error, or other exception. In this state
the CPU carries out a hardware-controlled sequence that prepares it to execute a user-coded
exception-handling routine.
71
In the hardware exception-handling sequence the CPU does the following:
1. Saves the program counter and status register (in minimum mode) or program counter, code
page register, and status register (in maximum mode) to the stack.
2. Clears the T bit in the status register to “0.”
3. Fetches the start address of the exception-handling routine from the exception vector table.
4. Branches to that address, returning to the program execution state.
See section 4, “Exception Handling,” for further information on the exception-handling state.
3.8.4 Bus-Released State
When so requested, the CPU can grant control of the external bus to an external device. While an
external device has the bus right, the CPU is said to be in the bus-released state. The bus right is
controlled by two pins:
• BREQ:Input pin for the Bus Request signal from an external device
• BACK:Output pin for the Bus Request Acknowledge signal from the CPU, indicating that the
CPU has released the bus
The procedure by which the CPU enters and leaves the bus-released state is:
1. The CPU receives a Low BREQ signal from an external device.
2. The CPU places the address bus pins (A19 – A0), data bus pins (D7 – D0) and bus control pins
(RD, WR, R/W, DS, and AS) in the high-impedance state, sets the BACK pin to the Low level
to indicate that it has released the bus, then halts.
3. The external device that requested the bus (with the BREQ signal) becomes the bus master. It
can use the data bus and address bus. The external device is responsible for manipulating the
bus control signals (RD, WR, R/W, DS, and AS).
4. When the external device finishes using the bus, it clears the BREQ signal to the High level.
The CPU then reassumes control of the bus and returns to the program execution state.
Bus Release Timing: The CPU can release the bus right at the following times:
1. The BREQ signal is sampled during every memory access cycle (instruction prefetch or data
read/write). If BREQ is Low, the CPU releases the bus right at the end of the cycle. (In
word data access to external memory or an address from H'FF80 to H'FFFF, the CPU does
not release the bus right until it has accessed both the upper and lower data bytes.)
2. During execution of the MULXU and DIVXU instructions, since considerable time may
pass without an instruction prefetch or data read/write, BREQ is also sampled at internal
machine cycles, and the bus right is released if BREQ is Low.
3. The bus right can also be released in the sleep mode.
The CPU does not recognize interrupts while the bus is released.
72
Timing Charts: Timing charts of the operation by which the bus is released are shown in
RD, WR, R/W
DS, AS
D –D70
A –A190
ø
BREQ
BACK
On-chip memory
Access cycle
Bus-right release cycleCPU cycle
T
2T1T2TXTXTXTXT1***
(1)(2)(3)(4)(5)
Fig. 3-13
figure 3-13 for the case of bus release during an on-chip memory read cycle, in figure 3-14 for
bus release during an external memory read cycle, and in figure 3-15 for bus release while the
CPU is performing an internal operation.
(1) The BREQ pin is sampled at the start of the T1 state and the Low level is detected.
(2) At the end of the memory access cycle, the BACK pin goes Low and the CPU releases the bus.
(3) While the bus is released, the BREQ pin is sampled at each Tx state.
(4) A High level is detected at the BREQ pin.
(5) The BACK pin is returned to the High level, ending the bus-right release cycle.
(1) The BREQ pin is sampled at the start of the TW state and the Low level is detected.
(2) At the end of the external access cycle, the BA CK pin goes Lo w and the CPU releases the bus.
(3) The BREQ pin is sampled at the T
X state and a High level is detected.
(4) The BACK pin is returned to the High level, ending the bus-right release cycle.
(1) The BREQ pin is sampled at the start of a TI state and the Low level is detected.
(2) At the end of the internal operation cycle, the BACK pin goes Lo w and the CPU releases the b us.
(3) The BREQ pin is sampled at the T
X state and a High level is detected.
(4) The BACK pin is returned to the High level, ending the bus-right release cycle.
* T
I : Internal CPU operation state.
T
X : Bus-right released state.
Figure 3-15 Bus-Right Release Cycle (During Internal CPU Operation)
75
Notes: The BREQ signal must be held Low until BACK goes Low. If BREQ returns to the High
level before BACK goes Low, the bus release operation may be executed incorrectly.
To leave the bus-released state, the High level at the BREQ pin must be sampled two times. If the
BREQ returns to Low before it is sampled two times, the bus released cycle will not end.
The bus release operation is enabled only when the BRLE bit in the port 1 control register (P1CR)
is set to “1.” When this bit is cleared to “0” (its initial value), the BREQ and BACK pins are used
for general-purpose input and output, as P13 and P12.
An instruction that sets the BRLE bit is: BSET.B #3, @H'FFFC
Note the following point when using the H8/532’s release function.
If the BREQ signal is asserted and an interrupt is requested simultaneously during execution of the
SLEEP instruction, the BACK signal may fail to be output even though the CPU has released the
bus. This may cause the system to stop for the interval during which BREQ is asserted, with no
device in control of the bus. The interrupts that can cause this state include NMI, IRQ, and all the
interrupts from on-chip supporting modules. When the BREQ signal is deasserted, ending this
state, the CPU takes control of the bus again and resumes normal instruction execution.
The following methods can be used to avoid entering this state.
Method 1: If the BREQ signal is used, do not use the SLEEP instruction.
Method 2: Disable the BREQ signal during execution of the SLEEP instruction. This can be
done by clearing the bus release enable bit (BRLE) in the port 1 control register (P1CR) to 0
immediately bifore executing the SLEEP instruction. (When the BRLE bit is cleared, low inputs
on the BREQ line are not latched on-chip.) Place instructions to set the BRLE bit to 1 at the
beginning of interrupt-handling routines. If the data transfer controller (DTC) is used, place an
instruction to set the BRLE bit immediately after the SLEEP instruction.
If method 2 is used, BREQ inputs will be ignored while the chip is in sleep mode.
In the reset state, the CPU and all on-chip supporting modules are initialized and placed in the
stopped state. The CPU enters the reset state whenever the RES pin goes Low, unless the CPU is
currently in the hardware standby mode. It remains in the reset state until the RES pin goes High.
See section 4.2, “Reset,” for further information on the reset state.
3.8.6 Power-Down State
The power-down state comprises three modes: the sleep mode, the software standby mode, and
the hardware standby mode.
See section 18, “Power-Down State,” for further information.
The following restriction applies when instructions are located in on-chip RAM.
• Restriction
Instruction execution cannot proceed continuously from an external address to on-chip RAM in
the ZTAT versions. This restriction does not apply to versions with masked ROM.
• Solution
To execute instructions located in on-chip RAM, use a branch instruction (examples: Bcc, JMP,
etc.) to branch to the first instruction located in on-chip RAM. Do not place instruction code in
the last three bytes of external memory (H'FB7D to H'FB7F).
78
3.9.2 Note on MULXU Instruction
Note that in the case described below, the H8/532 multiply instruction does not give correct
results.
(1)Problem
The result of a squaring operation such as MULXU.B Rn, Rn is indeterminate. This problem
occurs when the same register is specified for the source and destination of a byte
multiplication operation.
This problem occurs only in ZTAT versions of the H8/532. It does not occur in versions
with masked ROM.
(2)Solution
The problem can be avoided by the following methods.
➀ Place the source and destination operands in different registers.
Example: MULXU.B R4, R4→MOV.W R4, R5
MULXU.B R5, R4
➁ Use a word multiplication instruction.
Example: MULXU.B R4, R4→MULXU.W R4, R4
MOV.W R5, R4
➂ Place one of the operands in memory.
Example: MULXU.B R4, R4→MOV.W R4, @–SP
MULXU.B @(1,SP), R4
ADDS #2, SP
This problem occurs only in the H8/532. It does not occur in other chips in the H8/500
Series (such as the H8/520).
(3)Note on usage of C compiler
Programmers using the C compiler should bear the following programming note in mind.
• Conditions under which the compiler generates a MULXU.B Rn, Rn instruction
The C compiler generates a MULXU.B Rn, Rn instruction when the following two conditions
are satisfied in the source program:
79
➀ A one-byte variable (char or unsigned char) is declared as a register variable.
➁ The variable declared as in ➀ is squared by compound substitution
Example: register char a;
a *= a;
• Solution
The problem can be avoided as follows:
➀ In the example above, do not declare the variable (a) as a register variable.
Example: register char a;→char a;
a *= a;a *= a;
➁ When squaring one-byte data, do not use compound substitution. Code as follows:
Example: a *= a;→ a = a *a;
80
Section 4 Exception Handling
4.1 Overview
4.1.1 Types of Exception Handling and Their Priority
As indicated in table 4-1 (a) and (b), exception handling can be initiated by a reset, address error,
trace, interrupt, or instruction. An instruction initiates exception handling if the instruction is an
invalid instruction, a trap instruction, or a DIVXU instruction with zero divisor. Exception
handling begins with a hardware exception-handling sequence which prepares for the execution of
a user-coded software exception-handling routine.
There is a priority order among the different types of exceptions, as shown in table 4-1 (a). If two
or more exceptions occur simultaneously, they are handled in their order of priority. An
instruction exception cannot occur simultaneously with other types of exceptions.
Table 4-1 (a) Exceptions and Their Priority
Exception Start of ExceptionTypeSourceDetection TimingHandling Sequence
Exception TypeStart of Exception-Handling Sequence
Invalid instructionAttempted execution of instruction with undefined code
Trap instructionStarted by execution of trap instruction
Zero divideAttempted execution of DIVXU instruction with zero divisor
81
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.