
µ PD789800 Subseries
8-Bit Single-Chip Microcontrollers
µ PD789800 µ PD78F9801
Document No. U12978EJ3V0UD00 (3rd edition) Date Published February 2003 N CP (K)
1998, 2003 · Printed in Japan
![Page 2 of the NEC switch user manual — [MEMO]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-2.webp?w=400)

1 PRECAUTION AGAINST ESD FOR SEMICONDUCTORS Note: Strong electric field, when exposed to a MOS device, can cause destruction of the gate oxide and ultimately degrade the device operation. Steps must be taken to stop generation of static electricity as much as possible, and quickly dissipate it once, when it has occurred. Environmental control must be adequate. When it is dry, humidifier should be used. It is recommended to avoid using insulators that easily build static electricity. Semiconductor devices must be stored and transported in an anti-static container, static shielding bag or conductive material. All test and measurement tools including work bench and floor should be grounded. The operator should be grounded using wrist strap. Semiconductor devices must not be touched with bare hands. Similar precautions need to be taken for PW boards with semiconductor devices on it.
2 HANDLING OF UNUSED INPUT PINS FOR CMOS Note: No connection for CMOS device inputs can be cause of malfunction. If no connection is provided to the input pins, it is possible that an internal input level may be generated due to noise, etc., hence causing malfunction. CMOS devices behave differently than Bipolar or NMOS devices. Input levels of CMOS devices must be fixed high or low by using a pull-up or pull-down circuitry. Each unused pin should be connected to VDD or GND with a resistor, if it is considered to have a possibility of being an output pin. All handling related to the unused pins must be judged device by device and related specifications governing the devices.
3 STATUS BEFORE INITIALIZATION OF MOS DEVICES Note: Power-on does not necessarily define initial status of MOS device. Production process of MOS does not define the initial operation status of the device. Immediately after the power source is turned ON, the devices with reset function have not yet been initialized. Hence, power-on does not guarantee out-pin levels, I/O settings or contents of registers. Device is not initialized until the reset signal is received. Reset operation must be executed immediately after power-on for devices having reset function.
FIP and EEPROM are trademarks of NEC Electronics Corporation.
Windows and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the
United States and/or other countries.
PC/AT is a trademark of International Business Machines Corporation.
HP9000 Series 700 and HP-UX are trademarks of Hewlett-Packard Company.
SPARCstation is a trademark of SPARC International, Inc.
Solaris and SunOS are trademarks of Sun Microsystems, Inc.

These commodities, technology or software, must be exported in accordance with the export administration regulations of the exporting country. Diversion contrary to the law of that country is prohibited.
The information in this document is current as of September, 2002. The information is subject to change without notice. For actual design-in, refer to the latest publications of NEC Electronics data sheets or data books, etc., for the most up-to-date specifications of NEC Electronics products. Not all products and/or types are available in every country. Please check with an NEC Electronics sales representative for availability and additional information. No part of this document may be copied or reproduced in any form or by any means without the prior written consent of NEC Electronics. NEC Electronics assumes no responsibility for any errors that may appear in this document. NEC Electronics does not assume any liability for infringement of patents, copyrights or other intellectual property rights of third parties by or arising from the use of NEC Electronics products listed in this document or any other liability arising from the use of such products. No license, express, implied or otherwise, is granted under any patents, copyrights or other intellectual property rights of NEC Electronics or others. Descriptions of circuits, software and other related information in this document are provided for illustrative purposes in semiconductor product operation and application examples. The incorporation of these circuits, software and information in the design of a customer's equipment shall be done under the full responsibility of the customer. NEC Electronics assumes no responsibility for any losses incurred by customers or third parties arising from the use of these circuits, software and information. While NEC Electronics endeavors to enhance the quality, reliability and safety of NEC Electronics products, customers agree and acknowledge that the possibility of defects thereof cannot be eliminated entirely. To minimize risks of damage to property or injury (including death) to persons arising from defects in NEC Electronics products, customers must incorporate sufficient safety measures in their design, such as redundancy, fire-containment and anti-failure features. NEC Electronics products are classified into the following three quality grades: "Standard", "Special" and "Specific". The "Specific" quality grade applies only to NEC Electronics products developed based on a customer- designated "quality assurance program" for a specific application. The recommended applications of an NEC Electronics product depend on its quality grade, as indicated below. Customers must check the quality grade of each NEC Electronics product before using it in a particular application. "Standard": Computers, office equipment, communications equipment, test and measurement equipment, audio
and visual equipment, home electronic appliances, machine tools, personal electronic equipment and industrial robots. "Special": Transportation equipment (automobiles, trains, ships, etc.), traffic control systems, anti-disaster systems, anti-crime systems, safety equipment and medical equipment (not specifically designed for life support). "Specific": Aircraft, aerospace equipment, submersible repeaters, nuclear reactor control systems, life
support systems and medical equipment for life support, etc.
The quality grade of NEC Electronics products is "Standard" unless otherwise expressly specified in NEC Electronics data sheets or data books, etc. If customers wish to use NEC Electronics products in applications not intended by NEC Electronics, they must contact an NEC Electronics sales representative in advance to determine NEC Electronics' willingness to support a given application.
(Note) (1) "NEC Electronics" as used in this statement means NEC Electronics Corporation and also includes its
majority-owned subsidiaries. (2) "NEC Electronics products" means any product developed or manufactured by or for NEC Electronics
(as defined above).

Some information contained in this document may vary from country to country. Before using any NEC Electronics product in your application, pIease contact the NEC Electronics office in your country to obtain a list of authorized representatives and distributors. They will verify:
In addition, trademarks, registered trademarks, export restrictions, and other legal issues may also vary from country to country.
NEC Electronics America, Inc. (U.S.) Santa Clara, California Tel: 408-588-6000 800-366-9782 Fax: 408-588-6130 800-729-9288
NEC Electronics Hong Kong Ltd. Hong Kong Tel: 2886-9318 Fax: 2886-9022/9044
NEC Electronics Hong Kong Ltd. Seoul Branch Seoul, Korea Tel: 02-528-0303 Fax: 02-528-4411
NEC Electronics (Europe) GmbH Duesseldorf, Germany Tel: 0211-65 03 01 Fax: 0211-65 03 327
NEC Electronics Shanghai, Ltd. Shanghai, P.R. China Tel: 021-6841-1138 Fax: 021-6841-1137
NEC Electronics Taiwan Ltd. Taipei, Taiwan Tel: 02-2719-2377 Fax: 02-2719-5951
NEC Electronics Singapore Pte. Ltd. Novena Square, Singapore Tel: 6253-8311 Fax: 6250-3583

The mark shows major revised points.

Readers This manual is intended for users who wish to understand the functions of the
µPD789800 Subseries and who design and develop its application systems and
programs.
Target products:
Purpose This manual is intended to give users an understanding of the functions described in
the Organization below.
Organization Two manuals are available for the µPD789800 Subseries:
This manual and the Instruction Manual (common to the 78K/0S Series).
How to Read This Manual It is assumed that the readers of this manual have general knowledge in the fields of
electrical engineering, logic circuits, and microcontrollers.
→Read this manual in the order of the CONTENTS.
→The name of a bit whose number is enclosed in angle brackets (< >) is reserved
in the assembler and is defined in the C compiler by the header file sfrbit.h.
→See APPENDIX B REGISTER INDEX.
→Refer to 78K/0S Series Instruction User’s Manual (U11047E) separately
available.
→Refer to CHAPTER 16 ELECTRICAL SPECIFICATIONS.
Decimal ... xxxx
Hexadecimal ... xxxxH

Related Documents The related documents indicated in this publication may include preliminary versions.
However, preliminary versions are not marked as such.
latest version of each document for designing.

latest version of each document for designing.


3.3.4 Register addressing 50 3.4 Operand Address Addressing 51
3.4.1 Direct addressing 51
3.4.2 Short direct addressing 52
3.4.3 Special function register (SFR) addressing 53
3.4.4 Register addressing 54
3.4.5 Register indirect addressing 55
3.4.6 Based addressing 56
3.4.7 Stack addressing 56
4.1 Port Functions ............................................................................................................................57 4.2 Port Configuration......................................................................................................................59
4.2.1 Port 0 60
4.2.2 Port 1 61
4.2.3 Port 2 62
4.2.4 Port 4 68 4.3 Registers Controlling Port Function 69 4.4 Port Function Operation 72
4.4.1 Writing to I/O port 72
4.4.2 Reading from I/O port 72
4.4.3 Arithmetic operation of I/O port 72
5.1 Clock Generator Functions 73 5.2 Clock Generator Configuration 73 5.3 Register Controlling Clock Generator 74 5.4 System Clock Oscillators 75
5.4.1 System clock oscillator 75
5.4.2 Examples of incorrect resonator connection 76
5.4.3 Frequency divider 77 5.5 Clock Generator Operation 77 5.6 Changing Setting of CPU Clock 78
5.6.1 Time required for switching CPU clock 78
5.6.2 Switching CPU clock 78
6.1 Functions of 8-Bit Timer/Event Counters 00 and 01 79 6.2 Configuration of 8-Bit Timer/Event Counters 00 and 01 80 6.3 Registers Controlling 8-Bit Timer/Event Counters 00 and 01 82 6.4 Operation of 8-Bit Timer/Event Counters 00 and 01 85
6.4.1 Operation as interval timer 85
6.4.2 Operation as external event counter (timer 01 only) 87
6.4.3 Operation as square-wave output (timer 01 only) 88 6.5 Notes on Using 8-Bit Timer/Event Counters 00 and 01 90

7.1 Watchdog Timer Functions 91 7.2 Watchdog Timer Configuration 92 7.3 Registers Controlling Watchdog Timer 93 7.4 Watchdog Timer Operation 95
7.4.1 Operation as watchdog timer 95
7.4.2 Operation as interval timer 96
8.1 USB Overview 97 8.2 USB Function Features 98 8.3 USB Function Configuration 98 8.4 Registers Controlling USB Function 109 8.5 USB Function Operation 122
8.5.1 USB timer operation 122
8.5.2 Remote wakeup control operation 125 8.6 Interrupt Request from USB Function 127
8.6.1 Interrupt sources 127
8.6.2 Cautions when using interrupts 129 8.7 USB Function Control 130
8.7.1 Relationship between packets and operation modes 130
8.7.2 Interrupt servicing flow 136 8.8 USB Function Internal Circuit Operations 140
8.8.1 Operation of transmit/receive pointer 140
8.8.2 Receive bank switching ID detection buffer operation 147
8.8.3 Sync detection/USBCLK detector operation 148
8.8.4 NRZI encoder operation 150
8.8.5 Bit stuffing/strip controller operation 151
9.1 Functions of Serial Interface 10 154 9.2 Configuration of Serial Interface 10 155 9.3 Register Controlling Serial Interface 10 157 9.4 Operation of Serial Interface 10 159
9.4.1 Operation stop mode 159
9.4.2 3-wire serial I/O mode 160
CHAPTER 11 INTERRUPT FUNCTIONS............................................................................................163
11.1 Interrupt Function Types 163 11.2 Interrupt Sources and Configuration 163 11.3 Registers Controlling Interrupt Function 166 11.4 Interrupt Servicing Operation 171
11.4.1 Non-maskable interrupt acknowledgment operation 171


B.1 Register Index (Alphabetic Order of Register Name) 229 B.2 Register Index (Alphabetic Order of Register Symbol) 231

Figure No. Title Page
2-1 Pin I/O Circuits 34
3-1 Memory Map (µPD789800) 35
3-2 Memory Map (µPD78F9801) 36
3-3 Data Memory Addressing (µPD789800) 38
3-4 Data Memory Addressing (µPD78F9801) 39
3-5 Configuration of Program Counter 40
3-6 Configuration of Program Status Word 40
3-7 Configuration of Stack Pointer 42
3-8 Data to Be Saved to Stack Memory 42
3-9 Data to Be Restored from Stack Memory 42
3-10 Configuration of General-Purpose Registers 43
4-1 Port Types 57
4-2 Block Diagram of P00 to P07 60
4-3 Block Diagram of P10 to P17 61
4-4 Block Diagram of P20 62
4-5 Block Diagram of P21 63
4-6 Block Diagram of P22 64
4-7 Block Diagram of P23 and P24 65
4-8 Block Diagram of P25 66
4-9 Block Diagram of P26 67
4-10 Block Diagram of P40 to P47 68
4-11 Format of Port Mode Register 69
4-12 Format of Pull-up Resistor Option Register 0 70
4-13 Format of Port Output Mode Register 0 71
4-14 Format of Port Output Mode Register 1 71
5-1 Block Diagram of Clock Generator 73
5-2 Format of Processor Clock Control Register 74
5-3 External Circuit of System Clock Oscillator 75
5-4 Examples of Incorrect Resonator Connection 76
5-5 Switching of CPU Clock 78
6-1 Block Diagram of 8-Bit Timer 00 80
6-2 Block Diagram of 8-Bit Timer/Event Counter 01 81
6-3 Format of 8-Bit Timer Mode Control Register 00 82
6-4 Format of 8-Bit Timer Mode Control Register 01 83
6-5 Format of Port Mode Register 2 84
6-6 Interval Timer Operation Timing of 8-Bit Timer 00 86

Figure No. Title Page
6-7 Interval Timer Operation Timing of 8-Bit Timer/Event Counter 01 86
6-8 Timing of External Event Counter Operation (with Rising Edge Specified) 87
6-9 Timing of Square-Wave Output 89
6-10 Start Timing of 8-Bit Timer Counter 90
6-11 Timing of External Event Counter Operation 90
7-1 Block Diagram of Watchdog Timer 92
7-2 Format of Timer Clock Select Register 2 93
7-3 Format of Watchdog Timer Mode Register 94
8-1 USB Bus Topology (Desktop Type PC) 97
8-2 Block Diagram of USB Function 99
8-3 Block Diagram of USB Timer 100
8-4 Configuration of Receive Token Bank 102
8-5 Configuration of Receive Data Bank 103
8-6 Configuration of Transmit Data Bank 0 (Buffer 0) 104
8-7 Configuration of Transmit Data Bank 1 (Buffer 1) 105
8-8 Configuration of TIDCMP and ADRCMP 107
8-9 Configuration of DIDCMP 108
8-10 Format of USB Receiver Enable Register 109
8-11 Format of Data/Handshake Packet Receive Mode Register 110
8-12 Format of Packet Receive Status Register 112
8-13 Format of Data/Handshake Packet Receive Result Store Register 113
8-14 Format of Token Packet Receive Result Store Register 114
8-15 Format of Data Packet Transmit Reservation Register 115
8-16 Format of Handshake Packet Transmit Reservation Register 116
8-17 Configuration of Handshake Packet Transmit Reservation Register 119
8-18 Format of USB Timer Start Reservation Control Register 120
8-19 Format of Remote Wakeup Control Register 121
8-20 Flowchart of USB Timer Operation 123
8-21 Flow Chart of Remote Wakeup Control Operation 125
8-22 Configuration of Remote Wakeup Control 126
8-23 Timing of Data/Handshake Packet Receive Interrupt Request Generation 127
8-24 Timing of INTUSBRE Generation 128
8-25 Flowchart of Transmit/Receive Pointer Operation 140
8-26 Flowchart of Receive Bank Switching ID Detection Buffer Operation 147
8-27 Timing of Sync Detection/USBCLK Detector Operation 148
8-28 Timing of Sync Detection/USBCLK Generation Operation 148
8-29 Flowchart of Sync Detection/USBCLK Detector Operation 149
8-30 Timing of NRZI Encoder Operation 150

Figure No. Title Page
8-31 Flow Chart of NRZI Encoder Operation 150
8-32 Timing of Bit Stuffing/Strip Controller Operation 151
8-33 Flow Chart of Bit Stuffing Control Operation 152
8-34 Flow Chart of Bit Strip Control Operation 153
9-1 Block Diagram of Serial Interface 10 156
9-2 Format of Serial Operation Mode Register 10 157
9-3 3-Wire Serial I/O Mode Timing 161
10-1 Block Diagram of Regulator and USB Driver/Receiver 162
11-1 Basic Configuration of Interrupt Function 165
11-2 Format of Interrupt Request Flag Register 167
11-3 Format of Interrupt Mask Flag Register 168
11-4 Format of External Interrupt Mode Register 0 168
11-5 Configuration of Program Status Word 169
11-6 Format of Key Return Mode Register 00 170
11-7 Block Diagram of Falling Edge Detector 170
11-8 Flowchart of Non-Maskable Interrupt Request Acknowledgment 172
11-9 Timing of Non-Maskable Interrupt Request Acknowledgment 172
11-10 Acknowledging Non-Maskable Interrupt Request 172
11-11 Interrupt Acknowledgment Program Algorithm 173
11-12 Timing of Interrupt Request Acknowledgment (Example of MOV A,r) 174
11-13 Timing of Interrupt Request Acknowledgment
(When Interrupt Request Flag Is Generated at Last Clock of Instruction Execution) 174
11-14 Example of Multiplexed Interrupt Servicing 176
12-1 Format of Oscillation Stabilization Time Select Register 179
12-2 Releasing HALT Mode by Interrupt 181
12-3 Releasing HALT Mode by RESET Input 182
12-4 Releasing STOP Mode by Interrupt 184
12-5 Releasing STOP Mode by RESET Input 185
13-1 Block Diagram of Reset Function 186
13-2 Reset Timing by RESET Input 187
13-3 Reset Timing by Overflow in Watchdog Timer 187
13-4 Reset Timing by RESET Input in STOP Mode 187
14-1 Environment for Writing Program to Flash Memory 191
14-2 Communication Mode Selection Format 192

Figure No. Title Page
14-3 Example of Connection with Dedicated Flash Programmer 193
14-4 VPP Pin Connection Example 195
14-5 Signal Conflict (Input Pin of Serial Interface) 196
14-6 Abnormal Operation of Other Device 196
14-7 Signal Conflict (RESET Pin) 197
14-8 Wiring Example for Flash Writing Adapter with 3-Wire Serial I/O 198
14-9 Wiring Example for Flash Writing Adapter with Pseudo-3-Wire Method 199
A-1 Development Tools 222
A-2 Distance Between In-Circuit Emulator and Conversion Adapter 227
A-3 Connection Condition of Target System (NP-H44GB-TQ) 228

Table No. Title Page
2-1 Type of Pin I/O Circuit Recommended Connection of Unused Pins 33
3-1 Vector Table 37
3-2 Special Function Register List 45
4-1 Functions of Ports 58
4-2 Configuration of Port 59
4-3 Port Mode Register and Output Latch Settings When Using Alternate Functions 70
5-1 Configuration of Clock Generator 73
5-2 Maximum Time Required for Switching CPU Clock 78
6-1 Interval Time of 8-Bit Timer 00 79
6-2 Interval Time of 8-Bit Timer/Event Counter 01 79
6-3 Square Wave Output Range of 8-Bit Timer/Event Counter 01 80
6-4 Configuration of 8-Bit Timer/Event Counters 00 and 01 80
6-5 Interval Time of 8-Bit Timer 00 85
6-6 Interval Time of 8-Bit Timer/Event Counter 01 85
6-7 Square-Wave Output Range of 8-Bit Timer/Event Counter 01 88
7-1 Inadvertent Loop Detection Time of Watchdog Timer 91
7-2 Interval Time 91
7-3 Configuration of Watchdog Timer 92
7-4 Inadvertent Loop Detection Time of Watchdog Timer 95
7-5 Interval Time of Interval Timer 96
8-1 Configuration of USB Function 98
8-2 Flag of RXSTAT After Reception of USB Reset Signal and Resume Signal 113
8-3 Conditions in Transmit Reservation 117
8-4 List of Sources of Interrupts from USB Function 127
9-1 Configuration of Serial Interface 10 155
9-2 Operating Mode Settings of Serial Interface 10 158
11-1 Interrupt Source List 164
11-2 Flags Corresponding to Interrupt Request Signals 166
11-3 Time from Generation of Maskable Interrupt Request to Servicing 173
12-1 HALT Mode Operation Status 180
12-2 Operation After Release of HALT Mode 182

Table No. Title Page
12-3 STOP Mode Operation Status 183
12-4 Operation After Release of STOP Mode 185
13-1 Hardware Status After Reset 188
14-1 Differences Between µPD78F9801 and Mask ROM Versions 190
14-2 Communication Mode List 192
14-3 Pin Connection List 194
15-1 Operand Identifiers and Description Methods 200
18-1 Surface Mounting Type Soldering Conditions 220

1.1 Features
driver/receiver.
Flash memory (for µPD78F9801 only): 16 KB
clock operating at 6.0 MHz
TA = 0 to +70°C (when the USB is operating)
TA = 10 to 40°C (when the flash memory is written)
USB keyboards, etc.
Part Number Package Internal ROM
µPD789800GB-×××-8ES 44-pin plastic LQFP (10 × 10) Mask ROM
µPD78F9801GB-8ES 44-pin plastic LQFP (10 × 10) Flash memory
Remark ××× indicates ROM code suffix.

1.4 Pin Configuration (Top View)
µPD789800GB-×××-8ES, µPD78F9801GB-8ES

44 43 42 41 40 39 38 37 36 35 34
P03
P02
P01
P00
V DD1
V SS1
P17
P16
P15
P14
12 13 14 15 16 17 18 19 20 21 22
Remark The parenthesized values apply to the µPD78F9801.
INTP0: Interrupt from peripherals SO10: Serial data output KR00 to KR07 : Key return TI01: Timer input

1.5 78K/0S Series Lineup
The products in the 78K/0S Series are listed below. The names enclosed in boxes are subseries names.
Products under development Products in mass production
Y subseries supports SMB.
Small-scale package, general-purpose applications
µ
PD789074 with subsystem clock added
µ
PD789014 with enhanced timer function and expanded ROM and RAM
30-pin PD789074 with enhanced timer function and expanded ROM and RAM
PD789026 with enhanced timer function
On-chip UART and capable of low-voltage (1.8 V) operation
RC oscillation version of PD789052
PD789860 without EEPROMTM, POC, and LVI µ
Small-scale package, general-purpose applications and A/D function
PD789177 PD789167 30-pin 30-pin
µ
µ
PD789167 with 10-bit A/D PD789104A with enhanced timer
PD789146 PD789156
PD789104A with EEPROMTM added PD789146 with 10-bit A/D
30-pin
PD789124A with 10-bit A/D RC oscillation version of PD789104A
PD789104A with 10-bit A/D PD789026 with 8-bit A/D and multiplier added
µ
UART + dot LCD (40 × 16) UART + 8-bit A/D + dot LCD (total display outputs: 96)
SIO + 10-bit A/D + internal voltage boosting method LCD (28 × 4) 80-pin
SIO + 8-bit A/D + resistance division method LCD (28 × 4) 80-pin PD789479
µ
PD789407A with 10-bit A/D
PD789446 with 10-bit A/D SIO + 8-bit A/D + resistance division method LCD (28 × 4)
PD789436 PD789446
SIO + 8-bit A/D + internal voltage boosting method LCD (15 × 4)
PD789426 with 10-bit A/D
SIO + 8-bit A/D + internal voltage boosting method LCD (5 × 4) RC oscillation version of PD789306 SIO + internal voltage boosting method LCD (24 × 4)
PD789467 PD789306
8-bit A/D + internal voltage boosting method LCD (23 × 4) PD789327
52-pin SIO + resistance division method LCD (24 × 4)
44-pin PD789800 For PC keyboard. On-chip USB function
44-pin PD789842 On-chip inverter controller and UART
30-pin PD789850 On-chip CAN controller
PD789862 µ µ µ
PD789860 with enhanced timer function, SIO, and expanded ROM and RAM
RC oscillation version of PD789860
On-chip POC and key return circuit
PD789871 On-chip VFD controller (total display outputs: 25)
PD789881 UART + resistance division method LCD (26 × 4)
TM (Fluorescent Indicator Panel) in some
Remark VFD (Vacuum Fluorescent Display) is referred to as FIP
documents, but the functions of the two are same.

