Document No. U12978EJ3V0UD00 (3rd edition)
Date Published February 2003 N CP (K)
Printed in Japan
1998, 2003
Page 2
[MEMO]
2
User’s Manual U12978EJ3V0UD
Page 3
NOTES FOR CMOS DEVICES
1PRECAUTION 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.
2HANDLING 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 V
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.
or GND with a resistor, if it is considered
DD
3STATUS 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.
User’s Manual U12978EJ3V0UD
3
Page 4
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 customerdesignated "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.
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).
M8E 02. 11-1
4
User’s Manual U12978EJ3V0UD
Page 5
Regional Information
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:
•
Device availability
•
Ordering information
•
Product release schedule
•
Availability of related technical literature
•
Development environment specifications (for example, specifications for third-party tools and
components, host computers, power plugs, AC supply voltages, and so forth)
•
Network requirements
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
5-1Block Diagram of Clock Generator........................................................................................................... 73
5-2Format of Processor Clock Control Register............................................................................................ 74
5-3External Circuit of System Clock Oscillator.............................................................................................. 75
5-4Examples of Incorrect Resonator Connection.......................................................................................... 76
5-5Switching of CPU Clock ........................................................................................................................... 78
6-1Block Diagram of 8-Bit Timer 00 .............................................................................................................. 80
6-2Block Diagram of 8-Bit Timer/Event Counter 01 ...................................................................................... 81
6-3Format of 8-Bit Timer Mode Control Register 00 ..................................................................................... 82
6-4Format of 8-Bit Timer Mode Control Register 01 ..................................................................................... 83
6-5Format of Port Mode Register 2............................................................................................................... 84
6-6Interval Timer Operation Timing of 8-Bit Timer 00 ................................................................................... 86
User’s Manual U12978EJ3V0UD
15
Page 16
LIST OF FIGURES (2/4)
Figure No.TitlePage
6-7Interval Timer Operation Timing of 8-Bit Timer/Event Counter 01............................................................ 86
3-2Special Function Register List.................................................................................................................. 45
4-1Functions of Ports .................................................................................................................................... 58
4-2Configuration of Port ................................................................................................................................ 59
4-3Port Mode Register and Output Latch Settings When Using Alternate Functions ................................... 70
5-1Configuration of Clock Generator............................................................................................................. 73
5-2Maximum Time Required for Switching CPU Clock ................................................................................. 78
6-1Interval Time of 8-Bit Timer 00................................................................................................................. 79
6-2Interval Time of 8-Bit Timer/Event Counter 01......................................................................................... 79
6-3Square Wave Output Range of 8-Bit Timer/Event Counter 01................................................................. 80
6-4Configuration of 8-Bit Timer/Event Counters 00 and 01........................................................................... 80
6-5Interval Time of 8-Bit Timer 00................................................................................................................. 85
6-6Interval Time of 8-Bit Timer/Event Counter 01......................................................................................... 85
6-7Square-Wave Output Range of 8-Bit Timer/Event Counter 01 ................................................................ 88
7-1Inadvertent Loop Detection Time of Watchdog Timer.............................................................................. 91
7-2Interval Time ............................................................................................................................................ 91
7-3Configuration of Watchdog Timer ............................................................................................................ 92
7-4Inadvertent Loop Detection Time of Watchdog Timer.............................................................................. 95
7-5Interval Time of Interval Timer ................................................................................................................. 96
8-1Configuration of USB Function................................................................................................................. 98
8-2Flag of RXSTAT After Reception of USB Reset Signal and Resume Signal ......................................... 113
8-3Conditions in Transmit Reservation ....................................................................................................... 117
8-4List of Sources of Interrupts from USB Function.................................................................................... 127
9-1Configuration of Serial Interface 10........................................................................................................ 155
9-2Operating Mode Settings of Serial Interface 10 ..................................................................................... 158
Note 16-bit access is possible only in short direct addressing.
User’s Manual U12978EJ3V0UD
45
Page 46
CHAPTER 3 CPU ARCHITECTURE
Table 3-2. Special Function Register List (2/3)
AddressSpecial Function Register (SFR) NameSymbolR/WManipulatable Bit UnitAfter Reset
1 Bit8 Bits16 Bits
FF62HToken packet receive result store registerTRXRSLR/W√√—00H
FF63HData/handshake PID compare registerDIDCMPW—√—C3H
FF64HData/handshake packet receive byte
number counter
FF65HData/handshake packet receive result store
register
FF66HData/handshake packet receive mode
register
FF67HPacket receive status registerRXSTAT—√—
FF68HData packet transmit byte number counter 0DTXCO0W—√—20H
FF69HData packet transmit byte number counter 1DTXCO1—√—30H
FF6AHRemote wakeup control registerREMWUPR/W√√—08H
FF6BHTransmit/receive pointerUSBPOWR—√—00H
FF6CHUSB timer start reservation control registerUSBTCLR/W√√—01H
FF6DHUSB receiver enable registerUSBMOD√√—00H
FF72HSerial operation mode register 10CSIM10√√—
FFA1HTransmit data PID bank 0USBTD0W—√—Undefined
FFA2HTransmit data bank 0 address 00USBT00—√—
FFA3HTransmit data bank 0 address 01USBT01—√—
FFA4HTransmit data bank 0 address 02USBT02—√—
FFA5HTransmit data bank 0 address 03USBT03—√—
FFA6HTransmit data bank 0 address 04USBT04—√—
FFA7HTransmit data bank 0 address 05USBT05—√—
FFA8HTransmit data bank 0 address 06USBT06—√—
FFA9HTransmit data bank 0 address 07USBT07—√—
FFABHTransmit data PID bank 1USBTD1—√—
FFACHTransmit data bank 1 address 10USBT10—√—
FFADHTransmit data bank 1 address 11USBT11—√—
FFAEHTransmit data bank 1 address 12USBT12—√—
FFAFHTransmit data bank 1 address 13USBT13—√—
FFB0HTransmit data bank 1 address 14USBT14—√—
FFB1HTransmit data bank 1 address 15USBT15—√—
FFB2HTransmit data bank 1 address 16USBT16—√—
FFB3HTransmit data bank 1 address 17USBT17—√—
FFB5HReceive token PIDUSBRTPR—√—00H
FFB6HReceive token address LUSBRAL—√—
FFB7HReceive token address HUSBRAH—√—
FFE0HInterrupt request flag register 0IF0R/W√√—
FFE1HInterrupt request flag register 1IF1√√—
FFE4HInterrupt mask flag register 0MK0√√—FFH
FFE5HInterrupt mask flag register 1MK1√√—
DRXCON—√—18H
DRXRSLR/W√√—00H
URXMOD√√—
46
User’s Manual U12978EJ3V0UD
Page 47
CHAPTER 3 CPU ARCHITECTURE
Table 3-2. Special Function Register List (3/3)
AddressSpecial Function Register (SFR) NameSymbolR/WManipulatable Bit UnitAfter Reset
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)).
3.3.1 Relative addressing
[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.
[Illustration]
150
PC
+
150
α
150
PC
When S = 0, α indicates all bits 0.
When S = 1, α indicates all bits 1.
876
S
jdisp8
...
PC is the start address of
the next instruction of
a BR instruction.
48
User’s Manual U12978EJ3V0UD
Page 49
CHAPTER 3 CPU ARCHITECTURE
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.
[Illustration]
In case of CALL !addr16 and BR !addr16 instructions
70
CALL or BR
Low Addr.
High Addr.
150
PC
87
User’s Manual U12978EJ3V0UD
49
Page 50
CHAPTER 3 CPU ARCHITECTURE
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.
[Illustration]
76510
Instruction code
ta4–0
001
Effective address
Effective address + 1
151
0100000000
Memory (Table)
70
Low Addr.
High Addr.
150
PC
87
87
650
0
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.
[Illustration]
50
70
rp
150
PC
AX
User’s Manual U12978EJ3V0UD
07
87
Page 51
CHAPTER 3 CPU ARCHITECTURE
3.4 Operand Address Addressing
The following methods are available to specify the register and memory (addressing) to undergo manipulation
during instruction execution.
3.4.1 Direct addressing
[Function]
The memory indicated by immediate data in an instruction word is directly addressed.
[Operand format]
IdentifierDescription
addr16Label or 16-bit immediate data
[Description example]
MOV A, !FE00H; When setting !addr16 to FE00H
Instruction code00101001Opcode
[Illustration]
00000000
11111110
70
Opcode
addr16 (Low)
addr16 (High)
00H
FEH
Memory
User’s Manual U12978EJ3V0UD
51
Page 52
CHAPTER 3 CPU ARCHITECTURE
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.
[Operand format]
IdentifierDescription
saddrLabel or FE20H to FF1FH immediate data
saddrpLabel or FE20H to FF1FH immediate data (even address only)
[Description example]
MOV FE30H, #50H; When setting saddr to FE30H and the immediate data to 50H
Instruction code11110101
00110000
01010000
Opcode
30H (saddr-offset)
50H (Immediate data)
[Illustration]
07
Opcode
saddr-offset
8
α
0
Effective
address
15
1
111111
Short direct memory
52
When 8-bit immediate data is 20H to FFH, α = 0.
When 8-bit immediate data is 00H to 1FH, α = 1.
User’s Manual U12978EJ3V0UD
Page 53
CHAPTER 3 CPU ARCHITECTURE
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.
[Operand format]
IdentifierDescription
sfrSpecial function register name
[Description example]
MOV PM0, A; When selecting PM0 for sfr
Instruction code11100111
[Illustration]
Effective
Address
Opcode
sfr-offset
15
1
111111
07
87
1
00100000
SFR
0
User’s Manual U12978EJ3V0UD
53
Page 54
CHAPTER 3 CPU ARCHITECTURE
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.
[Operand format]
IdentifierDescription
rX, A, C, B, E, D, L, H
rpAX, 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).
[Description example]
MOV A, C; When selecting the C register for r
Instruction code00001010
00100101
INCW DE; When selecting the DE register pair for rp
Instruction code10001000
Register specification code
Register specification code
54
User’s Manual U12978EJ3V0UD
Page 55
CHAPTER 3 CPU ARCHITECTURE
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.
[Operand format]
IdentifierDescription
—[DE], [HL]
[Description example]
MOV A, [DE]; When selecting register pair [DE]
Instruction code00101011
[Illustration]
1508D7
DE
Addressed memory
contents are
transferred
7 0
A
E
Memory address
07
specified with
register pair DE
User’s Manual U12978EJ3V0UD
55
Page 56
CHAPTER 3 CPU ARCHITECTURE
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.
[Operand format]
IdentifierDescription
—[HL+byte]
[Description example]
MOV A, [HL+10H]; When setting byte to 10H
Instruction code00101101
00010000
3.4.7 Stack addressing
[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.
[Description example]
In the case of PUSH DE
Instruction code10101010
56
User’s Manual U12978EJ3V0UD
Page 57
CHAPTER 4 PORT FUNCTIONS
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.
Figure 4-1. Port Types
P20
Port 2
P26
P40
Port 4Port 1
P47
P00
Port 0
P07
P10
P17
User’s Manual U12978EJ3V0UD
57
Page 58
CHAPTER 4 PORT FUNCTIONS
Table 4-1. Functions of Ports
Pin NameI/OFunctionAfter ResetAlternate
Function
P00 to
P07
P10 to
P17
P20
P21SO10
P22SI10
P23—
P24—
P25—
P26
P40 to
P47
I/OPort 0
8-bit I/O port
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).
I/OPort 1
8-bit I/O port
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).
I/OPort 2
7-bit I/O port
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).
I/OPort 4
8-bit I/O port
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).
Input—
Input—
Input
Input
SCK10
INTP0/TI01/TO01
KR00 to KR07
58
User’s Manual U12978EJ3V0UD
Page 59
CHAPTER 4 PORT FUNCTIONS
4.2 Port Configuration
Ports consists the following hardware.
Table 4-2. Configuration of Port
ParameterConfiguration
Control registersPort mode register (PMm: m = 0 to 2, 4)
Pull-up resistor option register (PU0)
Port output mode register (POMm: m = 0, 1)
PortsTotal: 31 (N-ch open-drain output is specifiable for 18 ports.)
Pull-up resistorsSoftware control: 31
User’s Manual U12978EJ3V0UD
59
Page 60
CHAPTER 4 PORT FUNCTIONS
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.
Figure 4-2. Block Diagram of P00 to P07
WR
POM0
PU0
WR
RD
Internal bus
WR
PORT
WR
PM
POM00
PU00
Output latch
(P00 to P07)
PM00 to PM07
Selector
V
DD0
P-ch
V
DD0
P00 to P07
P-ch
N-ch
POM0:Port output mode register 0
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 0 read signal
WR:Port 0 write signal
60
User’s Manual U12978EJ3V0UD
Page 61
CHAPTER 4 PORT FUNCTIONS
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.
Figure 4-3. Block Diagram of P10 to P17
POM0
WR
WR
PU0
RD
Internal bus
WR
PORT
WR
PM
POM01
PU01
Output latch
(P10 to P17)
PM10 to PM17
Selector
V
DD0
P-ch
V
DD0
P10 to P17
P-ch
N-ch
POM0:Port output mode register 0
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 1 read signal
WR:Port 1 write signal
User’s Manual U12978EJ3V0UD
61
Page 62
CHAPTER 4 PORT FUNCTIONS
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.
CautionWhen using the pins of port 2 as the serial interface, the I/O or output latch must be set
according to the function to be used. For how to set the latches, see Table 9-2.
Figure 4-4. Block Diagram of P20
V
DD0
PU0
WR
RD
WR
PORT
Internal bus
WR
PU02
Alternate
function
Selector
Output latch
(P20)
PM
PM20
Alternate
function
P-ch
P20/SCK10
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 2 read signal
WR:Port 2 write signal
62
User’s Manual U12978EJ3V0UD
Page 63
WR
PU0
CHAPTER 4 PORT FUNCTIONS
Figure 4-5. Block Diagram of P21
V
DD0
RD
WR
PORT
Internal bus
WR
PU02
P-ch
Selector
Output latch
(P21)
PM
P21/SO10
PM21
Alternate
function
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 2 read signal
WR:Port 2 write signal
User’s Manual U12978EJ3V0UD
63
Page 64
WR
PU0
CHAPTER 4 PORT FUNCTIONS
Figure 4-6. Block Diagram of P22
V
DD0
RD
WR
PORT
Internal bus
WR
PU02
P-ch
Alternate
function
Selector
Output latch
(P22)
PM
P22/SI10
PM22
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 2 read signal
WR:Port 2 write signal
64
User’s Manual U12978EJ3V0UD
Page 65
WRPU0
CHAPTER 4 PORT FUNCTIONS
Figure 4-7. Block Diagram of P23 and P24
VDD0
PU02
RD
PORT
WR
Internal bus
WRPM
Output latch
(P23, P24)
PM23, PM24
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 2 read signal
WR:Port 2 write signal
P-ch
Selector
P23, P24
User’s Manual U12978EJ3V0UD
65
Page 66
WR
CHAPTER 4 PORT FUNCTIONS
Figure 4-8. Block Diagram of P25
POM1
WR
PU0
RD
Internal bus
WR
PORT
WR
PM
POM125
PU02
Output latch
(P25)
PM25
Selector
V
DD0
P-ch
V
DD0
P25
P-ch
N-ch
POM1:Port output mode register 1
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 2 read signal
WR:Port 2 write signal
66
User’s Manual U12978EJ3V0UD
Page 67
WR
CHAPTER 4 PORT FUNCTIONS
Figure 4-9. Block Diagram of P26
POM1
WR
PU0
RD
Internal bus
WR
PORT
WR
POM126
PU02
V
DD0
P-ch
Selector
V
DD0
P26
P-ch
Output latch
(P26)
PM
N-ch
PM26
POM1:Port output mode register 1
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 2 read signal
WR:Port 2 write signal
User’s Manual U12978EJ3V0UD
67
Page 68
CHAPTER 4 PORT FUNCTIONS
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.
CautionWhen using the pins of port 4 as the key return, key return mode register 00 (KRM00) must be
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).
Figure 4-10. Block Diagram of P40 to P47
V
DD0
WR
PU0
RD
WR
KRM
PORT
WR
Internal bus
WR
PU04
Selector
KRM000 to
KRM007
Output latch
(P40 to P47)
PM
PM40 to PM47
Alternate
function
P-ch
P40/KR00 to
P47/KR07
KRM00:Key return mode register 00
PU0:Pull-up resistor option register 0
PM:Port mode register
RD:Port 4 read signal
WR:Port 4 write signal
68
User’s Manual U12978EJ3V0UD
Page 69
CHAPTER 4 PORT FUNCTIONS
4.3 Registers Controlling Port Function
The following three types of registers control the ports.
• Port mode registers (PM0, PM1, PM2, PM4)
• Pull-up resistor option register (PU0)
• Port output mode registers (POM0, POM1)
(1) Port mode registers (PM0, PM1, PM2, PM4)
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.
CautionAs P26 can be used as an external interrupt input, when the port function output mode is
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.
Figure 4-11. Format of Port Mode Register
7
SymbolAddressAfter reset
PM0
PM071PM06
PM17 PM16 PM15 PM14 PM13 PM12 PM11 PM10PM1
PM2
PM47 PM46 PM45 PM44 PM43 PM42 PM41 PM40
PM4
PMmn
6543210R/W
PM05
PM04
PM03
PM02
PM26
PM25
PM24
PM23
PM22
0Output mode (output buffer on)
Input mode (output buffer off) 1
PM01
PM00
PM21
PM20
Pmn pin input/output mode selection
FF20H
FF21HFFHR/W
FF22H
FF24HFFHR/W
FFH
FFH
R/W
R/W
User’s Manual U12978EJ3V0UD
69
Page 70
CHAPTER 4 PORT FUNCTIONS
Table 4-3. Port Mode Register and Output Latch Settings When Using Alternate Functions
Secondary Function
NameInput/Output
P26TO01Output00
TI01Input1×
INTP0Input1×
P40 to
Note
P47
KR00 to KR07Input1×
PxxPMxxPin Name
Note Set key return mode register 00 (KRM00) to 1 when using the alternate function (see Section 11.3 (5)
Key return mode register 00 (KRM00)).
CautionWhen Port 2 is used as a serial interface pin, the I/O latch or output latch must be set
according to its function. For the setting method, see Table 9-2 Settings of Serial interface
10 Operating Mode.
Remarkx:Don’t care
PMxx: Port mode register
Pxx:Port output latch
(2) Pull-up resistor option register 0 (PU0)
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.
Figure 4-12. Format of Pull-up Resistor Option Register 0
Symbol
765<4>3<2><1><0>
000PU040PU01 PU00PU0
PU0m
0
On-chip pull-up resistor not connected
1
On-chip pull-up resistor connected
CautionBits 3 and 5 to 7 must be set to 0.
70
PU02
Pm on-chip pull-up resistor selection
(m = 0 to 2, 4)
User’s Manual U12978EJ3V0UD
AddressAfter resetR/W
FFF7H00HR/W
Page 71
CHAPTER 4 PORT FUNCTIONS
(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.
Figure 4-13. Format of Port Output Mode Register 0
Symbol
POM0
765432<1><0>
00000
POM0m
0
CMOS output
1
N-ch open-drain output
POM01POM00
0
Pm output mode selection
Note POM0 selects the output mode for a port in 8-bit units.
CautionBits 2 to 7 must be set to 0.
Figure 4-14. Format of Port Output Mode Register 1
Symbol
7<6><5>43210
0
POM126 POM125
POM12n
0
CMOS output
1
N-ch open-drain output
0000POM1
0
Output mode selection for bit n of port 2
AddressAfter resetR/W
FF30H00HR/W
Note
(m = 0, 1)
AddressAfter resetR/W
FF31H00HR/W
Note
(n = 5, 6)
Note POM1 selects the output mode for P25 or P26 in 1-bit units.
CautionBits 0 to 4 and 7 must be set to 0.
User’s Manual U12978EJ3V0UD
71
Page 72
CHAPTER 4 PORT FUNCTIONS
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.
4.4.1 Writing to I/O port
(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.
(2) In input mode
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.
CautionA 1-bit memory manipulation instruction is executed to manipulate 1 bit of a port.
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.
4.4.2 Reading from I/O port
(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.
(2) In input mode
The status of a pin can be read by using a transfer instruction. The contents of the output latch are not
changed.
4.4.3 Arithmetic operation of I/O port
(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.
(2) In input mode
The contents of the output latch become undefined. However, the status of the pin is not changed because the
output buffer is off.
CautionA 1-bit memory manipulation instruction is executed to manipulate 1 bit of a port.
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.
72
User’s Manual U12978EJ3V0UD
Page 73
CHAPTER 5 CLOCK GENERATOR
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.
•••• System clock oscillator
This circuit oscillates at 6.0 MHz. Oscillation can be stopped by executing the STOP instruction.
5.2 Clock Generator Configuration
The clock generator consists of the following hardware.
Table 5-1. Configuration of Clock Generator
ItemConfiguration
Control registerProcessor clock control register (PCC)
OscillatorSystem clock oscillator
X1
X2
System
clock oscillator
STOP
Figure 5-1. Block Diagram of Clock Generator
Prescaler
f
Prescaler
X
X
f
2
2
Selector
PCC1
Internal bus
Standby
controller
Processor clock
control register (PCC)
Wait
controller
Clock for peripheral
hardware
CPU clock (f
CPU
)
User’s Manual U12978EJ3V0UD
73
Page 74
CHAPTER 5 CLOCK GENERATOR
5.3 Register Controlling Clock Generator
The clock generator is controlled by the following register.
• Processor clock control register (PCC)
(1) Processor clock control register (PCC)
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.
Figure 5-2. Format of Processor Clock Control Register
SymbolAddressAfter resetR/W
76543210
000000PCC10PCC
PCC1
0
1
f
X
fX/22
CPU clock (f
CPU
) selection
FFFBH02HR/W
Minimum instruction execution time: 2/f
fX = 6.0 MHz operation
µ
0.33 s
1.33 s
µ
CautionBits 0 and 2 to 7 must be set to 0.
Remark fX
: system clock oscillation frequency
CPU
74
User’s Manual U12978EJ3V0UD
Page 75
CHAPTER 5 CLOCK GENERATOR
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.
Figure 5-3. External Circuit of System Clock Oscillator
(a) Crystal oscillation(b) External clock
External
clock
OPEN
X1
X2
Crystal resonator
V
X1
X2
SS0
CautionWhen using the system clock oscillator, wire as follows in the area enclosed by the broken
lines in Figure 5-3 to avoid an adverse effect from wiring capacitance.
•••• Keep the wiring length as short as possible.
•••• Do not cross the wiring with other signal lines. Do not route the wiring near a signal line
through which a high fluctuating current flows.
•••• Always make the ground point of the oscillator capacitor the same potential as VSS0. Do not
ground the capacitor to a ground pattern through which a high current flows.
•••• Do not fetch signals from the oscillator.
User’s Manual U12978EJ3V0UD
75
Page 76
CHAPTER 5 CLOCK GENERATOR
5.4.2 Examples of incorrect resonator connection
Figure 5-4 shows examples of incorrect resonator connection.
Figure 5-4. Examples of Incorrect Resonator Connection (1/2)
(a) Too long wiring(b) Crossed signal line
PORTn
(n = 0, 1, 2, 4)
SS0
V
X1X2
(c) Wiring near high fluctuating current
SS0
X1X2
V
V
SS0
X1X2
(d) Current flowing through ground line of oscillator
(potential at points A, B, and C fluctuates)
Pmn
SS0
V
X1
X2
DD0
V
76
High current
ABC
High current
User’s Manual U12978EJ3V0UD
Page 77
CHAPTER 5 CLOCK GENERATOR
Figure 5-4. Examples of Incorrect Resonator Connection (2/2)
(e) Signals are fetched
V
SS0
X1X2
5.4.3 Frequency divider
The frequency divider divides the output of the system clock oscillator (fX
) to generate various clocks.
5.5 Clock Generator Operation
The clock generator generates the following clocks and controls the operation modes of the CPU, such as the
standby mode.
• System clock f
X
• CPU clock fCPU
• Clock to peripheral hardware
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).
User’s Manual U12978EJ3V0UD
77
Page 78
CHAPTER 5 CLOCK GENERATOR
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).
Table 5-2. Maximum Time Required for Switching CPU Clock
Set Value Before SwitchingSet Value After Switching
PCC1PCC1PCC1
01
04 clocks
12 clocks
Remark Before switching, the minimum instruction execution time of the CPU clock is two clocks.
5.6.2 Switching CPU clock
The following figure illustrates how the CPU clock switches.
Figure 5-5. Switching of CPU Clock
V
DD
RESET
CPU clock
Slow
operation
Wait (5.46 ms: at 6.0 MHz operation)
Internal reset operation
Fastest operation
<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
which oscillation stabilization (2
/fX) is automatically secured.
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.
78
User’s Manual U12978EJ3V0UD
Page 79
CHAPTER 6 8-BIT TIMER/EVENT COUNTERS 00 AND 01
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.
• Interval timer (TM00 and TM01)
• External event counter (TM01 only)
• Square wave output (TM01 only)
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”.
(1) 8-bit interval timer
When the 8-bit timer/event counter is used as an interval timer, it generates an interrupt at any preset time