Hitachi Single-Chip Microcomputer
H8/338 Series
H8/338
HD6473388, HD6433388, HD6413388
H8/337
HD6473378, HD6433378, HD6413378
H8/336
HD6433368
Hardware Manual
Preface
The H8/338 Series is a series of high-performance single-chip microcomputers having a fast
H8/300 CPU core and a set of on-chip supporting functions optimized for embedded control.
These include ROM, RAM, three types of timers, a serial communication interface, an A/D
converter, a D/A converter, I/O ports, and other functions needed in control system configurations,
so that compact, high-performance systems can be realized easily. The H8/338 Series includes
three chips: the H8/338 with 48K-byte ROM and 2K-byte RAM; the H8/337 with 32K-byte ROM
and 1K-byte RAM; and the H8/336 with 24K-byte ROM and 1K-byte RAM.
The H8/338 and H8/337 are available in a masked ROM version, a ZTAT™*(Zero Turn-Around
Time) version, and a ROMless version, providing a quick and flexible response to conditions from
ramp-up through full-scale volume producion, even for applications with frequently-changing
specifications.
This manual describes the hardware of the H8/338 Series. Refer to the
H8/300 Series
Programming Manual
for a detailed description of the instruction set.
Note: ZTAT is a registered trademark of Hitachi, Ltd.
Contents
Section 1. Overview
............................................................................................................... 1
1.1
1.2
1.3
Overview...............................................................................................................................
Block Diagram......................................................................................................................
Pin Assignments and Functions............................................................................................
1.3.1 Pin Arrangement......................................................................................................
1.3.2 Pin Functions ...........................................................................................................
1
5
6
6
9
Section 2. MCU Operating Modes and Address Space
................................................ 17
2.1
Overview...............................................................................................................................
2.1.1 Mode Selection ........................................................................................................
2.1.2 Mode and System Control Registers (MDCR and SYSCR) ...................................
System Control Register (SYSCR)—H'FFC4 ......................................................................
Mode Control Register (MDCR)—H'FFC5 .........................................................................
Address Space Map ..............................................................................................................
17
17
18
18
20
21
2.2
2.3
2.4
Section 3. CPU
........................................................................................................................ 25
3.1
3.2
Overview...............................................................................................................................
3.1.1 Features....................................................................................................................
Register Configuration..........................................................................................................
3.2.1 General Registers.....................................................................................................
3.2.2 Control Registers .....................................................................................................
3.2.3 Initial Register Values..............................................................................................
Addressing Modes ................................................................................................................
3.3.1 Addressing Modes ...................................................................................................
3.3.2 How to Calculate Where the Excution Starts ..........................................................
Data Formats.........................................................................................................................
3.4.1 Data Formats in General Registers..........................................................................
3.4.2 Memory Data Formats.............................................................................................
Instruction Set .......................................................................................................................
3.5.1 Data Transfer Instructions .......................................................................................
3.5.2 Arithmetic Operations .............................................................................................
3.5.3 Logic Operations .....................................................................................................
3.5.4 Shift Operations.......................................................................................................
3.5.5 Bit Manipulations ....................................................................................................
3.5.6 Branching Instructions.............................................................................................
3.5.7 System Control Instructions ....................................................................................
3.5.8 Block Data Transfer Instruction ..............................................................................
i
3.3
3.4
3.5
25
25
26
26
27
28
29
29
30
34
35
36
37
39
41
42
42
44
48
50
51
3.6
3.7
CPU States ............................................................................................................................
3.6.1 Program Execution State .........................................................................................
3.6.2 Exception-Handling State........................................................................................
3.6.3 Power-Down State ...................................................................................................
Access Timing and Bus Cycle ..............................................................................................
3.7.1 Access to On-Chip Memory (RAM and ROM) ......................................................
3.7.2 Access to On-Chip Register Field and External Devices ........................................
52
53
53
54
54
54
56
Section 4. Exception Handling
............................................................................................ 59
4.1
4.2
Overview...............................................................................................................................
Reset .....................................................................................................................................
4.2.1 Overview .................................................................................................................
4.2.2 Reset Sequence ........................................................................................................
4.2.3 Disabling of Interrupts after Reset...........................................................................
Interrupts...............................................................................................................................
4.3.1 Overview .................................................................................................................
4.3.2 Interrupt-Related Registers......................................................................................
4.3.3 External Interrupts ...................................................................................................
4.3.4 Internal Interrupts ....................................................................................................
4.3.5 Interrupt Handling ...................................................................................................
4.3.6 Interrupt Response Time..........................................................................................
4.3.7 Precaution ................................................................................................................
Note on Stack Handling........................................................................................................
59
59
59
59
62
62
62
64
66
66
67
72
72
73
4.3
4.4
Section 5. I/O Ports
................................................................................................................ 75
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
5.10
Overview............................................................................................................................... 75
Port 1..................................................................................................................................... 78
Port 2..................................................................................................................................... 81
Port 3..................................................................................................................................... 85
Port 4..................................................................................................................................... 89
Port 5..................................................................................................................................... 93
Port 6..................................................................................................................................... 98
Port 7..................................................................................................................................... 104
Port 8..................................................................................................................................... 106
Port 9..................................................................................................................................... 113
Section 6. 16-Bit Free-Running Timer
.............................................................................. 121
6.1
Overview............................................................................................................................... 121
6.1.1 Features.................................................................................................................... 121
ii
6.2
6.3
6.4
6.5
6.6
6.7
6.1.2 Block Diagram......................................................................................................... 122
6.1.3 Input and Output Pins .............................................................................................. 123
6.1.4 Register Configuration ............................................................................................ 123
Register Descriptions............................................................................................................ 124
6.2.1 Free-Running Counter (FRC)—H'FF92.................................................................. 124
6.2.2 Output Compare Registers A and B (OCRA and OCRB)—H'FF94....................... 125
6.2.3 Input Capture Registers A to D (ICRA to ICRD)—
H'FF98, H'FF9A, H'FF9C, H'FF9E ......................................................................... 125
6.2.4 Timer Interrupt Enable Register (TIER)—H'FF90 ................................................. 128
6.2.5 Timer Control/Status Register (TCSR)—H'FF91 ................................................... 130
6.2.6 Timer Control Register (TCR)—H'FF96 ................................................................ 133
6.2.7 Timer Output Compare Control Register (TOCR)—H'FF97.................................. 135
CPU Interface ....................................................................................................................... 136
Operation .............................................................................................................................. 138
6.4.1 FRC Incrementation Timing.................................................................................... 138
6.4.2 Output Compare Timing.......................................................................................... 140
6.4.3 Input Capture Timing .............................................................................................. 141
6.4.4 Setting of FRC Overflow Flag (OVF)..................................................................... 144
Interrupts............................................................................................................................... 145
Sample Application............................................................................................................... 145
Application Notes ................................................................................................................. 146
Section 7. 8-Bit Timers
......................................................................................................... 151
7.1
Overview............................................................................................................................... 151
7.1.1 Features.................................................................................................................... 151
7.1.2 Block Diagram......................................................................................................... 151
7.1.3 Input and Output Pins .............................................................................................. 152
7.1.4 Register Configuration ............................................................................................ 153
Register Descriptions............................................................................................................ 153
7.2.1 Timer Counter (TCNT)—H'FFCC (TMR0), H'FFD4 (TMR1)............................... 153
7.2.2 Time Constant Registers A and B (TCORA and TCORB)—
H'FFCA and H'FFCB (TMR0), H'FFD2 and H'FFD3 (TMR1) .............................. 154
7.2.3 Timer Control Register (TCR)—H'FFC8 (TMR0), H'FFD0 (TMR1) .................... 154
7.2.4 Timer Control/Status Register (TCSR)—H'FFC9 (TMR0), H'FFD1 (TMR1) ....... 157
7.2.5 Serial/Timer Control Register (STCR)—H'FFC3 ................................................... 159
Operation .............................................................................................................................. 160
7.3.1 TCNT Incrementation Timing................................................................................. 160
7.3.2 Compare Match Timing........................................................................................... 161
7.2
7.3
iii