The major differences between subseries are shown below.

1.8 V − Small- scale package, general- purpose applica- tions µPD789062 4 K − 14 RC-oscillation version
µPD789088 16 K to 32 K 3 ch
µPD789074 2 K to 8 K 1 ch
µPD789014 2 K to 4 K 2 ch −
16 K to 24 K 3 ch 1 ch
µPD789835 24 K to 60 K 6 ch − 3 ch 37 1.8 V Note
µPD789479 24 K to 48 K 8 ch −
8 K to 16 K − 2 ch (UART: 1ch) 23

Series for ASSP

USB µPD789800 8 K 2 ch − − 1 ch − − 2 ch (USB: 1ch) 31 4.0 V −
µPD789842 8 K to 16 K 3 ch Note 1 1 ch 1 ch 8 ch − 1 ch (UART: 1ch) 30 4.0 V −
µPD789850 16 K 1 ch 1 ch − 1 ch 4 ch − 2 ch (UART: 1ch) 18 4.0 V −
4 K 2 ch − − 1 ch − − − 14 Keyless
µPD789862 16 K 1 ch 2 ch 1 ch (UART: 1ch) 22
µPD789871 4 K to 8 K 3 ch − 1 ch 1 ch − − 1 ch 33 2.7 V −
µPD789881 16 K 2 ch 1 ch − 1 ch − − 1 ch (UART: 1 ch) 28 2.7 V Note 2 −

1.6 Block Diagram
TI01/TO01/P26/INTP0
8-bit timer/event counter 01
V REG
USBDM
RAM
USBDP
RESET X1 X2
SCK10/P20
SO10/P21
SI10/P22
INTP0/P26 VDD0 VDD1 VSS0 VSS1 IC
Remark The parenthesized values apply to the µPD78F9801.

1.7 Functions
µPD789800 µPD78F9801
Internal memory ROM Mask ROM 8 KB Flash memory 16 KB
High-speed RAM 256 bytes
Minimum instruction execution time 0.33 µs/1.33 µs (at 6.0 MHz operation with system clock)
I/O ports CMOS I/O 31
(Of the above COMS I/O ports, 18 ports can be switched to N-ch open-drain I/O ports.)
Regulator Incorporated (VREG = 3.3 ±0.3 V)
Power supply voltage VDD = 4.0 to 5.5 V
Package 44-pin plastic LQFP (10 × 10)
An outline of the timer is shown below.

Interval timer 1 channel 1 channel 1 channel Note Operation mode
selecting either the watchdog timer function or interval timer function.
Product Item

2.1 List of Pin Functions
(1) Port pins
Pin Name I/O Function After Reset Alternate
P00 to P07 I/O Port 0
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).
When used as an output port, CMOS output or N-ch open-drain output can be specified in 8-bit units by port output mode register 0 (POM0).
P10 to P17 I/O Port 1
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).
When used as an output port, CMOS output or N-ch open-drain output can be specified in 8-bit units by port output mode register 0 (POM0).
P21 SO10
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).
P23 to P25 —
When P25 or P26 is used as an output port, CMOS output or N-ch open-drain output can be specified in 1-bit units by port output mode register 1 (POM1).
P40 to P47 I/O Port 4
Input KR00 to KR07
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).

(2) Non-port pins
Pin Name I/O Function After Reset Alternate
INTP0 Input External interrupt request input for which valid edge (rising and/or falling edge) can be specified
Input Input for detecting key return signals Input P40 to P47
NC — No connection. Can be left open. — —
REGC — Internally generated power supply for driving USB driver/receiver. Connect this pin to VSS via a 22 µF capacitor.
RESET Input System reset input Input —
SCK10 I/O Serial clock input/output for serial interface Input P20
SI10 Input Serial data input for serial interface Input P22
SO10 Output Serial data output for serial interface Input P21
TI01 Input External count clock input to 8-bit timer TM01 Input P26/INTP0/TO01
TO01 Output Output from 8-bit timer TM01 Input P26/INTP0/TI01
USBDM I/O Serial data input/output (negative side) for USB function. The pull-up resistor (1.5 kΩ) for the USBDM pin must be connected to the REGC pin.
USBDP I/O Serial data input/output (positive side) for USB function Input —
VDD0 — Positive power supply for ports — —
VDD1 — Positive power supply for circuits other than ports — —
VSS0 — Ground potential for ports — —
VSS1 — Ground potential for circuits other than ports — —
X1 Input Input —
Crystal resonator connection to for system clock oscillator
IC — Internally connected directly to VSS0 — —
VPP — Sets flash memory programming mode. Apply high voltage when a program is written or verified.

2.2 Pin Functions
2.2.1 P00 to P07 (Port 0)
These pins constitute an 8-bit I/O port and can be set to the input or output port mode in 1-bit units by using port
mode register 0 (PM0). When these pins are used as an input port, an on-chip pull-up resistor can be used by
setting pull-up resistor option register 0 (PU0). When these pins are used as an output port, CMOS output or N-ch
open-drain output can be specified in 8-bit units by setting port output mode register 0 (POM0).
These pins constitute an 8-bit I/O port. Port 1 can be set to the input or output mode in 1-bit units by using port
mode register 1 (PM1). When the port is used as an input port, an on-chip pull-up resistor can be used by setting
pull-up resistor option register 0 (PU0). When these pins are used as an output port, CMOS output or N-ch open-
drain output can be specified in 8-bit units by setting port output mode register 0 (POM0).
These pins constitute a 7-bit I/O port. In addition, these pins function as data I/O, and clock I/O to and from the
serial interface, external interrupt input, and timer I/O.
Port 2 can be specified in the following operation modes in 1-bit units.
In the port mode, P20 to P26 function as a 7-bit I/O port. Port 2 can be set to the input or output mode in 1-bit
units by using port mode register 2 (PM2). When the port is used as an input port, an on-chip pull-up resistor
can be used by setting pull-up resistor option register 0 (PU0). When P25 or P26 is used as an output port,
CMOS output or N-ch open-drain output can be specified by setting in 1-bit units port output mode register 1
(POM1).
In this mode, P20 to P26 function as the data I/O and the clock I/O to and from the serial interface.
These are the serial data I/O pins of the serial interface.
This is the serial clock I/O pin of the serial interface.
This is the external clock input pin for the 8-bit timer/event counter.
This is the output pin of the 8-bit timer.
This is an external interrupt input pin for which the valid edge (rising edge, falling edge, or both rising and
falling edges) can be specified.
according to the functions to be used. For setting details, see Table 9-2.

2.2.4 P40 to P47 (Port 4)
These pins constitute an 8-bit I/O port. In addition, they also function as key return signal detection pins.
The following operation modes can be specified in 1-bit units.
In this mode, port 4 functions as an 8-bit I/O port. Port 4 can be set to the input or output mode in 1-bit units by
using port mode register 4 (PM4). When used as an input port an on-chip pull-up resistor can be used by
setting pull-up resistor option register 0 (PU0).
In this mode, the pins function as key return signal detection pins (KR00 to KR07).
This pin inputs an active-low system reset signal.
These pins are used to connect a crystal resonator for system clock oscillation.
To supply an external clock, input the clock to X1 and input the inverted signal to X2.
This pin is a power supply pin for driving a USB driver/receiver generated internally. Connect this pin to the VSS
pin via 22 µF capacitor.
This pin (negative side) inputs or outputs serial data for the USB function.
This pin (positive side) inputs or outputs serial data for the USB function.
These pins are positive power supply pins.
These pins are ground pins.

2.2.12 V PP ( µ PD78F9801 only)
A high voltage should be applied to this pin when the flash memory programming mode is set and when the
program is written or verified.
Handle this pin in either of the following ways.
normal operation mode using a jumper on the board.
The IC (Internally Connected) pin is used to set the µPD789800 Subseries in the test mode before shipment. In
the normal operation mode, directly connect this pin to the VSS0 pin with as short a wiring length as possible.
If a potential difference is generated between the IC pin and VSS0 pin due to a long wiring length between the IC
pin and VSS0 pin or an external noise superimposed on the IC pin, a user program may not run correctly.
Keep short

2.3 Pin I/O Circuits and Recommended Connection of Unused Pins
Table 2-1 lists the types of I/O circuits for each pin and explains how unused pins are handled.
Figure 2-1 shows the configuration of each type of I/O circuit.

Pin Name I/O Circuit Type I/O Recommended Connection of Unused Pins
Input: Independently connect to VDD0, VDD1, VSS0, or VSS1 via a resistor.
Independently connect to VSS0 or VSS1 via a resistor.
Independently connect a 10 kΩ pull-down resistor, or connect directly to VSS0.

Figure 2-1. Pin I/O Circuits


3.1 Memory Space
The µPD789800 Subseries can access 64 KB of memory space.
Figures 3-1 and 3-2 show the memory maps.
Figure 3-1. Memory Map (µPD789800)
256 × 8 bits
H F F E F
256 × 8 bits
H F F D F
H F F F 1
H 0 0 0 2
H F F F 1
H 0 8 0 0 H F 7 0 0
Internal ROM 8,192 × 8 bits
H 0 4 0 0 H F 3 0 0
H A 1 0 0 H 9 1 0 0
H 0 0 0 0

Figure 3-2. Memory Map (µPD78F9801)
256 × 8 bits
H F F E F
256 × 8 bits
H F F D F
H F F F 3
H 0 0 0 4
H F F F 3
H 0 8 0 0 H F 7 0 0
Flash memory 16,384 × 8 bits
H 0 4 0 0 H F 3 0 0
H A 1 0 0 H 9 1 0 0
H 0 0 0 0

3.1.1 Internal program memory space
The internal program memory space stores programs and table data. This space is usually addressed by the
program counter (PC).
The following areas are allocated to the internal program memory space.
A 26-byte area of addresses 0000H to 0019H is reserved as a vector table area. This area stores program start
addresses to be used when branching by RESET input or interrupt request generation. Of a 16-bit program
address, the lower 8 bits are stored in an even address, and the higher 8 bits are stored in an odd address.
Vector Table Address Interrupt Request Vector Table Address Interrupt Request
0000H RESET input 000EH INTUSBRE
0006H INTUSBTM 0012H INTCSI10
0008H INTUSBRT 0014H INTTM00
000AH INTUSBRD 0016H INTTM01
000CH INTUSBST 0018H INTKR00
(2) CALLT instruction table area
The subroutine entry address of a 1-byte call instruction (CALLT) can be stored in a 64-byte area of addresses
0040H to 007FH.
An internal high-speed RAM is incorporated in the area between FE00H and FEFFH.
The internal high-speed RAM is also used as a stack.
Special function registers (SFRs) of on-chip peripheral hardware are allocated to an area of FF00H to FFFFH
(see Table 3-2).

3.1.4 Data memory addressing
The µPD789800 Subseries provides a variety of addressing modes which take account of memory manipulability,
etc. Especially at addresses corresponding to data memory area (FE00H to FFFFH), particular addressing modes
are possible to meet the functions of the special function registers (SFR) and general-purpose registers. Figures 3-3
and 3-4 show the data memory addressing modes.
Figure 3-3. Data Memory Addressing (µPD789800)
Special function registers (SFR)
256 × 8 bits
FF00H FEFFH
256 × 8 bits
FE00H FDFFH
2000H 1FFFH
Internal ROM 8,192 × 8 bits

Figure 3-4. Data Memory Addressing (µPD78F9801)
Special function registers (SFR)
256 × 8 bits
FF00H FEFFH
256 × 8 bits
FE00H FDFFH
4000H 3FFFH
Flash memory 16,384 × 8 bits

3.2 Processor Registers
The µPD789800 Subseries provides the following on-chip processor registers.
The control registers contain special functions to control the program sequence, statuses and stack memory. A
program counter, a program status word, and a stack pointer are the control registers.
The program counter is a 16-bit register which holds the address information of the next program to be
executed.
In normal operation, the PC is automatically incremented according to the number of bytes of the instruction to
be fetched. When a branch instruction is executed, immediate data or register contents are set.
RESET input sets the program counter to the reset vector table values at addresses 0000H and 0001H.
PC15 PC PC14 PC13 PC12 PC11 PC10 PC9 PC8 PC7 PC6 PC5 PC4 PC3 PC2 PC1 PC0
The program status word is an 8-bit register consisting of various flags to be set/reset by instruction execution.
Program status word contents are automatically stacked upon interrupt request generation or PUSH PSW
instruction execution and are automatically restored upon execution of the RETI and POP PSW instructions.
RESET input sets the PSW to 02H.
IE Z 0 AC 0 0 1 CY

(a) Interrupt enable flag (IE)
This flag controls interrupt request acknowledgment operations of the CPU.
When 0, the IE flag is set to the interrupt disabled status (DI), and interrupt requests other than non-
maskable interrupts are all disabled.
When 1, the IE flag is set to the interrupt enabled status (EI). Interrupt request acknowledgment enable is
controlled by the interrupt mask flag corresponding to each interrupt source.
The IE flag is reset (0) upon DI instruction execution or interrupt acknowledgment and is set (1) upon EI
instruction execution.
When the operation result is zero, this flag is set (1). It is reset (0) in all other cases.
If the operation result has a carry from bit 3 or a borrow at bit 3, this flag is set (1). It is reset (0) in all other
cases.
This flag stores overflow and underflow upon add/subtract instruction execution. It stores the shift-out
value upon rotate instruction execution and functions as a bit accumulator during bit manipulation
instruction execution.

(3) Stack pointer (SP)
This is a 16-bit register that holds the start address of the memory stack area. Only the internal high-speed
RAM area can be set as the stack area.
SP15 SP SP14 SP13 SP12 SP11 SP10 SP9 SP8 SP7 SP6 SP5 SP4 SP3 SP2 SP1 SP0
The SP is decremented ahead of write (save) to the stack memory and is incremented after read (restore) from
the stack memory.
Each stack operation saves/restores data as shown in Figures 3-8 and 3-9.
instruction execution.
CALL, CALLT instructions PUSH rp instruction
SP SP _ 2
SP SP _ 2
PC7 to PC0 SP _ 3
PC7 to PC0 Lower half register pairs
SP _ 2
Upper half register pairs
SP _ 1
SP _ 1
PSW
SP
SP
SP
Figure 3-9. Data to Be Restored from Stack Memory
RET instruction POP rp instruction
PC7 to PC0 Lower half register pairs
SP PC7 to PC0
SP
Upper half register pairs SP + 1
PC15 to PC8 PC15 to PC8
SP SP + 2
SP SP + 2
SP + 2
PSW
SP SP + 3

3.2.2 General-purpose registers
The general-purpose registers consist of eight 8-bit registers (X, A, C, B, E, D, L, and H).
In addition that each register can be used as an 8-bit register, two 8-bit registers in pairs can be used as a 16-bit
register (AX, BC, DE, and HL).
They can be described in terms of functional names (X, A, C, B, E, D, L, H, AX, BC, DE, and HL) and absolute
names (R0 to R7 and RP0 to RP3).
(a) Absolute names
16-bit processing 8-bit processing
RP3
R6
R5
RP2
R4
R3
RP1
R2
R1
RP0
R0
15 0 7 0
16-bit processing 8-bit processing
HL
D
DE
E
B
BC
A
AX
15 0 7 0

3.2.3 Special function registers (SFRs)
Unlike general-purpose registers, each special function register has a special function.
The special function registers are allocated in the 256-byte area FF00H to FFFFH.
The special function registers can be manipulated, like the general-purpose registers, with operation, transfer, and
bit manipulation instructions. Manipulatable bit units (1, 8, and 16) differ depending on the special function register
type.
Each manipulation bit can be specified as follows.
Describe the symbol reserved by the assembler for the 1-bit manipulation instruction operand (sfr.bit). This
manipulation can also be specified using address.
Describe the symbol reserved by the assembler for the 8-bit manipulation instruction operand (sfr). This
manipulation can also be specified using an address.
Describe the symbol reserved by the assembler for the 16-bit manipulation instruction operand. When
specifying an address, describe an even address.
Table 3-2 lists the special function registers. The meanings of the symbols in this table are as follows.
Indicates the address of the implemented special function register. The symbols shown in this column are
reserved words in the assembler, and have already been defined in the header file “sfrbit.h” in the C compiler.
Therefore, these symbols can be used as instruction operands if an assembler or integrated debugger is used.
Indicates whether the special function register in question can be read or written.
R: Read only
W: Write only
Indicates the bit units (1, 8, 16) in which the special function register in question can be manipulated.
Indicates the status of the special function register when the RESET signal is input.

Table 3-2. Special Function Register List (1/3)

Address Special Function Register (SFR) Name Symbol R/W Manipulatable Bit Unit After Reset
FF00H Port 0 P0 R/W √ √ — 00H
FF07H Receive data PID USBRD R — √ —
FF08H Receive data address 0 USBR0 USBR10 — √ √ Undefined
FF0AH Receive data address 2 USBR2 USBR32 — √ √
FF0CH Receive data address 4 USBR4 USBR54 — √ √
FF0EH Receive data address 6 USBR6 USBR76 — √ √
FF10H Transmit/receive shift register 10 SIO10 R/W — √ —
FF20H Port mode register 0 PM0 √ √ — FFH
FF21H Port mode register 1 PM1 √ √ —
FF22H Port mode register 2 PM2 √ √ —
FF24H Port mode register 4 PM4 √ √ —
FF30H Port output mode register 0 POM0 √ √ — 00H
FF31H Port output mode register 1 POM1 √ √ —
FF42H Timer clock select register 2 TCL2 — √ —
FF50H 8-bit compare register 00 CR00 W — √ — Undefined
FF51H 8-bit timer counter 00 TM00 R — √ — 00H
FF53H 8-bit timer mode control register 00 TMC00 R/W √ √ —
FF54H 8-bit compare register 01 CR01 W — √ — Undefined
FF55H 8-bit timer counter 01 TM01 R — √ — 00H
FF57H 8-bit timer mode control register 01 TMC01 R/W √ √ —
FF60H Token PID compare register TIDCMP W — √ —
FF61H Token address compare register ADRCMP — √ —

Table 3-2. Special Function Register List (2/3)
Address Special Function Register (SFR) Name Symbol R/W Manipulatable Bit Unit After Reset
1 Bit 8 Bits 16 Bits
FF62H Token packet receive result store register TRXRSL R/W √ √ — 00H
FF63H Data/handshake PID compare register DIDCMP W — √ — C3H
FF64H Data/handshake packet receive byte number counter
FF65H Data/handshake packet receive result store register
FF66H Data/handshake packet receive mode register
FF67H Packet receive status register RXSTAT — √ —
FF68H Data packet transmit byte number counter 0 DTXCO0 W — √ — 20H
FF69H Data packet transmit byte number counter 1 DTXCO1 — √ — 30H
FF6AH Remote wakeup control register REMWUP R/W √ √ — 08H
FF6BH Transmit/receive pointer USBPOW R — √ — 00H
FF6CH USB timer start reservation control register USBTCL R/W √ √ — 01H
FF6DH USB receiver enable register USBMOD √ √ — 00H
FF72H Serial operation mode register 10 CSIM10 √ √ —
FFA1H Transmit data PID bank 0 USBTD0 W — √ — Undefined
FFA2H Transmit data bank 0 address 00 USBT00 — √ —
FFA3H Transmit data bank 0 address 01 USBT01 — √ —
FFA4H Transmit data bank 0 address 02 USBT02 — √ —
FFA5H Transmit data bank 0 address 03 USBT03 — √ —
FFA6H Transmit data bank 0 address 04 USBT04 — √ —
FFA7H Transmit data bank 0 address 05 USBT05 — √ —
FFA8H Transmit data bank 0 address 06 USBT06 — √ —
FFA9H Transmit data bank 0 address 07 USBT07 — √ —
FFABH Transmit data PID bank 1 USBTD1 — √ —
FFACH Transmit data bank 1 address 10 USBT10 — √ —
FFADH Transmit data bank 1 address 11 USBT11 — √ —
FFAEH Transmit data bank 1 address 12 USBT12 — √ —
FFAFH Transmit data bank 1 address 13 USBT13 — √ —
FFB0H Transmit data bank 1 address 14 USBT14 — √ —
FFB1H Transmit data bank 1 address 15 USBT15 — √ —
FFB2H Transmit data bank 1 address 16 USBT16 — √ —
FFB3H Transmit data bank 1 address 17 USBT17 — √ —
FFB5H Receive token PID USBRTP R — √ — 00H
FFB6H Receive token address L USBRAL — √ —
FFB7H Receive token address H USBRAH — √ —
FFE0H Interrupt request flag register 0 IF0 R/W √ √ —
FFE1H Interrupt request flag register 1 IF1 √ √ —
FFE4H Interrupt mask flag register 0 MK0 √ √ — FFH
FFE5H Interrupt mask flag register 1 MK1 √ √ —

Table 3-2. Special Function Register List (3/3)

Address Special Function Register (SFR) Name Symbol R/W Manipulatable Bit Unit After Reset
FFECH External interrupt mode register 0 INTM0 R/W — √ — 00H
FFF5H Key return mode register 00 KRM00 √ √ —
FFF7H Pull-up resistor option register 0 PU0 √ √ —
FFF9H Watchdog timer mode register WDTM √ √ —
FFFAH Oscillation stabilization time select register OSTS — √ — 04H
FFFBH Processor clock control register PCC √ √ — 02H

3.3 Instruction Address Addressing
An instruction address is determined by program counter (PC) contents. PC contents are normally incremented
(+1 for each byte) automatically according to the number of bytes of an instruction to be fetched each time another
instruction is executed. When a branch instruction is executed, the branch destination information is set to the PC
and branched by the following addressing (for details of each instruction, refer to 78K/0S Series Instruction User’s
Manual (U11047E)).
[Function]
The value obtained by adding 8-bit immediate data (displacement value: jdisp8) of an instruction code to the
start address of the following instruction is transferred to the program counter (PC) and branched. The
displacement value is treated as signed two’s complement data (−128 to +127) and bit 7 becomes a sign bit.
This means that information is relatively branched to a location between −128 and +127, from the start address
of the next instruction when relative addressing is used.
This function is carried out when the BR $addr16 instruction or a conditional branch instruction is executed.
... PC is the start address of the next instruction of a BR instruction.
S
PC
When S = 0, α indicates all bits 0.
When S = 1, α indicates all bits 1.
+ · α · jdisp8

3.3.2 Immediate addressing
[Function]
Immediate data in the instruction word is transferred to the program counter (PC) and branched.
This function is carried out when the CALL !addr16 or BR !addr16 instruction is executed.
The CALL !addr16 and BR !addr16 instructions can be branched to any location in the memory space.
In case of CALL !addr16 and BR !addr16 instructions
Low Addr.
High Addr.
CALL or BR
![Page 50 of the NEC switch user manual — [Illustration]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-50.webp?w=400)
3.3.3 Table indirect addressing
[Function]
Table contents (branch destination address) of the particular location to be addressed by the lower-5-bit
immediate data of an instruction code from bit 1 to bit 5 are transferred to the program counter (PC) and
branched.
This function is carried out when the CALLT [addr5] instruction is executed. The instruction enables a branch
to any location in the memory space by referring to the addresses stored in the memory table at 40H to 7FH.
7 6 5 1 0
ta4–0 Instruction code
Effective address 0 1 0
Low Addr.
Effective address + 1
High Addr.
3.3.4 Register addressing
[Function]
Register pair (AX) contents to be specified with an instruction word are transferred to the program counter
(PC) and branched.
This function is carried out when the BR AX instruction is executed.
A X
PC
Memory (Table) · rp

3.4 Operand Address Addressing
The following methods are available to specify the register and memory (addressing) to undergo manipulation
during instruction execution.
[Function]
The memory indicated by immediate data in an instruction word is directly addressed.
addr16 Label or 16-bit immediate data
MOV A, !FE00H; When setting !addr16 to FE00H
Instruction code 0 0 1 0 1 0 0 1 Opcode
0
1 0
[Illustration]
![Page 52 of the NEC switch user manual — [Illustration]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-52.webp?w=400)
3.4.2 Short direct addressing
[Function]
The memory to be manipulated in the fixed space is directly addressed with 8-bit data in an instruction word.
The fixed space is the 256-byte space FE20H to FF1FH where the addressing is applied. An internal high-
speed RAM and special function registers (SFR) are mapped at FE20H to FEFFH and FF00H to FF1FH,
respectively.
The SFR area (FF00H to FF1FH), where short direct addressing is applied, is a part of the whole SFR area.
In this area, ports which are frequently accessed in a program and a compare register of the timer/event
counter are mapped, and these SFRs can be manipulated with a small number of bytes and clocks.
When 8-bit immediate data is at 20H to FFH, bit 8 of an effective address is set to 0. When it is at 00H to
1FH, bit 8 is set to 1. See [Illustration] below.
saddr Label or FE20H to FF1FH immediate data
saddrp Label or FE20H to FF1FH immediate data (even address only)
MOV FE30H, #50H; When setting saddr to FE30H and the immediate data to 50H
Instruction code 1 0 1 0 1
0 0 1 1 0
0 1 0 1 0
15 0 Short direct memory
Effective address 1
When 8-bit immediate data is 20H to FFH, α = 0. When 8-bit immediate data is 00H to 1FH, α = 1.
![Page 53 of the NEC switch user manual — [Illustration]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-53.webp?w=400)
3.4.3 Special function register (SFR) addressing
[Function]
The memory-mapped special function register (SFR) is addressed with 8-bit immediate data in an instruction
word.
This addressing is applied to the 240-byte spaces FF00H to FFCFH and FFE0H to FFFFH. However, the
SFR mapped at FF00H to FF1FH can be accessed with short direct addressing.
sfr Special function register name
MOV PM0, A; When selecting PM0 for sfr
Instruction code 1 1 1 0 0 1 1 1
0 0 1 0
15 0 SFR
Effective Address 1
Identifier Description · Opcode · sfr-offset
![Page 54 of the NEC switch user manual — [Description example]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-54.webp?w=400)
3.4.4 Register addressing
[Function]
In the register addressing mode, general-purpose registers are accessed as operands. The general-purpose
register to be accessed is specified by the register specification code or function name in the instruction code.
Register addressing is carried out when an instruction with the following operand format is executed. When
an 8-bit register is specified, one of the eight registers is specified with 3 bits in the instruction code.
r X, A, C, B, E, D, L, H
rp AX, BC, DE, HL
r and rp can be described by absolute names (R0 to R7 and RP0 to RP3) as well as function names (X, A, C,
B, E, D, L, H, AX, BC, DE, and HL).
MOV A, C; When selecting the C register for r
Instruction code 0 1 0 1 0
0 0 1 0 0 1 0 1
INCW DE; When selecting the DE register pair for rp
Instruction code 1 0 0 0 1 0 0 0
Identifier Description · Register specification code · Register specification code

3.4.5 Register indirect addressing
[Function]
In the register indirect addressing mode, memory is manipulated according to the contents of a register pair
specified as an operand. The register pair to be accessed is specified by the register pair specification code
in an instruction code.
This addressing can be carried out for all the memory spaces.
— [DE], [HL]
[Description example]
MOV A, [DE]; When selecting register pair [DE]
Instruction code 0 0 1 0 1 0 1 1
DE
D
E
Memory address specified with register pair DE
Addressed memory contents are transferred
Identifier Description
![Page 56 of the NEC switch user manual — [Description example]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-56.webp?w=400)
3.4.6 Based addressing
[Function]
8-bit immediate data is added to the contents of the base register, that is, the HL register pair, and the sum is
used to address the memory. Addition is performed by expanding the offset data as a positive number to 16
bits. A carry from the 16th bit is ignored. This addressing can be carried out for all the memory spaces.
[Description example]
MOV A, [HL+10H]; When setting byte to 10H
Instruction code 0 0 1 0 1 1 0 1
0 0 0 1 0
[Function]
The stack area is indirectly addressed with the stack pointer (SP) contents.
This addressing method is automatically employed when the PUSH, POP, subroutine call, and RETURN
instructions are executed or the register is saved/reset upon generation of an interrupt request.
Stack addressing can only be used to address the internal high-speed RAM area.
In the case of PUSH DE
Instruction code 1 0 1 0 1 0 1 0
Identifier Description · — [HL+byte]

4.1 Port Functions
The µPD789800 Subseries provides the ports shown in Figure 4-1, enabling various methods of control.
Numerous other functions are provided that can be used in addition to the digital I/O port functions. For more
information on these additional functions, see CHAPTER 2 PIN FUNCTIONS.
P20
P00
P26
P07
P40
P10
Port 4 Port 1
P17
Port 2 · Port 0

Table 4-1. Functions of Ports
Pin Name I/O Function After Reset Alternate
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).
When used as an output port, CMOS output or N-ch open-drain output can be specified in 8-bit units by port output mode register 0 (POM0).
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).
When used as an output port, CMOS output or N-ch open-drain output can be specified in 8-bit units by port output mode register 0 (POM0).
P21 SO10
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).
When P25 or P26 is used as an output port, CMOS output or N-ch open-drain output can be specified in 1-bit units by port output mode register 1 (POM1).
P25 —
P26
INTP0/TI01/TO01
Input KR00 to KR07
Input/output can be specified in 1-bit units.
When used as an input port, use of on-chip pull-up resistors can be specified by pull-up resistor option register 0 (PU0).

4.2 Port Configuration
Ports consists the following hardware.
Control registers Port mode register (PMm: m = 0 to 2, 4)
Pull-up resistor option register (PU0)
Parameter Configuration

4.2.1 Port 0
This is an 8-bit I/O port with an output latch. Port 0 can be specified in the input or output mode in 1-bit units by
using port mode register 0 (PM0). When the P00 to P07 pins are used as input port pins, on-chip pull-up resistors
can be connected in 8-bit units by using pull-up resistor option register 0 (PU0). CMOS output or N-ch open-drain
output can also be specified in 8-bit unit by using port output mode register 0 (POM0).
Port 0 is set in the input mode when the RESET signal is input.
Figure 4-2 shows a block diagram of port 0.
WR POM0
V DD0 POM00
WR PU0
PU00
RD
V DD0
WR PORT
Output latch (P00 to P07)

4.2.2 Port 1
This is an 8-bit I/O port with an output latch. Port 1 can be specified in the input or output mode in 1-bit units by
using port mode register 1 (PM1). When the P10 to P17 pins are used as input port pins, on-chip pull-up resistors
can be connected in 8-bit units by using pull-up resistor option register 0 (PU0). CMOS output or N-ch open-drain
output can also be specified in 8-bit unit by using port output mode register 0 (POM0).
Port 0 is set in the input mode when the RESET signal is input.
Figure 4-3 shows a block diagram of port 1.
WR POM0
V DD0 POM01
WR PU0
PU01
RD
V DD0
WR PORT
Output latch (P10 to P17)

4.2.3 Port 2
This is a 7-bit I/O port with an output latch. Port 2 can be specified in the input or output mode in 1-bit units by
using port mode register 2 (PM2). When using the P20 to P26 pins as input port pins, on-chip pull-up resistors can
be connected in 7-bit units by using pull-up resistor option register 0 (PU0).
When P25 or P26 is used, CMOS output or N-ch open-drain output can be specified in 1-bit units by using port
output mode register 1 (POM1).
The port is also used as a data I/O and clock I/O to and from the serial interface, timer I/O, and external interrupt.
This port to set to the input mode when the RESET signal is input.
Figures 4-4 through 4-9 show block diagrams of port 2.
according to the function to be used. For how to set the latches, see Table 9-2.
V DD0
WR PU0
PU02
RD
WR PORT
(P20)
P20/SCK10
WR PM
PM20

Figure 4-5. Block Diagram of P21
V DD0
WR PU0
PU02
RD
WR PORT
(P21)
P21/SO10
WR PM
PM21

Figure 4-6. Block Diagram of P22
V DD0
WR PU0
PU02
RD
WR PORT
(P22)
P22/SI10
WR PM
PM22

Figure 4-7. Block Diagram of P23 and P24
V DD0
WR PU0
PU02
RD
WR PORT
P23, P24
(P23, P24)
WR PM
PM23, PM24

Figure 4-8. Block Diagram of P25
WR POM1
V DD0 POM125
WR PU0
PU02
RD
V DD0
P25
WR PORT
(P25)
WR PM
PM25

Figure 4-9. Block Diagram of P26
WR POM1
V DD0 POM126
WR PU0
PU02
RD
V DD0
P26
WR PORT
(P26)
WR PM
PM26

4.2.4 Port 4
This is an 8-bit I/O port with an output latch. Port 4 can be specified in the input or output mode in 1-bit units by
using port mode register 4 (PM4). When using P40 to P47 pins as input port pins, on-chip pull-up resistors can be
connected in 8-bit units by using pull-up resistor option register 0 (PU0).
The port is also used as a key return input.
This port is set in the input mode when the RESET signal is input.
Figure 4-10 shows a block diagram of port 4.
set according to the function to be used. For how to set the register, see Section 11.3 (5) Key
return mode register 00 (KRM00).
V DD0
WR PU0
PU04
RD
WR KRM
KRM007
WR PORT
Output latch (P40 to P47)

4.3 Registers Controlling Port Function
The following three types of registers control the ports.
These registers are used to set port input/output in 1-bit units.
The port mode registers are independently set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets registers to FFH.
When port pins are used as alternate-function pins, set the port mode register and output latch according to
Table 4-3.
specified and the output level is changed, the interrupt request flag is set. When the
output mode is used, therefore, the interrupt mask flag should be set to 1 beforehand.
7 Symbol Address After reset 6 5 4 3 2 1 0 R/W
PM07
PM06
PM05
PM04
PM03
PM02
PM01
PM00
FF20H
FFH
R/W
PM17 PM16 PM15 PM14 PM13 PM12 PM11 PM10 PM1 FF21H FFH R/W
PM26
PM25
PM24
PM23
PM22
PM21
PM20
FF22H
FFH
R/W
PM47 PM46 PM45 PM44 PM43 PM42 PM41 PM40 PM4 FF24H FFH R/W
Pmn pin input/output mode selection
0 Output mode (output buffer on)
Input mode (output buffer off) 1
PMmn

Table 4-3. Port Mode Register and Output Latch Settings When Using Alternate Functions
Pxx PMxx Pin Name
P26 TO01 Output 0 0
TI01 Input 1 ×
INTP0 Input 1 ×
KR00 to KR07 Input 1 ×
Key return mode register 00 (KRM00)).
according to its function. For the setting method, see Table 9-2 Settings of Serial interface
10 Operating Mode.
The pull-up resistor option register (PU0) sets whether an on-chip pull-up resistor on each port is used or not.
On the port which is specified to use the on-chip pull-up resistor in the PU0, the pull-up resistor can be internally
used only for the bits set to the input mode. No on-chip pull-up resistors can be used for the bits set in the
output mode regardless of the setting PU0. This applies to the case when using the output pins for alternate
functions.
PU0 is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets PU0 to 00H.
7 6 5 3
Address After reset R/W
PU02
FFF7H 00H R/W
Pm on-chip pull-up resistor selection
(m = 0 to 2, 4)
On-chip pull-up resistor not connected
On-chip pull-up resistor connected

(3) Port output mode registers (POM0 and POM1)
The port output mode registers (POM0 and POM1) are used to switch from CMOS output to N-ch open-drain
output for port 0, port 1, pin P25, and pin P26.
Set POM0 and POM1 with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets P0M0 and POM1 to 00H.
7 6 5 4 3 2
Address After reset R/W
FF30H 00H R/W
Pm output mode selectionNote
(m = 0, 1)
7 4 3 2 1 0
Address After reset R/W
FF31H 00H R/W
Output mode selection for bit n of port 2Note
(n = 5, 6)

4.4 Port Function Operation
The operation of a port differs depending on whether the port is set to the input or output mode, as described
below.
(1) In output mode
A value can be written to the output latch of a port by using a transfer instruction. The contents of the output
latch can be output from the pins of the port.
The data once written to the output latch is retained until new data is written to the output latch.
A value can be written to the output latch by using a transfer instruction. However, the status of the port pin is
not changed because the output buffer is off.
The data once written to the output latch is retained until new data is written to the output latch.
However, this instruction accesses the port in 8-bit units. When this instruction is
executed to manipulate a bit of an input/output port, therefore, the contents of the output
latch of the pin that is set to the input mode and not subject to manipulation become
undefined.
(1) In output mode
The status of a pin can be read by using a transfer instruction. The contents of the output latch are not
changed.
The status of a pin can be read by using a transfer instruction. The contents of the output latch are not
changed.
(1) In output mode
An arithmetic operation can be performed on the contents of the output latch. The result of the operation is
written to the output latch. The contents of the output latch are output from the port pins.
The data once written to the output latch is retained until new data is written to the output latch.
The contents of the output latch become undefined. However, the status of the pin is not changed because the
output buffer is off.
However, this instruction accesses the port in 8-bit units. When this instruction is
executed to manipulate a bit of an input/output port, therefore, the contents of the output
latch of the pin that is set to the input mode and not subject to manipulation become
undefined.

5.1 Clock Generator Functions
The clock generator generates the clock to be supplied to the CPU and peripheral hardware. The following type
of system clock oscillator is used.
This circuit oscillates at 6.0 MHz. Oscillation can be stopped by executing the STOP instruction.
The clock generator consists of the following hardware.
Control register Processor clock control register (PCC)
Oscillator System clock oscillator
Clock for peripheral hardware
Prescaler System clock oscillator fX
fX 22
Wait controller CPU clock (fCPU) STOP
Processor clock control register (PCC)

5.3 Register Controlling Clock Generator
The clock generator is controlled by the following register.
PCC selects the CPU clock and sets the of division ratio.
PCC is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets the PCC to 02H.
Symbol Address After reset R/W
7 6 5 4 3 2 1 0
0 PCC1 0 PCC
PCC1
CPU clock (fCPU) selection
fX = 6.0 MHz operation
0.33 s
fX/22
1.33 s
fX · µ · µ

5.4 System Clock Oscillators
5.4.1 System clock oscillator
The system clock oscillator is oscillated by the crystal resonator (6.0 MHz TYP.) connected across the X1 and X2
pins.
An external clock can also be input to the circuit. In this case, input the clock signal to the X1 pin, and leave the
X2 pin open.
Figure 5-3 shows the external circuit of the system clock oscillator.
(a) Crystal oscillation (b) External clock
V SS0
X2 OPEN
lines in Figure 5-3 to avoid an adverse effect from wiring capacitance.
through which a high fluctuating current flows.
ground the capacitor to a ground pattern through which a high current flows.
External clock X1 · Crystal resonator

5.4.2 Examples of incorrect resonator connection
Figure 5-4 shows examples of incorrect resonator connection.
(a) Too long wiring (b) Crossed signal line
PORTn (n = 0, 1, 2, 4)
V SS0 X1 X2
(c) Wiring near high fluctuating current
(d) Current flowing through ground line of oscillator
(potential at points A, B, and C fluctuates)
V DD0
V SS0 X1 X2
V SS0 X1
A B C
Pmn · High current · High current

Figure 5-4. Examples of Incorrect Resonator Connection (2/2)
(e) Signals are fetched
V SS0 X1 X2
5.4.3 Frequency divider
The frequency divider divides the output of the system clock oscillator (fX) to generate various clocks.
The clock generator generates the following clocks and controls the operation modes of the CPU, such as the
standby mode.
The operation of the clock generator is determined by the processor clock control register (PCC), as follows.
(a) The slow mode (1.33 µs: at 6.0 MHz operation) of the system clock is selected when the RESET signal is
generated (PCC = 02H). While a low level is being input to the RESET pin, oscillation of the system clock
is stopped.
(b) Two types of minimum instruction execution time (0.33 µs and 1.33 µs: at 6.0 MHz operation) can be
selected by the PCC setting.
(c) Two standby modes, STOP and HALT, can be used.
(d) The clock pulse for the peripheral hardware is generated by dividing the frequency of the system clock. So,
the other hardware stops when the system clock stops (except for external clock pulses).

5.6 Changing Setting of CPU Clock
5.6.1 Time required for switching CPU clock
The CPU clock can be selected by using bit 1 (PCC1) of the processor clock control register (PCC).
Actually, the specified clock is not selected immediately after the setting of PCC has been changed; the old clock
is used for the duration of several instructions after that (see Table 5-2).
Set Value Before Switching Set Value After Switching
Remark Before switching, the minimum instruction execution time of the CPU clock is two clocks.
The following figure illustrates how the CPU clock switches.
V DD
RESET
<1> The CPU is reset when the RESET pin is made low on power application. The effect of resetting is released
when the RESET pin is later made high, and the system clock starts oscillating. At this time, the time during
15/fX) is automatically secured.
which oscillation stabilization (2
After that, the CPU starts instruction execution at the slow speed of the system clock (1.33 µs: at 6.0 MHz
operation).
<2> After the time required for the VDD voltage to rise to the level at which the CPU can operate at the highest
speed has elapsed, the processor clock control register (PCC) is rewritten so that the highest speed
operation can be selected.

6.1 Functions of 8-Bit Timer/Event Counters 00 and 01
The 8-bit timer/event counters (TM00 and TM01) have the following functions.
The µPD789800 Subseries is provided with a 1-channel (TM01) 8-bit timer/event counter and a 1-channel (TM00)
8-bit timer. When reading the description of TM00, “timer/event counter” should be read as “ timer”.
When the 8-bit timer/event counter is used as an interval timer, it generates an interrupt at any preset time
interval.
Minimum Interval Time Maximum Interval Time Resolution
2 6/fX (10.7 µs) 2 14/fX (2.73 ms) 2 6/fX (10.7 µs)
2 9/fX (85.3 µs) 2 17/fX (21.8 ms) 2 9/fX (85.3 µs)
Minimum Interval Time Maximum Interval Time Resolution
2 4/fX (2.67 µs) 2 12/fX (682.7 µs) 2 4/fX (2.67 µs)
2 8/fX (42.7 µs) 2 16/fX (10.9 ms) 2 8/fX (42.7 µs)
The number of pulses of an externally input signal can be measured.

(3) Square wave output
A square wave of arbitrary frequency can be output.
Minimum Pulse Width Maximum Pulse Width Resolution
2 4/fX (2.67 µs) 2 12/fX (682.7 µs) 2 4/fX (2.67 µs)
2 8/fX (42.7 µs) 2 16/fX (10.9 ms) 2 8/fX (42.7 µs)
8-bit timer/event counters 00 and 01 consist of the following hardware.
Timer counter 8 bits × 2 (TM00 and TM01)
Timer outputs 1 (TO01)
Control registers 8-bit timer mode control registers 00 and 01 (TMC00 and TMC01) Port mode register 2 (PM2)
8-bit compare register 00 (CR00)
fX/26
8-bit timer counter 00 (TM00)
fX/29
8-bit timer mode control register 00 (TMC00)

Figure 6-2. Block Diagram of 8-Bit Timer/Event Counter 01
8-bit compare register 01 (CR01)
P26 Output latch PM26
fX/24
8-bit timer counter 01 (TM01)
fX/28
TO01/P26/ INTP0/TI01
TCE01 TCL011 TCL010 TOE01
8-bit timer mode control register 01 (TMC01)
This is an 8-bit register used to compare the value set to CR0n with the 8-bit timer counter 0n (TM0n) count
value, and if they match, generate used an interrupt request (INTTM0n).
CR0n is set with an 8-bit memory manipulation instruction. Values from 00H to FFH can be set.
RESET input sets CR0n undefined.
Remark n = 0 or 1
This is an 8-bit register used to count pulses.
TM0n is read with an 8-bit memory manipulation instruction.
RESET input sets TMn to 00H.
Remark n = 0 or 1

6.3 Registers Controlling 8-Bit Timer/Event Counters 00 and 01
The following two types of registers are used to control 8-bit timer/event counters 00 and 01.
This register enables/stops operation of 8-bit timer counter 00 (TM00) and sets the counter clock of 8-bit timer
TMC00 is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets TMC00 to 00H.
Symbol Address After reset
6 5 4 3 2 1
TCE00 TCL000 0 TMC00
TCE00
8-bit timer counter 00 operation control
Operation disabled (TM00 cleared to 0)
8-bit timer 00 count clock selection
fX/26 (93.8 kHz)
fX/29 (11.7 kHz)
Refer to 6.4 Operation of 8-Bit Timer/Event Counters 00 and 01 for details.
0 · Operation enabled

(2) 8-bit timer mode control register 01 (TMC01)
TMC01 determines whether to enable or disable 8-bit timer counter 01 (TM01), specifies the count clock for the
8-bit timer/event counter, and controls the operation of the output controller.
TMC01 is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets TMC01 to 00H.
Symbol Address After reset R/W
6 5 4 3 2 1
FF57H 00H R/W
TCE01
8-bit timer counter 01 operation control
Operation disabled (TM01 is cleared to 0.)
8-bit timer/event counter 01 count clock selection TCL010
fX/24
fX/28
(23.4 kHz)
Rising edge of TI01Note
Falling edge of TI01Note
8-bit timer/event counter 01 output control
Output disabled (port mode)
Refer to 6.4 Operation of 8-Bit Timer/Event Counters 00 and 01 for details.
Operation enabled · (375 kHz) · Output enabled

(3) Port mode register 2 (PM2)
This register sets port 2 input/output in 1-bit units.
When using the P26/TO01/INTP0/TI01 pin for timer output, set P26 and the output latch of P26 to 0.
When P26/TO01/INTP0/TI01 pin is used as a timer input, set PM26 to 1.
PM2 is set by a 1-bit or 8-bit memory manipulation instruction.
RESET input sets PM2 to FFH.
7 6 5 4 R/W
3 2 1 0
1 PM26 PM25 PM24 PM23 PM22 PM21 PM20 PM2
R/W
PM26
P26 pin input/output mode selection
Output mode (output buffer on)
Input mode (output buffer off)
Symbol Address · After reset

6.4 Operation of 8-Bit Timer/Event Counters 00 and 01
6.4.1 Operation as interval timer
Interval timer repeatedly generates an interrupt at time intervals specified by the count value set to 8-bit compare
registers 00 and 01 (CR00 and CR01) in advance.
To operate the 8-bit timer/event counter as an interval timer, the following settings are required.
Disable operation of the 8-bit timer counter 0n (TM0n) by setting TCE0n (bit 7 of 8-bit timer mode control
register 0n (TMC0n)) to 0.
Set the count clock of the 8-bit timer/event counter (see Tables 6-5 and 6-6).
Set count values to CR0n.
Enable operation of TM0n by setting TCE0n to 1.
When the count value of 8-bit timer counter 0n (TM0n) matches the value set to CR0n, the value of TMn is
cleared to 0 and TM0n continues counting. At the same time, an interrupt request signal (INTTM0n) is generated.
Tables 6-5 and 6-6 show the interval time, and Figures 6-6 and 6-7 show the timing of interval timer operation.
8-bit memory manipulation instruction, an error of more than 1 clock may occur in 1 cycle after
the timer has been started. Therefore, be sure to follow the settings above when the 8-bit
timer/event counter is operating as an interval timer.
Remark n = 0 or 1
TCL000 Minimum Interval Time Maximum Interval Time Resolution
0 2 6/fX (10.7 µs) 2 14/fX (2.73 µs) 2 6/fX (10.7 µs)
1 2 9/fX (85.3 µs) 2 17/fX (21.8 ms) 2 9/fX (85.3 µs)
TCL011 TCL010 Minimum Interval Time Maximum Interval Time Resolution
0 0 2 4/fX (2.67 µs) 2 12/fX (682.7 µs) 2 4/fX (2.67 µs)
0 1 2 8/fX (42.7 µs) 2 16/fX (10.9 ms) 2 8/fX (42.7 µs)
1 0 TI01 input cycle 2 8 × TI01 input cycle TI01 input edge cycle
1 1 TI01 input cycle 2 8 × TI01 input cycle TI01 input edge cycle

Figure 6-6. Interval Timer Operation Timing of 8-Bit Timer 00

N 01 00 N 01 00 N 00 01
TCE00
INTTM00
Remark Interval time = (N + 1) × t where N = 00H to FFH

N 01 00 N 01 00 N 00 01
TCE01
INTTM01
TO01
Remark Interval time = (N + 1) × t, where N = 00H to FFH

6.4.2 Operation as external event counter (timer 01 only)
The external event counter counts the number of external clock pulses input to the TI01/P26/INTP0/TO01 pin by
using timer counter 01 (TM01).
To operate the 8-bit timer/event counter as an external event counter, the following settings are required.
Disable operation of 8-bit timer counter 01 (TM01) by setting TCE01 (bit 7 of 8-bit timer mode control
register 01 (TMC01)) to 0.
Specify the rising/falling edge of TI01 (see Table 6-6), and set TO01 to output-disabled (TOE01 (bit 0 of
TMC01) = 0).
Set count values to CR01.
Enable operation of TM01 by setting TCE01 to 1.
Each time the valid edge specified by bit 1 or 2 (TCL011 or TCL010) of TMC01 is input, the value of 8-bit timer
counter 01 (TM01) is incremented.
When the count value of TM01 matches the value set to CR01, the value of TM01 is cleared to 0 and TM01
continues counting. At the same time, an interrupt request signal (INTTM01) is generated.
Figure 6-8 shows the timing of external event counter operation (with rising edge specified).
8-bit memory manipulation instruction, an error of more than 1 clock may occur in 1 cycle after
the timer has been started. Therefore, be sure to follow the settings above when the 8-bit
timer/event counter is operating as an external event counter.
00 01 02 03 04 05 N – 1 N 00 01 02 03
N
TCE01
INTTM01
Remark N = 00H to FFH
TI01 pin input · TM01 count value

6.4.3 Operation as square-wave output (timer 01 only)
The 8-bit timer/event counter can generate output square waves of arbitrary frequency at intervals specified by
the count value set to 8-bit compare register 01 (CR01) in advance.
To operate 8-bit timer/event counter 01 as square wave output, the following settings are required.
Set P26 to output mode (PM26 = 0) and the output latch of P26 to 0.
Disable operation of 8-bit timer counter 01 (TM01) by setting TCE01 (bit 7 of 8-bit timer mode control
register 01 (TMC01)) to 0.
Set the count clock of 8-bit timer/event counter 01 (see Table 6-7) and enable output of TO01 by setting
TOE01 (bit 0 of TMC01) to 1
Set count values to CR01.
Enable operation of TM01 by setting TCE01 to 1.
When the count value of 8-bit timer counter 01 (TM01) matches the value set to CR01, the TO01/P26/INTP0/TI01
pin output will be inverted. Through application of this mechanism, square waves of any frequency can be output.
As soon as a match occurs, the TM01 value is cleared to 0, TM01 resumes counting, and an interrupt request signal
(INTTM01 is generated).
Setting bit 7 of TMC01 (TCE01) to 0 clears the square-wave output to 0.
Table 6-7 lists the square wave output range, and Figure 6-9 shows timing of square wave output.
8-bit memory manipulation instruction, an error of more than 1 clock may occur in 1 cycle after
the timer has been started. Therefore, be sure to follow the settings above when the 8-bit
timer/event counter is operating as square-wave output.
TCL011 TCL010 Minimum Pulse Width Maximum Pulse Width Resolution
0 0 2 4/fX (2.67 µs) 2 12/fX (682.7 µs) 2 4/fX (2.67 µs)
0 1 2 8/fX (42.7 µs) 2 16/fX (10.9 ms) 2 8/fX (42.7 µs)

Figure 6-9. Timing of Square-Wave Output
N 01 00 N 01 00 N 00 01
N N N N
TCE01
INTTM01
Interrupt acknowledged Interrupt acknowledged

6.5 Notes on Using 8-Bit Timer/Event Counters 00 and 01
(1) Error on starting timer
An error of up to 1 clock occurs after the timer is started until a match signal is generated. This is because 8-bit
timer counters 00 and 01 (TM00 and TM01) are started asynchronously to the count pulse.
TM00, TM01 count value
(2) Setting of 8-bit compare register
8-bit compare registers 00 and 01 (CR00 and CR01) can be set to 00H.
Therefore, one pulse can be counted when the 8-bit timer/event counter operates as an event counter.
CR00, CR01 00H
TM00, TM01 count value 00H

7.1 Watchdog Timer Functions
The watchdog timer has the following functions.
register (WDTM).
The watchdog timer is used to detect inadvertent program loops. When an inadvertent loop is detected, a non-
maskable interrupt or the RESET signal can be generated.
Operation at fX = 6.0 MHz
2 11 × 1/fX 341 µs
2 13 × 1/fX 1.37 ms
2 15 × 1/fX 5.46 ms
2 17 × 1/fX 21.8 ms
The interval timer generates an interrupt at arbitrary intervals set in advance.
Interval Time Operation at fX = 6.0 MHz
2 11 × 1/fX 341 µs
2 13 × 1/fX 1.37 ms
2 15 × 1/fX 5.46 ms
2 17 × 1/fX 21.8 ms
Inadvertent Loop · Detection Time

7.2 Watchdog Timer Configuration
The watchdog timer consists of the following hardware.
Control register Timer clock select register 2 (TCL2) Watchdog timer mode register (WDTM)
fX 24
fX 26 fX 28 fX 210
INTWDT maskable interrupt request
RESET
INTWDT non-maskable interrupt request
RUN
WDTM4 WDTM3
Timer clock select register 2 (TCL2)
Watchdog timer mode register (WDTM)

7.3 Registers Controlling Watchdog Timer
The following two registers are used to control the watchdog timer.
This register sets the watchdog timer count clock.
TCL2 is set with an 8-bit memory manipulation instruction.
RESET input sets TCL2 to 00H.
7 6 5 4 3 2 1 0
0 TCL22 TCL21 TCL20 TCL2
R/W
TCL22
TCL21
TCL20
Watchdog timer count clock selection Interval time
fX/24
211/fX
fX/26
213/fX
(1.37 ms)
(93.8 kHz)
fX/28
(23.4 kHz)
215/fX
(5.46 ms)
fX/210
(5.86 kHz)
217/fX
(21.8 ms)

(2) Watchdog timer mode register (WDTM)
This register sets the operation mode of the watchdog timer, and enables/disables counting of the watchdog
timer.
The WDTM is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets the WDTM to 00H.
Symbol Address After reset R/W
6 5 4 3 2 1 0
RUN 0 0 WDTM4 WDTM3 0 0 0 WDTM
RUN
Selection of operation of watchdog timerNote 1
Clear counter and start counting
WDTM4 Selection of operation mode of watchdog timerNote 2 WDTM3
Interval timer mode (overflow and maskable interrupt occur)Note 3
Watchdog timer mode 1 (overflow and non-maskable interrupt occur)
Watchdog timer mode 2 (overflow occurs and reset operation started)
started, it cannot be stopped by any means other than RESET input.
to 0.8% shorter than the time set by timer clock select register 2 (TCL2).
interrupt request flag register 0 (IF0)) is set to 0. While TMIF4 is 1, a non-maskable
interrupt is generated upon write completion if watchdog timer mode 1 or 2 is
selected.
Stop counting · Operation disabled

7.4 Watchdog Timer Operation
7.4.1 Operation as watchdog timer
The watchdog timer detects an inadvertent program loop when bit 4 (WDTM4) of the watchdog timer mode
register (WDTM) is set to 1.
The count clock (inadvertent loop detection time interval) of the watchdog timer can be selected by bits 0 to 2
(TCL20 to TCL22) of timer clock select register 2 (TCL2). By setting bit 7 (RUN) of WDTM to 1, the watchdog timer
is started. Set RUN to 1 within the set inadvertent loop detection time interval after the watchdog timer has been
started. By setting RUN to 1, the watchdog timer can be cleared and start counting. If RUN is not set to 1, and the
inadvertent loop detection time is exceeded, the system is reset or a non-maskable interrupt is generated by the
value of bit 3 (WDTM3) of WDTM.
The watchdog timer continues operation in the HALT mode, but stops in the STOP mode. Therefore, set RUN to
1 before entering the STOP mode to clear the watchdog timer, and then execute the STOP instruction.
TCL22 TCL21 TCL20 Inadvertent Loop Detection Time Operation at fX = 6.0 MHz
0 0 0 2 11 × 1/fX 341 µs
0 1 0 2 13 × 1/fX 1.37 ms
1 0 0 2 15 × 1/fX 5.46 ms
1 1 0 2 17 × 1/fX 21.8 ms

7.4.2 Operation as interval timer
When bit 4 (WDTM4) and bit 3 (WDTM3) of the watchdog timer mode register (WDTM) are set to 0 and 1,
respectively, the watchdog timer also operates as an interval timer that repeatedly generates an interrupt at time
intervals specified by a count value set in advance.
Select the count clock (or interval time) by setting bits 0 to 2 (TCL20 to TCL22) of timer clock select register 2
(TCL2). The watchdog timer starts operation as an interval timer when the RUN bit (bit 7 of WDTM) is set to 1.
In the interval timer mode, the interrupt mask flag (TMMK4) is valid, and a maskable interrupt (INTWDT) can be
generated. The priority of INTWDT is set as the highest of all the maskable interrupts.
The interval timer continues operation in the HALT mode, but stops in the STOP mode. Therefore, set RUN to 1
before entering the STOP mode to clear the interval timer, and then execute the STOP instruction.
interval timer mode is not set, unless the RESET signal is input.
the set time.
TCL22 TCL21 TCL20 Interval Time Operation at fX = 6.0 MHz
0 0 0 2 11 × 1/fX 341 µs
0 1 0 2 13 × 1/fX 1.37 ms
1 0 0 2 15 × 1/fX 5.46 ms
1 1 0 2 17 × 1/fX 21.8 ms

8.1 USB Overview
The USB (Universal Serial Bus) is suitable for connecting personal computers and external devices such as audio
equipment, keyboards, pointing devices, and telephones. Two data transfer rates, 12 Mbps and 1.5 Mbps, are
provided.
Plug & Play can also be realized.
Figure 8-1 shows an example of USB connection to a desktop PC. The USB consists of the host controller
installed in the PC, hubs installed for port expansion and connection, and functions installed at bus ends. These
functions are called endpoints and are the data transfer destinations or data transfer sources in the USB.
Function (monitor) Function (modem)
Function (keyboard) Function (mouse)
Function (CD-ROM) Function Function

8.2 USB Function Features
The features of the on-chip USB function provided for the µPD789800 Subseries are described below.
(1) Video display devices and human interface devices are assumed to be the target applications. For this
reason, only Endpoint 0 for control transfer and Endpoint 1 for interrupt transfer are supported.
(2) 1.5 Mbps (low speed) data transfer using a 6.0 MHz system clock is supported.
(3) The following buffers are provided on-chip.
(4) NRZI (Non Return to Zero Invert) decode/encode function specified by the USB communication protocol, bit
stuffing function, and on-chip CRC (Cyclic Redundancy Check) function are also provided and automatically
executed.
The USB function consists of the following hardware.
Buffer Receive bank switching ID detection buffer (internal buffer)
Registers Transmit/receive pointer (USBPOW) Receive token PID (USBRTP) Receive token address L, H (USBRAL, USBRAH) Receive data PID (USBRD) Receive data address (USBR0 to USBR7) Transmit data PID bank 0 (USBTD0) Transmit data bank 0 address (USBT00 to USBT07) Transmit data PID bank 1 (USBTD1) Transmit data bank 1 address (USBT10 to USBT17) Data/handshake packet receive byte number counter (DRXCON) Data packet transmit byte number counter 0, 1 (DTXCO0, DTXCO1) Token PID compare register (TIDCMP) Token address compare register (ADRCMP) Data/handshake PID compare register (DIDCMP)
Transmit data bank 0
Transmit data bank 1
Control registers USB receiver enable register (USBMOD) Data/handshake packet receive mode register (URXMOD) Packet receive status register (RXSTAT) Data/handshake packet receive result store register (DRXRSL) Token packet receive result store register (TRXRSL) Data packet transmit reservation register (DTXRSV) Handshake packet transmit reservation register (HTXRSV) USB timer start reservation control register (USBTCL) Remote wakeup control register (REMWUP)
Item Configuration · Receive token bank · Receive data bank

Figure 8-2. Block Diagram of USB Function
USB receiver enable register
Data/handshake packet receive mode register (URXMOD)
DTXRSV)
(USBPOB, USBPOW) Remote wakeup
Resume & reset detection control
SYNC detection/ USB clock generator
switching ID detection buffer
USB timerNote 4
Compare registerNote 2
CRC circuit ENDP detector
USB timer start reservation control
Receive result store registerNote 3
counter 0, 1 (DTXCO0, DTXCO1)
PID compare register (DIDCMP)

Figure 8-3. Block Diagram of USB Timer
INTUSBTM
UWDERR
RESUME RXNote Clear circuit
TX MASTER ENNote
USB timer start reservation control register (USBTCL)

(1) Receive bank switching ID detection buffer (internal buffer)
This is an internal 2-bit buffer placed before a receive buffer. It detects the lower 2 bits below the packet ID
during packet reception and determines the store bank of a packet.
The following controls are performed depending on the stored 2-bit data. For details, see Section 8.5.3 Receive
bank switching ID detection buffer operation.
If the first 2 bits of the stored bits (lower 2 bits in ID area) are 01B, TOSTAT (bit 0 of the packet receive
status register (RXSTAT)) indicating token packet reception is set and a signal specifying packet store
at the receive token address is output to the transmit/receive pointer.
If the first 2 bits of the stored bits are 11B, DASTAT (bit 1 of RXSTAT) indicating data packet reception
is set and a signal specifying packet store at the receive data address is sent to the transmit/receive
pointer.
If the first 2 bits of the stored bits are 10B, HSSTAT (bit 2 of RXSTAT) indicating handshake packet
reception is set and a signal specifying packet store at the receive data address is output to the
transmit/receive pointer.
The USBPOB is a pointer on the bit side in the transmit/receive buffer and the USBPOW is a pointer on the
word side of the transmit/receive buffer. USBPOB and USBPOW output a control signal to the CRC circuit, etc.
They are reset and started by the packet ID detection signal from the receive bank switching ID detection buffer.
USBPOB is incremented by the USB clock. USBPOW is incremented by USBPOB overflow.
USBPOW is read with an 8-bit memory manipulation instruction. As USBPOB is an internal pointer, control with
software is not possible.
RESET input sets these pointers to 00H.
The value of USBPOW is changed as follows depending on the receive/transmit byte length match signal or
transmit reservation. Moreover, control signals are also output. For details, see Section 8.8.1 Operation of
transmit/receive pointer.
are set to 00H.
pointers are set to 10H.
output.
and USBPOW is set to 70H.
(DRXCON), a signal specifying CRC16 comparison start is output when USBPOB overflows, and USBPOW
is set to 70H.
USBPOW is set to 20H, 30H, 40H, 50H, or 60H depending on the error between the present transmit
reservation and previous receive data, when USBPOB overflows.
packet transmit byte number counter 1 (DTXCO1), USBPOW is set to 70H when USBPOB overflows (CRC
redundant bits are appended).
overflows.

(3) Receive token bank
(a) Receive token PID (USBRTP)
This is the receive token packet ID area. The data input to the token PID compare register (TIDCMP) is
stored here.
USBRTP is read with an 8-bit memory manipulation instruction.
RESET input sets USBRTP to 00H.
This stores the token packet to be transferred from the host. USBRAL and USBRAH consist of 16 bits.
Bits 0 to 6 of USBRAL store the data input to the token address compare register (ADRCMP).
Both USBRAL and USBRAH are read with an 8-bit memory manipulation instruction.
RESET input sets these registers to 00H.
07H 06H 05H 04H 03H 02H 01H 00H
00H
USBRTP
USBRAL
01H
USBRAH
Endpoint area Fixed to 0

(4) Receive data bank
(a) Receive data PID (USBRD)
This is the receive data packet ID area. The data input to the data/handshake PID compare register
(DIDCMP) is stored here.
USBRD is read with an 8-bit memory manipulation instruction.
RESET input sets USBRD to 00H.
This is an 8-byte register that stores the data/handshake packet transferred from the host.
USBR0 to USBR7 are read with an 8-bit memory manipulation instruction.
If the following combinations are used, they are read with a 16-bit memory manipulation instruction.
RESET input makes USBR0 to USBR7 undefined.
07H 06H 05H 04H 03H 02H 01H 00H
USBRD
10H
USBR0
11H
USBR1
12H
USBR2
13H
USBR3
Data area (8 bytes)
USBR4
15H
USBR5
16H
USBR6
17H
USBR7
18H
The operation during reception appears as follows.
Packet from host controller
OUT DATA1
ACK
ACK
USBT00
USBT07
The data packet from the host controller is stored in the USBT00 to USBT07 registers.

(5) Transmit data banks 0 and 1
(a) Transmit data PID banks 0 and 1 (USBTD0 and USBTD1)
USBTD0 and USBTD1 correspond to the transmit buffer 0 ID area and transmit buffer 1 ID area,
respectively. USBTD0 and USBTD1 store DATA0 (C3H) or DATA1 (4BH).
USBTD0 and USBTD1 are set with an 8-bit memory manipulation instruction.
RESET input makes both USBTD0 and USBTD1 undefined.
(b) Transmit data bank 0 address (USBT00 to USBT07) and transmit data bank 1 address (USBT10 to
These are 8-byte registers that store the data to be transferred to the host. USBT00 to USBT07 and
USBT10 to USBT17 correspond to transmit buffer 0 of the data area and transmit buffer 1 of the data area,
respectively. Because CRC redundant bits (16 bits) are always appended to packets sent from these
registers, these registers cannot be used for transmitting handshake packets.
USBT00 to USBT07 and USBT10 to USBT17 are set with an 8-bit memory manipulation instruction.
RESET input makes this area undefined.
07H 06H 05H 04H 03H 02H 01H 00H
USBTD0
20H
USBT00
21H
USBT01
22H
USBT02
23H
USBT03
Data area (8 bytes)
USBT04
25H
USBT05
26H
USBT06
27H
USBT07
28H

Figure 8-7. Configuration of Transmit Data Bank 1 (Buffer 1)
Symbol 07H 06H 05H 04H 03H 02H 01H
USBTD1
30H
USBT10
31H
USBT11
32H
USBT12
33H
USBT13
Data area (8 bytes)
USBT14
35H
USBT15
36H
USBT16
37H
USBT17
38H
The operation during transmission appears as follows.
ACK Packet from host controller
IN
ACK
DATA0
DATA1
USBT00
USBT07
USBT10
USBT10
USBT17
Data is read according to the data sequence in the control read data stage and is transmitted to the host. In the
DATA0 sequence, the values saved in USBT00 to USBT07 are transmitted in sequence to the host. In the
DATA1 sequence, the values saved in USBT10 to USBT17 are transmitted in sequence to the host.

(6) Data/handshake packet receive byte number counter (DRXCON)
This register sets the number of data of the data/handshake packet to be received. During data/handshake
packet reception, if this register value and the transmit/receive pointer (USBPOW) value match, a match signal
is output from the comparator.
During data packet reception, set the USBPOW address at which the last byte before the appended CRC
redundant bits is stored to DRXCON. When a handshake packet is received, set DRXCON to 10H.
DRXCON is set with an 8-bit memory manipulation instruction.
RESET input sets DRXCON to 18H.
(7) Data packet transmit byte number counters 0 and 1 (DTXCO0 and DTXCO1)
DTXCO0 sets the data packet data number of transmit data bank 0 and DTXCO1 sets the transmit data number
of transmit data bank 1. During data packet transmission, if these register values and the transmit/receive
pointer (USBPOW) value match, a match signal is output from the comparator.
The value to be set to these registers is the USBPOW address (buffer 0: 20H to 28H, buffer 1: 30H to 38H) at
which the last byte before the appended CRC redundant bits is stored.
DTXCO0 and DTXCO1 are set with an 8-bit memory manipulation instruction.
RESET input sets DTXCO0 to 20H and DTXCO1 to 30H.
This register sets the token packet ID to be received. If this register value and the value of the receive token
PID (USBRTP) match during token packet reception match, TIDRST (bit 1 of the token packet receive result
store register (TRXRSL)) is set.
TIDCMP is set with an 8-bit memory manipulation instruction.
RESET input sets TIDCMP to 00H.
SETUP reception

(9) Token address compare register (ADRCMP)
This register sets the address specified from the host during control transfer. If this register value and the
address area of the receive token bank (bits 0 to 6 of receive token address L (USBRAL)) match during token
packet reception coincide, ADRRST (bit 2 of the token packet receive result store register (TRXRSL)) is set.
00H must be set by software when an USB reset is received.
ADRCMP is set with an 8-bit memory manipulation instruction.
RESET input sets ADRCMP to 00H.
07H 06H 05H 04H 03H 02H 01H 00H
USBRTP
00H
USBRAL
ENDP.0
01H
USBRAH
ENDP.3-1
02H
Match signal (TIDRST) SETUP packet detection signal (SETRX)
0 0 1 0 1 1 0 1
IN packet detection signal (INRX)
ID packet set in TIDCMP
0 1 1 0 1 0 0 1
OUT packet detection signal (OUTRX)
1 1 1 0 1
ADRCMP
Endpoint 0 detection signal (END0RX)
Endpoint 1 detection signal (END1RX)

(10) Data/handshake PID compare register (DIDCMP)
This register sets the data/handshake packet ID to be received. If this register value and the value of the
receive data PID (USBRD) match during data/handshake packet reception coincide, the DIDRST (bit 1 of the
data/handshake packet receive result store register (DRXRSL)) is set.
DIDCMP is set with an 8-bit memory manipulation instruction.
RESET input sets DIDCMP to C3H.
07H 06H 05H 04H 03H 02H 01H 00H
USBRD
00H
11H
Data area (8 bytes)
DIDCMP

8.4 Registers Controlling USB Function
The following nine registers are used to control the USB function.
This register controls USB receiver operation and halt.
Because a single-ended receiver does not have an enable flag, regular operation is possible. Thus reception of
the USB reset signal, Resume signal, and EOP signal for bus idle can be performed any time.
USBMOD is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets USBMOD to 00H.
Symbol 6 7 5 4 3 2 1
USBMOD
0 0 0 0 0 0 0 RXEN
FF6DH
00H
R/W
RXEN USB receiver operation control
USB receiver operation is stopped.
USB receiver operation is possible.
This register sets the data/handshake packet receive mode.
Bit 0 (DWRMSK) is set while saving a data packet and prevents an address greater than 11H in the receive
data address from being overwritten when the next packet is received.
Bit 1 (DINTEN) is a flag used to set the receive status synchronous interrupt (to generate the INTUSBRD
interrupt request to perform data packet reception and data save simultaneously).
Bit 2 (RESMOD) is a flag used to switch the detection mode of the USB reset signal between bus idle mode and
bus suspend mode.
URXMOD is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets URXMOD to 00H.
Address · After reset · SETUP reception

Figure 8-11. Format of Data/Handshake Packet Receive Mode Register
Symbol 6 7 5 4 3
URXMOD
0 0 0 0 0 RESMOD DINTEN DWRMSK
FF66H
00H
R/W
RESMOD USB reset signal detection mode setting
Reject USB reset signal less than 3.0 s SE0 (Single-ended 0) period.
Detect transition from J state to SE0 as USB reset signal.
DINTEN Data packet receive status synchronous interrupt enable flag
Do not generate data packet receive status synchronous interrupt.
Generate data packet receive status synchronous interrupt Note 3.
DWRMSK Data/handshake packet write disable setting
Enable write operation to all addresses in data/handshake packet receive buffer.
Disable write operation to addresses greater than 11H in data/handshake packet receive buffer.
idle mode. And do not set data immediately before entering bus suspend mode. Clear
immediately when returning from the bus suspend mode.
USB reset signal has been input by checking the URESRX flag (bit 4 of the USB receive status
register (RXSTAT)) more than once by software.
packet receive interrupt (INTUSBRD) signal input.
Sync Data0 Data1 DataX CRC16 EOP
INTUSBRD (DINTEN = 1)
Data packet receive status synchronous interrupt
Data/handshake packet receive interrupt

(3) Packet receive status register (RXSTAT)
This register indicates the receive status of each packet.
Bits 0 to 2 (TOSTAT, DASTAT, and HSSTAT) are flags that indicate that a token packet, data packet, or
handshake packet is currently being received. These flags are set upon detection of a packet ID by an ID
detection buffer, and cleared upon reception of EOP.
Bits 3 to 6 (EOPRX, URESRX, SE0RX, RESMRX) are flags that detect bus status transition. These flags are
set immediately after each bus transition is detected. These flags are cleared by software but cannot be set to 1
by software.
Bit 7 (UWDERR) is set if an inadvertent program loop is detected by the USB timer. The flags are cleared by
software. UWDERR cannot be set by software. An inadvertent program loop of the USB timer means a status
in which the USB clock does not stop when EOP cannot be detected in a packet received from the host, or
when noise on the bus was detected as a bus status transition.
RXSTAT is set with an 8-bit memory manipulation instruction.
RESET input sets RXSTAT to 00H.

Figure 8-12. Format of Packet Receive Status Register
Symbol 6 7 5 4 3 2 1 0
RXSTAT
UWDERR RESMRX SE0RX URESRX EOPRX HSSTAT DASTAT TOSTAT
FF67H
00H
R/W
UWDERR USB timer inadvertent program loop detection
No USB timer inadvertent program loop was detected.
USB timer inadvertent program loop (USB clock operation faster than 85.3 s (at 6.0 MHz)) was detected, forcibly terminating USB clock. This flag is also set when USB reset or Resume signal was received.
RESMRX Resume signal receive status
No Resume signal was received.
Received Resume signal (level detection)
SE0RX Single-ended 0 signal detection status
No Single-ended 0 (SE0) signal was detected.
Detected SE0 signal one or more times
URESRX USB reset signal detection status
No USB reset signal was detected.
Detected USB reset signal one or more times
EOPRX EOP detection status
No EOP signal was detected.
Detected EOP one or more times
HSSTAT Handshake packet receive status
No handshake packet was received.
DASTAT Data packet receive status
No data packet was received.
TOSTAT Token packet receive status
No token packet was received.

Table 8-2 shows the state of each flag after receiving the USB reset signal and the Resume signal during the
bus idle state and bus suspend state.
Table 8-2. Flag of RXSTAT After Reception of USB Reset Signal and Resume Signal
Bus State Device State Received Signal RESMRX SE0RX URESRX
USB reset 0 1 1 Idle Main system clock operation mode Resume 1 1 0
USB reset 0 1 1 Suspend STOP mode
Resume 1 1 0
This register stores the data/handshake packet reception result.
Register contents are updated upon reception of data/handshake EOP.
DRXRSL is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets DRXRSL to 00H.
Symbol 4 3 2 0
DRXRSL
CR16ER DBITER DBYER 0 0 0 DIDRST 0
FF65H
00H
R/W
CR16ER CRC error detection (16-bit mode)
CRC error did not occur in received data packet.
CRC error occurred in received data packet.
DBITER Bit stuffing error detection
Bit stuffing error did not occur in received data/handshake packet.
Bit stuffing error occurred in received data/handshake packet.
DBYER Received data/handshake packet length error detection
Packet length of received data/handshake packet is normal.
Packet length of received data/handshake packet is abnormal.
DIDRST Data/handshake packet ID comparison result
Received data/handshake packet ID and value of data/handshake PID compare register (DIDCMP) do not match.
Received data/handshake packet ID and value of DIDCMP match.
This register stores the token packet reception status.
Register contents are updated upon reception of token packet EOP.
TRXRSL is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets TRXRSL to 00H.
Address · After reset

Figure 8-14. Format of Token Packet Receive Result Store Register
Symbol
TRXRSL
CRC5ER TBITER TBYER END1RX END0RX ADRRST TIDRST SETRX
FF62H
00H
R/W
CRC5ER CRC error detection (5-bit mode)
CRC error did not occur in received token packet.
CRC error occurred in received token packet.
TBITER Bit stuffing error detection
Bit stuffing error did not occur in received token packet.
Bit stuffing error occurred in received token packet.
TBYER Received token packet length error detection
Packet length of received token packet is normal.
Packet length of received token packet is abnormal.
END1RX Endpoint 1 reception detection
No token packet corresponding to Endpoint 1 is received.
Token packet corresponding to Endpoint 1 was received.
END0RX Endpoint 0 reception detection
No token packet corresponding to Endpoint 0 is received.
Token packet corresponding to Endpoint 0 was received.
ADRRST Token packet address compare result
Received token packet address and value of token address compare register (ADRCMP) do not match.
Received token packet address and value of ADRCMP match.
TIDRST Token packet ID compare result detection
Received token packet ID and value of token PID compare register (TIDCMP) do not match.
Received token packet ID and value of TIDCMP match.
SETRX Setup token packet reception detection
Received token packet ID is other than Setup packet.
Received token packet ID is Setup packet Note.
Address · After reset

(6) Data packet transmit reservation register (DTXRSV)
This register sets the bank where the data packet to be transmitted is stored. By setting each flag of this
register, the stored data is transmitted following normal reception of the IN token packet.
DTXRSV is set with a 1-bit or 8-bit memory manipulation instruction. When DTXRSV is used in combination
with the handshake packet transmit reservation register (HTXRSV) as the 16-bit register USBCON, DTXRSV is
set with a 16-bit memory manipulation instruction.
RESET input sets DTXRSV to 00H.
Symbol 6 7 5 4 3 2 1 0
DTXRSV
0 0 0 0 DT11EN DT10EN DT01EN DT00EN
FF15H
00H
R/W
DT11EN Transmit reservation flag for transmit bank 1 (Endpoint 1)
No data is transmitted.
Stored data is transmitted when all the following conditions are satisfied in EOP during IN packet reception. Setting is disabled during control read transmission. INRX (Internal signal) = 1, ADRRST = 1, END1RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
DT10EN Transmit reservation flag for transmit bank 1 (Endpoint 0)
No data is transmitted.
Stored data is transmitted when all the following conditions are satisfied in EOP during IN packet reception. INRX (internal signal) = 1, TIDRST = 1, ADRRST = 1, END0RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
DT01EN Transmit reservation flag for transmit buffer 0 (Endpoint 1)
No data is transmitted.
Stored data is transmitted when all the following conditions are satisfied in EOP during IN packet reception. Setting is disabled during control read transmission. INRX (internal signal) = 1, ADRRST = 1, END1RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
DT00EN Transmit reservation flag for transmit buffer 0 (Endpoint 0)
No data is transmitted.
Stored data is transmitted when all the following conditions are satisfied in EOP during IN packet reception. INRX (internal signal) = 1, TIDRST = 1, ADRRST = 1, END0RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
SETUP reception · Address · After reset

(7) Handshake packet transmit reservation register (HTXRSV)
This register sets the handshake packet to be transmitted. By setting each flag of this register, a handshake
packet is transmitted following normal reception of an IN packet, or normal or abnormal reception of a data
packet.
Bit 0 corresponds to the ACK packet transmit reservation flag, bits 1 to 3 correspond to the NAK packet transmit
reservation flag, and bits 4 to 7 correspond to the STALL packet transmit reservation flag.
HTXRSV is set with a 1-bit or 8-bit memory manipulation instruction. When HTXRSV is used in combination
with the data packet transmit reservation register (DTXRSV) as the 16-bit register USBCON, HTXRSV is set
with a 16-bit memory manipulation instruction.
RESET input sets HTXRSV to 00H.
Symbol 6 7 5 4 3 2 1 0
HTXRSV
E1STEN E0STEN DSTEN STALEN E1NAEN E0NAEN DNAEN ACKEN
FF14H
00H
R/W
E1STEN STALL packet transmit reservation flag for Endpoint 1 after IN packet
No data is transmitted.
STALL handshake is transmitted when all the following conditions are satisfied in EOP during IN packet reception.
INRX (internal signal) = 1, ADRRST = 1, END1RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
E0STEN STALL packet transmit reservation flag for Endpoint 0 after IN packet
No data is transmitted.
STALL handshake is transmitted when all the following conditions are satisfied in EOP during IN packet reception.
INRX (internal signal) = 1, TIDRST = 1, ADRRST = 1, END0RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
DSTEN STALL packet transmitted reservation flag for data packet receive byte length error
No data is transmitted.
STALL handshake is transmitted when all the following conditions are satisfied in EOP during data packet reception.
Set this flag to transmit STALL handshake when byte length error has occurred in one data packet during
control write transfer.
DIDRST = 1, DBYER = 1, DBITER = 0
STALEN STALL packet transmit reservation flag after data packet
No data is transmitted.
STALL handshake is transmitted when all the following conditions are satisfied in EOP during data packet reception.
Set this flag when length error of transfer occurs in control write transfer.
SETUP reception · Address · After reset

Figure 8-16. Format of Handshake Packet Transmit Reservation Register (2/2)
E1NAEN NAK packet transmit reservation flag for Endpoint 1 after IN packet
No data is transmitted.
NAK handshake is transmitted when all the following conditions are satisfied in EOP during IN packet reception. INRX (internal signal) = 1, ADRRST = 1, END1RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
E0NAEN NAK packet transmit reservation flag for Endpoint 0 after IN packet
No data is transmitted.
NAK handshake is transmitted when all the following conditions are satisfied in EOP during IN packet reception. INRX (internal signal) = 1, TIDRST = 1, ADRRST = 1, END0RX = 0, TBYER = 0, TBITER = 0, CRC5ER = 0
DNAEN NAK packet transmit reservation flag after data packet reception
No data is transmitted.
If all the following conditions are met, NAK handshake is transmitted in EOP during data packet reception. Set this flag when saving data from reception data addresses (USBR0 to USBR7). OUTRX (internal signal) = 1, DIDRST = 1, DBYER = 0, DBITER = 0, CR16ER = 0, UWDERR = 0
ACKEN ACK packet transmit reservation flag after data packet reception
No data is transmitted.
ACK handshake is transmitted when all the following conditions are satisfied in EOP during data packet reception. DIDRST = 1, DBYER = 0, DBITER = 0, CR16ER = 0
During transmit reservation, all the conditions listed in Table 8-3 below must be satisfied.
(a) Transmit reservation for Endpoint 0 and IN token packet
Type of Reservation DT00EN DT10EN E0STEN E0NAEN
Transmit reservation of data in transmit buffer 0 1 0 0 0
Transmit reservation of data in transmit buffer 1 0 1 0 0
Endpoint 0 STALL transmit reservation (occurrence of length error, or halt status)
0 0 1 0
Endpoint 0 NAK transmit reservation (data creation incomplete)
0 0 0 1
Two or more reservations above Setting prohibited

Table 8-3. Conditions in Transmit Reservation (2/2)
(b) Transmit reservation for Endpoint1 and IN token packet

Transmit reservation of data in transmit buffer 0 1 0 0 0
Transmit reservation of data in transmit buffer 1 0 1 0 0


receive mode register (URXMOD)) at the same time.

Figure 8-17. Configuration of Handshake Packet Transmit Reservation Register
E1STEN E1NAEN E0NAEN DNAEN ACKEN E0STEN DSTEN STALEN
END1RX
END0RX
TIDRST
ADRRST
TBYER TBITER CRC5ER
TX MASTER ENNote
DBYER DBITER
CR16ER
IN RXNote · JUDGE TOKENNote · JUDGE DATANote

(8) USB timer start reservation control register (USBTCL)
This register reserves USB timer start after reception of a SETUP/OUT packet or transmission of a data packet.
USBTCL is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets USBTCL to 01H.
Symbol 6 7 5 4 3 2 1 0
USBTCL
0 0 0 0 0 0 DATATX SETORX
FF6CH
01H
R/W
DATATX USB timer start reservation after data packet transmission
Do not start USB timer.
USB timer starts when all the following conditions are satisfied in EOP during data packet transmission. DIDRST = 1, DBYER = 0, DBITER = 0, CR16ER = 0
SETORX USB timer start reservation after SETUP/OUT token packet reception
Do not start USB timer.
USB timer starts when all the following conditions are satisfied in EOP during SETUP/OUT token packet reception.
OUTRX (internal signal) = 1 or SETRX = 1, ADRRST = 1, END0RX = 1, TBYER = 0, TBITER = 0, CRC5ER = 0
SETUP reception · Address · After reset

(9) Remote wake-up control register (REMWUP)
This register transmits the Resume signal to perform remote wakeup.
Remote wakeup must be performed after confirming that bus idle has continued longer than 5 ms.
REMWUP is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets REMWUP to 08H.
Symbol 6 7 5 4
REMWUP
0 0 0 0 PULLDM PULLDP PULLEN WAKEUP
FF6AH
08H
R/W
PULLDM D- lead low/high fixed output setting
D- (TXDM) is fixed to low output.
D- (TXDM) is fixed to high output.
PULLDP D+ lead low/high fixed output setting
D+ (TXDP) is fixed to low output.
D+ (TXDP) is fixed to high output.
PULLEN D+/D- lead fixed output enable
Output from transmit buffer is input to USB driver.
Level set to PULLDP or PULLDM is input to USB driver.
WAKEUP Wakeup signal output
No data is sent.
Pin status set to PULLDP or PULLDM is output.
Address · After reset

8.5 USB Function Operation
8.5.1 USB timer operation
The USB timer is a 7-bit counter that performs time management during packet transmission and reception and
inadvertent program loop detection of the USB clock.
The USB timer has two modes: high-speed mode (source clock = fX) and low-speed mode (source clock = USB
clock: fX = 1.5 MHz during 6.0 MHz operation). In the high-speed mode, the USB functions as a 6-bit counter.
High-speed mode is used for time management during packet transmission and reception. The timer starts after
EOP reception or data packet EOP transmission. The start condition is set by the USB timer start reservation control
register (USBTCL).
Low-speed mode is used for detecting inadvertent program loops of the USB clock. The timer starts upon
detection of the SYNC signal of a receive packet, or upon reception of the USB reset or Resume signals.
When the USB timer overflows, an interrupt request signal (INTUSBTM) is generated, regardless of whether the
current mode is the high-speed or low-speed mode. When overflow of the USB timer occurs in the low-speed mode,
UWDERR (bit 7 of the packet receive status register (RXSTAT)) is set, allowing detection of an inadvertent loop of
the USB timer. At this time, the USB clock is forcibly stopped.
Figure 8-20 shows the operation flowchart of the USB timer.

Figure 8-20. Flowchart of USB Timer Operation (1/2)
N
2 Y
USB timer start (low-speed mode)
Y
N
Y
SETUP/OUT
N
UWDERR set (inadvertent program
N
N
Y
Y
N
Y
N
Y
DATA TX (internal signal)
Y

Figure 8-20. Flowchart of USB Timer Operation (2/2)
USB timer start (high-speed mode)
N Y
Y

8.5.2 Remote wakeup control operation
Figure 8-21. Flow Chart of Remote Wakeup Control Operation
N
Y
N Is bus idle duration longer
Did HOST output USB reset or
Y
Y
PULLDP = 0 PULLDM = 1
PULLDP = 0 PULLDM = 1
Resume outputNote 1
PULLEN = 1 WAKEUP = 1
REMWUP ← A
N
10 ms to 15 ms elapsed?
WAKEUP = 0
Resume output completionNote 2

CLR1 REMWUP.2 ; (PULLDP ← 0)
MOV A, #00000111B ; (A ← 00000111B)
SET1 REMWUP.1 ; (PULLEN ← 1)
SET1 REMWUP.0 ; (WAKEUP ← 1), “J” state output
MOV REMWUP, A ; (REMWUP ← A), “K” state output
CLR1 REMWUP.0 ; (WAKEUP ← 0) , Resume output end
CLR1 REMWUP.2 ; (PULLDP ← 0)
SET1 REMWUP.3 ; (PULLDM ← 1)
Figure 8-22. Configuration of Remote Wakeup Control
<Analog part> <Function part>
Transmit data (+ side)
Transmit data (- side)
PULLEN (REMWUP.1)
SEP, SEM disable signal TX MASTER ENNote

8.6 Interrupt Request from USB Function
8.6.1 Interrupt sources
Interrupt request sources generated by the USB function fall into the following five categories.
Interrupt Source Type of Interrupt Priority
1 INTUSBTM USB timer overflow 0006H
2 INTUSBRT EOP detection when a USB token packet is received 0008H
3 INTUSBRD EOP detection when a USB data/handshake packet is received 000AH
4 INTUSBST EOP detection when a USB data/handshake packet is transmitted 000CH
5 INTUSBRE Detection of transition from J state to K state or SE0 on the USB bus 000EH
Upon EOP detection during token packet reception, an interrupt request signal is generated and an interrupt
request flag (USBRTIF) is set. If ADRRST (bit 2 of the token packet receive result store register (TRXRSL)) is
0, no interrupt request is generated because a token packet of another device exists on the bus.
Upon EOP detection during data/handshake packet reception, an interrupt request signal is generated and an
interrupt request flag (USBRDIF) is set regardless of error at reception.
If DINTEN (bit 1 of the data/handshake packet receive mode register (URXMOD)) is set to 1, an interrupt
request (receive status synchronous interrupt) signal is generated when 11B is detected by the ID detection
buffer.
Sync Data0 Data1 DataX CRC16 EOP
INTUSBRD (DINTEN = 1)
Data packet receive status synchronous interrupt
Data/handshake packet receive interrupt

(3) Data/handshake packet transmit interrupt (INTUSBST)
Upon EOP detection during data/handshake packet transmission, an interrupt request signal is generated and
an interrupt request flag (USBSTIF) is set.
If the USB timer overflows, an interrupt request signal is generated and an interrupt request flag (USBTMIF) is
set.
This is an interrupt to release the STOP mode.
If transition from J state (logic 0) to K state (logic 1) is detected on the bus, or transition to SE0 is detected, an
interrupt request signal is generated and an interrupt request flag (USBREIF) is set.
(a) Period of RESMOD = 0 and Single-ended 0 (SE0) is 3.0 µs or longer (microcontroller operation)
D- (USBDM)
3.0 s or longer
3.0 s µ
(b) Period of RESMOD = 0 and SE0 is shorter than 3.0 µs (microcontroller operation)
D- (USBDM)
Shorter than 3.0 s
(c) RESMOD = 1
D- (USBDM)
INTUSBRE
Set irrespective of SE0 period
µ · µ · Not set

8.6.2 Cautions when using interrupts
Pay attention to the following when using an interrupt request generated by the USB function.
(1) Because USBREIF is set by transition from the J state to the K state on the bus, it is also set during sync
detection or packet reception. Thus, disable the generation of interrupt requests by setting the interrupt mask
flag (USBREMK) during bus idle or control transfer.
(2) Because USBREIF is set by transition from the J state to the SE0 state, or by transition from the K state to
the SE0 state on the bus, it is also set during EOP reception or bus idle retention EOP reception. Thus,
disable the generation of interrupt requests by setting the interrupt mask flag (USBREMK) during bus idle or
control transfer.
(3) When clearing the interrupt mask flag (USBREMK), do so immediately before the transition to bus suspend
mode (immediately before the STOP instruction execution).
(4) When the USB reset signal or the Resume signal is received, the USB clock starts operating. As a
consequence, USBTMIF and UWDERR are set after the elapse of a certain period (85.3 µs: fX = 6.0 MHz
operation) of time from reception start. Therefore, when shifting to bus suspend mode (execution of stop
instruction), set the interrupt mask flag (USBTMMK) and disable the generation of interrupt requests.

8.7 USB Function Control
8.7.1 Relationship between packets and operation modes
The relationship between packets and operation modes in the USB function is as follows.
Packet from host controller
Operation of host controller
Operation of USB function of PD789800
DATA0
OUT
ACK
Status stage IN reception
DATA1
ACK

(2) Control transfer (OUT) (Transfer byte count: 9 bytes or more)
Packet from host controller
Operation of host controller
Operation of USB function of PD789800



(3) Control transfer (IN) (Transfer byte count: 8 bytes or less)
Packet from host controller
Operation of host controller
Operation of USB function of PD789800
SETUP
DATA0
IN
Data stage IN reception
ACK
OUT
USB communication completion timer timeoutNote
the OUT receive wait state for a period so that the OUT can be received. Use a normal 8-bit timer for
counting during this period.

(4) Control transfer (IN) (Transfer byte count: 9 bytes or more)
Packet from host controller
Operation of host controller
Operation of USB function of PD789800


Data stage IN reception

(5) No data control
Packet from host controller
Operation of host controller
Operation of USB function of PD789800
SETUP
DATA0
ACK

(6) Interrupt transfer
Packet from host controller
Operation of host controller
Operation of USB function of PD789800
IN
IN
ACK
IN
NAK
ACK
IN
NAK

8.7.2 Interrupt servicing flow
(1) USB token packet reception interrupt servicing
Receive token is OUT?
Waiting for OUT token?
Receive token is unplanned token?
OUT to ENDPOINT 1?
SETUP token reception processing
OUT token reception processing to ENDPOINT 1
to ENDPOINT 1? IN token reception processing to ENDPOINT 0
OUT token reception processing when status stage IN or data stage IN is received
IN token reception processing to ENDPOINT 1

(2) Data/handshake packet reception interrupt servicing
USB_MODE is data stage OUT
Transition processing to status stage OUT reception
USB_MODE is waiting for communication
DATA/ACK reception processing to ENDPOINT 0

(3) USB timer inadvertent program loop detection interrupt servicing
Processing for each operation mode when ACK is not received and for when DATA is not received after receiving OUT
INTUSBTM occurrence

(4) 1 ms timer interrupt servicing
10 ms timer counting
USB communication completion timer processing
Waiting for resume signal
USB reset processing Resume signal completion
RETI

8.8 USB Function Internal Circuit Operations
8.8.1 Operation of transmit/receive pointer
Figure 8-25. Flowchart of Transmit/Receive Pointer Operation (1/7)
(1) Token packet reception (1/2)
EOP
Y
Y
Set USBPOW to 00H
Set USBPOB to 00H
EOP
N
USBPOB
Y
= 02H?
Y
Y
EOP
N
N
Y
N
USBPOB
N
Y
Set USBPOW to 70H
Set USBPOB to 00H
USBPOW
= 01H?
N
N
USBPOW
= 02H?
Y

Figure 8-25. Flowchart of Transmit/Receive Pointer Operation (2/7)
(1) Token packet reception (2/2)
EOP
Y
Y
N
N
USBPOW
= 05H?
Y
N
Y

Figure 8-25. Flowchart of Transmit/Receive Pointer Operation (3/7)
(2) Data/Handshake packet reception (1/2)
EOP
Y
Y
Set USBPOW to 10H
Set USBPOB to 00H
Y
DRXCON?
N
USBPOB
N
Y
EOP
Y
HSSTAT = 1?
Y
N
Y
Set USBPOW to 70H
N
USBPOB
Y
USBPOW
Y
= 11H?
N

Figure 8-25. Flowchart of Transmit/Receive Pointer Operation (4/7)
(2) Data/Handshake packet reception (2/2)
EOP
Y
Y
N
N
USBPOB
Y
Y USBPOW
= 71H?
N
N
Y

Figure 8-25. Flowchart of Transmit/Receive Pointer Operation (5/7)
(3) Data packet transmit (1/2)
Y
N
Set USBPOW to 7FH
Set USBPOB to 00H
N
Y
N
USBPOB
N
Y
N
USBPOB
Y
USBPOW
Y
Transmit area? (reservation flag
start signal Go to (4)
Set USBPOW to n0H

Figure 8-25. Flowchart of Transmit/Receive Pointer Operation (6/7)
(3) Data packet transmit (2/2)
Set EOP transmit signal
N
N
USBPOB
Y
Set USBPOW to 70H
Read CRC redundant bit
N
N USBPOB
Y
Y USBPOW
= 71H?
N

Figure 8-25. Flowchart of Transmit/Receive Pointer Operation (7/7)
(4) Handshake packet transmission
Y
Y
Set USBPOW to 7FH
Set USBPOB to 00H
USBPOB
Y
Y
Set EOP transmit signal
N
USBPOB
Y
Transmit area? (reservation flag
Set USBPOW to n0H

8.8.2 Receive bank switching ID detection buffer operation
Figure 8-26. Flowchart of Receive Bank Switching ID Detection Buffer Operation
Y
2-bit store & shift
11B 10B
01B
Set DASTAT Set HSSTAT
1-bit store & shift
Y
Set buffer to 00H

8.8.3 Sync detection/USBCLK detector operation
This circuit generates the USBCLK signal (1.5 MHz) upon detecting the sync part of the receive packet. In
addition, it contains an NRZI decoder that decodes receive packets and detects the last bit of the sync part.
When the last sync bit is detected, a signal that specifies start of storing in the ID detection buffer is output.
USBCLK
SYNC last bit detection
SYNC pattern After token packet
TX MASTER ENNote
1 0 1 0 1 0 1 1 1 0 0
(INTUSBRE)
Remark The USB clock starts operating at the falling edge of fX after transition from the J state to the K state of
the bus. However, this control is masked if TX MASTER EN = 1.

Figure 8-29. Flowchart of Sync Detection/USBCLK Detector Operation
N
Y
USB clock oscillation start
Output 0 from NRZI decoder
N
Output 1 from NRZI decoder
Detect last Sync bit
N
N
Y
Output 0 from NRZI decoder
Output 1 from NRZI decoder

8.8.4 NRZI encoder operation
This circuit performs NRZI encoding of data to be transmitted.
Sync pattern Data/handshake packet
N
Y
Sync.0 input
Input bit = 0?
Maintain previous output level
Was EOP transmit signal
Y

8.8.5 Bit stuffing/strip controller operation
This circuit counts the number of “logic 1” of transmit/receive packets. If six successive logic 1s are detected, it
outputs an increment disable signal to the transmit/receive pointer (USBPOB). During packet transmission, it inserts
“logic 0” simultaneously with the increment disable signal.
Moreover, during bit stripping, if the bit that should be deleted was a “logic 1,” this is detected as a bit stuffing
error.
(1) Bit stuffing
If “1” occurs six successive times, a “0” is inserted forcibly to shift the level.
Sync pattern Packet data
Idle Bit stuffing data Sync pattern Packet data
Logic 1 × 6 times
Idle NRZI encoding data Sync pattern Packet data
If “1” occurs six successive times, the next bit is deleted as a stuffing bit.
Idle Bit stuffing data (NRZI decoding) Sync pattern Packet data
Logic 1 × 6 times
Idle Bit strip data
Sync pattern Packet data
Idle RAW data · Stuff bit · Stuffing bit

Figure 8-33. Flow Chart of Bit Stuffing Control Operation
N
Y
N
Transmit bit = 1?
Shift bit stuffing register
Reset bit stuffing register
N Bit stuffing register
Y
Reset bit stuffing register
Disable save of next transmit bit
Was EOP receive signal
Y

Figure 8-34. Flow Chart of Bit Strip Control Operation
N
Y
N
Receive bit = 1?
Shift bit stuffing register
Reset bit stuffing register
N Bit stuffing register
Y
Was EOP receive signal
N
N Receive bit = 1?
Reset bit stuffing register
Bit stuffing error output
Was EOP receive signal
Y

9.1 Functions of Serial Interface 10
Serial interface 10 has the following two modes.
This mode is used when serial transfer is not carried out. It enables a reduction in power consumption.
In this mode, 8-bit data transfer is carried out with three lines: one for the serial clock (SCK10) and two for serial
data (SI10 and SO10).
The 3-wire serial I/O mode supports simultaneous transmit and receive operations, reducing data transfer
processing time.
It is possible to switch the start bit of 8-bit data to be transmitted between the MSB and the LSB, thus allowing
connection to devices with either start bit.
The 3-wire serial I/O mode is effective for connecting display controllers and peripheral I/Os such as the 75XL
Series, 78K Series, and 17K Series that have an internal conventional clocked serial interface.

9.2 Configuration of Serial Interface 10
Serial interface 10 consists of the following hardware.
Register Transmit/receive shift register 10 (SIO10)
Control register Serial operating mode register 10 (CSIM10)
This is an 8-bit register used for parallel-to-serial conversion and to perform serial data transmission/reception in
synchronization with the serial clock.
SIO10 is set with an 8-bit memory manipulation instruction.
RESET input makes SIO10 undefined.
Item Configuration

INTCSI10
fX/22
fX/23
Transmit/receive shift register 10
Figure 9-1. Block Diagram of Serial Interface 10
CSCK10
CSIE10 TPS100 DIR10
SI10/P22
SO10/P21
SCK10/P20

9.3 Register Controlling Serial Interface 10
The following register is used to control serial interface 10.
This register is used to control serial interface 10 and set the serial clock and start bit.
CSIM10 is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets CSIM10 to 00H.
Symbol Address After reset R/W
6 5 4 3 2 1 0
CSIE10 0 0 TPS100 0 DIR10 CSCK10 0 CSIM10
CSIE10
Operation control in 3-wire serial I/O mode
Count clock selection when operation enabled in 3-wire serial I/O mode
fX/22
fX/23
MSB
LSB
CSCK10
Clock selection in 3-wire serial I/O mode
Clock input to SCK10 pin from external
Internal clock selected by TPS100
Operation disabled · Operation enabled · Start bit specification

Table 9-2. Operating Mode Settings of Serial Interface 10
(1) Operation stop mode

CSIM10 PM22 P22 PM21 P21 PM20 P20 Start Shift P22/SI10 P21/SO10 P20/SCK10
CSIE10 DIR10 CSCK10 Bit Clock Pin Function Pin Function Pin Function
CSIM10 PM22 P22 PM21 P21 PM20 P20 Start Shift P22/SI10 P21/SO10 P20/SCK10
CSIE10 DIR10 CSCK10 Bit Clock Pin Function Pin Function Pin Function

9.4 Operation of Serial Interface 10
Serial interface 10 provides the following two modes.
In the operation stop mode, serial transfer is not executed; therefore, the power consumption can be reduced.
The P20/SCK10, P21/SO10, and P22/SI10 pins can be used as normal I/O ports.
Operation stop mode is set by serial operation mode register 10 (CSIM10).
CSIM10 is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets CSIM10 to 00H.
Symbol Address After reset R/W
6 5 4 3 2 1 0
CSIE10 0 0 TPS100 0 DIR10 CSCK10 0 CSIM10
CSIE10
Operation control in 3-wire serial I/O mode
Operation disabled · Operation enabled

9.4.2 3-wire serial I/O mode
The 3-wire serial I/O mode is useful for connection of peripheral I/Os and display controllers, etc., which
incorporate a conventional synchronous serial interface, such as the 75XL Series, 78K Series, 17K Series, etc.
Communication is performed using three lines: the serial clock (SCK10), serial output (SO10), and serial input
(SI10).
3-wire serial I/O mode settings are performed using serial operating mode register 10 (CSIM10).
CSIM10 is set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets CSIM10 to 00H.
Symbol Address After reset R/W
6 5 4 3 2 1 0
CSIE10 0 0 TPS100 0 DIR10 CSCK10 0 CSIM10
Operation control in 3-wire serial I/O mode
TPS100
Count clock selection when operation enabled in 3-wire serial I/O mode
fX/22
fX/23
MSB
LSB
CSCK10
Clock selection in 3-wire serial I/O mode
Clock input to SCK10 pin from external
Internal clock selected by TPS100
Operation disabled · Operation enabled · Start bit specification

(2) Communication operation
In the 3-wire serial I/O mode, data transmission/reception is performed in 8-bit units. Data is
transmitted/received bit by bit in synchronization with the serial clock.
Transmit/receive shift register 10 (SIO10) shift operations are performed in synchronization with the fall of the
serial clock (SCK10). Then transmit data is held in the SO10 latch and output from the SO10 pin. Also, receive
data input to the SI10 pin is latched in the input bits of SIO10 on the rise of SCK10.
At the end of an 8-bit transfer, the operation of SIO10 stops automatically, and the interrupt request signal
(INTCSI10) is generated.
SCK10
1 2 3 4 5 6 7 8
DI7 DI6 DI5 DI4 DI3 DI2 DI1 DI0
SO10
DO7 DO6 DO5 DO4 DO3 DO2 DO1 DO0
INTCSI10
End of transfer Transfer start at the falling edge of SCK10
data cannot be transmitted or received.
then serial operation is enabled (CSIE10 = 1), the data cannot be transmitted or
received.
overwriting the data does not update the contents of SIO10.
transmitted or received normally.
transmitted or received normally.
Serial transfer is started by setting transfer data to transmit/receive shift register 10 (SIO10) when the following
two conditions are satisfied.
Termination of 8-bit transfer stops the serial transfer automatically and generates the interrupt request signal
(INTCSI10).

The µPD789800 incorporates a regulator that powers the USB driver/receiver. The features are as follows.
PD789800
V DD0
V REG
REGC
22 F
V SS0 V SS
1.5 kΩ
RXD
SEP
USBDM
SEM
TXDP
TXDM
TXEN
USBDP
RXEN
V SS0

11.1 Interrupt Function Types
The following two types of interrupt functions are used.
This interrupt is acknowledged unconditionally. It does no undergo interrupt priority control and is given top
priority over all other interrupt requests.
A standby release signal is generated.
One interrupt source from the watchdog timer is incorporated as a non-maskable interrupt.
These interrupts undergo mask control. If two or more interrupts with the same priority are simultaneously
generated, each interrupt has a predetermined priority as shown in Table 11-1.
A standby release signal is generated.
Two external and nine internal interrupt sources are incorporated as maskable interrupts.
A total of 12 non-maskable and maskable interrupts are incorporated as interrupt sources (see Table 11-1).

Table 11-1. Interrupt Source List
Type of Interrupt Priority
Nonmaskable - INTWDT Watchdog timer overflow (when watchdog timer mode 1 is selected)
Maskable 0 INTWDT Watchdog timer overflow (when interval timer mode is selected)
1 INTUSBTM USB timer overflow 0006H (B)
2 INTUSBRT EOP detection when a USB token packet is received
3 INTUSBRD EOP detection when a USB data/handshake packet is received
4 INTUSBST EOP detection when a USB data/ handshake packet is transmitted
5 INTUSBRE Detection of transition from J state to K state or SE0 on the USB bus
6 INTP0 Detection of a pin input edge External 0010H (C)
7 INTCSI10 End of three-wire SIO bus interface transmission and reception
8 INTTM00 Generation of the 8-bit timer 00 match signal
9 INTTM01 Generation of the 8-bit timer/event counter 01 match signal
10 INTKR00 Detection of the key return signal External 0018H (C)
is the highest priority and 10 is the lowest.
Remark Only one of the two watchdog timer interrupt (INTWDT) sources, non-maskable or maskable (internal),
can be selected.

Figure 11-1. Basic Configuration of Interrupt Function
(A) Internal non-maskable interrupt
Interrupt request Vector table address generator
MK
IE
Vector table address generator
(C) External maskable interrupt
INTM0, KRM00
MK
IE
Vector table address generator

11.3 Registers Controlling Interrupt Function
The following five registers are used to control the interrupt functions.
Table 11-2 gives a listing of interrupt request flag and interrupt mask flag names corresponding to interrupt
requests.
Interrupt Request Signal Name Interrupt Request Flag Interrupt Mask Flag
INTUSBTM USBTMIF USBTMMK
INTUSBRT USBRTIF USBRTMK
INTUSBRD USBRDIF USBRDMK
INTUSBST USBSTIF USBSTMK
INTUSBRE USBREIF USBREMK
INTP0 PIF0 PMK0
INTCSI10 CSIIF10 CSIMK10
INTTM00 TMIF00 TMMK00
INTTM01 TMIF01 TMMK01
INTKR00 KRIF00 KRMK00

(1) Interrupt request flag registers (IF0 and IF1)
The interrupt request flag is set to 1 when the corresponding interrupt request is generated or an instruction is
executed. It is cleared to 0 when an instruction is executed upon acknowledgement of an interrupt request or
upon RESET input.
IF0 and IF1 are set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets IF0 and IF1 to 00H.
Symbol Address After reset 3 2
TMIF01 TMIF00 CSIIF10 KRIF00 0 0 PIF0 TMIF4 IF0
1 7 0
0 USBTMIFUSBRTIFUSBRDIFUSBSTIF USBREIF 0 0
XXIFX
No interrupt request signal is generated
Interrupt request signal is generated; interrupt request state
timer. If watchdog timer mode 1 or 2 is used, set the TMIF4 flag to 0.
output level is changed by specifying the output mode of the port function, an
interrupt request flag is set. Therefore, the interrupt mask flag should be set to 1
before using the output mode.
then the interrupt routine is entered.
Interrupt request flag

(2) Interrupt mask flag registers (MK0 and MK1)
The interrupt mask flag is used to enable/disable the corresponding maskable interrupt servicing.
MK0 and MK1 are set with a 1-bit or 8-bit memory manipulation instruction.
RESET input sets MK0 and MK1 to FFH.
Symbol Address After reset 3 2
TMMK01 TMMK00 CSIMK10 KRMK00 1 1 PMK0 TMMK4 MK0
1 7 0
0 USBTMMKUSBRTMKUSBRDMKUSBSTMK USBREIF 1 1
XXMKX
or 2, its value becomes undefined.
output level is changed by specifying the output mode of the port function, an
interrupt request flag is set. Therefore, the interrupt mask flag should be set to 1
before using the output mode.
This register is used to set the valid edge of INTP0.
INTM0 is set with an 8-bit memory manipulation instruction.
RESET input sets INTM0 to 00H.
Symbol Address After reset
7 6 5 4 3 2 1 0
0 ES01 ES00 0 0 INTM0
ES00 ES01
INTP0 valid edge selection
Both rising and falling edges
flag to 1 to disable interrupts. After that clear the interrupt mask flag (xxMKx = 0) to
enable interrupts after clearing the interrupt request flag(xxIFx = 0).

(4) Program status word (PSW)
The program status word is a register used to hold the instruction execution result and the current status for
interrupt requests. The IE flag to set maskable interrupt enable/disable is mapped here.
Besides 8-bit unit read/write, this register can carry out operations with bit manipulation instructions and
dedicated instructions (EI, DI). When a vectored interrupt is acknowledged, the PSW is automatically saved into
a stack, and the IE flag is reset to 0.
RESET input sets the PSW to 02H.
7 6 5 4 3 2 1 0
IE Z 0 AC 0 0 1 CY PSW
Used when normal instruction is executed

(5) Key return mode register 00 (KRM00)
This register sets the pin that detects a key return signal (rising edge of port 4).
KRM00 is set with a 1-bit an 8-bit memory manipulation instruction.
Bit 0 (KRM000) is set in 4-bit units for the KR00/P40 to KR03/P43 pins. Bits 4 to 7 (KRM004 to KRM007) are
set in 1-bit units for the KR04/P44 to KR07/P47 pins, respectively.
RESET input sets KRM00 to 00H.
Figures 11-6 and 11-7 show the format of key return mode register 00 and the block diagram of the falling edge
detector, respectively.
Symbol Address After reset 6 5 4 3 2 1 7 0
KRM007 KRM006 KRM005 KRM004 0 0 0 KRM000 KRM00
Key return signal detection selection for P4n/KR0n pin (n = 4 to 7)
Detection (detecting falling edge of P4n/KR0n)
Key return signal detection selection for P40/KR00 to P43/KR03 pins
Detection (detecting falling edge of P40/KR00 to P43/KR03)
However, the pull-up resistor is cut for pins in output mode.
advance. After setting KRM00, clear bit 4 of MK0 (KRMK00 = 0) after clearing bit 4 of
IF0 (KRIF00 = 0) to enable interrupts.
Key return mode register 00 (KRM00)Note
P41/KR01
P42/KR02
P43/KR03
P44/KR04
P45/KR05
KRMK00
P46/KR06
P47/KR07

11.4 Interrupt Servicing Operation
11.4.1 Non-maskable interrupt acknowledgment operation
The non-maskable interrupt is unconditionally acknowledged even when interrupts are disabled. It is not subject
to interrupt priority control and takes precedence over all other interrupts.
When the non-maskable interrupt request is acknowledged, the PSW and PC are saved to the stack in that order,
the IE flag is reset to 0, the contents of the vector table are loaded to the PC, and then program execution branches.
interrupt request; if it is input, the service program will be interrupted and the new interrupt
request will be acknowledged.

Figure 11-8. Flowchart of Non-Maskable Interrupt Request Acknowledgment
WDTM4 = 1 (watchdog timer mode
WDTM3 = 0 (non-maskable interrupt
Interrupt request is generated
Interrupt servicing is started
Instruction Instruction Save PSW and PC, and jump to interrupt servicing Interrupt servicing program CPU processing
Figure 11-10. Acknowledging Non-Maskable Interrupt Request
NMI request (second) NMI request (first)

11.4.2 Maskable interrupt acknowledgment operation
A maskable interrupt can be acknowledged when the interrupt request flag is set to 1 and the corresponding
interrupt mask flag is cleared to 0. A vectored interrupt is acknowledged in the interrupt enabled status (when the IE
flag is set to 1).
The time required to start the interrupt servicing after a maskable interrupt request has been generated is as
follows.
Minimum Time Maximum Time
8 clocks 19 clocks
instruction.
When two or more maskable interrupt requests are generated at the same time, they are acknowledged starting
from the one assigned the highest priority.
A pending interrupt is acknowledged when the status in which it can be acknowledged is set.
Figure 11-11 shows the algorithm of acknowledging interrupts.
When a maskable interrupt request is acknowledged, the PSW and PC are saved to the stack in that order, the IE
flag is reset to 0, the data in the vector table determined for each interrupt request is loaded to the PC, and
execution branches.
To return from interrupt servicing, use the RETI instruction.
xxIF = 1 ?
Yes (interrupt request generated)
xxMK = 0 ?

Figure 11-12. Timing of Interrupt Request Acknowledgment (Example of MOV A,r)
Saving PSW and PC, and jump to interrupt handling
When an interrupt request flag (xxIF) is generated before clock n (n = 4 to 10) of the instruction being executed
turns to n - 1, the interrupt is acknowledged after the instruction has been executed. Figure 11-12 shows an
example for 8-bit data transfer instruction MOV A,r. It takes 4 clocks for this instruction to be executed. So, when an
interrupt occurs within 3 clocks after the instruction execution started, the interrupt is acknowledged after MOV A,r
has been executed.
(When Interrupt Request Flag Is Generated at Last Clock of Instruction Execution)
CPU NOP MOV A,r Save PSW and PC, and jump to interrupt servicing
When an interrupt request flag (xxIF) is generated at the last clock for instruction execution, after the next
instruction has been executed, the interrupt acknowledgment servicing starts.
Figure 11-13 shows an example when an interrupt request flag is generated at the second clock for NOP (2-clock
instruction). In this case, the interrupt is acknowledged after MOV A,r has been executed after the NOP instruction
execution.
IF1) or interrupt mask flag registers 0, 1 (MK0, MK1).

11.4.3 Multiplexed interrupt servicing
Servicing in which another interrupt is acknowledged while an interrupt is being processed is called multiplexed
interrupt servicing.
Multiplexed interrupt is not performed unless interrupt requests are enabled (IE = 1) (except the non-maskable
interrupt request). Other interrupt requests are disabled (IE = 0) as soon as an interrupt request is acknowledged.
Therefore, it is necessary to set (1) the IE flag to realize the interrupt enable state using the EI instruction during
interrupt request servicing in order to enable multiplexed interrupt servicing.

Figure 11-14. Example of Multiplexed Interrupt Servicing
Example 1. Acknowledging multiplexed interrupts
INTyy processing INTxx processing
IE = 0
EI
EI
RETI
RETI
The interrupt request INTyy is acknowledged and multiplexed interrupt servicing is performed during the interrupt
INTxx servicing. Before each interrupt is acknowledged, the IE instruction is issued and interrupt requests are
enabled.
Example 2. Multiplexed interrupts are not performed because interrupts are disabled.
INTyy processing INTxx processing
INTyy is held pending
IE = 0
RETI
Interrupt requests are disabled (EI instruction is not issued) in the interrupt INTxx servicing. The interrupt request
INTyy is not acknowledged and multiplexed interrupt servicing is not performed. INTyy is held pending and is
acknowledged after INTxx servicing is completed.
IE = 0: Interrupt request acknowledgment disabled.

11.4.4 Interrupt request hold
If an interrupt (such as a maskable, non-maskable, or external interrupt) is requested when a certain type of
instruction is being executed, the interrupt request will not be acknowledged until the instruction is completed. Such
instructions include:

12.1 Standby Function and Configuration
12.1.1 Standby function
The standby function is used to reduce the power consumption of the system and can be effected in the following
two modes.
This mode is set when the HALT instruction is executed. The HALT mode stops the operation clock of the CPU.
The system clock oscillator continues oscillating. This mode does not reduce the power consumption as much
as the STOP mode, but is useful for resuming processing immediately when an interrupt request is generated,
or for intermittent operations.
This mode is set when the STOP instruction is executed. The STOP mode stops the system clock oscillator
and stops the entire system. The power consumption of the CPU can be substantially reduced in this mode.
The STOP mode can be released by an interrupt request, so that this mode can be used for intermittent
operations. However, some time is required until the system clock oscillator stabilizes after the STOP mode has
been released. If processing must be resumed immediately by using an interrupt request, therefore, use the
HALT mode.
In both modes, the previous contents of the registers, flags, and data memory before setting the standby mode
are all retained. In addition, the statuses of the output latches of the I/O ports and output buffers are also retained.
execute the STOP instruction.

12.1.2 Register controlling standby function
The wait time after the STOP mode is released upon interrupt request until oscillation stabilizes is controlled with
the oscillation stabilization time select register (OSTS).
OSTS is set with an 8-bit memory manipulation instruction.
15/fX until oscillation stabilizes after RESET input.
RESET input sets OSTS to 04H. However, it takes 2
Symbol Address After reset
7 6 5 4 3 2 1 0
0 OSTS2 OSTS1 OSTS0 OSTS
OSTS2
OSTS1
OSTS0
Oscillation stabilization time selection
212/fX
215/fX
(5.46 ms)
217/fX
(21.8 ms)
release to clock oscillation start (“a” in the figure below), regardless of release by RESET input
or by interrupt generation.

12.2 Standby Function Operation
12.2.1 HALT mode
(1) HALT mode
The HALT mode is set by executing the HALT instruction.
The operation status in the HALT mode is shown in the following table.
Item HALT Mode Operation Status
Clock generator Oscillation enabled
Port (output latch) Remains in the state before the selection of HALT mode.
8-bit timer 00 (TM00) Operation enabled
8-bit timer/event counter 01 (TM01) Operation enabled
Watchdog timer Operation enabled
USB function Operation enabled
Serial interface Operation enabled
Key return Operation enabled
External interrupt Operation enabled
CPU Operation disabled

(2) Releasing HALT mode
The HALT mode can be released by the following three sources.
The HALT mode is released by an unmasked interrupt request. In this case, if interrupts are enabled to be
acknowledged, vectored interrupt servicing is performed. If interrupts are disabled, the instruction at the
next address is executed.
Wait HALT mode Operation
Remarks 1. The broken lines indicate the case where the interrupt request that has released the
standby mode is acknowledged.
The HALT mode is released regardless of whether interrupts are enabled or disabled, and vectored
interrupt servicing is performed.

(c) Releasing by RESET input
When the HALT mode is released by the RESET signal, execution branches to the reset vector address in
the same manner as the ordinary reset operation, and program execution is started.
Reset period HALT mode Operation
Releasing Source MKxx IE Operation
Maskable interrupt request 0 0 Executes next address instruction
0 1 Executes interrupt servicing
1 × Retains HALT mode
Non-maskable interrupt request — × Executes interrupt servicing
RESET input — — Reset processing

12.2.2 STOP mode
(1) Setting and operation status of STOP mode
The STOP mode is set by executing the STOP instruction.
current leakage of the crystal oscillator block. Therefore, do not use the STOP mode
in a system where an external clock is used as the system clock.
mode is released as soon as it is set if there is an interrupt source whose interrupt
request flag is set and interrupt mask flag is reset. When the STOP mode is set,
therefore, the HALT mode is set immediately after the STOP instruction has been
executed, the wait time set by the oscillation stabilization time select register (OSTS)
elapses, and then the operation mode is set.
The operation status in the STOP mode is shown in the following table.
Item STOP Mode Operation Status
Clock generator Oscillation disabled
Port (output latch) Remains in the state before the selection of STOP mode.
8-bit timer 00 (TM00) Operation disabled
8-bit timer/event counter 01 (TM01) Operation enabled
Watchdog timer Operation disabled
USB function Operation enabled
Serial interface 10 Operation enabled
Key return Operation enabled
External interrupt Operation enabled
CPU Operation disabled

(2) Releasing STOP mode
The STOP mode can be released by the following two sources.
The STOP mode can be released by an unmasked interrupt request. In this case, if interrupts are enabled
to be acknowledged, vectored interrupt servicing is performed, after the oscillation stabilization time has
elapsed. If interrupt acknowledgement is disabled, the instruction at the next address is executed.
Wait ( set time by OSTS)
Remark The broken lines indicate the case where the interrupt request that has released the standby
mode is acknowledged.

(b) Releasing by RESET input
When the STOP mode is released by the RESET signal, the reset operation is performed after the
oscillation stabilization time has elapsed.
Releasing Source MKxx IE Operation
Maskable interrupt request 0 0 Executes next address instruction
0 1 Executes interrupt servicing
1 × Retains STOP mode
RESET input — — Reset processing
After the STOP instruction is executed in the SE0 state (USBDM = 0, USBDP = 0), the STOP mode cannot be
released by a USB reset/Resume detection interrupt (INTUSBRE).
Therefore, the following control should be performed.
Do not execute the STOP instruction in the SE0 state.
In addition, when executing the STOP instruction in the suspend mode, execute both the following two
software countermeasures.
suspend state is detected and when the STOP instruction is executed.
as the 3 ms timer for suspend state detection is reset.

The following two operations are available to generate reset signals.
(1) External reset input via RESET pin
(2) Internal reset by inadvertent program loop time detected by watchdog timer
External and internal reset have no functional differences. In both cases, program execution starts at the address
at 0000H and 0001H by RESET input.
When a low level is input to the RESET pin or the watchdog timer overflows, a reset is applied and each of the
hardware is set to the status shown in Table 13-1. Each pin is high impedance during reset input or during the
oscillation stabilization time just after reset release.
When a high level is input to the RESET pin, the reset is released and program execution is started after the
oscillation stabilization time (2
15/fx) has elapsed. The reset applied by watchdog timer overflow is automatically
released after reset, and program execution is started after the oscillation stabilization time (2
15/fx) has elapsed (see
Figures 13-2 through 13-4.)
input. However, the port pins become high impedance.
RESET
Interrupt function Count clock

Figure 13-2. Reset Timing by RESET Input
Oscillation stabilization time wait
Reset period (oscillation stops)
Normal operation (reset processing)
Figure 13-3. Reset Timing by Overflow in Watchdog Timer
Oscillation stabilization time wait
Reset period (oscillation stops)
Normal operation (reset processing)
Overflow in watchdog timer
STOP instruction execution During normal operation
Oscillation stabilization time wait
Reset period (oscillation stops) Stop status (oscillation stops)
Normal operation (reset processing)

Table 13-1. Hardware Status After Reset (1/2)

Transmit data bank address (USBT00 to USBT07, USBT10 to USBT17)
statuses become undefined.
All other hardware remains unchanged after reset.

Table 13-1. Hardware Status After Reset (2/2)

USB function Data packet transmit byte number counter 0 (DTXCO0) 20H
Data packet transmit byte number counter 1 (DTXCO1) 30H

CHAPTER 14 µPD78F9801
The µPD78F9801 is a product that substitutes flash memory for the internal ROM of the mask ROM version. The
differences between the µPD78F9801 and the mask ROM versions are shown in Table 14-1.
Table 14-1. Differences Between µPD78F9801 and Mask ROM Versions
Item Flash Memory Version Mask ROM Version
µPD78F9801 µPD789800
Internal memory ROM 16 KB (Flash memory) 8 KB
High-speed RAM 256 bytes
IC pin Not provided Provided
VPP pin Provided Not provided
Electrical specifications Refer to CHAPTER 16 ELECTRICAL SPECIFICATIONS.
mask ROM versions. When pre-producing an application set with the flash memory version
and then mass-producing it with the mask ROM version, be sure to conduct sufficient
evaluations for the commercial samples (not engineering samples) of the mask ROM version.

CHAPTER 14 µPD78F9801
Flash memory programming is performed by connecting a dedicated flash programmer (Flashpro III (part no. FL-
PR3, PG-FP3)/Flashpro IV (part no. FL-PR4, PG-FP4)) to the target system with the µPD78F9801 mounted on the
target system (on-board). A flash memory program adapter (FA adapter), which is a target board used exclusively for
programming, is also provided.
Remark FL-PR3, FL-PR4, and the program adapter are products made by Naito Densei Machida Mfg. Co., Ltd.
(TEL +81-45-475-4191).
Programming using flash memory has the following advantages.
The following shows the environment required for µPD78F9801 flash memory programming.
When Flashpro III (part no. FL-PR3, PG-FP3) or Flashpro IV (part no. FL-PR4, PG-FP4) is used as a dedicated
flash programmer, a host machine is required to control the dedicated flash programmer. Communication between
the host machine and flash programmer is performed via RS-232C/USB (Rev. 1.1).
For details, refer the manuals for Flashpro III/Flashpro IV.
Remark USB is supported by Flashpro IV only.

programmer · Host machine

CHAPTER 14 µPD78F9801
Use the communication mode shown in Table 14-2 to perform communication between the dedicated flash
programmer and µPD78F9801.
Pins Used Number of VPP Pulses
Mode COMM PORT SIO Clock CPU Clock Flash Clock Multiple Rate
Optional 1 to 5 MHz Note 2 1.0 SI10/P22 SO10/P21 SCK10/P20
SIO ch-0 (3-wire, sync.)
100 Hz to 1.25 MHz Note 2
100 Hz to 1 kHz Optional 1 to 5 MHz Note 2 1.0 P10 (serial clock input) P11 (serial data output) P12 (serial data input)
Pseudo-3-wire Port A (pseudo- 3-wire)
PG-FP3)/Flashpro IV (part no. FL-PR4, PG-FP4)).
ELECTRICAL SPECIFICATIONS.
V DD V PP
V SS
V DD
V SS RESET

CHAPTER 14 µPD78F9801
(a) 3-wire serial I/O
VPP1
V PP
VDD
V DD0 , V DD1
RESET
RESET
SCK
SCK10
SO
SI10
SI
SO10
GND
V SS0 , V SS1
(b) Pseudo-3-wire
VPP1
V PP
VDD
V DD0 , V DD1
RESET
RESET
SCK
P10
SO
P12
SI
P11
GND
V SS0 , V SS1
already connected to the X1 pin, the CLK pin does not need to be connected.
dedicated flash programmer. When using the power supply connected to the VDD pin, supply
voltage before starting programming.

CHAPTER 14 µPD78F9801
If Flashpro III (part no. FL-PR3, PG-FP3)/Flashpro IV is used as a dedicated flash programmer, the following
signals are generated for the µPD78F9801. For details, refer to the manual of Flashpro III/Flashpro IV.
Table 14-3. Pin Connection List

Signal Name I/O Pin Function Pin Name 3-Wire Serial I/O Pseudo-3-Wire
VDD I/O VDD voltage generation/voltage monitoring VDD0, VDD1
Remark : Pin must be connected.
: If the signal is supplied on the target board, pin does not need to be connected.
×: Pin does not need to be connected.

CHAPTER 14 µPD78F9801
When performing programming on the target system, provide a connector on the target system to connect the
dedicated flash programmer.
An on-board function that allows switching between normal operation mode and flash memory programming mode
may be required in some cases.
In normal operation mode, input 0 V to the VPP pin. In flash memory programming mode, a write voltage of 10.0 V
(TYP.) is supplied to the VPP pin, so perform either of the following.
(1) Connect a pull-down resistor (RVPP = 10 kΩ) to the VPP pin.
(2) Use the jumper on the board to switch the VPP pin input to either the writer or directly to GND.
A VPP pin connection example is shown below.
PD78F9801
Connection pin of dedicated flash programmer
Pull-down resistor (RVPP)
The following shows the pins used by the serial interface.
Serial Interface Pins Used
3-wire serial I/O SI10, SO10, SCK10
Pseudo-3-wire P12, P11, P10
When connecting the dedicated flash programmer to a serial interface pin that is connected to another device on-
board, signal conflict or abnormal operation of the other device may occur. Care must therefore be taken with
such connections.
· µ ·

CHAPTER 14 µPD78F9801
If the dedicated flash programmer (output) is connected to a serial interface pin (input) that is connected to
another device (output), a signal conflict occurs. To prevent this, isolate the connection with the other
device or set the other device to the output high impedance status.
Connection pin of dedicated flash programmer
In the flash memory programming mode, the signal output by another device and the signal sent by the dedicated flash programmer conflict; therefore, isolate the signal of the other device.
If the dedicated flash programmer (output or input) is connected to a serial interface pin (input or output)
that is connected to another device (input), a signal is output to the device, and this may cause an abnormal
operation. To prevent this abnormal operation, isolate the connection with the other device or set so that the
input signals to the other device are ignored.
PD78F9801
Connection pin of dedicated flash programmer
If the signal output by the PD78F9801 affects another device in the flash memory programming mode, isolate the signals of the other device.
Connection pin of dedicated flash programmer
If the signal output by the dedicated flash programmer affects another device in the flash memory programming mode, isolate the signals of the other device.

CHAPTER 14 µPD78F9801
If the reset signal of the dedicated flash programmer is connected to the RESET pin connected to the reset signal
generator on-board, a signal conflict occurs. To prevent this, isolate the connection with the reset signal
generator.
If the reset signal is input from the user system in the flash memory programming mode, a normal programming
operation cannot be performed. Therefore, do not input reset signals from other than the dedicated flash
programmer.
Connection pin of dedicated flash programmer
The signal output by the reset signal generator and the signal output from the dedicated flash programmer conflict in the flash memory programming mode, so isolate the signal of the reset signal generator.
When the µPD78F9801 enters the flash memory programming mode, all the pins other than those that
communicate with flash programmer are in the same status as immediately after reset.
If the external device does not recognize initial statuses such as the output high impedance status, therefore,
connect the external device to VDD0, VDD1, VSS0, or VSS1 via a resistor.
When using the on-board clock, connect X1 and X2 as required in the normal operation mode.
When using the clock output of the flash programmer, connect it directly to X1, disconnecting the main resonator
on-board, and leave the X2 pin open.
To use the power output from the flash programmer, connect the VDD0 and VDD1 pins to VDD of the flash
programmer, and the VSS0 and VSS1 pins to GND of the flash programmer.
To use the on-board power supply, make connections in accordance with the normal operation mode. However,
because the voltage is monitored by the flash programmer, be sure to connect VDD of the flash programmer.
Process the other pins (USBDP, USBDM, REGC) in the same manner as in the normal operation mode.

CHAPTER 14 µPD78F9801
The following figure shows an example of recommended connection when the adapter for flash writing is used.
VDD (4.0 to 5.5 V)
VDD2(LVDD)
GND VDD
44 43 42 41 40 39 38 37 36 35 34
12 13 14 15 16 17 18 19 20 21 22 23
WRITER INTERFACE FRASH
µ

CHAPTER 14 µPD78F9801
VDD (4.0 to 5.5 V)
VDD2(LVDD)
GND VDD
44 43 42 41 40 39 38 37 36 35 34
12 13 14 15 16 17 18 19 20 21 22 23
WRITER INTERFACE FRASH
µ

This chapter lists the instruction set of the µPD789800 Subseries. For details of the operation and machine
language (instruction code) of each instruction, refer to 78K/0S Series Instruction User’s Manual (U11047E).
15.1.1 Operand identifiers and description methods
Operands are described in the “Operands” column of each instruction in accordance with the description method
of the instruction operand identifier (see the assembler specifications for details). When there are two or more
description methods, select one of them. Uppercase letters and the symbols #, !, $, and [ ] are keywords and are
described as they are. Each symbol has the following meaning.
In the case of immediate data, describe an appropriate numeric value or a label. When using a label, be sure to
describe the #, !, $ and [ ] symbols.
For operand register identifiers, r and rp, either function names (X, A, C, etc.) or absolute names (names in
parentheses in the table below: R0, R1, R2, etc.) can be used for description.
X (R0), A (R1), C (R2), B (R3), E (R4), D (R5), L (R6), H (R7) AX (RP0), BC (RP1), DE (RP2), HL (RP3) Special-function register symbol
FE20H to FF1FH Immediate data or label FE20H to FF1FH Immediate data or label (even addresses only)
0000H to FFFFH Immediate data or label (only even addresses for 16-bit data transfer instructions) 0040H to 007FH Immediate data or label (even addresses only)
16-bit immediate data or label 8-bit immediate data or label 3-bit immediate data or label
Remark See Table 3-2 Special Function Register List for symbols of special function registers.

15.1.2 Description of “operation” column
A: A register; 8-bit accumulator
X: X register
B: B register
C: C register
D: D register
E: E register
H: H register
L: L register
Z: Zero flag
V: Exclusive logical sum (exclusive OR)
: Inverted data
x: Set/cleared according to the result
R: Previously saved value is restored

15.2 Operation List

PSW,#byte 3 6 PSW ← byte × × ×
PSW,A 2 4 PSW ← A × × ×
Remark One instruction clock cycle is one CPU clock cycle (fCPU) selected by the processor clock control
register (PCC).


ADD A,#byte 2 4 A,CY ← A+byte × × ×
saddr,#byte 3 6 (saddr),CY ← (saddr) + byte × × ×
A,r 2 4 A,CY ← A+r × × ×
A,saddr 2 4 A,CY ← A+(saddr) × × ×
A,!addr16 3 8 A,CY ← A+(addr16) × × ×
A,[HL] 1 6 A,CY ← A+(HL) × × ×
A,[HL+byte] 2 6 A,CY ← A+(HL+byte) × × ×
ADDC A,#byte 2 4 A,CY ← A+byte+CY × × ×
saddr,#byte 3 6 (saddr),CY ← (saddr)+byte+CY × × ×
A,r 2 4 A,CY ← A+r+CY × × ×
A,saddr 2 4 A,CY ← A+(saddr)+CY × × ×
A,!addr16 3 8 A,CY ← A+(addr16)+CY × × ×
A,[HL] 1 6 A,CY ← A+(HL)+CY × × ×
A,[HL+byte] 2 6 A,CY ← A+(HL+byte)+CY × × ×
SUB A,#byte 2 4 A,CY ← A−byte × × ×
saddr,#byte 3 6 (saddr), CY ← (saddr)− byte × × ×
A,r 2 4 A,CY ← A−r × × ×
A,saddr 2 4 A,CY ← A−(saddr) × × ×
A,!addr16 3 8 A,CY ← A−(addr16) × × ×
A,[HL] 1 6 A,CY ← A−(HL) × × ×
A,[HL+byte] 2 6 A,CY ← A−(HL+byte) × × ×
Remark One instruction clock cycle is one CPU clock cycle (fCPU) selected by the processor clock control
register (PCC).


SUBC A,#byte 2 4 A,CY ← A−byte−CY × × ×
saddr,#byte 3 6 (saddr),CY ← (saddr)−byte−CY × × ×
A,r 2 4 A,CY ← A−r−CY × × ×
A,saddr 2 4 A,CY ← A−(saddr)−CY × × ×
A,!addr16 3 8 A,CY ← A−(addr16)−CY × × ×
A,[HL] 1 6 A,CY ← A−(HL)−CY × × ×
A,[HL+byte] 2 6 A,CY ← A−(HL+byte)−CY × × ×
AND A,#byte 2 4 A ← A∧byte ×
saddr,#byte 3 6 (saddr) ← (saddr)∧byte ×
A,r 2 4 A ← A∧r ×
A,saddr 2 4 A ← A∧(saddr) ×
A,!addr16 3 8 A ← A∧(addr16) ×
A,[HL] 1 6 A ← A∧(HL) ×
A,[HL+byte] 2 6 A ← A∧(HL+byte) ×
OR A,#byte 2 4 A ← A∨byte ×
saddr,#byte 3 6 (saddr) ← (saddr)∨byte ×
A,r 2 4 A ← A∨r ×
A,saddr 2 4 A ← A∨(saddr) ×
A,!addr16 3 8 A ← A∨(addr16) ×
A,[HL] 1 6 A ← A∨(HL) ×
A,[HL+byte] 2 6 A ← A∨(HL+byte) ×
Remark One instruction clock cycle is one CPU clock cycle (fCPU) selected by the processor clock control
register (PCC).


CMP A,#byte 2 4 A−byte × × ×
saddr,#byte 3 6 (saddr)−byte × × ×
A,r 2 4 A−r × × ×
A,saddr 2 4 A−(saddr) × × ×
A,!addr16 3 8 A−(addr16) × × ×
A,[HL] 1 6 A−(HL) × × ×
A,[HL+byte] 2 6 A−(HL+byte) × × ×
ADDW AX,#word 3 6 AX,CY ← AX+word × × ×
SUBW AX,#word 3 6 AX,CY ← AX−word × × ×
CMPW AX,#word 3 6 AX−word × × ×
INC r 2 4 r ← r+1 × ×
DEC r 2 4 r ← r−1 × ×
saddr 2 4 (saddr) ← (saddr)−1 × ×
DECW rp 1 4 rp ← rp−1
ROR A,1 1 2 (CY,A7 ← A0, Am−1 ← Am)×1 ×
ROL A,1 1 2 (CY,A0 ← A7, Am+1 ← Am)×1 ×
RORC A,1 1 2 (CY ← A0, A7 ← CY, Am−1 ← Am)×1 ×
ROLC A,1 1 2 (CY ← A7, A0 ← CY, Am+1 ← Am)×1 ×
PSW.bit 3 6 PSW.bit ← 1 × × ×
PSW.bit 3 6 PSW.bit ← 0 × × ×
Remark One instruction clock cycle is one CPU clock cycle (fCPU) selected by the processor clock control
register (PCC).

Mnemonic Operands Bytes Clocks Operation Flag
CALL !addr16 3 6 (SP−1) ← (PC+3)H, (SP−2) ← (PC+3)L, PC ← addr16, SP ← SP−2
CALLT [addr5] 1 8 (SP−1) ← (PC+1)H, (SP−2) ← (PC+1)L, PCH ← (00000000, addr5+1), PCL ← (00000000, addr5), SP ← SP−2
RET 1 6 PCH ← (SP+1), PCL ← (SP), SP ← SP+2
RETI 1 8 PCH ← (SP+1), PCL ← (SP), PSW ← (SP+2), SP ← SP+3, NMIS ← 0
PUSH PSW 1 2 (SP−1) ← PSW, SP ← SP−1
rp 1 4 (SP−1) ← rpH, (SP−2) ← rpL, SP ← SP−2
POP PSW 1 4 PSW ← (SP), SP ← SP+1 R R R
rp 1 6 rpH ← (SP+1), rpL ← (SP), SP ← SP+2
AX, SP 2 6 AX ← SP
BR !addr16 3 6 PC ← addr16
$addr16 2 6 PC ← PC+2+jdisp8
AX 1 6 PCH ← A, PCL ← X
BC $saddr16 2 6 PC ← PC+2+jdisp8 if CY=1
BNC $saddr16 2 6 PC ← PC+2+jdisp8 if CY=0
BZ $saddr16 2 6 PC ← PC+2+jdisp8 if Z=1
BNZ $saddr16 2 6 PC ← PC+2+jdisp8 if Z=0
BT saddr.bit,$addr16 4 10 PC ← PC+4+jdisp8 if (saddr.bit)=1
sfr.bit,$addr16 4 10 PC ← PC+4+jdisp8 if sfr.bit=1
A.bit,$addr16 3 8 PC ← PC+3+jdisp8 if A.bit=1
PSW.bit,$addr16 4 10 PC ← PC+4+jdisp8 if PSW.bit=1
BF saddr.bit,$addr16 4 10 PC ← PC+4+jdisp8 if (saddr.bit)=0
sfr.bit,$addr16 4 10 PC ← PC+4+jdisp8 if sfr.bit=0
A.bit,$addr16 3 8 PC ← PC+3+jdisp8 if A.bit=0
PSW.bit,$addr16 4 10 PC ← PC+4+jdisp8 if PSW.bit=0
DBNZ B,$addr16 2 6 B ← B−1, then PC ← PC+2+jdisp8 if B≠0
C,$addr16 2 6 C ← C−1, then PC ← PC+2+jdisp8 if C≠0
saddr,$addr16 3 8 (saddr) ← (saddr)−1, then PC ← PC+3+jdisp8 if (saddr)≠0
NOP 1 2 No Operation
EI 3 6 IE ← 1 (Enable interrupt)
DI 3 6 IE ← 0 (Disable interrupt)
HALT 1 2 Set HALT mode
STOP 1 2 Set STOP mode
Remark One instruction clock cycle is one CPU clock cycle (fCPU) selected by the processor clock control
register (PCC).

15.3 Instructions Listed by Addressing Type
(1) 8-bit instructions
MOV, XCH, ADD, ADDC, SUB, SUBC, AND, OR, XOR, CMP, INC, DEC, ROR, ROL, RORC, ROLC, PUSH,

#byte A r sfr saddr !addr16 PSW [DE] [HL] [HL+byte] $addr16 1 None
A ADD ADDC SUB SUBC AND OR XOR CMP
MOV XCH ADD ADDC SUB SUBC AND OR XOR CMP
MOV XCH ADD ADDC SUB SUBC AND OR XOR CMP
MOV XCH ADD ADDC SUB SUBC AND OR XOR CMP
saddr MOV ADD ADDC SUB SUBC AND OR XOR CMP

(2) 16-bit instructions
MOVW, XCHW, ADDW, SUBW, CMPW, PUSH, POP, INCW, DECW


(4) Call instructions/branch instructions
CALL, CALLT, BR, BC, BNC, BZ, BNZ, DBNZ
AX !addr16 [addr5] $addr16
Basic Instructions BR CALL BR
(5) Other instructions
RET, RETI, NOP, EI, DI, HALT, STOP
2nd Operand · 1st Operand · Compound Instructions DBNZ

Absolute Maximum Ratings (T A = 25 ° C)

VDD −0.3 to +6.5 V Supply voltage
Input voltage VI −0.3 to VDD + 0.3
Output voltage VO −0.3 to VDD + 0.3
Per pin −10 mA Output current, high IOH
Per pin 30 mA Output current, low IOL
In normal operation mode −40 to +85 °C Operating ambient temperature TA
During flash memory programming 10 to 40 °C
Mask ROM version −65 to +150 °C Storage temperature Tstg
flash memory is written.
VPP must exceed VDD 10 µs or more after VDD has reached the lower-limit value (4.0 V) of the
operating voltage range (see a in the figure below).
VDD must be lowered 10 µs or more after VPP falls below the lower-limit value (4.0 V) of the operating
voltage range of VDD (see b in the figure below).

V PP
any parameter. That is, the absolute maximum ratings are rated values at which the product is
on the verge of suffering physical damage, and therefore the product must be used under
conditions that ensure that the absolute maximum ratings are not exceeded.
Remark Unless specified otherwise, the characteristics of alternate-function pins are the same as those of port
pins.

System Clock Oscillation Circuit Characteristics (TA = −40 to +85°C, VDD = 4.0 to 5.5 V)

Resonator Recommended Circuit Parameter Conditions MIN. TYP. MAX. Unit
X1 input high-low-level width (tXH, tXL)
time.
oscillation before the oscillation stabilization time elapses.
in the above figure to avoid an adverse effect from wiring capacitance.
Remark For the resonator selection and oscillator constant, customers are required to either evaluate the
oscillation themselves or apply to the resonator manufacturer for evaluation.
Flash Memory Write/Erase Characteristics (TA = 10 to 40°C, VDD = 4.0 to 5.5 V) (µPD78F9801 only)

Write current (VDD pin) IDDW When VPP supply voltage = VPP1 (in 6.0 MHz operation mode)
Write current (VPP pin) IPPW When VPP supply voltage = VPP1 7.5 mA
Erase current (VDD pin) IDDE When VPP supply voltage = VPP1 (in 6.0 MHz operation mode)
Erase current (VPP pin) IPPE When VPP supply voltage = VPP1 100 mA
Unit erase time ter 1 1 1 s
Write count Erase/write are regarded as 1 cycle. 1 Times
VPP0 In normal operation 0 0.2VDD V VPP supply voltage
VPP1 During flash memory programming 9.7 10.0 10.3 V
included.

DC Characteristics (TA = −40 to +85°C, VDD = 4.0 to 5.5 V) (1/2)
Parameter Symbol Conditions MIN. TYP. MAX. Unit
Per pin −1 mA Output current, high IOH
Total for all pins −15 mA
Per pin 10 mA Output current, low IOL
Total for all pins 80 mA
VIH1 P00 to P07, P10 to P17 0.7VDD VDD V
VIH2 RESET, P20 to P26, P40 to P47 0.8VDD VDD V
VIH3 X1 VDD − 0.1 VDD V
VIH4 USBDM, USBDP TA = 0 to +70°C 2.0 3.6 V
VIL1 P00 to P07, P10 to P17 0 0.3VDD V
VIL2 RESET, P20, P22, P40 to P47 0 0.2VDD V
VIL4 USBDM, USBDP TA = 0 to +70°C 0 0.8 V
IO = −1 mA VDD − 1.0 V Output voltage, high
VOH1 Pins other than USBDM and USBDP
VOH2 USBDM, USBDP TA = 0 to +70°C, RL = 15 kΩ (connected to VSS)
IO = 10 mA 1.0 V Output voltage, low
VOL1 Pins other than USBDM and USBDP
VOL2 USBDM, USBDP TA = 0 to +70°C, RL = 15 kΩ (connected to VDD)
Input leakage current, high
ILIH1 Pins other than X1, X2, USBDM, and USBDP
VI = VDD 3 µA
ILIH2 X1, X2 VI = VDD 20 µA
ILIH3 USBDM, USBDP TA = 0 to +70°C
0 V ≤ VI ≤ VREG 10 µA
Input leakage current, low
ILIL1 Pins other than X1, X2, USBDM, and USBDP
VI = 0 V −3 µA
ILIL2 X1, X2 VI = 0 V −20 µA
ILIL3 USBDM, USBDP TA = 0 to +70°C
0 V ≤ VI ≤ VREG −10 µA
Output leakage current, high ILOH VO = 0 V 3 µA
Output leakage current, low ILOL VO = 0 V −3 µA
Software pull-up resistance R VI = 0 V 50 100 200 kΩ
Regulator output voltage VREG IO = 0 to −3 mA 3.0 3.3 3.6 V
Remark Unless specified otherwise, the characteristics of alternate-function pins are the same as those of port
pins.
Input voltage, high · Input voltage, low

DC Characteristics (TA = −40 to +85°C, VDD = 4.0 to 5.5 V) (2/2)
Parameter Symbol Conditions MIN. TYP. MAX. Unit
IDD1 6.0 MHz crystal oscillation (operating mode)
1.5 3.0 mA
IDD2 6.0 MHz crystal oscillation (HALT mode)
0.5 1.1 mA
IDD3 STOP mode
When the USB function is disabled
10 30 µA
When the USB function is enabled (TA = 0 to +70°C)
50 100 µA
IDD1 6.0 MHz crystal oscillation (operating mode)
5.0 10.0 mA
IDD2 6.0 MHz crystal oscillation (HALT mode)
1.5 3.5 mA
IDD3 STOP mode
When the USB function is disabled
10 30 µA
When the USB function is enabled (TA = 0 to +70°C)
50 100 µA

AC Characteristics
(1) Basic operations (TA = −40 to +85°C, VDD = 4.0 to 5.5 V)

When PCC = 00H (fX = 6.0 MHz) 0.333 0.333 0.333 µs Cycle time (minimum instruction execution time)
When PCC = 02H (fX = 6.0 MHz) 1.333 1.333 1.333 µs
tINTH, tINTL INTP0 10 µs
RESET input low-level width tRSL 10 µs
(a) USB function (TA = 0 to +70°C, VDD = 4.0 to 5.5 V)

tR and tF matching tRFM tR/tF 80 120 %
Data transfer rate tDRATE When the microcontroller operates at the system clock (fX) of 6.0 MHz
tUDJ1 Upon transferring the next bit −95 0 95 ns Transmission differential signal jitter tUDJ2 Upon transferring the bit following the next bit −150 0 150 ns
Transmission EOP width tEOPT1 1.25 1.33 1.50 µs
tEOPR1 EOP width to be eliminated 300 µs Reception EOP width
tEOPR2 EOP width to be detected 675 µs
tURES1 USB reset width to be eliminated 2.5 µs Reception USB reset width
tURES2 USB reset width to be detected 5.5 µs

(b) 3-wire serial I/O mode (TA = −40 to +85°C, VDD = 4.0 to 5.5 V)

SI10 setup time tSIK1 To SCK10 ↑ 150 ns
SO10 output delay tKSO1 From SCK10 ↓, CL = 100 pF

SO10 output delay tKSO2 From SCK10 ↓, CL = 100 pF

AC Timing Measurement Points (Except X1 Input and USB Function)
0.8V DD
0.8V DD
0.2V DD
0.2V DD
Clock timing
tXL tXH
V IL3 (MAX.)
TI Timing
tTIL tTIH
Interrupt Input Timing
tINTL tINTH
RESET Input Timing
RESET

Serial Transfer Timing
USB function:
USBDM and USBDP rise/fall time
0.9V DD
USBDM, USBDP
0.1V DD
Transmission differential signal jitter
Next bit Bit following the next bit
tUDJ1 tUDJ2
Differential output signal cross-over point, transmission EOP width, reception EOP width, and reception
USBDM, USBDP V CRS
tEOPT1, tEOPRm, tURESm
m = 1, 2
tKLm tKHm
SCK10
0.2V DD
tSIKm tKSIm
SO10
m = 1, 2

Data Memory STOP Mode Low Supply Voltage Data Retention Characteristics (TA = −40 to +85°C)
Item Symbol Conditions MIN. TYP. MAX. Unit
Data hold supply voltage VDDDR 4.0 5.5 V
Release signal set time tSREL 0 µs
Release by RESET 2 15/fX ms Oscillation stabilization time
Release by interrupt request Note 2 ms
unstable upon the start of oscillation.
oscillation stabilization time selection register.
V DD
V DDDR
RESET
Data Hold Timing (Standby Release Signal: STOP Mode Release by Interrupt Signal)
V DD
V DDDR
Standby release signal (interrupt request)

44 PIN PLASTIC LQFP (10x10)
A
B
detail of lead end
P
T
C D
R
44 1 12 11
Q
F
J
G
I H
M
K
M
N
S S
ITEM MILLIMETERS
NOTE
A 12.0 ± 0.2
Each lead centerline is located within 0.20 mm of its true position (T.P.) at maximum material condition.
C 10.0 ± 0.2
D 12.0 ± 0.2
F
G
+0.08 −0.07
J
0.8 (T.P.)
K
1.0±0.2
+0.03 −0.06
N
P 1.4 ± 0.05
Q 0.1 ± 0.05
R 3 °
+4° −3°
1.6 MAX.
0.25 (T.P.)
U
0.6±0.15
33 34 22

The µPD789800 Subseries should be soldered and mounted under the following recommended conditions.
For details of the recommended soldering conditions, refer to the document Semiconductor Device Mounting
Technology Manual (C10535E).
For soldering methods and conditions other than those recommended below, contact an NEC Electronics sales
representative.
µPD789800GB-×××-8ES: 44-pin plastic LQFP (10 × 10)
Soldering Method Soldering Conditions Symbol
Wave soldering Solder bath temperature: 260°C max., Time: 10 seconds max., Count: Once, Preheating temperature: 120°C max. (package surface temperature)

The following development tools are available for development of systems using the µPD789800 Subseries.
Figure A-1 shows the development tools.
Unless otherwise stated, the µPD789800 Subseries, which is supported by IBM PC/AT™ and compatibles, can
be used for the PC98-NX series. When using the PC98-NX series, refer to the descriptions of IBM PC/AT and
compatibles.
Unless otherwise stated, “Windows” indicates the following OSs.
TM Ver.4.0

Figure A-1. Development Tools
· Software package
· Assembler package · C compiler package · Device file · C library source fileNote 1
Control software · Project Manager
(Windows version only)Note 2
Flash memory writing environment
Flash memory writing adapter
Conversion socket or conversion adapter
Project Manager is used only in the Windows environment.

A.1 Software Package
Software tools for development of the 78K/0S Series are combined in this package. The following tools are included. RA78K0S, CC78K0S, ID78K0S-NS, SM78K0S, and device files
Remark ×××× in the part number differs depending on the OS used.
µS××××SP78K0S
×××× Host Machine OS Supply Medium
AB17 Japanese Windows CD-ROM
PC-9800 series, IBM PC/AT compatibles English Windows
A.2 Language Processing Software
Program that converts a program written in mnemonic into object codes that can be executed by a microcontroller. In addition, automatic functions to generate a symbol table and optimize branch instructions are also provided. Used in combination with a device file (DF789801) (sold separately). <Caution when used in PC environment> The assembler package is a DOS-based application but may be used in the Windows environment by using the Project Manager of Windows (included in the assembler package).
CC78K0S C compiler package
Program that converts a program written in C language into object codes that can be executed by a microcontroller. Used in combination with an assembler package (RA78K0S) and device file (DF789801) (both sold separately). <Caution when used in PC environment> The C compiler package is a DOS-based application but may be used in the Windows environment by using the Project Manager of Windows (included in the assembler package).
File containing information inherent to the device. Used in combination with the RA78K0S, CC78K0S, ID78K0S-NS, and SM78K0S (all sold separately).
Source file of functions for generating the object library included in the C compiler package. Necessary for changing the object library included in the C compiler package according to the customer’s specifications. Since this is a source file, its working environment does not depend on any particular operating system.
C library source file
SP78K0S Software package · RA78K0S Assembler package · Device file

Remark ×××× in the part number differs depending on the host machine and operating system to be used.
µS××××RA78K0S
µS××××CC78K0S

µS××××DF789801
µS××××CC78K0S-L


Project Manager Control software created for efficient development of the user program in the Windows environment. User program development operations such as editor startup, build, and debugger startup can be performed from the Project Manager.
The Project Manager is included in the assembler package (RA78K0S).
The Project Manager is used only in the Windows environment.

Flashpro III (FL-PR3, PG-FP3) Flashpro IV (FL-PR4, PG-FP4) Flash programmer
Adapter for writing to flash memory and connected to Flashpro III or Flashpro IV. FA-44GB-8ES: For 44-pin plastic LQFP (GB-8ES type)
Remark The FL-PR3, FL-PR4 and FA-44GB-8ES are products made by Naito Densei Machida Mfg. Co., Ltd.
(TEL +81-45-475-4191).

A.5 Debugging Tools (Hardware)
In-circuit emulator for debugging hardware and software of an application system using the 78K/0S Series. Supports a integrated debugger (ID78K0S-NS). Used in combination with an AC adapter, emulation probe, and interface adapter for connecting the host machine.
The IE-78K0S-NS-A provides a coverage function in addition to the IE-78K0S-NS functions, thus enhancing the debug functions, including the tracer and timer functions.
Adapter for supplying power from an AC 100 to 240 V outlet.
Adapter necessary when using PC-9800 series PC (except notebook type) as host machine (C bus supported)
IE-70000-CD-IF-A PC card interface
PC card and interface cable necessary when using notebook PC as host machine (PCMCIA socket supported)
Interface adapter necessary when using IBM PC/AT compatible as host machine (ISA bus supported)
Adapter necessary when using personal computer incorporating PCI bus as host machine
Board for emulating the peripheral hardware inherent to the device. Used in combination with an in-circuit emulator.
NP-44GB-TQ NP-H44GB-TQ Emulation probe
Cable to connect the in-circuit emulator and target system. Used in combination with the TGB-044SAP.
Conversion adapter to connect the NP-44GB-TQ or NP-H44GB-TQ and a target system board on which a 44-pin plastic LQFP (GB-8ES type) can be mounted
Remarks 1. The NP-44GB-TQ and NP-H44GB-TQ are products made by Naito Densei Machida Mfg. Co., Ltd.
(TEL +81-45-475-4191).
For further information, contact: Daimaru Kogyo, Ltd.
Tokyo Electronics Department (TEL +81-3-3820-7112)
Osaka Electronics Department (TEL +81-6-6244-6672)

A.6 Debugging Tools (Software)
This debugger supports the in-circuit emulators IE-78K0S-NS and IE-78K0S-NS-A for the 78K/0S Series. The ID78K0S-NS is Windows-based software. It has improved C-compatible debugging functions and can display the results of tracing with the source program using an integrating window function that associates the source program, disassemble display, and memory display with the trace result. Used in combination with a device file (DF789801) (sold separately).
This is a system simulator for the 78K/0S Series. The SM78K0S is Windows-based software. It can be used to debug the target system at C source level or assembler level while simulating the operation of the target system on the host machine. Using SM78K0S, the logic and performance of the application can be verified independently of hardware development. Therefore, the development efficiency can be enhanced and the software quality can be improved. Used in combination with a device file (DF789801) (sold separately).
File containing information inherent to the device. Used in combination with the RA78K0S, CC78K0S, ID78K0S-NS, and SM78K0S (sold separately).
Remark ×××× in the part number differs depending on the operating system and supply medium to be used.
µS××××ID78K0S-NS
µS××××SM78K0S
×××× Host Machine OS Supply Medium
PC-9800 series IBM PC/AT compatibles
CD-ROM
BB17

A.7 Notes on Target System Design
Figures A-2 and A-3 show the conditions when connecting the emulation probe to the conversion adapter. Follow
the configuration below and consider the shape of parts to be mounted on the target system when designing a
system.
In-circuit emulator IE-78K0S-NS or IE-78K0S-NS-A
Emulation probe NP-44GB-TQ, NP-H44GB-TQ
Conversion adapter:
Remarks 1. NP-44GB-TQ and NP-H44GB-TQ are products of Naito Densei Machida Mfg. Co., Ltd.
Target system · Emulation board IE-789801-NS-EM1 · 170 mmNote

Figure A-3. Connection Condition of Target System (NP-H44GB-TQ)

Remarks 1. NP-H44GB-TQ is a product of Naito Densei Machida Mfg. Co., Ltd.
Emulation board IE-789801-NS-EM1 · Target system


![Page 231 of the NEC switch user manual — [P]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-231.webp?w=400)
B.2 Register Index (Alphabetic Order of Register Symbol)
[A]
CR00: 8-bit compare register 00 81
CR01: 8-bit compare register 01 81
IF0: Interrupt request flag register 0 167
IF1: Interrupt request flag register 1 167
INTM0: External interrupt mode register 0 168
KRM00: Key return mode register 00 170
MK0: Interrupt mask flag register 0 168
MK1: Interrupt mask flag register 1 168
OSTS: Oscillation settling time select register 179
P0: Port 0 60
P1: Port 1 61
P2: Port 2 62
P4: Port 4 68
PCC: Processor clock control register 74
PM0: Port mode register 0 69
PM1: Port mode register 1 69
PM2: Port mode register 2 69
PM4: Port mode register 4 69
POM0: Port output mode register 0 71
POM1: Port output mode register 1 71
![Page 232 of the NEC switch user manual — [W]](/cdn/reader/71/7104eb6e7ad50e0a5c5ed5328e913eaa9a03e3ba768e4b4d50d139e25583144d/images/page-232.webp?w=400)
PU0: Pull-up resistor option register 0 70
RXSTAT: Packet receive status register 111
SIO10: Transmit/receive shift register 10 155
TCL2: Timer clock select register 2 93
TIDCMP: Token PID compare register 106
TM00: 8-bit timer counter 00 81
TM01: 8-bit timer counter 01 81
TMC00: 8-bit timer mode control register 00 82
TMC01: 8-bit timer mode control register 01 83
USBMOD: USB receiver enable register 109
USBPOB, USBPOW: Transmit/receive pointer 101
USBR0 to USBR7: Receive data address 103
USBRAL, USBRAH: Receive token address 102
USBRD: Receive data PID 103
USBRTP: Receive token PID 102
USBT00 to USBT07: Transmit data bank 0 address 104
USBT10 to USBT17: Transmit data bank 1 address 104
USBTD0: Transmit data PID bank 0 104
USBTD1: Transmit data PID bank 1 104
WDTM: Watchdog timer mode register 94

The revision history is described below. The “Applied to” column indicates the chapters in each edition.
Edition Major Revisions from Previous Edition Applied to:
Deletion of description “under development” for µPD789800, since it has been developed
Addition of GB-8ES type package
Modification of recommended connection of unused pins in type of input/output circuit for each pin
Addition of illustration in direct addressing CHAPTER 3 CPU ARCHITECTURE
Addition of caution regarding operation of 8-bit compare register n (CR0n)
Addition to setting method in description of operation as interval timer
Addition to setting method in description of operation as external event counter
Addition to setting method in description of operation as square wave output
Addition of the value of each register when SETUP received
Deletion of setting RXSTAT with a 1-bit memory manipulation instruction in description of packet receive status register (RXSTAT)
Modification of each bit of RXSTAT from reserved words to non-reserved words in packet receive status register format
Modification of note in Format of Packet Receive Status Register
Modification of flag names in Conditions in Transmit Reservation
Modification of contents in block diagram of regulator and USB driver/receiver CHAPTER 10 REGULATOR
Addition of caution regarding replacement of flash memory version with mask ROM version
CHAPTER 14 µPD78F9801
Modification of description from Flashpro II to Flashpro III in µPD78F9801
Addition of restrictions to pins used when pseudo 3-wire mode is selected as communication mode
Addition of setting example when Flashpro III (PG-FP3) is used
Whole appendix revised for supporting IE-78K0S-NS APPENDIX A DEVELOPMENT TOOLS
Addition of ordering information of MX78K0S in embedded software APPENDIX B EMBEDDED SOFTWARE
Deletion of CU-type and GB-3BS type packages
Deletion of indication “under development” for µPD78F9801
Modification of operating ambient temperature when flash memory is written in 1.1 Features
Addition of outline of timer in 1.7 Functions
Modification of handling of REGC and VPP pins CHAPTER 2 PIN FUNCTIONS

Edition Major Revisions from Previous Edition Applied to:
Correction of address values in Figure 3-1 Memory Map (µPD789800) and Figure 3-2 Memory Map (µPD78F9801)
Modification of Figure 5-3 External Circuit of System Clock Oscillator (b) External clock
Modification of Figure 10-1 Block Diagram of Regulator and USB Driver/Receiver and Cautions
Addition of Remark in Table 11-1 Interrupt Source List
Addition of Caution 3 on watchdog timer interrupt to Figure 11-2 Format of Interrupt Request Flag Register
Addition of 12.2.2 STOP mode (3) Cautions on STOP instruction execution
Revision of contents of flash memory programming as 14.1 Flash Memory Characteristics
CHAPTER 14 µPD78F9801
Addition of CHAPTER 16 ELECTRICAL SPECIFICATIONS CHAPTER 16 ELECTRICAL SPECIFICATIONS
Addition of CHAPTER 17 PACKAGE DRAWING CHAPTER 17 PACKAGE DRAWING
Addition of CHAPTER 18 RECOMMENDED SOLDERING CONDITIONS CHAPTER 18 RECOMMENDED SOLDERING CONDITIONS
Revision of APPENDIX A DEVELOPMENT TOOLS Deletion of embedded software and addition of notes on target system design
Addition of the revision contents in 3rd edition in APPENDIX C REVISION HISTORY
(2/2) · 3rd
Owners and our team usually reply within a day — and your question helps the next person too.
Be the first to ask — other owners or our team will answer.