Description
1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
M30245 Group
The M30245 group is a 16-bit microcomputer based on the M16C family core technology that uses a high
performance silicon gate CMOS process with an M16C/62 Series CPU core. It comes packaged in a 100-pin
molded plastic LQFP. They are single-chip USB peripheral microcontrollers that operate at Full Speed (12
Mbps) and are compliant with the Universal Serial Bus (USB) Version 2.0 specification. They also include
many built-in peripherals including: A/D converter, Timers, UARTs, Serial Sound Interface, I2C, DMAC, CRC
and more. These microcontrollers operate using sophisticated instructions featuring a high level of instruction
efficiency, making them capable of executing instructions at high speed.
Features
Number of instructions................................ 91
Shortest instruction execution time ............. 62.5ns f(XIN)=16MHz, Vcc=3V with no wait
USB features: .............................................. Supports full-speed operation (12 Mbps)
3.25K programmable FIFO
9 endpoints
Integrated transceiver
Conforms to USB V 2.0 Specification
Frequency synthesizer ................................ PLL for 48MHz clock
Memory capacity .......................................... 64K ROM / 5K RAM (M30245M8-XXXGP)
128K ROM / 10K RAM (M30245MC-XXXGP)
128K Flash /10K RAM (M30245FCGP)
Supply voltage ............................................. 3.0 to 3.6V (f(XIN)=16MHz)
Processor modes ....................................... Single chip, Memory expansion, Microprocessor
Interrupts ..................................................... 31 internal and 5 external interrupt sources
4 software interrupt sources
7 levels (including key input interrupt X 8)
Multifunction 16-bit timer ............................. 5 16-bit timers
UART ........................................................... 2 X 7/8/9, 2 X 7/8/9/16/24/32 bits
Configurable for synchronous or asynchronous mode,
Serial Sound Interface, I2C Bus
DMAC ........................................................... 4 channels
A-D Converter .............................................. 10 bits X 8 channels
CRC calculation circuit................................ 2 polynomials with MSB/LSB selectable
Watchdog timer ........................................... 1 line
Key-on wake up ........................................... 8 inputs
Programmable I/O ....................................... 82 lines
Clock-generating circuit .............................. 2 built-in clock generation circuits
(built-in feedback resistor, and external ceramic or quartz oscillator)
Description
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
2
Table of Contents
Features ................................................................................................................................................................. 1
Description............................................................................................................................................................. 3
Memory................................................................................................................................................................. 12
Central Processing Unit ...................................................................................................................................... 13
Reset.................................................................................................................................................................... 16
Special Function Registers ................................................................................................................................. 18
Processor Modes ................................................................................................................................................. 26
System Clock ....................................................................................................................................................... 38
Frequency synthesizer circuit............................................................................................................................... 47
Interrupts .............................................................................................................................................................. 50
INT interrupt.......................................................................................................................................................... 62
NMI Interrupt ......................................................................................................................................................... 62
Key-Input Interrupt ................................................................................................................................................ 62
Address-Match Interrupt....................................................................................................................................... 65
Watchdog Timer ................................................................................................................................................... 68
Universal Serial Bus ............................................................................................................................................ 70
Vbus Detect .......................................................................................................................................................... 98
Direct memory access controller....................................................................................................................... 100
Timer A ............................................................................................................................................................... 110
Serial Communication ....................................................................................................................................... 125
Clock synchronous serial I/O mode .................................................................................................................. 132
Clock asynchronous serial I/O (UART) mode ................................................................................................... 137
UART mode (compliant with the SIM interface)................................................................................................. 142
I2C Bus interface mode ..................................................................................................................................... 145
Serial Interface Special Function (SPI mode) ................................................................................................... 152
Serial Sound Interface ....................................................................................................................................... 155
A-D converter...................................................................................................................................................... 165
CRC calculation circuit ...................................................................................................................................... 174
Programmable I/O ports .................................................................................................................................... 177
Flash memory .................................................................................................................................................... 186
CPU Rewrite Mode ............................................................................................................................................ 188
Parallel I/O Mode................................................................................................................................................ 197
Standard Serial I/O Mode ................................................................................................................................... 199
Electrical Specifications ..................................................................................................................................... 225
Applications........................................................................................................................................................ 237
Description
3
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Applications
USB peripherals, such as telephones, audio systems, office equipment, communications equipment, portable
devices, scanners, digital cameras, and memory card readers.
Block Diagram
Figure 1.1 is a block diagram of the M30245 group.
Figure 1.1. Block diagram of M30245 group
A1
FB
Port P0 Port P1 Port P2 Port P3 Port P4 Port P5 Port P6
Port P8 Port P10
INTB
PC
FLG
R0H R0L
R1H R1L
R2
R3
A0
A1
FB
R0H R0L
R1H R1L
R2
R3
SB
Multiplier
M16C/62 16-bit CPU Core
ROM/FLASH
RAM
Memory
CRC Arithmetic Circuit
(X
16
+X
12
+X
5
+1, X
16
+X
15
+X
2
+1)
UART/Clock Synchronous SI/O
(8 bits X 4 channels)
A-D Converter
(10 bits X 8 channels)
DMAC
(4 channels)
USB Function
(Note 2)
USB FIFO
(3.25K bytes)
Timer TA0 (16 bits)
Timer TA1 (16 bits)
Timer TA2 (16 bits)
System Clock Generator
Xin - Xout
Xcin - Xcout
Watchdog Timer
(15 bits)
with frequency synthesizer
Internal Peripheral Functions
8 8 8 8 8 8 8
7 8
(Note 1)
Port P7
8
3
A0
USP
ISP
Program counter
Vector table
Stack pointer
Registers
Port P85
1
Timer TA4 (16 bits)
Timer TA3 (16 bits)
Timers
Ports P90, P92, P93
Note 1: ROM size depends on MCU type
Note 2: RAM size depends on MCU type
Description
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
4
Performance outline
Parameters Function Description
Number of basic Instructions 91
Shortest Instruction execution time 62.5 ns f(Xin)= 16 MHz, Vcc = 3V
Memory size ROM 128/64 Kbytes
RAM 10/5 Kbytes
Input/Output ports P0 to P8, P10 (excl P8
5
) I/O 8 bits x 10
P8
5
I 1 bit x 1
Multifuncti on timer TA0, TA 1, TA2, TA3, TA4 16 bits x 5
Serial I/O UART0 to 1 UAR T (or cloc k synchrono us or Serial Sou nd Interfac e) x 2
UART2 to 3 UART (or clock synchronous) x 2
A-D converter 10 bits x 8 channels
DMAC 4 channels (31 trigger sources)
CRC calculation circuits CRC-CCITT and CRC-16
Watchdog timer 15 bits x 1 (with prescaler)
Interrupts 31 internal, 4 external sources, 4 software, 7 levels
Clock-generating circuit 2 built-in clock generating circuits
(built in feedback resistor, and external ceramic or quartz oscillator)
Supply voltage 3.0 ~ 3.6V, f(X
in
) = 16MHz
Power consumption TBD
I/O characteristics I/O withstand voltage 3V
Output current 5mA (20mA available on P7)
Operati ng tem pera ture -20 to 85 C
Device configuration CMOS high performance silicon gate
Package 100-pin plastic mold LQFP
P9 I/O 4 bits x 1
Table 1.1 is a performance outline of the M30245 group.
Table 1.1. M30245 Group performance outline
Description
5
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Pin Configuration
Figure 1.2 shows the pin configuration (top view). Table 1.2 lists the pin cross references and Table 1.3 de-
scribes the pin functions.
Figure 1.2. Pin Configuration (top view)
100
99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76
VbusDTCT
P9
0
/ATTACH
UVcc
USB D+
USB D-
BYTE
CNVss
P8
7
/XC
IN
P8
6
/XC
OUT
RESET
X
OUT
Vss
X
IN
Vcc
P8
5
/NMI
P8
4
/INT2
P8
3
/INT1
P8
2
/INT0
P8
1
/TA4
IN
P8
0
/TA4
OUT
P7
7
/CTS3/RTS3/SS3/TA3
IN
/LED7
P7
6
/CLK3/SCK3/TA3
OUT
/LED6
P7
5
/RxD3/SCL3/STxD3/TA2
IN
/LED5
P7
4
/TxD3/SDA3/SRxD3/TA2
OUT
/LED4
P7
3
/CTS2/RTS2/SS2/TA1
IN
/LED3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
P1
3
/D
11
P1
4
/D
12
P1
5
/D
13
P1
6
/D
14
P1
7
/D
15
P2
0
/A
0
P2
1
/A
1
P2
2
/A
2
P2
3
/A
3
P2
4
/A
4
P2
5
/A
5
P2
6
/A
6
P2
7
/A
7
Vss
P3
0
/A
8
Vcc
P3
1
/A
9
P32/A
10
P3
3
/A
11
P3
4
/A
12
P3
5
/A
13
P3
6
/A
14
P3
7
/A
15
P4
0
/A
16
P4
1
/A
17
75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51
50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26
P4
2
/A18
P4
3
/A19
P4
4
/CS0
P4
5
/CS1
P4
6
/CS2
P4
7
/CS3
P5
0
/WRL/WR
P5
1
/WRH/BHE
P5
2
/RD
P5
3
/BCLK
P5
4
/HLDA
P5
5
/HOLD
P5
6
/ALE
P5
7
/RDY
P6
0
/CTS0/RST0/SS0/WS0
P6
1
/CLK0/SCK0
P6
2
/RxD0/SCL0/STxD0/SRxD0
P6
3
/TxD0/SDA0/SRxD0/STxD0
P6
4
/CTS1/RTS1/SS1/WS1
P6
5
/CLK1/SCK1
P6
6
/RxD1/SCL1/STxD1/SRxD1
P6
7
/TxD1/SDA1/SRxD1/STxD1
P7
0
/TxD2/SDA2/SRxD2/TA0
OUT
/LED0
P7
1
/RxD2/SCL2/STxD2/TA0
IN
/LED1
P7
2
/CLK2/TA1
OUT
/SCK2/LED2
P1
2
/D
10
P1
1
/D
9
P1
0
/D
8
P0
7
/D
7
P0
6
/D
6
P0
5
/D
5
P0
4
/D
4
P0
3
/D
3
P0
2
/D
2
P0
1
/D
1
P0
0
/D
0
P10
7
/AN
7
/KI
7
P10
6
/AN
6
/KI
6
P10
5
/AN
5
/KI
5
P10
4
/AN
4
/KI
4
P10
3
/AN
3
/KI
3
P10
2
/AN
2
/KI
2
P10
1
/AN
1
/KI
1
AVss
LPF
V
REF
AVcc
P10
0
/AN
0
/KI
0
P9
3
/AD
TRG
P9
2
/SOF
M30245Mx/FC
100-pin QFP (0.5mm pitch)
Description
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
6
Table 1.2. Pin cross reference
Pin
No. Control Port Interrupt Timer UART/
USB SPI I
2
CSerial Sound
Interface Analog/
Other Bus Control
1 Vbus DTCT
2P9
0
ATTACH
3UVcc
6BYTE
7CNVss
8X
CIN
P8
7
9X
COUT
P8
6
10 RESET
11 X
OUT
12 Vss
13 X
IN
14 Vcc
15 P8
5
NMI
16 P8
4
INT2
17 P8
3
INT1
18 P8
2
INT0
19 P8
1
TA4
IN
20 P8
0
TA4
OUT
21 P7
7
TA3
IN
CTS3/RTS3 SS3 LED7
22 P7
6
TA3
OUT
CLK3 SCK3 LED6
23 P7
5
TA2
IN
RxD3 STxD3 SCL3 LED5
24 P7
4
TA2
OUT
TxD3 SRxD3 SDA3 LED4
25 P7
3
TA1
IN
CTS2/RTS2 SS2 LED3
26 P7
2
TA1
OUT
CLK2 SCK2 LED2
27 P7
1
TA0
IN
RxD2 STxD2 SCL2 LED1
28 P7
0
TA0
OUT
TxD2 SRxD2 SDA2 LED0
29 P6
7
TxD1 SRxD1 SDA1 STxD1
30 P6
6
RxD1 STxD1 SCL1 SRxD1
31 P6
5
CLK1 SCK1 SCK1
32 P6
4
CTS1/RTS1 SS1 WS1
33 P6
3
TxD0 SRxD0 SDA0 STxD0
34 P6
2
RxD0 STxD0 SCL0 SRxD0
35 P6
1
CLK0 SCK0 SCK0
36 P6
0
CTS0/RTS0 SS0 WS0
37 P5
7
RDY
38 P5
6
ALE
39 P5
5
HOLD
40 P5
4
HLDA
41 P5
3
BCLK
42 P5
2
RD
43 P5
1
WRH/BHE
44 P5
0
WRL/WR
45 P4
7
CS3
46 P4
6
CS2
47 P4
5
CS1
48 P4
4
CS0
49 P4
3
A19
50 P4
2
A18
51 P4
1
A17
4
5USB D+
USB D-
CLK3
CLK2
CLK1
CLK0
Description
7
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.2. Pin cross reference
52 P4
0
A
16
53 P3
7
A
15
54 P3
6
A
14
55 P3
5
A
13
56 P3
4
A
12
57 P3
3
A
11
58 P3
2
A
10
59 P3
1
A
9
60 Vcc
61 P3
0
A
8
62 Vss
63 P2
7
A
7
64 P2
6
A
6
65 P2
5
A
5
66 P2
4
A
4
67 P2
3
A
3
68 P2
2
A
2
69 P2
1
A
1
70 P2
0
A
0
71 P1
7
D
15
72 P1
6
D
14
73 P1
5
D
13
74 P1
4
D
12
75 P1
3
D
11
76 P1
2
D
10
77 P1
1
D
9
78 P1
0
D
8
79 P0
7
D
7
80 P0
6
D
6
81 P0
5
D
5
82 P0
4
D
4
83 P0
3
D
3
84 P0
2
D
2
85 P0
1
D
1
86 P0
0
D
0
87 P10
7
KI
7
AN
7
88 P10
6
KI
6
AN
6
89 P10
5
KI
5
AN
5
90 P10
4
KI
4
AN
4
91 P10
3
KI
3
AN
3
92 P10
2
KI
2
AN
2
93 P10
1
KI
1
AN
1
94 AVss
95 LPF
96 V
REF
97 AVcc
98 P10
0
KI
0
AN
0
99 P9
3
AD
TRG
100 P9
2
SOF
Pin
No. Control Port Interrupt Timer UART/
USB SPI I
2
CSerial Sound
Interface Analog/
Other Bus Control
Description
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
8
With a 16-bit external data bus, data is written to even addresses when the
WRL signal is "L", and to the odd addresses when the WRH signal is "L". Data
is read when RD is "L".
Port Function Pin Name I/O Description
Power supply input Vcc 3.0 to 3.6V
Vss 0V
CPU mode switch CNVss I Connect to Vss: single-chip or memory expansion mode
Connect to Vcc: Microprocessor mode only
External data bus width select
input BYTE I Selects external memory data bus width.
Connect to Vss: 16-bit.
Connect to Vcc: 8-bit.
Reset input RESET I "L" resets the microcomputer.
Clock input X
IN
I These pins support the main clock generating circuit. Connect a crystal between
the X
IN
and X
OUT
pins. To use an external clock, i nput it to the X
IN
pin and leave
the X
OUT
pin open.
Clock output X
OUT
O
Analog power supply input AVcc Connect to Vcc.
AVss Connect to Vss.
Reference voltage input V
REF
I This is a reference voltage for A-D converter.
Low pass filter LPF O Loop filter for the frequency synthesizer circuit.
USB power supply input UVcc Power pin for USB
Vbus detect VbusDTCT I Detects USB host power
USB D+ USB D+ I/O USB D+ voltage line interface
USB D- USB D- I/O USB D- voltage line interface
P0 I/O port P0
0
to P0
7
I/O This is an 8-bit CMOS I/O port. The input/output port direction register allows
each pin to be set individually. When used for input, the port can be set to include
internal pull-up resistors in 4-pin blocks.
Data bus D
0
to D
7
I/O Thes e pins input and output 8 low-order data bits when set as a separate bus.
P1 I/O port P1
0
to P1
7
I/O This is an 8-bit I/O port equivalent to P0.
Data bus D
8
to D
15
I/O These pins input and output 8 high-order data bits when set as a separate bus.
P2 I/O port P2
0
to P2
7
I/O This is an 8-bit I/O port equivalent to P0.
Address bus A
0
to A
7
O These pins output 8 low-order address bits.
P3 I/O port P3
0
to P3
7
I/O This is an 8-bit I/O port equivalent to P0.
Address bus A
8
to A
15
O These pins output 8 middle-order address bits.
P4 I/O port P4
0
to P4
7
I/O This is an 8-bit I/O port equivalent to P0.
Address bus A
16
to A
19
O These pins output 4 high-order address bits.
Chip select CS0 to CS3 OP4
4
to P4
7
are chip select output pins that specify access areas.
P5 I/O port P5
0
to P5
7
I/O This is an 8-bit I/O port equivalent to P0.
Bus control WRL/WR O Ouput WRL, WRH (WR, BHE), and RD bus control signals. Using WRL and
WRH or WR and BHE can be switched using software control.
WRL, WRH, and RD selected.
WR, BHE, and RD selected.
Data is written when WR is "L". Data is read when RD is "L". Odd addresses are
accessed when BHE is "L". Use this mode when using an 8-bit external data bus.
WRH/BHE O
RD O
BCLK O Output operation clock for the CPU.
HOLD I While the HOLD pin input is "L", the MCU is placed in the Hold state.
HLDA OThe HLDA pin output is "L" while the MCU is in the hold state.
ALE O The ALE pin can be used to latch the address.
RDY I While the RDY pin input is "L", the MCU is in the ready state.
Table 1.3. Pin description
Description
9
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.3. Pin descriptions
P6 I/O port P60 to P6 7I/O This is an 8-bit I/O port equivalent to P0.
UART CTS/RTS/SS/WS
CLK/SCK
RxD/SCL/STxD
TxD/SDA/SRxD
I/O P60 to P63 are I/O ports for UART0.
P64 to P67 are I/O ports for UART1.
These pins can be used for Serial Sound Interface, I2C and SPI communication.
P7 I/O port P70 to P7 7I /O This is an 8-bit I/O port equivalent to P0. P70 and P71 are N-channel open drain
output.
Timer A TAIN IP7
0 to P77 are I/O ports for Timer A0 to A3.
TAOUT O
UART CTS/RTS/SS/WS
CLK/SCK
RxD/SCL/STxD
TxD/SDA/SRxD
P70 to P73 are I/O ports for UART2.
P74 to P77 are I/O ports for UART3.
These pins can be used for I2C and SPI communication.
LED drive LED0 to LED7O These pins are capable of sinking 20mA for driving LEDs.
P8
External interrupt input INT0 to INT 2 IP8
2 to P84 are external interrupt input ports.
Input P85/NMI I Input port for NMI interrupt.
P9 I/O port P90, P92, P93I/O This is a 3-bit I/O port equivalent to P0.
A-D ADTRG IP9
3 is an A-D trigger input port.
USB-ATTACH ATTACH O P90 can be used to attach or det ach from the USB host without disconnecting t he
USB cable.
USB SOF SOF O P92 is an output for the USB start of frame signal pulse.
P10 I/O port P100 to P107I/O This is an 8-bit I/O port equivalent to P0.
Key-input interrupt KI0 to KI7IP10
0 to P107 are key-input interrupt ports.
Analog input AN0 to AN7IP10
0 to P107 are analog input ports for A-D converter.
Port Function Pin Name I/O Description
I/O
I/O port P80 to P84, P86, P87This is a 7-bit I/O port equivalent to P0.
XC
IN
, XC
OUT
P86 and P87
, connect an oscillator between these pins for sub-clock generation.
I/O
I, O
Sub-Clock
Description
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
10
Type No. M30 24 5 F C - XXX GP
Package typ e: GP: Pack ag e 100P6Q-A
ROM No.: Omitted for flash memory version
ROM capacity: 4: 32Kbytes
8: 64Kbytes
A: 96Kbytes
C: 128Kbytes
G: 256Kbytes
Memory type: M: Mask ROM version
F: Flash memory version
Part type: The value itself has no specific meaning
M16C/24 Group
M16C Family
Type ROM Capacity RAM Capacity Package Type Remarks
M30245FCGP 128K bytes 10K bytes 100P6Q-A Flash Memory Version 
M30245MC-XXXGP 128K bytes 10K bytes 100P6Q-A Mask ROM Version
M30245M8-XXXGP 64K bytes 5K bytes 100P6Q-A Mask ROM Version
Mitsubishi plans to release the following products in the M30245 group:
(1) Support for Flash memory version and mask ROM versions
(2) ROM capacity: 128 or 64 Kbytes
(3) Package: 100P6Q-A Plastic molded LQFP
Figure 1.3 shows the type number, memory size and package for the M30245 group. Table 1.4 lists the package
number, type, ROM and RAM capacity for the M30245 group.
Figure 1.3. Type number, memory size, and package
Table 1.4. Package number, type, ROM and RAM capacity for M30245 group
Description
11
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
frequency
RAM
DMAC x 4
M16C CPU
UART x 4
Timers x 5
Watchdog
CRC Circuit
I/O Ports (P0 to P10)
FIFOs
USB Function Control Unit
Transceiver
D
+
D
-
(Normal MCU or DMA Transfer)
1 - 16MHz
48 MHz
synthesizer
LED Drivers
(X 8)
A-D
Converter
Timer
ROM
USB Overview
The M30245 group is a single-chip PC peripheral microcontroller that is compliant with the Universal Serial
Bus (USB) Version 2.0 specification for full-speed USB operation (12Mbps). This device provides an interface
between a USB-equipped host computer and PC peripherals such as telephones, audio systems, and digital
cameras. The M30245 architectural overview is shown in Figure 1.4.
The USB function control unit of the M30245 group supports full-speed operation and all four data transfer types
listed in the USB specification. Each transfer type is used for controlling a different set of PC peripherals.
Isochronous transfers provide guaranteed bus access, a constant data rate, and error tolerance for devices
such as computer-telephone integration (CTI) and audio systems.
Interrupt transfers are designed to support human input devices (HID) that communicate small amounts of
data infrequently.
Bulk transfers are necessary for devices such as digital cameras and scanners that communicate large
amounts of data to the PC as bus bandwidth becomes free.
Control transfers are supported and are useful for bursty, host-initiated type communication where bus man-
agement is the primary concern.
Figure 1.4. M30245 architectural overview
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Functional Block Operation
12
Functional Block Operation
The M30245 group contains many functional blocks in a single chip. These blocks include ROM and RAM
to store instructions and data and the central processing unit (CPU) to execute arithmetic/logic operations.
Also included are peripheral blocks such as Timer A, serial I/O, DMAC, CRC calculation circuit, A-D con-
verter, and I/O ports.
Memory
Figure 1.5 is a memory map of the M30245 group. The address space extends the 1M bytes from address
0000016 to FFFFF16. From FFFFF16 down is ROM. For example, in the M30245MC-XXXGP, there is 128K bytes
of internal ROM from E000016 to FFFFF16. The vector table for fixed interrupts such as the reset and NMI are
mapped to FFFDC16 to FFFFF16. The starting address of the interrupt routine is stored here. The address of the
vector table for timer interrupts, etc., can be set as desired using the internal register (INTB). See the section on
interrupts for details.
From 0040016 up is RAM. For example, in the M30245MC-XXXGP, 10K bytes of internal RAM is mapped to the
space from 0040016 to 02BFF16. In addition to storing data, the RAM also stores the stack used when calling
subroutines and when interrupts are generated.
The SFR area is mapped to 0000016 to 003FF16. This area accommodates the control registers for peripheral
devices such as I/O ports, A-D converter, serial I/O, and timers, etc. Any part of the SFR area that is not occupied
is reserved and cannot be used for other purposes.
The special page vector table is mapped to FFE0016 to FFFDB16. If the starting addresses of subroutines or the
destination addresses of jumps are stored here, subroutine call instructions and jump instructions can be used as
2-byte instructions, reducing the number of program steps.
In memory expansion mode and microprocessor mode, some memory areas are reserved and cannot be used.
For example, in the M30245MC-XXXGP, the following areas cannot be used.
• The space between 02C0016 and 03FFF16 (Memory expansion and microprocessor modes)
• The space between D000016 and E000016 (Memory expansion mode)
Figure 1.5. Memory map
00000
16
YYYYY
16
FFFFF
16
00400
16
04000
16
XXXXX
16
D0000
16
External area
Internal ROM area
SFR area
For details, see
Table 1.6 to 1.13
Internal RAM area
Internal reserved
area (Note 1)
Internal reserved
area (Note 2)
FFE00
16
FFFDC
16
FFFFF
16
Note 1: Cannot be used during memory expansion and microprocessor mode
s
Note 2: Cannot be used in memory expansion mode.
Undefined instruction
Overflow
BRK instruction
Address match
Single step
Watchdog timer
Reset
Special page
vector table
DBC
NMI
M30245FCGP 02BFF16 E000016
M30245MC-XXXGP 02BFF16 E000016
M30245M8-XXXGP F000016017FF16
Address XXXXX16
Type No. Address YYYYY16
Central Processing Unit
13
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS USB MICROCOMPUTER
Central Processing Unit
The CPU has a total of 13 registers shown in Figure 1.6. Seven of these registers (R0, R1, R2, R3, A0, A1, and FB)
come in two sets; therefore, these have two register banks.
Figure 1.6. Central processing unit register
HL
b15 b8 b7 b0
R0
(Note)
HL
b15 b8 b7 b0
R1
(Note)
R2
(Note) b15 b0
R3
(Note) b15 b0
A0
(Note) b15 b0
A1
(Note) b15 b0
FB
(Note) b15 b0
Data
registers
Address
registers
Frame base
registers
b15 b0
b15 b0
b15 b0
b15 b0
b0 b19
b0
b19
HL
Program counter
Interrupt table
register
User stack pointer
Interrupt stack
pointer
Static base
register
Flag register
PC
INTB
USP
ISP
SB
FLG
Note: These registers consist of two register banks.
CDZSBOIU
IPL
Data registers (R0, R0H, R0L, R1, R1H, R1L, R2, and R3)
Data registers (R0, R1, R2, and R3) are configured with 16 bits, and are used primarily for transfer and
arithmetic/logic operations.
Registers R0 and R1 each can be used as separate 8-bit data registers, high-order bits as (R0H/R1H), and
low-order bits as (R0L/R1L). In some instructions, registers R2 and R0, as well as R3 and R1 can use as
32-bit data registers (R2R0/R3R1).
Address registers (A0 and A1)
Address registers (A0 and A1) are configured with 16 bits, and have functions equivalent to those of data
registers. These registers can also be used for address register indirect addressing and address register
relative addressing.
In some instructions, registers A1 and A0 can be combined for use as a 32-bit address register (A1A0).
Frame base register (FB)
Frame base register (FB) is configured with 16 bits, and is used for FB relative addressing.
Central Processing Unit
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS USB MICROCOMPUTER
14
Program counter (PC)
Program counter (PC) is configured with 20 bits, indicating the address of an instruction to be executed.
Interrupt table register (INTB)
Interrupt table register (INTB) is configured with 20 bits, indicating the start address of an interrupt vector
table.
Stack pointer (USP/ISP)
The stack pointer comes in two types: user stack pointer (USP) and interrupt stack pointer (ISP), each
configured with 16 bits.
The desired type of stack pointer (USP or ISP) can be selected by the stack pointer select flag (U flag). This
flag is located at bit 7 of the flag register (FLG).
Static base register (SB)
Static base register (SB) is configured with 16 bits, and is used for SB relative addressing.
Flag register (FLG)
Flag register (FLG) is configured with 11 bits, each bit is used as a flag. Figure 1.7 shows the flag register
(FLG). The following explains the function of each flag:
• Bit 0: Carry flag (C flag)
This flag retains a carry, borrow, or shift-out bit that has occurred in the arithmetic/logic unit.
• Bit 1: Debug flag (D flag)
This flag enables a single-step interrupt.
When this flag is “1”, a single-step interrupt is generated after instruction execution. This flag is cleared to
“0” when the interrupt is acknowledged.
• Bit 2: Zero flag (Z flag)
This flag is set to “1” when an arithmetic operation resulted in 0; otherwise, cleared to “0”.
• Bit 3: Sign flag (S flag)
This flag is set to “1” when an arithmetic operation resulted in a negative value; otherwise, cleared to “0”.
• Bit 4: Register bank select flag (B flag)
This flag chooses a register bank. Register bank 0 is selected when this flag is “0”; register bank 1 is
selected when this flag is “1”.
• Bit 5: Overflow flag (O flag)
This flag is set to “1” when an arithmetic operation resulted in overflow; otherwise, cleared to “0”.
• Bit 6: Interrupt enable flag (I flag)
This flag enables all maskable interrupts.
Interrupts are disabled when this flag is “0”, and are enabled when this flag is “1”. This flag is cleared to “0”
when an interrupt is acknowledged.
Central Processing Unit
15
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS USB MICROCOMPUTER
• Bit 7: Stack pointer select flag (U flag)
Interrupt stack pointer (ISP) is selected when this flag is “0”; user stack pointer (USP) is selected when this
flag is “1”.
This flag is cleared to “0” when a hardware interrupt is acknowledged or an INT instruction of software
interrupt Nos. 0 to 31 is executed.
• Bits 8 to 11: Reserved area
• Bits 12 to 14: Processor interrupt priority level (IPL)
Processor interrupt priority level (IPL) is configured with three bits, for specification of up to eight processor
interrupt priority levels from level 0 to level 7.
If a requested interrupt has priority greater than the processor interrupt priority level (IPL), the interrupt is
enabled.
• Bit 15: Reserved area
The C, Z, S, and O flags are changed when instructions are executed. See the software manual for details.
Carry flag
Debug flag
Zero flag
Sign flag
Register bank select flag
Overflow flag
Interrupt enable flag
Stack pointer select flag
Reserved area
Processor interrupt priori
t
Flag register (FLG)
CDZSBOIU
IPL
b0b15
Reserved area
Figure 1.7. Flag register
Reset
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
16
Reset
There are two kinds of resets: software and hardware. In both cases, operation is the same after the reset.
Software Reset
Writing a “1” to bit 3 of the processor mode register 0 (address 000416) applies a (software) reset to the
microcomputer. A software reset has almost the same effect as a hardware reset with the following
exceptions:
• The contents of internal RAM are preserved in a software reset.
• The contents of all USB and PLL SFR values are preserved in a software reset.
• For bit 0 and 1 of processor mode register 0 (address 000416), and bit 1 of pull-up control register 1
(address 03FD16), the value after software reset will be different from the value after hardware reset.
Hardware reset
When the supply voltage is in the range where operation is guaranteed, a reset is executed by holding the
reset pin to “L” level (0.2VCC max.) for at least 20 cycles. When the reset pin level is then returned to the
“H” level while the main clock is stable, the device exits reset and the program execution resumes from the
address in the reset vector table.
Figure 1.8 shows an example reset circuit. Figure 1.9 shows the reset sequence.
RESET V
CC
0.6V
RESET
V
CC
0V
0V
3.3V 2.7V
Example when V
CC
= 3.3V
3.3V
Figure 1.8. Reset circuit
I/O Status during Reset
When the RESET pin level is “L”, all ports change to input mode (floating) Table 1.5 shows the status of
the other pins while the RESET pin level is “L”.
Reset
17
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.9. Reset sequence
Table 1.5. Pin status when RESET pin level is “L”
BCLK
Address
Address
Address
Microprocessor 
modeBYTE=“H”
Microprocessor 
modeBYTE=“L”
Content ofreset vector
Singlechip
mode
BCLK24cycles
FFFFC
16
FFFFD
16
FFFFE
16
Content ofreset vector
FFFFC
16
FFFFE
16
Content ofreset vector
FFFFE
16
X
IN
RESET
RD
WR
CS0
RD
WR
CS0
FFFFC
16
Morethan20cyclesareneeded
Pin name
Status
CNVss=Vss CNVss=Vcc
BYTE=Vss BYTE=Vcc
P0Input port (floati ng) Data input (floating) Data input (f loa tin g)
P1Input port (floating) Data input (floating) Input port (floating)
P2, P3, P40 to P43Input port (floati ng) Address output (undefined) Address outpu t (unde fine d)
P44Input port (floating) CS0 output (“H” level is output) CS0 output (“H” level is output)
P45 to P47Input port (floating) Input port (floating)
(pull-up resistor is on) Input port (floating)
(pull-up resistor is on)
P50Input port (floating) WR output (”H” level is output) WR output (”H” level is output)
P51Input port (floati ng) BHE output (undefined) BHE output (undefined)
P52Input port (floating) RD output (“H” level is output) RD output (“H” level is output)
P53Input port (floati ng) BCLK output BCLK output
P54Input port (floating) HLDA output (The output value
depends on the input to the
HOLD pin)
HLDA output (The output value
depends on the input to the
HOLD pin)
P55Input port (floating) HOLD input (floating) HOLD input (floating)
P56Input port (floating) ALE output (“L” level is output) ALE output (“L” level is output)
P57Input port (floating) RDY input (floating) RDY input (floating)
P6, P7, P80 to P84,
P86, P87, P9, P10 Input port (floating) Input port (floating) Input port (floating)
Special Function Registers
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
18
Special Function Registers
Tables 1.6 to 1.13 show the peripheral control registers, their addresses, names, acronyms, and values after
reset.
Table 1.6. SFR Map (1)
Address
Register name
Acronym Value after reset
0000
16
0001
16
0002
16
0003
16
0004
16
Processor mode register 0 (Note 3) PM0 00
16
0005
16
Processor mode register 1 PM1 0 0 0
0006
16
System clock control register 0 CM0 48
16
0007
16
System clock control register 1 CM1 20
16
0008
16
CSR 00000001
0009
16
Address match interrupt enable register AIER 00
000A
16
Protect register PRCR 000
000B
16
000C
16
USB control register USBC 00
16
000D
16
000E
16
Watchdog timer start register WDTS
000F
16
Watchdog timer control register WDC 000?????
0010
16
Address match interrupt register 0 RMAD0 00
16
0011
16
00
16
0012
16
0000
0013
16
0014
16
Address match interrupt register 1 RMAD1 00
16
0015
16
00
16
0016
16
0000
0017
16
0018
16
0019
16
001A
16
001B
16
Chip select expansion register CSE 00
16
001C
16
001D
16
001E
16
Reserved
001F
16
USB Attach/Detach register USBAD 00
16
0020
16
DMA0 source pointer SAR0
0021
16
0022
16
0023
16
0024
16
DMA0 destination pointer DAR0
0025
16
0026
16
0027
16
0028
16
DMA0 transfer counter TCR0
0029
16
002A
16
002B
16
002C
16
DM0CON 00000?00
002D
16
002E
16
002F
16
0030
16
DMA1 source pointer SAR1
0031
16
0032
16
0033
16
0034
16
DMA1 destination pointer DAR1
0035
16
0036
16
0037
16
0038
16
DMA1 transfer counter TCR1
0039
16
003A
16
003B
16
003C
16
DM1CON 00000?00
Chip select control register
DMA0 control register
DMA1 control register
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
Note 3: For hardware reset, when Vcc is applied to the CNVss pin, it is 03
16
at reset. For software reset, the contents of bit 0 and 1
are preserved as before the reset.
? : Undefined
: Nothing is mapped
to this bit
Special Function Registers
19
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.7. SFR Map (2)
Address
Register name Acronym Value after reset
0040
16
0041
16
Key input interrupt control register KUPIC ?000
0042
16
UART2 receive/ACK interrupt control register S2RIC ?000
0043
16
UART1/3 Bus collision interrupt control register S13BCNIC ?000
0044
16
INT1 interrupt control register INT1IC 00?000Polarity
0045
16
Timer A1 interrupt control register TA1IC ?000
0046
16
USB Endpoint 0 interrupt control register EP0IC ?000
0047
16
Timer A2 interrupt control register TA2IC ?000
0048
16 UART1 receive/ACK/SSI1 interrupt control register
S1RIC 00?000Polarity
0049
16
UART0/2 Bus collision interrupt control register S02BCNIC 00?000Polarity
004A
16 UART0 receive/ACK/SSI0 interrupt control register
S0RIC ?000
004B
16
A-D conversion interrupt control register ADIC ?000
004C
16
DMA0 interrupt conrol register DM0IC ?000
004D
16
UART3 transmit/NACK interrupt control register
S3TIC ?000
004E
16
DMA1 interrupt control register DM1IC ?000
004F
16
UART2 transmit/NACK interrupt control register
S2TIC ?000
0050
16
DMA2 interrupt control register DM2IC ?000
0051
16 UART1 transmit/NACK/SSI1 interrupt control register
S1TIC ?000
0052
16
DMA3 interrupt control register DM3IC ?000
0053
16 UART0 transmit/NACK/SSI0 interrupt control register
S0TIC ?000
0054
16
Timer A0 interrupt control register TA0IC ?000
0055
16
UART3 receive/ACK interrupt control register
S3RIC ?000
0056
16
USB suspend interrupt control register SUSPIC ?000
0057
16
Timer A3 interrupt control register TA3IC ?000
0058
16
USB resume interrupt control register RSMIC ?000
0059
16
Timer A4 interrupt control register TA4IC ?000
005A
16
USB reset interrupt control register RSTIC ?000
005B
16
USB SOF interrupt control register SOFIC ?000
005C
16
USB V bus detect interrupt control register VBDIC ?000
005D
16
USB function interrupt control register USBFIC ?000
005E
16
INT2 interrupt control register INT2IC 00?000Polarity
005F
16
INT0 interrupt control register INT0IC 00?000Polarity
0180
16
DMA2 source pointer SAR2
0181
16
0182
16
0183
16
0184
16
DMA2 destination pointer DAR2
0185
16
0186
16
0187
16
0188
16
DMA2 transfer counter TCR2
0189
16
018A
16
018B
16
018C
16
DM2CON 00000?00
018D
16
018E
16
018F
16
0190
16
DMA3 source pointer SAR3
0191
16
0192
16
0193
16
0194
16
DMA3 destination pointer DAR3
0195
16
0196
16
0197
16
0198
16
DMA3 transfer counter TCR3
0199
16
019A
16
019B
16
019C
16
DM3CON 00000?00
019D
16
019E
16
019F
16
DMA2 control register
DMA3 control register
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
? : Undefined
: Nothing is mappe
d
to this bit
Special Function Registers
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
20
Table 1.8. SFR Map (3)
Address
Register name Acronym Value after reset
0280
16
USB address register USBA 0000
16
0281
16
0282
16
USB power management register USBPM 0000
16
0283
16
0284
16
USB interrupt status register USBIS 0000
16
0285
16
0286
16
USB interrupt clear register USBIC 0000
16
0287
16
0288
16
USB interrupt enable register USBIE 01FF
16
0289
16
028A
16
USB frame number register USBFN 0000
16
028B
16
028C
16
USB ISO control register USBISOC 0000
16
028D
16
028E
16
USB endpoint enable register USBEPEN 0000
16
028F
16
0290
16
USB DMA0 request register USBDMA0 0000
16
0291
16
0292
16
USB DMA1 request register USBDMA1 0000
16
0293
16
0294
16
USB DMA2 request register USBDMA2 0000
16
0295
16
0296
16
USB DMA3 request register USBDMA3 0000
16
0297
16
0298
16
USB EP0 control/status register EP0CS 2000
16
0299
16
029A
16
USB EP0 max packet size register EP0MP 0008
16
029B
16
029C
16
USB EP0 write count register EP0WC 0000
16
029D
16
029E
16
USB EP1 IN control/status register EP1ICS 0003
16
029F
16
02A0
16
USB EP1 IN max packet size register EP1IMP 0000
16
02A1
16
02A2
16
USB EP1 IN FIFO configuration register EP1IFC 0000
16
02A3
16
02A4
16
USB EP2 IN control/status register EP2ICS 0003
16
02A5
16
02A6
16
USB EP2 IN max packet size register EP2IMP 0000
16
02A7
16
02A8
16
USB EP2 IN FIFO configuration register EP2IFC 0000
16
02A9
16
02AA
16
USB EP3 IN control/status register EP3ICS 0003
16
02AB
16
02AC
16
USB EP3 IN max packet size register EP3IMP 0000
16
02AD
16
02AE
16
USB EP3 IN FIFO configuration register EP3IFC 0000
16
02AF
16
02B0
16
USB EP4 IN control/status register EP4ICS 0003
16
02B1
16
02B2
16
USB EP4 IN max packet size register EP4IMP 0000
16
02B3
16
02B4
16
USB EP4 IN FIFO configuration register EP4IFC 0000
16
02B5
16
02B6
16
USB EP1 OUT control/status register EP1OCS 0000
16
02B7
16
02B8
16
USB EP1 OUT max packet size register EP1OMP 0000
16
02B9
16
02BA
16
USB EP1 OUT write count register EP1WC 0000
16
02BB
16
02BC
16
USB EP1 OUT FIFO configuration register EP1OFC 0000
16
02BD
16
02BE
16
USB EP2 OUT control /status register EP2OCS 0000
16
02BF
16
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
Special Function Registers
21
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.9. SFR Map (4)
Address
Register name
Acronym Value after reset
02C0
16 USB EP2 OUT max packet size register EP2OMP 000016
02C1
16
02C2
16 USB EP2 OUT write count register EP2WC 000016
02C3
16
02C4
16 USB EP2 OUT FIFO configuration register EP2OFC 000016
02C5
16
02C6
16 USB EP3 OUT control/status register EP3OCS 000016
02C7
16
02C8
16 USB EP3 OUT max packet size register EP3OMP 000016
02C9
16
02CA
16 USB EP3 OUT write count register EP3WC 000016
02CB
16
02CC
16 USB EP3 OUT FIFO configuration register EP3OFC 000016
02CD
16
02CE
16 USB EP4 OUT control/status register EP4OCS 000016
02CF
16
02D0
16 USB EP4 OUT max packet size register EP4OMP 000016
02D1
16
02D2
16 USB EP4 OUT write count register EP4WC 000016
02D3
16
02D4
16 USB EP4 OUT FIFO configuration register EP4OFC 000016
02D5
16
02D6
16
02D7
16
02D8
16 USB reserved
02D9
16 USB reserved
02DA
16 USB reserved
02DB
16 USB reserved
02DC
16 USB reserved
02DD
16 USB reserved
02DE
16 USB reserved
02DF
16 USB reserved
02E0
16 USB EP0 IN FIFO EP0I
02E1
16
02E2
16 USB EP0 OUT FIFO EP0O
02E3
16
02E4
16 USB EP1 IN FIFO EP1I
02E5
16
02E6
16 USB EP1 OUT FIFO EP1O
02E7
16
02E8
16 USB EP2 IN FIFO EP2I
02E9
16
02EA
16 USB EP2 OUT FIFO EP2O
02EB
16
02EC
16 USB EP3 IN FIFO EP3I
02ED
16
02EE
16 USB EP3 OUT FIFO EP3O
02EF
16
02F0
16 USB EP4 IN FIFO EP4I
02F1
16
02F2
16 USB EP4 OUT FIFO EP4O
02F3
16
02F4
16
02F5
16
02F6
16
02F7
16 Flash memory control register 0 (Note 3) FMR0 0116
02F8
16
02F9
16
02FA
16
02FB
16
02FC
16
02FD
16
02FE
16
02FF
16
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
Note 3: This register exists only in the flash memory version.
Special Function Registers
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
22
Table 1.10. SFR Map (5)
Address Register name Acronym Value after reset
0300
16
0301
16
0302
16
0303
16
0304
16
0305
16
0306
16
0307
16
0308
16
0309
16
030A
16
030B
16
030C
16
030D
16
030E
16
030F
16
0310
16 Serial Sound Interface 0 mode register 0 SSI0MR0 00
16
0311
16 Serial Sound Interface 0 mode register 1 SSI0MR1 00
16
0312
16 Reserved
0313
16 Reserved
0314
16 Serial Sound Interface 0 transmit buffer register SSI0TXB 0000
16
0315
16
0316
16 Serial Sound Interface 0 receive buf fer register SSI0RXB 0000
16
0317
16
0318
16 Serial Sound Interface 0 rate feedback register SSI0RF 0000
16
0319
16
031A
16 Reserved
031B
16 Reserved
031C
16
031D
16
031E
16
031F
16
0320
16
0321
16
0322
16
0323
16
0324
16 UART3 special mode register 4 U3SMR4 0016
0325
16 UART3 special mode register 3 U3SMR3 0016
0326
16 UART3 special mode register 2 U3SMR2 0016
0327
16 UART3 special mode register U3SMR 0016
0328
16 UART3 transmit / receive mode register U3MR 0016
0329
16 UART3 bit rate generator U3BRG
032A
16 UART3 transmit buffer register U3TB
032B
16
032C
16 UART3 transmit / receive control register 0 U3C0 0816
032D
16 UART3 transmit / receive control register 1 U3C1 0216
032E
16 UART3 receive buffer register U3RB
032F
16
0330
16
0331
16
0332
16
0333
16
0334
16 UART2 special mode register 4 U2SMR4 0016
0335
16 UART2 special mode register 3 U2SMR3 0016
0336
16 UART2 special mode register 2 U2SMR2 0016
0337
16 UART2 special mode register U2SMR 0016
0338
16 UART2 transmit / receive mode register U2MR 0016
0339
16 UART2 bit rate generator U2BRG
033A
16 UART2 transmit buffer register U2TB
033B
16
033C
16 UART2 transmit / receive control register 0 U2C0 0816
033D
16 UART2 transmit / receive control register 1 U2C1 0216
033E
16 UART2 receive buffer register U2RB
033F
16
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
Special Function Registers
23
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.11. SFR Map (6)
Address
R
eg
i
ster name
Acronym Value after reset
0340
16
0341
16
0342
16
0343
16
0344
16
0345
16
0346
16
0347
16
0348
16
0349
16
034A
16
034B
16
034C
16
034D
16
034E
16
034F
16
0350
16
0351
16
0352
16
0353
16
0354
16
0355
16
0356
16
0357
16
0358
16
0359
16
035A
16
035B
16
035C
16
035D
16
035E
16
035F
16 Interrupt cause select register IFSR 0016
0360
16
0361
16
0362
16
0363
16
0364
16 UART1 special mode register 4 U1SMR4 0016
0365
16 UART1 special mode register 3 U1SMR3 0016
0366
16 UART1 special mode register 2 U1SMR2 0016
0367
16 UART1 special mode register U1SMR 0016
0368
16 UART1 transmit / receive mode register U1MR 0016
0369
16 UART1 bit rate generator U1BRG
036A
16 UART1 transmit buffer register U1TB
036B
16
036C
16 UART1 transmit / receive control register 0 U1C0 0816
036D
16 UART1 transmit / receive control register 1 U1C1 0216
036E
16 UART1 receive buffer register U1RB
036F
16
0370
16 Serial Sound Interface 1 mode register 0 SSI1MR0 0016
0371
16 Serial Sound Interface 1 mode register 1 SSI1MR1 0016
0372
16 Reserved
0373
16 Reserved
0374
16 Serial Sound Interface 1 transmit buffer register SSI1 TXB 000016
0375
16
0376
16 Serial Sound Interface 1 receive buffer register SSI1RXB 000016
0377
16
0378
16 Serial Sound Interface 1 rate feedback register SSI1RF‘ 000016
0379
16
037A
16 Reserved
037B
16 Reserved
037C
16
037D
16
037E
16
037F
16
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
Special Function Registers
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
24
Table 1.12. SFR Map (7)
Address
Register name
Acronym Value after reset
0380
16 Count start flag TABSR 00000
0381
16 Clock prescaler reset flag CPSRF 0
0382
16 One-shot start flag ONSF 0 0 00000
0383
16 Trigger select register TRGSR 0016
0384
16 Up-down flag UDF 0016
0385
16
0386
16 Timer A0 TA0
0387
16
0388
16 Timer A1 TA1
0389
16
038A
16 Timer A2 TA2
038B
16
038C
16 Timer A3 TA3
038D
16
038E
16 Timer A4 TA4
038F
16
0390
16
0391
16
0392
16
0393
16
0394
16
0395
16
0396
16 Timer A0 mode register TA0MR 0016
0397
16 Timer A1 mode register TA1MR 0016
0398
16 Timer A2 mode register TA2MR 0016
0399
16 Timer A3 mode register TA3MR 0016
039A
16 Timer A4 mode register TA4MR 0016
039B
16
039C
16
039D
16
039E
16
039F
16
03A0
16
03A1
16
03A2
16
03A3
16
03A4
16 UART0 special mode register 4 U0SMR4 0016
03A5
16 UART0 special mode register 3 U0SMR3 0016
03A6
16 UART0 special mode register 2 U0SMR2 0016
03A7
16 UART0 special mode register U0SMR 0016
03A8
16 UART0 transmit / receive mode register U0MR 0016
03A9
16 UART0 bit rate generator U0BRG
03AA
16 UART0 transmit buffer register U0TB
03AB
16
03AC
16 UART0 transmit / receive control register 0 U0C0 0816
03AD
16 UART0 transmit / receive control register 1 U0C1 0216
03AE
16 UART0 receive buffer register U0RB
03AF
16
03B0
16 DMA2 cause select register DM2SL 0016
03B1
16
03B2
16 DMA3 cause select register DM3SL 0016
03B3
16
03B4
16 CRC snoop address register CRCSAR
03B5
16
????????
03B6
16 CRC mode register CRCMR 0 0
03B7
16
03B8
16 DMA0 cause select register DM0SL 0016
03B9
16
03BA
16 DMA1 cause select register DM1SL 0016
03BB
16
03BC
16 CRC data register CRCD
03BD
16
03BE
16 CRC input register CRCIN
03BF
16
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
? :
Undefined
:
Nothing is mapped
to this bit
??
00
Special Function Registers
25
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.13. SFR Map (8)
Address
R
eg
i
ster name Acronym Value after reset
03C0
16
A-D register 0 AD0
03C1
16
03C2
16
A-D register 1 AD1
03C3
16
03C4
16
A-D register 2 AD2
03C5
16
03C6
16
A-D register 3 AD3
03C7
16
03C8
16
A-D register 4 AD4
03C9
16
03CA
16
A-D register 5 AD5
03CB
16
03CC
16
A-D register 6 AD6
03CD
16
03CE
16
A-D register 7 AD7
03CF
16
03D0
16
03D1
16
03D2
16
03D3
16
03D4
16
A-D control register 2 ADCON2 0
03D5
16
03D6
16
ADCON0 00000???
03D7
16
A-D conrol register 1 ADCON1 00
16
03D8
16
03D9
16
03DA
16
03DB
16
Frequency synthesizer clock control FSCCR 00
16
03DC
16
Frequency synthesizer control FSC 60
16
03DD
16
Frequency synthesizer multiplier control FSM FF
16
03DE
16
Frequency synthesizer prescaler control FSP FF
16
03DF
16
Frequency synthesizer divider FSD FF
16
03E0
16
Port P0 P0
03E1
16
Port P1 P1
03E2
16
Port P0 direction register PD0 00
16
03E3
16
Port P1 direction register PD1 00
16
03E4
16
Port P2 P2
03E5
16
Port P3 P3
03E6
16
Port P2 direction register PD2 00
16
03E7
16
Port P3 direction register PD3 00
16
03E8
16
Port P4 P4
03E9
16
Port P5 P5
03EA
16
Port P4 direction register PD4 00
16
03EB
16
Port P5 direction register PD5 00
16
03EC
16
Port P6 P6
03ED
16
Port P7 P7
03EE
16
Port P6 direction register PD6 00
16
03EF
16
Port P7 direction register PD7 00
16
03F0
16
Port P8 P8
03F1
16
Port P9 P9 00 0
03F2
16
Port P8 direction register PD8 0 0 00000
03F3
16
Port P9 direction register PD9 00 0
03F4
16
Port P10 P10
03F5
16
03F6
16
Port P10 direction register PD10 00
16
03F7
16
03F8
16
03F9
16
Key-input mode register KUPM 00
16
03FA
16
P7 drive capacity P7DR 00
16
03FB
16
03FC
16
Pull-up control register 0 PUR0 00
16
03FD
16
Pull-up control register 1 (Note 3) PUR1 00
16
03FE
16
Pull-up control register 2 PUR2 00 000
03FF
16
Port control register PCR 0
A-D conrol register 0
Note 1: The contents of other registers and RAM is undefined when the microcomputer is reset. The initial value must therefore be set.
Note 2: Locations in the SFR area where nothing is assigned are reserved areas. Do not access these areas for read or write.
Note 3: For hardware reset, when Vcc is applied to the CNVss pin, it is 02
16
at reset. For a software reset, if bit 1 and bit 0 of the
processor mode register 0 (address 0004
16
) are [10
2
] or [11
2
], then it becomes 02
16
at a reset.
? : Undefined
: Nothing is mapped
to this bit
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
26
Processor Mode
Processor Modes
One of three processor modes can be selected: single-chip mode, memory expansion mode, and microproces-
sor mode. The functions of some pins, the memory map, and the access space differ according to the selected
processor mode. Figure 1.10 shows the processor mode register 0 and 1.
Single-chip mode
In single-chip mode, only internal memory space (SFR, internal RAM, and internal ROM) can be accessed.
Ports P0 to P10 can be used as programmable I/O ports or as I/O ports for the internal peripheral func-
tions.
Memory expansion mode
In memory expansion mode, external memory can be accessed in addition to the internal memory space
(SFR, internal RAM, and internal ROM). However, if microprocessor mode is set (“H” applied to CNVss
pin) when coming out of a reset, the internal ROM cannot be accessed even if the CPU shifts to memory
expansion mode.
In memory expansion mode, some of the pins function as the address bus, the data bus, and as control
signals. The number of pins assigned to these functions depends on the bus and register settings. (See
“Bus Settings” for details.)
Microprocessor mode
In microprocessor mode, the SFR, internal RAM, and external memory space can be accessed. How-
ever, the internal ROM area cannot be accessed.
In this mode, some of the pins function as the address bus, the data bus, and as control signals. The
number of pins assigned to these functions depends on the bus and register settings. (See “Bus Settings”
for details).
Setting Processor Modes
The processor mode is set using the CNVss pin and the processor mode bits (bits 1 and 0 at address
000416). Do not set the processor mode bits to “102”.
Regardless of the level of the CNVss pin, changing the processor mode bits selects the mode. Therefore,
never change the processor mode bits when changing the contents of other bits. Also do not attempt to
change to or from microprocessor mode within the program stored in the internal ROM area.
• Applying Vss to CNVss pin
The microcomputer begins operation in single-chip mode after being reset. Memory expansion mode is
selected by writing “012” to the processor mode bits in the Processor Mode register 0 (000416).
• Applying Vcc to CNVss pin
The microcomputer starts to operate in microprocessor mode after being reset.
Figure 1.11 shows the applicable memory maps for each mode when memory area does not expand
(normal mode). Figure 1.12 shows the memory maps and chip-select areas in normal mode.
27
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Processor Mode
Figure 1.10. Processor mode register 0 and 1
Processor mode register 0 (Note 1)
Symbol Address When reset
PM0 0004
16 0016 (Note 2)
Bit name FunctionBit symbol WR
b7 b6 b5 b4 b3 b2 b1 b0
0 0: Single-chip mode
0 1: Memory expansion mode
1 0: Inhibited
1 1: Microprocessor mode
b1 b0
PM03
PM01
PM00 Processor mode bit
PM02 R/W mode select bit 0 : RD,BHE,WR
1 : RD,WRH,WRL
Software reset bit The device is reset when this bit is set
to "1". The value of this bit is "0" when
read.
PM04
PM05
PM06
PM07
Port P40 to P43 function
select bit (Note 3)
0 : Address output
1 : Port function
(Address is not output)
BCLK output disable bit 0 : BCLK is output
1 : BCLK is not output
(Pin is left floating)
Note 1: Set bit 1 of the protect register (address 000A16) to "1" before writing new
values to this register.
Note 2: For hardware reset: If VCC voltage is applied to the CNVSS pin, the value of this
register when reset is 0316. (PM00 and PM01 are both set to "1".)
For software reset: the value of PM00 and PM01 are preserved as before the reset.
Note 3: Valid in microprocessor and memory expansion modes.
Processor mode register 1 (Note 1)
Symbol Address When reset
PM1 0005
16 00000XX02
Bit name FunctionBit symbol WR
b7 b6 b5 b4 b3 b2 b1 b0
Reserved bit Must always be set to "0"
Note 1: Set bit 1 of the protect register (address 000A16) to "1" before writing new
values to this register.
Note 2: When a software wait is inserted in the internal ROM area, BCLK must be
8 MHz or higher.
PM17 Wait bit (Note 2) 0 : No wait state
1 : Wait state inserted
Reserved bit Must always be set to "0"
000
O O
O O
O O
Nothing is assigned.
Write "0" when writing to these bits. The value is indeterminate if read.
Reserved Must always be set to "0"
00
PM16 WR length control bit 0 : Normal
1 : Extended O O
0
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
28
Processor Mode
Figure 1.11. Memory map of each processor mode
Figure 1.12. Memory maps and chip-select areas
Bus Settings
The BYTE pin and bit 6 of the processor mode register 0 (address 000416) are used to change the bus
settings. Table 1.14 shows the factors used to change the bus settings.
Single-chip mode
SFR area
Internal
RAM area
Inhibited
Internal
ROM area
Microprocessor mode
SFR area
Internal
RAM area
External
area
Internally
reserved area
00000
16
00400
16
XXXXX
16
YYYYY
16
FFFFF
16
D0000
16
External area : Accessing this area allows
the user to access a device
connected externally to
the microcomputer.
04000
16
Memory expansion mode
SFR area
Internal
RAM area
External
area
Internal
ROM area
Internally
reserved area
Internally
reserved area
M30245FCGP 02BFF
16
E0000
16
M30245MC-XXXGP 02BFF
16
E0000
16
M30245M8-XXXGP F0000
16
017FF
16
Address XXXXX
16
Type No. Address YYYYY
16
Microprocessor mode
SFR area
Internal RAM area
External area
Internal area reserved
00000
16
00400
16
XXXXX
16
YYYYY
16
FFFFF
16
D0000
16
Note 1: The memor
y
ma
p
s in sin
g
le-chi
p
mode are omitted.
08000
16
Memory expansion mode
SFR area
Internal RAM area
External area
Internal ROM area
Internal area reserved
Internal area reserved
CS3
(16K bytes)
CS2
(128K bytes)
CS1
(32K bytes)
CS0
Memory expansion mode: 640K bytes
Microprocessor mode: 832K bytes
28000
16
30000
16
04000
16
M30245FCGP 02BFF
16
E0000
16
M30245MC-XXXGP 02BFF
16
E0000
16
M30245M8-XXXGP F0000
16
017FF
16
Address XXXXX
16
Type No. Address YYYYY
16
Bus setting Switching factor
Switching external address bus width
b6 of processor mode register 0
Switching external data bus width
BYTE pin
Table 1.14. Switching bus settings
29
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Processor Mode
Selecting external address bus width
The address bus width for external output in the 1M bytes of address space can be set to 16 bits (64K bytes
address space) or 20 bits (1M bytes address space). When bit 6 of the processor mode register 0 is set to
“1”, the external address bus width is set to 16 bits, and P2 and P3 become part of the address bus. P40 to
P43 can be used as programmable I/O ports. When bit 6 of processor mode register 0 is set to “0”, the
external address bus width is set to 20 bits, and P2, P3, and P40 to P43 become part of the address bus.
Selecting external data bus width
The external data bus width can be set to 8 or 16 bits. When the BYTE pin is “L”, the bus width is set to 16
bits; when “H”, it is set to 8 bits. (The internal bus width is permanently set to 16 bits.) While operating, fix the
BYTE pin either to “H” or to “L”. When the BYTE pin is “H”, the data bus is set to 8 bits and P0 functions as
the data bus and P1 as a programmable I/O port. When the BYTE pin is “L”, the data bus is set to 16 bits
and P0 and P1 are both used for the data bus. A software wait can also be added.
Table 1.15. Pin functions for each processor mode
Processor mode Single-chip mode Memory expansion mode/microprocessor modes
Data bus width
BYTE pin level
____________ 8 bits
BYTE = ìHî 16 bits
BYT E = ìLî
P0
0
to P0
7
I/O port Data bus Data bus
P1
0
to P1
7
I/O port I/O port Data bus
P2
0
I/O port Address bus Address bus
P2
1
to P2
7
I/O port Address bus Address bus
P3
0
I/O port Address bus Address bus
P3
1
to P3
7
I/O port Address bus Address bus
P4
0
to P4
3
(function sele ct bit =1)
I/O port I/O port I/O port
P4
0
to P4
3
(function sele ct bit =0)
I/O port Address bus Address bus
P4
4
to P4
7
I/O port CS (chip select) or programmable I/O port
(Refer to ìBus controlî for details)
P5
0
to P5
3
I/O port Outputs RD, WRL, WRH, and BCLK or RD, BHE, WR and
BCLK (Refer to ìBus controlî for details)
P5
4
I/O port HLDA HLDA
P5
5
I/O port HOLD HOLD
P5
6
I/O port ALE ALE
P5
7
I/O port RDY RDY
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
30
Processor Mode
Bus Control
The following explains the signals required for accessing external devices and software waits. The
signals required for accessing the external devices are valid when the processor mode is set to memory
expansion mode and microprocessor mode. The software waits are valid in all processor modes.
Address bus/data bus
The address bus consists of the 20 pins A0 to A19 for accessing the 1M bytes of address space.
The data bus consists of the pins for data I/O. When the BYTE pin is “H”, the 8 ports (D0 to D7) function as
the data bus. When BYTE is “L”, the 16 ports (D0 to D15) function as the data bus.
When a change is made from single-chip mode to memory expansion mode, the value of the address bus is
undefined until external memory is accessed.
Chip select signal
The chip select signal is output using the same pins as P44 to P47. Bits 0 to 3 of the chip select control
register (address 000816) set each pin to function as an I/O port or to output the chip select signal. The chip
select control register is valid in memory expansion mode and microprocessor mode. In single-chip mode,
P44 to P47 function as programmable I/O ports regardless of the value in the chip select control register.
In microprocessor mode, only CS0 outputs the chip select signal after reset. CS1 to CS3 function as input
ports. Figure 1.13 shows the chip select control register.
The chip select signal can be used to split the external area into as many as four blocks. Table 1.16 shows
the external memory areas specified using the chip select signal.
Figure 1.13. Chip-select control register
Bit Symbol Function R W
Symbol
CSE Address
001B
16
Chip select expansion register
Note : These bits function normally only when the corresponding CSxW bit is "0". When CSxW bits 
are set to "1", these bits must be returned to "00".
When reset
00
16
Bit Name
CSE0W
CSE1W
CSE2W
CSE3W
CS0 wait expansion bit
CS1 wait expansion bit
CS2 wait expansion bit
CS3 wait expansion bit
0 0 : CSxW setting enabled (x=0-3)
0 1 : 2 Wait states
1 0 : 3 Wait states
1 1 : Invalid O O
O O
b7 b0
b6 b5 b4 b3 b2 b1
O O
O O
Bit Symbol Function R W
Symbol
CSR Address
0008
16
Chip select control register
When reset
01
16
Bit Name
CS0
CS1
CS2
CS3
CS0W
CS1W
CS2W
CS3W
CS0 output enable bit
CS1 output enable bit
CS2 output enable bit
CS3 output enable bit
CS0 wait bit
CS1 wait bit
CS2 wait bit
CS3 wait bit
0 : Chip select output disabled (Normal port pin)
1 : Chip select output enabled O O
O O
b7 b0
b6 b5 b4 b3 b2 b1
O O
O O
0 : Wait state inserted
1 : No wait state
O O
O O
O O
O O
31
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Processor Mode
Table 1.16. External areas specified by the chip select signals
Processor
mode
Chip-select signal
CS0 CS1 CS2 CS3
Memory
expansion mode 3000016 to CFFFF16
(640 Kbytes ) 2800016 to 2FFFF16
(32 Kbytes) 0800016 to 27FFF 16
(128 Kbytes) 0400016 to 07FF F16
(16 Kbytes)
Microprocessor
mode 3000016 to FFFFF16
(832 Kbytes )
Read/write signals
With a 16-bit data bus (BYTE pin =“L”), bit 2 of the processor mode register 0 (address 000416) selects the
combinations of RD, BHE, and WR signals or RD, WRL, and WRH signals. With an 8-bit data bus (BYTE pin
= “H”), use the combination of RD, WR, and BHE signals. (Set bit 2 of the processor mode register 0 (ad-
dress 000416) to “0”.) Tables 1.17 and 1.18 show the operation of these signals.
After a reset, the combination of RD, WR, and BHE signals is automatically selected.
When switching to the RD, WRL, and WRH combination, do not write to external memory until bit 2 of the
processor mode register 0 (address 000416) has been set . Before attempting to change the contents of the
processor mode register 0, set bit 1 of the protect register (address 000A16) to “1”.
Table 1.17. Operation of RD, WRL, and WRH signals
Table 1.18. Operation of RD, WR, and BHE signals
Data bus width RD WRL WRH External data bus status
16-bit (BYTE = “L”)
L H H Read data
H L H Write 1 byte of data to even address
H H L Write 1 byte of data to odd address
H L L Write data to both even and odd addresses
Data bus width RD WRL BHE A0 External data bus status
16-bit
(BYT E = “L”)
H L L H Write 1 byte of data to odd address
L H L H Read 1 byte of data from odd address
H L H L Write 1 byte of data to even address
L H H L Read 1 byte of data from even address
H L L L Write data from both even and odd addresses
L H L L Read data from both even and odd addresses
8-bit
(BYTE = “H”) H L Not used H/L Write 1 byte of data
L H Not used H/L Read 1 byte of data
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
32
Processor Mode
The ALE signal
The ALE signal can be used by an external device to latch the address from the address bus. This signal
indicates when the address on the bus is valid. Latch the address when the ALE signal falls.
The RDY signal
RDY is a signal that facilitates access to an external device that requires long access time. As shown in
Figure 1.14, if an "L" is input to the RDY at the BCLK falling edge, the bus turns to the wait state. If an “H” is
being input to the RDY pin at the BCLK falling edge, the bus cancels the wait state. Table 1.19 shows the
state of the microcomputer with the bus in the wait state. Figure 1.15 is an example of the RD signal pro-
longed by the RDY signal.
The RDY signal is valid when accessing the external area during the bus cycle in which bits 4 to 7 of the chip
select control register (address 000816) are set to “0”. The RDY signal is invalid when setting “1” to all bits 4
to 7 of the chip select control register (address 000816), but the RDY pin should still be connected properly
as it is when not used.
Table 1.19. Microcomputer status in ready state (Note)
Note: The RDY si
nal cannot be received immediatel
before a software wait.
Item Status
Oscillation On
R/W signal, address bus, data bus, CS
ALE signal, HLDA, programmable I/O ports Maintain status when RDY signal received
Internal peripheral circuits On
Figure 1.14. Example of RD signal extended by RDY signal
BCLK
RD
CS
i
(i=0 to 3)
RDY
tsu(RDY - BCLK)
: Wait using RDY signal
: Wait usin
g
software
Accept timing of RDY signal
33
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Processor Mode
HOLD signal
The hold signal is used to transfer the bus privileges from the CPU to the external circuits. Inputting “L” to
the HOLD pin places the microcomputer in the hold state at the end of the current bus access. This status
is maintained and “L” is output from the HLDA pin as long as “L” is input to the HOLD pin. Table 1.20
shows the microcomputer status in the hold state.
Bus priorities listed in descending order are: HOLD, DMAC, and CPU.
Table 1.20. Microcomputer status in HOLD state
Item Status
Oscillation On
R/W signal, address bus, data bus, CS, BHE Floating
Programmable I/O ports P0, P1, P2, P3, P4, P5 Floating
P6, P7, P8, P9, P10 Maintains status when hold signal is received
HLDA Output "L"
Internal peripheral circuits On (Watchdog timer is stopped)
ALE signal Undefined
External bus status when the internal area is accessed
Table 1.21 shows the external bus status when the internal area is accessed.
Table 1.21. External bus status when the internal area is accessed
Item SFR accessed Internal ROM/RAM accessed
Address bus Address output Maintain status before accessing address of external
area
Data When read Floating Floating
When w rite O utpu t dat a Undefined
RD, WR, WRL, WRH RD, WR, WRL, WRH output Output "H"
BHE BHE output Maintain status before accessing status of external
area
CS Output "H" Output "H "
ALE Output "L" Output "L"
BCLK output
The user can choose to output BCLK on P53 by use of bit 7 of processor mode register 0 (000416) (Note).
When set to “1”, the output is left floating.
Note: Before attempting to change the contents of the processor mode register 0, set bit 1 of the protect
register (address 000A16) to “1”.
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
34
Processor Mode
Software wait
A software wait of one to three BCLK cycles can be inserted by setting the wait bit (bit 7) of the processor
mode register 1 (address 000516) (Note), bits 4 to 7 of the chip select control register (address 000816)
and the bits in the chip select expansion register (address 001B16).
A software wait is inserted in the internal ROM/RAM area and in the external memory area by setting the
wait bit of the processor mode register 1. When set to “0”, each bus cycle is executed in one BCLK cycle.
When set to “1”, each bus cycle is executed in two BCLK cycles. After the microcomputer has been reset,
this bit defaults to “0”. When set to “1”, a wait is applied to all memory areas (two BCLK cycles), regardless
of the contents of bits 4 to 7 of the chip select control register and the bits in the chip select expansion
register. Set this bit after referring to the recommended operating conditions (main clock input oscillation
frequency) of the electric characteristics. However, when the user is using the RDY signal, the relevant bit
in the chip select control register’s bits 4 to 7 must be set to “0”.
When the wait bit of the processor mode register 1 is “0”, software waits can be set independently for each
of the 4 chip select memory areas. Bits 4 to 7 of the chip select control register correspond to chip selects
CS0 to CS3. When one of these bits is set to “1”, the read bus cycle is executed in one BCLK cycle and
the write bus cycle is executed in two BCLK cycles. When set to “0”, the read and write bus cycles are
executed in two, three or four BCLK cycles, depending on the settings in the chip select expansion regis-
ter. The bits in the chip select expansion register are only valid when the corresponding bit in the chip
select control register is set to "0". When the bits in the chip select control register are set to "1", the
corresponding bits in the chip select expansion register must be set to "002". The bits in the chip select
control register and chip select expansion register default to “0” after the microcomputer has been reset.
The SFR area is always accessed in two BCLK cycles regardless of the setting of these control bits.
Table 1.22 shows the software waits and bus cycles. Figures 1.15 and 1.16 show example bus timing
when using software waits.
Note: When a software wait is inserted in the internal ROM area, BCLK must be 8 MHz or higher.
Note: Before attempting to change the contents of the processor mode register 1, set bit 1 of the protect
register (address 000A16) to “1”.
Table 1.22. Software waits and bus cycles
Note 1: When using the RDY signal, always set this bit to "0".
Note 2: Set the CSxW bit to 0 before setting these bits. Also, when setting the CSxW bit to 1, be sure to reset these bits to '002' first.
Area PM17 CSxW
(Note 1)
CSExW
(Note 2)
Bus Cycles
Read Write
SFR Invalid Invalid Invalid 2BCLK cycles 2 BCLK cycles
Internal ROM/RAM 0 Invalid Invalid 1 BCLK cycle 1 BCLK cycle
1 Invalid Invalid 2 BCLK cycles 2 BCLK cycles
External memory area
0 0 00 2 BCLK cycles 2 BCLK cycles
0 0 01 3 BCLK cycles 3 BCLK cycles
0 0 10 4 BCLK cycles 4 BCLK cycles
0 0 11 Invalid Invalid
0 1 00 1 BCLK cycle 2 BCLK cycles
1 0 00 2 BCLK cycles 2 BCLK cycles
1 0 01 3 BCLK cycles 3 BCLK cycles
1 0 10 4 BCLK cycles 4 BCLK cycles
1 0 11 Invalid Invalid
1 1 00 2 BCLK cycles 2 BCLK cycles
35
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Processor Mode
Figure 1.15. Typical bus timings using software wait (1)
Output Input
Address Address
Bus cycle(Note)
With 1 Wait
BCLK
Read signal
Write signal
Data bus
Address bus
Chip select
BCLK
Read signal
Write signal
Address bus Address Address
Bus cycle(Note)
No Wait
Data bus
Chip select
Bus cycle(Note)
Bus cycle(Note)
Note : These example timing charts indicate bus cycle length.
After this bus cycle sometimes come read and write cycles in succession.
Input
Output
PM16=0
Write signal
PM16=1
PM16=0
Data bus
Input
Output
PM16=1
PM16=0
PM16=0
Input
Write signal
Data bus
PM16=1
PM16=1
Output
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
36
Processor Mode
Figure 1.16. Typical bus timings using software wait (2)
BCLK
Read signal
Write signal
Address bus Address Address
Bus cycle(Note)
With 2 Waits
Data bus
Chip select
Bus cycle(Note)
Note : These example timing charts indicate bus cycle length.
After this bus cycle sometimes come read and write cycles in succession.
Input
PM16=0
Write signal
PM16=1
PM16=0
Data bus Input
PM16=1
Output
Output
Address
BCLK
Read signal
Write signal
Address bus Address
Bus cycle(Note)
With 3 Waits
Data bus
Chip select
Bus cycle(Note)
Input
PM16=0
Write signal
PM16=1
PM16=0
Data bus Input
PM16=1
Output
Output
Address
37
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Processor Mode
Protection
The protection function is provided so that the values in important registers cannot be changed in the
event that the program runs out of control. Figure 1.17 shows the protect register. The values in the
processor mode register 0 (address 000416), processor mode register 1 (address 000516), system
clock control register 0 (address 000616) and system clock control register 1 (address 000716) can only
be changed when the respective bit in the protect register is set to “1”. Setting the respective bits in the
protect register to "0" will write protect these registers and not allow them to be changed.
Figure 1.17. Protect register
Protect register
Symbol Address When reset
PRCR 000A16 XXXXX0002
Bit nameBit symbol
b7 b6 b5 b4 b3 b2 b1 b0
0 : Write-inhibited
1 : Write-enabled
PRC1
PRC0
Enables writing to processor mode
registers 0 and 1 (addresses 0004
16
and 0005
16
)
Function
0 : Write-inhibited
1 : Write-enabled
Enables writing to system clock
control registers 0 and 1 (addresses
0006
16
and 0007
16) and frequency
synthesizer registers (addresses
03DB
16
to 03DF
16)
WR
Nothing is assigned.
Write "0" when writing to these bits.
The values are indeterminate when read.
Reserved Must always be set to "0"
0
Clock Generating Circuit
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
38
System Clock
Clock-generating Circuit
The clock generating circuit contains two oscillator circuits that supply the operating clock sources to the
CPU and internal peripheral units. Figure 1.18 shows the block diagram of the clock-generating circuit.
Table 1.23 lists the main clock-generating circuits.
Figure 1.18. Block diagram of the clock-generating circuit
Table 1.23. Main clock-generating circuits
Functions Main clock-generating circuit Sub-clock generating clock
Use of clock CPU's operating clock source
Usable oscillator Crystal oscillator Crystal oscillator
Pins to connect oscillator X
IN
, X
OUT
Oscillation stop/restart function Available Available
Oscillator status immediately after reset Oscillating Stopped
Other Externally derived clock can be input
Internal peripheral unit's operating
clock source
CPU's operating clock source
Timer A's count clock source
X
CIN
, X
COUT
CM0i : Bit i at address 0006
16
CM1i : Bit i at address 0007
16
FSCCRi: Bit i at address 03DB
16
WAIT instruction
CM02
QS
R
NMI
Interrupt request
level judgment
output
RESET
Software
reset
fAD
Divider
ad
1/2 1/2 1/2 1/2
CM06=0
CM17,CM16=00
CM06=0
CM17,CM16=01
CM06=0
CM17,CM16=10
CM06=1
CM06=0
CM17,CM16=11
d
a
Details of divider
c
b
b
1/2
c
f1
f32SIO2
f8SIO2
f1SIO2
f8
f32
XOUT
Main clock
CM10 “1”
Write signal QS
R
XIN
Frequency
Synthesizer
Circuit
fusb (48MHz)
FSCCR0=1
FSCCR0=0
BCLK
fsyn
1/32 fc32
fc
Xcout
Xcin
Sub clock
CM04
CM05
CM07=0
fc
CM07=1
Clock Control
39
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.19 shows some examples of the main clock circuit, one using an oscillator connected to the
circuit, and the other one using an externally derived clock for input. Figure 1.20 shows some examples of
subclock circuits, one using an oscillator connected to the circuit, and the other one using an externally
derived clock for input. Circuit constants in Figure 1.19 and Figure 1.20 vary with each oscillator used. Use
the values recommended by the manufacturer of your oscillator.
Microcomputer
Externally derived clock
Open
Vcc (Note 2)
Vss
Note 1: Insert a damping resistor if required. The resistance will vary depending on the oscillator and the oscillation drive
capacity setting. Use the value recommended by the maker of the oscillator.
When the oscillation drive capacity is set to low, check that oscillation is stable. Also, if the oscillator manufacturer's
data sheet specifies that a feedback resistor be added external to the chip, insert a feedback resistor between X
CIN
and X
COUT
following their instructions.
Microcomputer
(Built-in feedback resistor)
Rcd
(Note 1)
Note 2: Reference X
CIN
to Vcc supply.
X
CIN
X
COUT
X
CIN
X
COUT
C
CIN
C
COUT
Microcomputer
Externally derived clock
Open
Vcc
Vss
Microcomputer
(Built-in feedback resistor)
R
d
C
IN
C
OUT
(Note)
Note: Insert a damping resistor if required. The resistance will vary depending on the oscillator and the oscillation drive
capacity setting. Use the value recommended by the maker of the oscillator.
When the oscillation drive capacity is set to low, check that oscillation is stable.
X
IN
X
OUT
X
IN
X
OUT
Figure 1.19. Examples of main clock
Figure 1.20. Examples of sub-clock
Clock Generating Circuit
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
40
Clock Control
Main clock
The main clock is generated by the main clock oscillation circuit. After a reset, this clock is divided by 8 to
produce the BCLK. The clock can be stopped using the main clock stop bit (bit 5 at address 000616).
Stopping the clock, after switching the operating clock source of CPU to the subclock, reduces the power
dissipation.
After the oscillation of the main clock oscillation circuit has stabilized, the drive capacity of the main clock
oscillation circuit can be reduced using the XIN-XOUT drive capacity select bit (bit 5 at address 000716).
Reducing the drive capacity of the main clock oscillation circuit reduces power dissipation. This bit changes
to “1” when shifting from high-speed/medium-speed mode to stop mode and at a reset. When shifting from
low-speed/low power dissipation mode to stop mode, the value before stop mode is retained.
Subclock
The subclock is generated by the subclock oscillation circuit. No subclock is generated after a reset. After
oscillation is started using the port Xc select bit (bit 4 at address 000616), the subclock can be selected as
the BCLK by using the system clock select bit (bit 7 at address 000616). However, be sure that the subclock
oscillation has fully stabilized before switching.
After the oscillation of the subclock oscillation circuit has stabilized, the drive capacity of the subclock
oscillation circuit can be reduced using the XCIN-XCOUT drive capacity select bit (bit 3 at address 000616).
Reducing the drive capacity of the subclock oscillation circuit reduces the power dissipation. This bit
changes to “1” when changing to stop mode and at a reset.
BCLK
The BCLK is the clock that drives the CPU, and is equal to fc or the clock that is derived by dividing the
main clock by 1, 2, 4, 8, or 16. The BCLK is derived by dividing the main clock by 8 after a reset. The BCLK
signal can be output from the BCLK pin (P53) by use of the BCLK output disable bit (bit 7 at address
000416) in the memory expansion and the microprocessor modes.
The main clock division select bit 0 (bit 6 at address 000616) changes to “1” when shifting from high-speed/
medium-speed to stop mode and at reset. When shifting from low-speed/low power dissipation mode to
stop mode, the value before stop mode is retained.
Peripheral function clock (f1, f8, f32, f1SIO2, f8SIO2, f32SIO2, fAD)
The clock for the peripheral devices is derived from the main clock or by dividing it by 1, 8, or 32. The
peripheral function clock is stopped by stopping the main clock or by setting the WAIT peripheral function
clock stop bit (bit 2 at 000616) to “1” and then executing a WAIT instruction.
fc32
This clock is derived by dividing the subclock by 32. It is used for the Timer A counts.
fc
This clock has the same frequency as the subclock. It is used for the BCLK and for the watchdog timer.
fUSB
This clock provides a 48 MHz signal required for USB operation. It is derived from the Frequency Synthesizer
circuit.
Stop Mode
41
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.21. Clock control registers 0 and 1
System clock control registers
Figure 1.21 shows the system clock control registers 0 and 1.
Bit Symbol Bit Name Function R W
Symbol
CM0
Address
0006
16
When reset
48
16
System clock control register 0 (Note 1)
b7 b5b6 b4 b3 b2 b1 b0
CM02
CM03
CM04
CM05
CM06
CM07
Reserved bit
WAIT peripheral function
clock stop bit
X
CIN
-X
COUT
drive capacity
select bit (Note 2)
Port Xc select bit
Main clock (X
IN
-X
OUT
)
stop bit (Note 3, 4, 5)
Main clock division select
bit 0 (Note 6)
System clock select bit
(Note 7)
Always set to "0"
0 : Do not stop in wait mode
1 : Stop in wait mode (Note 8)
0 : LOW
1 : HIGH
0 : I/O port
1 : X
CIN
-X
COUT
generation
0 : On
1 : Off
0 : CM16 and CM17 valid
1 : Divide-by-8 mode
0 : X
IN
, X
OUT
1 : X
CIN
, X
COUT
O O
O O
O O
O O
O O
O O
O O
Note 1: Set bit 0 of the protect register (address 000A
16
) to "1" before writing to this register.
Note 2: Changes to "1" when changing to Stop mode and Reset.
Note 3: When entering power saving mode, main clock is stopped using this bit. When returning from
stop mode and operating in X
IN
, set this bit to "0". When main clock oscillation is operating
by itself, set system clock select bit (CM07) to "1" before setting this bit to "1".
Note 4: When inputting external clock, only clock oscillation buffer is stopped and clock input is
acceptable.
Note 5: If this bit is set to "1", X
OUT
becomes "H". The built-in feedback resistor remains connected,
so X
IN
becomes pulled up to X
OUT
("H") using the feedback resistor.
Note 6: This bit changes to "1" when changing from high-speed/medium mode to stop mode and at
reset. When shifting from low-speed/low power dissipation mode to stop mode, the value
before stop mode is retained.
Note 7: Set Port Xc select bit (CM04) to "1" and stabilize the sub clock oscillating before setting to
this bit from "0" to "1". Do not write to both bits at the same time. Also, set the main clock
stop bit (CM05) to "0" and stabilize the main clock oscillating before setting this bit from ’1"
to "0".
Note 8: fc32 is not included. Do not set to "1" when using low-speed or low power dissipation mode.
Bit Symbol Bit Name Function R W
O O
Symbol
CM1
Address
0007
16
When reset
20
16
System clock control register 1 (Note 1)
b7 b5b6 b4 b3 b2 b1 b0
CM10
Reserved bit
CM15
CM16
CM17
All clock stop control bit
(Note 4)
0 : Clock on
1 : All clocks off (stop mode)
Always set to "0"
0 : LOW
1 : HIGH
b7 b6
0 0 : No division mode
0 1 : Divide-by-2 mode
1 0 : Divide-by-4 mode
1 1 : Divide-by-16 mode
O O
O O
O O
O O
X
IN
-X
OUT
drive capacity
select bit (Note 2)
Main clock division select
bit 1 (Note 3)
00
0
0
Note 1: Set bit "0" of the protect register (address 000A
16
) to "1" before writing to this register.
Note 2: This bit changes to "1" when shifting from high-speed/medium speed mode to stop mode a
n
at reset. When shifting from low-speed/low power dissipation mode to stop mode, the value
before stop mode is retained.
Note 3: Can be selected when bit 6 of the system clock control register 0 (address 0006
16
) is "0". If
"1", divide mode is fixed at 8.
Note 4: If this bit is set to "1", X
OUT
becomes "H" and the built-in feedback resistor is cut off.
X
CIN
and Xc
OUT
become high impedance state.
00
System Clock Control Register
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
42
Pin Memory expansion mode
Microprocessor mode Single-chip mode
Address bus, data bus, CS0 to CS3, Retains status before stop mode
RD, WR
BHE
, WRL, WRH "H"
HLDA, BCLK "H"
ALE "H"
Port Retains status before stop mode Retains status before stop mode
Stop Mode
Writing “1” to the all-clock stop control bit (bit 0 at address 000716) stops all oscillation and the micro-
computer enters stop mode. In stop mode, the content of the internal RAM is retained provided that Vcc
remains above 2V.
Because the oscillation of BCLK, f1 to f32, and fAD stops in stop mode, peripheral functions such as the A-D
converter and watchdog timer do not function. However, timer A operates, provided that the event counter
mode is set to an external pulse, and UARTi (i = 0 to 3) functions provided an external clock is selected.
Table 1.24 shows the status of the ports in stop mode.
Stop mode is cancelled by a hardware reset or interrupt. If an interrupt is to be used to cancel stop mode,
that interrupt must first be enabled and the interrupt priority of any interrupts not used to cancel stop
mode should be set to "0". The I flag must also be set prior to stopping for an interrupt to cancel it. When
returning by an interrupt, that interrupt routine is executed. If only a hardware reset or an NMI interrupt is
used to cancel stop mode, change the priority level of all interrupts to "0", then change to stop mode.
After coming out of stop mode, it is recommended that four “NOP” instructions be executed to clear the
instruction queue.
When changing from high-speed/medium speed mode to stop mode and at reset, the main clock
division select bit 0 (bit 6 at 000616) is set to “1”. When changing from low-speed/low power dissipation
mode to stop mode, the value before stop mode is retained.
Table 1.24. Port status during stop mode
BCLK Status Transition
43
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
BCLK Status transition
Power dissipation can be reduced and low-voltage operation achieved by changing the count source for
BCLK. Table 1.26 shows the operating modes corresponding to the settings of system clock control
registers 0 and 1.
When reset, the device starts in division by 8 mode. The main clock division select bit 0 (bit 6 at address
000616) changes to “1” when shifting from high-speed/medium-speed to stop mode and at a reset. When
shifting from low-speed/low power dissipation mode to stop mode, the value before stop mode is
retained. The following shows the operational modes of BCLK.
Wait Mode
When a WAIT instruction is executed, the BCLK stops and the microcomputer enters the wait mode. In
this mode, oscillation continues but the BCLK and watchdog timer stop. Writing “1” to the WAIT periph-
eral function clock stop bit and executing a WAIT instruction stops the clock being supplied to the internal
peripheral functions, allowing power dissipation to be reduced. However, the peripherial function clock
fC32 does not stop during wait mode and thus does not contribute to any power savings. When the MCU
is running in low-speed or low power dissipiation mode, do not enter WAIT mode with this bit set to "1".
Table 1.25 shows the status of the ports in wait mode.
Wait mode is cancelled by a hardware reset or interrupt. If an interrupt is used to cancel wait mode, that
interrupt must first be enabled and the interrupt priority levels of all other interrupts that are not used to
cancel wait mode must be set to "0". When returning from an interrupt, the microcomputer restarts using
as BCLK the clock that had been selected when the WAIT instruction was executed, and the program
continues from the interrupt routine. If only a hardware reset or NMI interrupt is used to cancel wait
mode, change the priority level of all interrupts to "0", then shift to wait mode.
Pin Memory expansion mode
Micro pr oce ssor mode Single-chip mode
Address bus, data bus, CS0 to CS3 Retains status before wait mode
RD, WR, BHE, WRL, WRH “H”
HLDA, BCLK “H”
ALE “H”
Port Retains status before wait mode Retains status before wait mode
Table 1.25. Port status during wait mode
Wait Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
44
CM17 CM16 CM07 CM06 CM05 CM04 BCLK operating mode
01000
10000
Invalid Invalid 0 1 0 Invalid
11000Invalid
00000Invalid
Invalid Invalid 1 Invalid 0 1 Low-speed mode
Invalid Invalid 1 Invalid 1 1 Low power dissipation mode
Invalid
Invalid Divide-by-2 mode
Divide-by-4 mode
Divide-by-8 mode
Divide-by-16 mode
No division mode
Table 1.26. System clock control registers 0 and 1 operating mode settings
• Divide by 2 mode
The main clock is divided by 2 to obtain the BCLK.
• Divide by 4 mode
The main clock is divided by 4 to obtain the BCLK.
• Divide by 8 mode
The main clock is divided by 8 to obtain the BCLK. When reset, the device starts operating from this mode.
Before the user can go from this mode to no division mode, division by 2 mode, or division by 4 mode, the
main clock oscillator must be stable. When going to low-speed or lower power consumption mode, make
sure the subclock's oscillator is stable.
• Divide by 16 mode
The main clock is divided by 16 to obtain the BCLK.
• No-division mode
The main clock is divided by 1 to obtain the BCLK.
• Low-speed mode
fc is used as the BCLK.
Note: Oscillation of both the main and sub-clocks must have stabilized before transferring from this mode
to another or vice versa. At least 2 to 3 seconds are required after the subclock starts. Therefore,
write the program to wait until this clock has stabilized after powering up and after returning from
stop mode.
• Low power dissipation mode
fc is the BCLK and the main clock is stopped.
Note: Before the count source for BCLK can be changed from XIN to XCIN or vice versa, the new count
source's oscillator must first be stable. Allow some wait time in software for the oscillation to
stabilize before switching the clock over.
Power Control
45
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Power control
The following is a description of the three available power control modes. Figure 1.22 shows the state
transition diagram for these modes.
Normal operation mode
• High-speed mode
Divide-by-1 frequency of the main clock becomes the BCLK. The CPU operates with the internal clock
selected. Each peripheral function operates according to its assigned clock.
• Medium-speed mode
Divide-by-2, divide-by-4, divide-by-8, or divide-by-16 frequency of the main clock becomes the BCLK.
The CPU operates according to the internal clock selected. Each peripheral function operates according
to its assigned clock.
• Low-speed mode
fc becomes the BCLK. The CPU operates according to the fc clock. The fc clock is supplied by the
secondary clock. Each peripheral function operates according to its assigned clock.
• Low power consumption mode
The main clock operating in low-speed mode is stopped. The CPU operates according to the fc clock.
The fc clock is supplied by the secondary clock. The only peripheral functions that operate are those with
the subclock selected as the count source.
Wait mode
The CPU operation is stopped. The oscillators do not stop.
Stop mode
All oscillators stop. The CPU and all built-in peripheral functions stop. Of the three modes discusses, the
stop mode is the most effective in decreasing power consumption.
Power Control
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
46
All oscillators stopped
Stop Mode Medium-speed mode
(divided-by-8 mode)
RESET
Normal Mode
WAIT
instruction
Interrupt
WAIT
instruction
Interrupt
CM10 = "1"
CM10 = "1"
Interrupt
Interrupt
S
tate Transitions for Stop and Wait modes
Main clock is oscillating
Sub clock is stopped
Medium-speed mode
(divided-by-8 mode)
BCLK : f(X
in
)/8
CM07 = "0" CM06 = "1"
High-speed mode
BCLK ; f(X
in
)
CM07 = "0" CM06 = "0"
CM17 = "0" CM16 = "0"
Medium-speed mode
(divided-by-4 mode)
BCLK : f(X
in
)/4
CM07 = "0" CM06 = "0"
CM17 = "1" CM16 = "0"
BCLK ; f(X
in
)/2
CM07 = "0" CM06 = "0"
CM17 = "0" CM16 = "1"
Medium-speed mode
(divided-by-2 mode)
Medium-speed mode
(divided-by-16 mode)
BCLK : f(X
in
)/4
CM07 = "0" CM06 = "0"
CM17 = "1" CM16 = "1"
Medium-speed mode
(divided-by-8 mode)
BCLK : f(X
in
)/8
CM07 = "0"
CM06 = "1"
High-speed mode
BCLK ; f(X
in
)
CM07 = "0" CM06 = "0"
CM17 = "0" CM16 = "0"
Medium-speed mode
(divided-by-4 mode)
BCLK : f(X
in
)/4
CM07 = "0" CM06 = "0"
CM17 = "1" CM16 = "0"
BCLK ; f(X
in
)/2
CM07 = "0" CM06 = "0"
CM17 = "0" CM16 = "1"
Medium-speed mode
(divided-by-2 mode)
Medium-speed mode
(divided-by-16 mode)
BCLK : f(X
in
)/4
CM07 = "0" CM06 = "0"
CM17 = "1" CM16 = "1"
CM04 = "0" Main clock is oscillating
Sub clock is stopped CM04 = "1"
Main clock is oscillating
Sub clock is oscillating
CM06 = "0"
(Notes 1, 3) CM07 = "0" (Note 1)
CM06 = "0" (Note 3)
CM07 = "1" (Note 2)
CM05 = "1"
CM05 = "0"
CM04 = "1" (Notes 1, 3)
CM04 = "0"
CM06 = "1"
CM07 = "0"
(Note 1, 3)
CM07 = "1"
(Note 2)
CM07 = "0" (Note 1)
CM06 = "1"
All oscillators stopped
Stop Mode
All oscillators stopped
Stop Mode
High speed /
Medium-speed mode
Low-speed / Low power
dissipation mode
CPU operation stopped
Wait mode
CPU operation stopped
Wait mode
CPU operation stopped
Wait mode
CM10 =
"1"
WAIT
instruction
Interrupt
Main clock is oscillating
Sub clock is oscillating
Low-speed mode
BCLK : f(Xcin)
CM07 = "1"
BCLK : f(Xcin)
CM07 = "1"
Main clock is stopped
Sub clock is oscillating
Low-power dissipation mode
CM05 = "1"
Note 1: Switch clock after oscillation of main clock is sufficiently stable.
Note 2: Switch clock after oscillation of sub clock is sufficiently stable.
Note 3: Change CM06 after changing CM17 and CM16.
Note 4: Transit in accordance with arrow.
State Transitions for normal mode
Interrupt
Figure 1.22. Power control mode state transition diagram
Frequency Synthesizer Circuit
47
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Frequency synthesizer circuit
The frequency synthesizer circuit generates a 48MHz clock (fUSB) needed by the USB block and a clock fSYN that
are a multiple of the external input reference clock f(XIN). A block diagram of the circuit is shown in Figure 1.23.
Figure 1.23. Frequency Synthesizer Circuit
The frequency synthesizer consists of a prescaler, frequency multiplier, a frequency divider, and five registers:
FSP; FSM; FSC; FSD; and FSCCR. Clock f(XIN) is prescaled down using FSP to generate fPIN. fPIN is multiplied by
FSM to generate an fVCO clock, which is then divided by FSD to produce the clock fSYN. The fVCO clock is
optimized for 48 MHz operation and is buffered and sent out of the frequency synthesizer block as signal fUSB.
This signal is used by the USB block.
The FSC0 bit in the FSC Control Register enables the frequency synthesizer block. When disabled (FSC0 = “0”),
fVCO is held at either a high or low state. When the frequency synthesizer control bit is active (FSC0 = “1”), a lock
status (LS = “1”) indicates that fSYN and fVCO are the correct frequency. The LS and FSCO control bits in the FSC
Control register are shown in Figure 1.24.
When using the frequency synthesizer, a low-pass filter must be connected to the LPF pin. Once the frequency
synthesizer is enabled, a delay of 2-5ms is recommended before the output of the frequency synthesizer is used.
This is done to allow the output to stabilize. It is also recommended that none of the registers be modified once the
frequency synthesizer is enabled as it will cause the output to be temporarily (2-5ms) unstable.
The MCU clock source is selected via the Frequency Synthesizer Clock Control register (FSCCR). See Figure
1.25.
Note: None of the registers must be written to once the frequency synthesizer is enabled and used as the
system clock source (FSCCR register, address 03DB16, bit ‘0’ set to ‘1’) because it will cause the output
of the PLL to freeze. Switch system back to f(XIN) and disable before modifying PLL registers.
FSP
Data Bus
FSM FSC FSD
03DE 03DD 03DC 03DF
Frequency
Multiplier Frequency
Divider
8 Bit
LS
8 Bit
f(Xin) f
VCO
f
SYN
f
USB
Prescaler
8 Bit
f
PIN
FSCCR
FSCCR0
03DB
EN
USBC5
Frequency Synthesizer Circuit
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
48
Figure 1.24. Frequency Synthesizer Control register (FSC)
Figure 1.25. Frequency Synthesizer Clock Control register (FSCCR)
Bit Symbol Bit Name Function R W
Symbol
FSC Address
03DC
16
When reset
60
16
Frequency Synthesizer Control register
b7 b5b6 b4 b3 b2 b1 b0
0 : Unlocked
1 : Locked
b2 b1
0 0 : Lowest gain
0 1 : Low gain
1 0 : High gain (Note )
1 1 : Highest gain
FSE
VCO0
VC01
Reserved bit
CHG0
CHG1
LS
Frequency Synthesizer enable bit
VCO Gain Control
0 : Disabled
1 : Enabled
Note: Recommended
O O
O O
O O
O O
O O
O O
O O
00
b6 b5
0 0 : Disabled
0 1 : Low current
1 0 : Medium current (Note)
1 1 : High current
Must always be set to "0"
LPF Current Control
Frequency Synthesizer Lock Status
Prescaler
Clock fPIN is a divided down version of clock f(XIN) (see Figure 1.26). The relationship between fPIN and
the clock f(XIN) input to the prescaler is as follows:
• fPIN = f(XIN) / 2(n+1) where n is the decimal equivalent loaded into the FSP.
• Setting FSP to 255 disables the prescaler and fPIN = f(XIN).
Note: fPIN frequency below 1 MHz is not recommended.
Figure 1.26. Frequency Synthesizer Prescaler register (FSP)
Bit Symbol Bit Name Function R W
Symbol
FSCCR Address
03DB
16
When reset
00
16
Frequency Synthesizer Clock Control register
b7 b5b6 b4 b3 b2 b1 b0
FSCCR0
Reserved
FCCR4
Reserved
Clock source selection 0 : Xin
1 : f
SYN
O O
O O
0
Must always be set to "0"
00000
Divide-by-3 option 0 : Normal
1 : Divide-by-3 O O
O O
Must always be set to "0"
f
PIN
FSP f(X
IN
)
Dec(n) Hex(n )
12 MHz 255 FF 12.00 MHz
1 MHz 7 07 16.00 MHz
2 MHz 2 02 12.00 MHz
3 MHz 1 01 12.00 MHz
6 MHz 0 00 12.00 MHz
MSB
7
LSB
0
Bit 6 Bit 1 Bit 0
Bit 2
Bit 5 Bit 4 Bit 3Bit 7 Access: R/W
Address: 03DE
16
Reset: FF
16
f(X
IN
) /2(n+1)
f
PIN =
1 MHz 5 05 12.00 MHz
2 MHz 3 03 16.00 MHz
Frequency Synthesizer Circuit
49
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Multiplier
Clock fVCO is a multiplied up version of clock fPIN (See Figure 1.27). The relationship between fVCO and
the clock (fPIN) input to the multiplier from the prescaler is as follows:
• fVCO = fPIN x 2(n+1) where n is the decimal equivalent of the value loaded in FSM.
• Setting FSM to 255 disables the multiplier and fVCO = fPIN.
Note 1: n must be chosen such that fVCO equals 48 MHz.
Note 2: Minimum fPIN is 1 MHz. Maximum fPIN is 12 MHz.
f
PIN
FSM f
VCO
Dec(n) Hex(n)
1 MHz 23 17 48.00 MHz
2 MHz 11 0B 48.00 MHz
4 MHz 5 05 48.00 MHz
6 MHz 3 03 48.00 MHz
8 MHz 2 02 48.00 MHz
12 MHz 1 01 48.00 MHz
MSB
7 LSB
0
Bit 6 Bit 1 Bit 0
Bit 2
Bit 5 Bit 4 Bit 3Bit 7
Address: 03DD
1
6
Access: R/W
Reset: FF
16
f
PIN
x 2(n+1)
f
VCO
=
Figure 1.27. Frequency Synthesizer Multiply register (FSM)
Divider
Clock fSYN is a divided down version of clock fVCO (See Figure 1.28). The relationship between fSYN and
the clock (fVCO) input to the divider from the multiplier is as follows:
• fSYN = fVCO / 2(m+1) where m is the decimal equivalent of the value loaded in FSD.
NOTE: fSYN = fVCO / (m+1) when the divide by 3 option (bit 4 at address 03DB16) is set and when m = 2.
• Setting FSD to 255 disables the divider and fSYN = fVCO.
Figure 1.28. Frequency Synthesizer Divide register (FSD)
H
fVCO /2(m+1) f
SYN
fVCO
FSD fSYN
Dec(m) Hex(m)
48.00 MHz 2 02 8.00 MHz
48.00 MHz 2 02 16.00 MHz
(Note)
MSB
7
LSB
0
Bit 6 Bit 1 Bit 0 Address: 03DF16
Access: R/W
Reset: FF16
Bit 2
Bit 7 Bit 5 Bit 4 Bit 3
Note: if FSCCR4 = 1 and m = 2
=
fVCO /(m+1) f
SYN =
H 127 7F 187.50 KHz48.00 M z
1 01 12.00 MHz
48.00 M z
H3 03
48.00 M z 6.00 MHz
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
50
Interrupts
Figure 1.29 lists the types of interrupts.
• Maskable: An interrupt that can be enabled or disabled by the interrupt enable flag (I flag) or can have its
interrupt priority changed by the priority level.
• Non-maskable: An interrupt that cannot be enabled or disabled by the interrupt enable flag (I flag) or cannot
have its interrupt priority changed by the priority level.
Software Interrupts
A software interrupt occurs when executing certain instructions. Software interrupts are non-maskable
interrupts.
• Undefined instruction interrupt
An undefined instruction interrupt occurs when executing the UND instruction.
• Overflow interrupt
An overflow interrupt occurs when an executing arithmetic instruction overflows. The instructions that set an
O flag when an overflow occurs are: ABS, ADC, ADCF, ADD, CMP, DIV, DIVU, DIVX, NEG, RMPA, SBB,
SHA, SUB
• BRK interrupt
A BRK interrupt occurs when executing the BRK instruction.
• INT interrupt
An INT interrupt occurs when specifying one of the software interrupt numbers 0 through 63 and executing
the INT instruction. Software interrupt numbers 0 through 31 are assigned to peripheral I/O interrupts, so
executing the INT instruction executes the same interrupt routine as the peripheral I/O interrupt.
The stack pointer (SP), used for the INT interrupt, is dependent on which software interrupt number is
selected.
As far as software interrupt numbers 0 through 31 are concerned, the microcomputer saves the stack
pointer assignment flag (U flag) when it accepts an interrupt request. The U flag is set to “0” selecting the
interrupt stack pointer then the interrupt sequence is executed. When returning from the interrupt routine,
the U flag is returned to its previous state before accepting the interrupt request.
As far as software numbers 32 through 63 are concerned, the stack pointer does not change.
Figure 1.29. Interrupt classification
Interrupt
Software
Hardware
Special
Peripheral I/O (Note)
Undefined instruction (UND instruction)
Overflow (INTO instruction)
BRK instruction
INT instruction
Reset
NMI
DBC
Watchdog timer
Single step
Address match
Note: Peripheral I/Ointerruptsare generated by the peripheral functionsbuiltintothe microcomputer system.
Interrupts
51
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Hardware Interrupts
Hardware interrupts are classified into two types — special interrupts and peripheral I/O interrupts.
Special interrupts
Special interrupts are non-maskable interrupts.
• Reset
Reset occurs if an “L” is input to the RESET pin.
• NMI interrupt
An NMI interrupt occurs if an “L” is input to the NMI pin.
• DBC interrupt
This interrupt is exclusively for the debugger, do not use it in other circumstances.
• Watchdog timer interrupt
Generated by the watchdog timer.
• Single-step interrupt
This interrupt is exclusively for the debugger, do not use it in other circumstances. With the debug flag (D
flag) set to “1”, a single-step interrupt occurs after one instruction is executed.
• Address match interrupt
An address match interrupt occurs immediately before the instruction held in the address indicated by
the address match interrupt register is executed with the address match interrupt enable bit set to “1”. If
an address other than the first address of the instruction in the address match interrupt register is set,
Peripheral I/O interrupts
A peripheral I/O interrupt is generated by one of the built-in peripheral functions. Built-in peripheral functions
are dependent on classes of products, so the interrupt factors are also dependent on classes of products.
The interrupt vector table is the same as the one for software interrupt numbers 0 through 31 the INT
instruction uses. Peripheral I/O interrupts are maskable interrupts.
• Bus collision detection interrupt
This is an interrupt that the serial I/O bus collision detection generates.
• DMA0 through DMA3 interrupt
These are interrupts the DMA generates.
• Key-input interrupt
A key-input interrupt occurs if an “L” is input to any of the KI1 to KI7 pins.
• A-D conversion interrupt
This is an interrupt that the A-D converter generates.
• UART0, UART1, UART2, UART3 transmit / NACK / SSI0, SSI1 transmit interrupt
These are interrupts that the serial I/O, I2C, and SSI generate.
• UART0, UART1, UART2, UART3 receive / ACK / SSI0, SSI1 receive interrupt
These are interrupts that the serial I/O, I2C, and SSI generate.
• Timer A0 interrupt through Timer A4 interrupt
These are interrupts that Timer A generates
• INT0 through INT2 interrupt
An INT interrupt occurs if either a rising edge or a falling edge or both edges are input to one of the INT
pins.
• USB interrupts (EP0, Suspend, Resume, SOF, Reset, USB Function)
These are interrupts that are generated from USB.
• VBus Detect interrupt
This interrupt is generated from the USB VBus detection circuitry.
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
52
Interrupt Routine
Interrupt vector tables
If an interrupt request is accepted, program execution branches to the interrupt routine set in the interrupt
vector table. Set the first address of the interrupt routine in each vector table. Figure 1.30 shows the format
for specifying the address.
Two types of interrupt vector tables are available — fixed vector table in which addresses are fixed and
variable vector table in which addresses can be varied by the setting.
Vector address + 0
Vector address + 1
Vector address + 2
Vector address + 3
Low address
Mid address
0 0 0 0 High
address
0 0 0 0 0 0 0 0
MSB LSB
Figure 1.30. Format for specifying interrupt vector addresses
Interrupt source Vector t able addr ess es
Address(L) to Address(H) Remarks
Undefined instruction FFFDC16 to FFFDF16 Interrupt on UND instruction
Overflow FFFE016 to FFFE316 Interrupt on INTO instruction
BRK instruction FFFE416 to FFFE716 If the vector is filled with FF16, program execution starts from
the address shown by the vector in the variable vector table
Address Ma tch FFFE816 to FFFEB16 There is an address-matching interrupt enable bit
Single Step (Note) FFFEC16 to FFFEF16 Do not us e
Watchdog timer FFFF016 to FFFF316
DBC (Note) FFFF416 to FFFF716 D o not us e
NMI FFFF816 to FFFFB16 External interrupt by NMI pin
Reset FFFFC16 to FFFFF16
Note: Interru
p
ts used for debu
gg
in
g
p
ur
p
oses onl
y
.
Fixed vector tables
The fixed vector table is a table in which addresses are fixed. The vector tables are located in an area
extending from FFFDC16 to FFFFF16. One vector table comprises four bytes. Set the first address of
interrupt routine in each vector table. Table 1.27 shows the interrupts assigned to the fixed vector tables
and addresses of vector tables.
Table 1.27. Interrupt vectors with fixed addresses
Interrupts
53
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.28. Interrupt vectors with variable addresses
Variable vector tables
The addresses in the variable vector table can be modified, according to the user’s settings. Before
enabling interrupts, the user must load the INTB register with the address of the first entry in the table.
The 256-byte area subsequent to the address the INTB indicates becomes the area for the variable
vector tables. One vector table comprises four bytes. Set the first address of the interrupt routine in each
vector table.
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
54
Figure 1.31. Interrupt control registers
b7 b6 b5 b4 b3 b2 b1 b0
Bit name FunctionBit symbol
WR
ILVL0
IR
Interrupt priority level
select bit
Interrupt request bit 0 : Interrupt not requested
1 : Interrupt requested
ILVL1
ILVL2
Nothing is assigned.
These bits can neither be set nor reset. When read, their contents are
indeterminate.
(Note)
Note: This bit can only be reset (= 0), but cannot be set ( = 1).
0 0 0 : Level 0 (interrupt disabled)
0 0 1 : Level 1
0 1 0 : Level 2
0 1 1 : Level 3
1 0 0 : Level 4
1 0 1 : Level 5
1 1 0 : Level 6
1 1 1 : Level 7
b2 b1 b0
Bit name FunctionBit symbol
W
R
b7 b6 b5 b4 b3 b2 b1 b0
ILVL0
IR
POL
Nothing is assigned.
These bits can neither be set nor reset. When read, their contents are
indeterminate.
Interrupt priority level
select bit
Interrupt request bit
Polarity select bit (Note 2)
Reserved bit
0: Interrupt not requested
1: Interrupt requested
0 : Selects falling edge
1 : Selects rising edge
Always set to “0”
ILVL1
ILVL2
(Note 1)
0 0 0 : Level 0 (interrupt disabled)
0 0 1 : Level 1
0 1 0 : Level 2
0 1 1 : Level 3
1 0 0 : Level 4
1 0 1 : Level 5
1 1 0 : Level 6
1 1 1 : Level 7
b2 b1 b0
0
Note 1: This bit can only be reset (=0), but cannot be set (=1).
Note 2: For S1RIC( 0048
16
)
and S02BCNIC
Symbol
KUPIC
S2RIC
S13BCNIC
TA1IC
EP0IC
TA2IC
S0RIC
ADIC
DMOIC
S3TIC
DM1IC
S2TIC
DM2IC
Address
0041
16
004216
004316
004516
004616
004716
004A16
004B16
004C16
004D16
004E16
004F16
005016
When reset
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
Symbol
S1TIC
DM3IC
S0TIC
TA0IC
S3RIC
SUSPIC
TA3IC
RSMIC
TA4IC
RSTIC
SOFIC
VBDIC
USBFIC
Address
005116
005216
005316
005416
005516
005616
005716
005816
005916
005A16
005B16
005C16
005D16
When reset
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
XXXXX0002
Interrupt control register
Symbol
INT1IC
S1RIC
S02BCNIC
INT2IC
INT0IC
Address
004416
004816
004916
005E16
005F16
When reset
XX00X0002
XX00X0002
XX00X0002
XX00X0002
XX00X0002
( 0049
16), "0" should always be written.
Interrupt control
The interrupt request bit is set by hardware to “0” when an interrupt request is received. The interrupt
request bit can also be set by software to “0”. (Do not set to “1”.)
INT0, INT1, and INT2 are triggered by the edges of external inputs. The edge polarity is selected using the
polarity select bit. (Other interrupts are described elsewhere.)
An interrupt must first be enabled before it can be used to cancel stop mode.
Peripheral I/O interrupts have their own interrupt control registers. Figure 1.31 shows the interrupt control
registers. Table 1.29 shows the addresses of the interrupt control registers.
Interrupts
55
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Example 1:
INT_SWITCH1:
FCLR I :Disable interrupts.
AND.B #00h, 0054h ;Clear TA0IC int. priority level and int. request bit.
NOP ;Four NOP instructions are required when using the HOLD function.
NOP
FSET I ;Enable interrupts.
Example 2:
INT_SWITCH2:
FCLR I :Disable interrupts.
AND.B #00h, 0054h ;Clear TA0IC int. priority level and int. request bit.
MOV.W MEM, R0 ;Dummy read.
FSET I ;Enable interrupts.
Example 3:
INT_SWITCH3:
PUSHC FLG ;Push Flag register onto stack
FCLR I ;Diable interrupts.
AND.B #00h, 0054h ;Clear TA0IC int. priority level and int. request bit.‘
POPC FLG ;Enable interrupts.
The reason why two NOP instructions (four using the HOLD function) or a dummy read is inserted before "FSET I" in
Examples 1 and 2, is to prevent the interrupt enable flag I from being set before the interrupt control register is
rewritten due to the effects of the instruction queue.
Table 1.29. Addresses in interrupt control register
Interrupt control register Symbol
name Address Interrupt control register Symbol
name Address
Key input KUPIC 0041
16
DMA2 DM2IC 0050
16
UART2 receive / ACK S2RIC 0042
16
UART1 transmit / NACK / Serial
Sound Interface 1 transmit SITIC 0051
16
UART1/UART3 Bus collision S13BCNIC 0043
16
DMA3 DM3IC 0052
16
INT1 INT1IC 0044
16
UART0 transmit / NACK / Serial
Sound Interface 0 transmit S0TIC 0053
16
Timer A1 TA1IC 0045
16
Timer A0 TA0IC 0054
16
USB EP0 EP0IC 0046
16
UART3 receive / ACK S3RIC 0055
16
Timer A2 TA2IC 0047
16
USB Suspend SUSPIC 0056
16
UART1 receive / ACK / Serial
Sound Interface 1 receive S1RIC 0048
16
Timer A3 TA3IC 0057
16
UART0/UART2 Bus collision S02BCNIC 0049
16
USB Resume RSMIC 0058
16
UART0 receive / ACK / Serial
Sound Interface 0 receive S0RIC 004A
16
Timer A4 TA4IC 0059
16
A-D ADIC 004B
16
USB Reset RSTIC 005A
16
DMA0 DM0IC 004C
16
USB SOF SOFIC 005B
16
UART3 transmit / NACK S3TIC 004D
16
USB Vbus Detect VBDIC 005C
16
DMA1 DM1IC 004E
16
USB Function USBFIC 005D
16
UART2 transmit / NACK S2TIC 004F
16
INT2 INT2IC 005E
16
INT0 INT0IC 005F
16
Modifying the interrupt control registers
When modifying the interrupt control register, do so at a point that does not generate the interrupt
request for that register. If there is a possibility of the interrupt request occurring, access the interrupt
control register after the interrupt is disabled. See Figure 1.32 for examples of programs.
Figure 1.32. Program examples
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
56
Interrupt Enable Flag (I flag)
The interrupt enable flag (I flag) controls the enabling and disabling of maskable interrupts. Setting this
flag to “1” enables all maskable interrupts; setting it to “0” disables all maskable interrupts. This flag is
set to “0” after reset.
Interrupt Request Bit
The interrupt request bit is set to “1” by hardware when an interrupt is requested. After the interrupt is
accepted and jumps to the corresponding interrupt vector, the request bit is set to “0” by hardware. The
interrupt request bit can also be set to “0” by software. (Do not set this bit to “1”).
Interrupt Sequence
The interrupt sequence, described below, is performed during the period from when an interrupt is accepted
to when the interrupt routine is executed.
If an interrupt occurs during execution of an instruction, the processor determines its priority when the
execution of the instruction is completed, and transfers control to the interrupt sequence from the next
cycle. If an interrupt occurs during execution of either the SMOVB, SMOVF, SSTR or RMPA instruction, the
processor temporarily suspends the instruction being executed, and transfers control to the interrupt
sequence.
The processor carries out the following in sequence after an interrupt request:
(1) CPU gets the interrupt information (the interrupt number and interrupt request level) by reading
address 0000016.
(2) Saves the contents of the flag register (FLG) as it was immediately before the start of interrupt se-
quence in the temporary register (Note) within the CPU.
(3) Sets the interrupt enable flag (I flag), the debug flag (D flag), and the stack pointer select flag (U flag) to
“0” (the U flag, however does not change if the INT instruction, in software interrupt numbers 32
through 63, is executed).
(4) Saves the contents of the temporary register (Note) within the CPU in the stack area.
(5) Saves the contents of the program counter (PC) in the stack area.
(6) Sets the interrupt priority level of the accepted instruction in the IPL.
After the interrupt sequence is completed, the processor resumes executing instructions from the first
address of the interrupt routine.
Note: This register cannot be utilized by the user.
Interrupts
57
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Interrupt Response Time
‘Interrupt response time’ is the period between when an interrupt occurs and when the first instruction
within the interrupt routine has been executed. This time comprises the period from the occurrence of an
interrupt to the completion of the instruction under execution at that moment (a) and the time required for
executing the interrupt sequence (b). Figure 1.33 shows the interrupt response time.
Figure 1.33. Interrupt response time
Instruction Interrupt sequence Instruction in
interrupt routine
Time
Interrupt response time
(a) (b)
Interrupt request acknowledgedInterrupt request generated
(a) Time from interrupt request is generated to when the instruction then under execution is completed.
(b) Time in which the instruction sequence is executed.
Time (a) is dependent on the instruction under execution. Thirty cycles is the maximum required for the
DIVX instruction (without wait).
Time (b) is as shown in Table 1.30 . Figure 1.34 shows the time required for executing the interrupt se-
quence.
Table 1.30. Time required for executing the interrupt sequence
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
58
Returning from an Interrupt Routine
Executing the REIT instruction at the end of an interrupt routine restores the contents of the flag register
(FLG) as it was immediately before the start of the interrupt sequence and the contents of the program
counter (PC), both of which were saved in the stack area. Then control returns to the program that was
being executed before the acceptance of the interrupt request, so that the suspended process resumes.
Return the other registers that were saved by software within the interrupt routine using the POPM instruc-
tion or a similar instruction before executing the REIT instruction.
Interrupt priority
The order of priority when two or more interrupts are generated simultaneously is determined by both
hardware and software.
The interrupt priority levels determined by hardware are:
RESET > NMI > DBC > Watchdog Timer > Peripheral I/O > Single step > Address match
The interrupt priority levels determined by software are set in the interrupt control registers.
When two or more interrupts are generated simultaneously, the interrupt with the higher software priority is
selected. However, if the interrupts have the same software priority level, the interrupt is selected according
to the hardware priority set in the circuit.
The selected interrupt is accepted only when the priority level is higher than the processor interrupt priority
level (IPL) in the flag register (FLG) and the interrupt enable flag (I flag) is “1”. Note that the reset, NMI,
DBC, watchdog timer, single-step, address-match, BRK instruction, overflow, and undefined instruction
interrupts are accepted regardless of the interrupt enable flag (I flag).
Interrupt Priority Level Select Bit and Processor Interrupt Priority Level (IPL)
Set the interrupt priority level using the interrupt priority level select bits, which consists of three interrupt
control register bits. When an interrupt request occurs, the interrupt priority level is compared with the
IPL of the CPU flag register. The interrupt is enabled only when the priority level of the interrupt is higher
than the IPL. Therefore, setting the interrupt priority level to “0” disables the interrupt.
Figure 1.34. Interrupt sequence timing
123456789 101112
The indeterminate segment is dependent on the queue buffer.
If the queue buffer is ready to take an instruction, a read cycle occurs.
Indeterminate SP-2 contents SP-4 contents
Interrupt
information
Address 0000 Indeterminate SP-2 SP-4 PC
BCLK
Internal
Address bus
Internal
Data bus
R
Indeterminate
vec vec + 2
vec + 2
contents
vec
contents
W
Interrupts
59
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.31 shows the settings of interrupt priority levels and Table 1.32 shows the interrupt levels
enabled, according to the contents of the IPL.
The following are conditions under which an interrupt is accepted:
•interrupt enable flag (I flag) = 1
•interrupt request bit = 1 (set by hardware)
•interrupt priority level > IPL
The interrupt enable flag (I flag), the interrupt request bit, the interrupt priority select bit, and the IPL are
independent, and they are not affected by one another.
Table 1.31. Interrupt priority level settings
Interrupt priority level select bit Interrupt priority level Priority order
b2 b1 b0
0 0 0
Level 0 (interrupt disabled)
0 0 1
Level 1 Low
0 1 0
Level 2
0 1 1
Level 3
1 0 0
Level 4
1 0 1
Level 5
1 1 0
Level 6
1 1 1
Level 7 High
Table 1.32. Interrupt levels enabled according to the contents of the IPL
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
60
Interrupt resolution circuit
When two or more interrupts are generated simultaneously, this circuit selects the interrupt with the
highest priority. Figure 1.35 shows the circuit that judges the interrupt priority.
Figure 1.35. Interrupt resolution circuit
INT1
DMA3
DMA2
DMA1
DMA0
UAR T0 receive/ACK/SSI0 receive
UART1 receive/ACK/SSI1 receive
UART2 receive/ACK
UART3 receive/ACK
UART0 transmit/NACK/SSI0 transmit
UART1 transmit/NACK/SSI1 transmit
UART2 transmit/NACK
UART3 transmit/NACK
UART0/2 Bus collision, Start/stop condition
UART1/3 Bus collision, Start/stop condition
Processor interrupt priority level (IPL)
USB EP0
Timer A0
Level 0 (initial value)
Priority level of each interrupt
High
Low
Priority of peripheral I/O interrupt
s
(if priority levels are same)
Interrupt enable flag (I flag)
Watchdog timer
Reset
DBC
NMI
Interrupt
request
accepted
Address match
Timer A3
Timer A4
Timer A2
USB Function
USB SOF
Timer A1
INT0
USB Suspend
USB Resume
USB Reset
Vbus Detect
INT2
A-D conversion
Key-input interrupt
Interrupts
61
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Interrupt Change of IPL
Reset Level 0 (000
2
), is set
NMI Lev el 7 (111
2
), is set
DBC Does not chang e
Watchdog timer Level 7 (111
2
), is set
Singl e step Does not ch ange
Address ma tch Does not change
Software interru pt Does not ch ang e
Flag changes
When an interrupt request is received, the stack pointer select flag (U flag) changes to “0” and the flag
register (FLG) and program counter (PC) are saved to the stack area indicated by the interrupt stack pointer
(ISP). Thereafter, the interrupt enable flag (I flag) and debug flag (D flag) change to “0” and the processor
interrupt priority level (IPL) at the flag register (FLG) is replaced by the priority level of the received interrupt.
However, when interrupt requests are received for software interrupts 32 to 63, the flag register (FLG) and
program counter (PC) are saved to the stack shown by the stack pointer select flag (U flag) at the time the
interrupt was received. The stack pointer select flag (U flag) does not change. The value of the processor
interrupt priority level (IPL) in the flag register (FLG) differs in the case of reset, NMI, DBC, watchdog timer,
single-step, address-match, BRK instruction, overflow, and undefined instruction interrupts. Table 1.34
shows how the IPL changes when interrupt requests are received.
Table 1.34. Change of IPL state when interrupt request are accepted
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
62
Interrupt request cause select register
Bit name Function
Bit symbol WR
Symbol Address When reset
IFSR 035F16 0016
IFSR0
b7 b6 b5 b4 b3 b2 b1 b0
INT0 interrupt polarity
swiching bit 0 : One edge
1 : Two edges
0 :
1 :
0 :
1 :
Nothing is assigned.
Write "0" when writing to these bits. The value is indeterminate when read.
INT1 interrupt polarity
swiching bit
INT2 interrupt polarity
swiching bit
IFSR1
IFSR2
IFSR6
IFSR7
0 :
1 :
0 :
1 :
Two edges
Two edges
UART2 Bus collision
UART3 Bus collision
One edge
One edge
UART0 Bus collision
UART1 Bus collision
Bus collision interrupt request
cause select bit 0
Bus collision interrupt request
cause select bit 1
INT interrupt
INT0 to INT2 are triggered by the edges of external inputs. The edge polarity is selected using the polarity
select bit in the interrupt control register (004416, 005E16, 005F16) and the polarity switching bit in the
interrupt request cause select register (035F16).
For an external interrupt input, an interrupt can be generated both at the rising edge and at the falling edge
by setting “1” in the INTi interrupt polarity switching bit of the interrupt request cause select register
(035F16). To select one edge, set the polarity switching bit of the corresponding interrupt request cause
select register to ‘one edge’ (“0”), and set the polarity select bit in the interrupt control register to rising
edge or falling edge.
Figure 1.36 shows the interrupt request cause select register.
Figure 1.36. Interrupt request cause select register.
NMI Interrupt
An NMI interrupt is generated when the input to the P85/NMI pin changes from “H” to “L”. The NMI interrupt
is a non-maskable external interrupt. The pin level can be checked in the Port P85 register (bit 5 at address
03F016). This pin cannot be used as a normal port input.
Notes:
When not intending to use the NMI function, be sure to connect the NMI pin to Vcc. Because the NMI
interrupt is non-maskable, it cannot be disabled.
When the NMI pin input is “L”, do not set the microcomputer in stop mode or wait mode. The NMI interrupt
is triggered by the falling edge, so the “L” level does not need to be maintained longer than necessary.
Key-Input Interrupt
A Key input interrupt can be generated by a falling edge, rising edge or both edges input to any Port 10
pin. It can also be used as a Key-on wake up function for canceling the wait mode or stop mode. Figure
1.37 shows the block diagram of the Key-input interrupt.
Figure 1.38 shows the Key-input mode register. It is possible to select both edges or the falling edge of the
Key input interrupt for P10 with bits 0 and 1 of this register. This register is also used to enable or disable
Port 10 pins that are to be used for Key-input interrupts. Port 10 can be configured with pull-up resistors
using the pull-up control resistor.
Interrupts
63
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.37. Block diagram of Key-input interrupt
Figure 1.38. Key-input mode register
Interrupt control circuit
Key input interrupt control register (address 004116)
Key input interrupt request
P10
7
/KI
7
P
10
6
/KI
6
P10
5
/KI
5
Port P10
0
-P10
7
pull-up select bit
Port P10
7
direction register
Pull-up
transistor
Port P10
7
direction register
Port P10
6
direction register
Port P10
5
direction register
Pull-up
transistor
Pull-up
transistor
P10
4
/KI
4
Port P10
4
direction register
Pull-up
transistor
P10
0
/KI
0
Port P10
0
direction register
Pull-up
transistor
Edge detect
Edge detect
Edge detect
Edge detect
Edge detect
KIE3
KIE2
KIE0
KIS0, KIS1
Enable/Disable
The key-input interrupts can be enabled and disabled in pairs using the Key-input mode register (03F916)
and Key-input interrupt register (004116). The key-input interrupt is affected by the interrupt priority level
(IPL) and the interrupt enable flag (I flag). The input signal edge that triggers the Key-input interrupt can be
selected by setting the P10 Key-input edge select bits (bits 0 and 1 at 03F916). Also, make sure to set the
port direction for the enabled Key-input interrupt pins to input.
Bit Symbol Bit Name Function R W
KIS0
KIS1
KIE0
KIE1
KIE2
KIE3
P10 Key-input edge select 0
P10 Key-input edge select 1
P10
0
and P10
1
Key-input enable bit
P10
2
and P10
3
Key-input enable bit
P10
4
and P10
5
Key-input enable bit
P10
6
and P10
7
Key-input enable bit
0 0 : Falling edge
0 1 : Rising edge
1 0 : Two edges
1 1 : Reserved
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
O O
Symbol
KUPM Address
0126
16
When reset
00
16
Key-input mode register
b7 b5b6 b4 b3 b2 b1 b0
Nothing is assigned. Write "0" when writing to these bits.
The value is "0" if read.
_ _
O O
O O
O O
O O
b1 b0
O O
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
64
Occurrence timing of the key-input interrupt
With the Key-input interrupt enabled, Port 10 pins that are enabled in the Key-input mode register are set
to input mode and become Key-input interrupt pins (KI0 through KI7). A Key-input interrupt occurs when the
selected edge is input to a Key-input interrupt pin. At this moment, the level of other key-input interrupt pins
must be “H”. No interrupt occurs when the level of any other key-input interrupt pins is “L”.
Determining a key-input interrupt
A key-input interrupt occurs when the selected edge is input to one of 8 pins, (if they are all enabled in the
Key-input mode register) but each pin has the same vector address. Therefore, read the input level of Port
P10 in the key-input interrupt routine to determine the interrupted pin.
Related registers
Figure 1.39 shows the memory map of key-input interrupt-related registers
Figure 1.39. Memory map of Key-input interrupt-related registers
Address
Register name
Acronym
0040
16
0041
16
Key input interrupt register KUPIC
03F0
16
03F1
16
03F2
16
03F3
16
03F4
16
Port 10 P10
03F5
16
03F6
16
Port 10 direction register PD10
03F7
16
03F8
16
03F9
16
03FA
16
03FB
16
03FC
16
03FD
16
03FE
16
Pull-up control register 2 PUR2
03FF
16
Key-input mode register KUPM
Interrupts
65
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Address-Match Interrupt
An address-match interrupt is generated when the address-match interrupt address register contents
match the program counter value. Two address-match interrupts can be set, each of which can be enabled
and disabled by an address-match interrupt enable bit. The interrupt enable flag (I flag) does not affect
address-match interrupts and processor interrupt priority level (IPL).
Figure 1.40 shows the address-match interrupt-related registers.
Figure 1.40. Address-match interrupt-related register Interrupt precautions
Bit nameBit symbol
Symbol Address When reset
AIER 000916 XXXXXX002
Address match interrupt enable register
Function WR
Address match interrupt 0
enable bit 0 : Interrupt disabled
1 : Interrupt enabled
AIER0
Address match interrupt 1
enable bit
AIER1
Symbol Address When reset
RMAD0 001216 to 001016 X0000016
RMAD1 001616 to 001416 X0000016
Nothing is assigned.
b7 b6 b5 b4 b3 b2 b1 b0
WR
Address setting register for address match interrupt
Function Values that can be set
Address match interrupt register i (i = 0, 1)
0000016 to FFFFF16
Nothing is assigned.
0 : Interrupt disabled
1 : Interrupt enabled
b0 b7 b0b3
(b19) (b16) b7 b0
(b15) (b8)
b7
(b23)
Write 0 when writing to these bits. If read, the value is indeterminate.
Write 0 when writing to these bits. If read, the value is indeterminate.
Precautions
Reading address 0000016
When maskable interrupt occurs, the CPU reads the interrupt information (the interrupt number and
interrupt request level) in the interrupt sequence. The interrupt request bit of the interrupt written in
address 0000016 will then be set to “0”.
Do not read address 0000016 by software. Reading address 0000016 by software sets enabled highest
priority interrupt source request bit to “0”. Though the interrupt is generated, the interrupt routine may not
be executed.
Setting the stack pointer
The value of the stack pointer immediately after reset is initialized to 000016. Accepting an interrupt
before setting a value in the stack pointer may cause program runaway. Be sure to set a value in the
stack pointer before accepting an interrupt.
When using the NMI interrupt, initialize the stack pointer at the beginning of a program. Generating any
interrupts including the NMI interrupt is prohibited for the first instruction immediately after reset.
Interrupts
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
66
Set the polarity select bit
Clear the interrupt request bit to “0”
Set the interrupt priority level 1 to 7
(Enable the INTi interrupt requests)
Set the interrupt priority level to level 0
(Disable INTi interrupt)
Clear the interrupt enable flag to “0”
(Disable interrupt)
Set the interrupt enable flag to “1”
(Enable interrupt)
Note: Execute the settin
g
s individuall
y
. Do not execute two or more settin
g
s simultaneousl
y
.
The NMI interrupt
The NMI interrupt can not be disabled. Be sure to connect NMI pin to Vcc with a pull-up resistor if
unused. Do not go into stop mode when the NMI pin set to “L”.
The NMI pin also serves as P85, which is exclusively an input. Reading the contents of the P8 register
allows the pin value to be read. Reading this pin is only to be used for establishing the pin level when the
NMI interrupt is input.
Do not reset the CPU with the input to the NMI pin in the “L” state.
Do not attempt to go into stop mode when the input to the NMI pin is in “L” state. When the input to the
NMI is in “L” state, CM10 is fixed to “0” thereby refusing to go into stop mode.
Do not attempt to go into wait mode when the input to the NMI pin is in “L” state. When the input to the
NMI pin is in “L” state, the CPU stops but the oscillation does not. This action does not save power.
When this occurs, the CPU is returned to the normal state by a later interrupt.
Signals input to the NMI pin require an "L" level of (2 clocks + 300nS) or more from the operation clock
of the CPU.
External interrupt
Either an “H” or “L” level of at least 250 ns width is necessary for the signal input to pins INT0 to INT2
regardless of the CPU operation clock.
When the polarity of the INT0 to INT2 pins is changed, the interrupt request bit is sometimes set to “1”.
After changing the polarity, reset the interrupt request bit to “0”. Figure 1.41 shows the procedure for
changing the INT interrupt generate factor.
Figure 1.41. Switching condition of INT interrupt request
Interrupts
67
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Example 1:
INT_SWITCH1:
FCLR I :Disable interrupts.
AND.B #00h, 0054h ;Clear TA0IC int. priority level and int. request bit.
NOP ;Four NOP instructions are required when using the HOLD function.
NOP
FSET I ;Enable interrupts.
Example 2:
INT_SWITCH2:
FCLR I :Disable interrupts.
AND.B #00h, 0054h ;Clear TA0IC int. priority level and int. request bit.
MOV.W MEM, R0 ;Dummy read.
FSET I ;Enable interrupts.
Example 3:
INT_SWITCH3:
PUSHC FLG ;Push Flag register onto stack
FCLR I ;Diable interrupts.
AND.B #00h, 0054h ;Clear TA0IC int. priority level and int. request bit.‘
POPC FLG ;Enable interrupts.
The reason why two NOP instructions (four using the HOLD function) or a dummy read is inserted before "FSET I" in
Examples 1 and 2, is to prevent the interrupt enable flag I from being set before the interrupt control register is
rewritten due to the effects of the instruction queue.
Rewriting the interrupt control register
Rewrite the interrupt control register so that it does not generate an interrupt request for that register. If
an interrupt request occurs, rewrite the interrupt control register after the interrupt is disabled. Some
program examples are described below.
When an instruction to rewrite the interrupt control register is executed but the interrupt is disabled, the
interrupt request bit is always not set even if the interrupt request for that register has been generated.
This will depend on the instruction. If this creates problems, use the instructions below to change the
register.
Instructions: AND, OR, BCLR, BSET
Watchdog Timer
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
68
Watchdog Timer
The watchdog timer can detect a runaway program. It is a 15-bit counter that decrements using the clock de-
rived from dividing the BCLK by the prescaler. A watchdog timer interrupt is generated when an underflow
occurs in the watchdog timer. The watchdog timer interrupt is a non-maskable interrupt.
When XIN is selected for BCLK, bit 7 (WDC7) of the watchdog timer control register (address 000F16) selects
the prescaler divide ratio to be either 16 or 128. When XCIN is selected for BCLK, the prescaler divide ratio is set
to 2 regardless of WDC7. The watchdog timer cycle can be calculated as follows:
When XIN chosen for BCLK:
Watchdog timer period = prescaler dividing ratio (16 or 128) X Watchdog timer count (32768)
BCLK
When XCIN chosen for BCLK:
Watchdog timer period = prescaler dividing ratio (2) X Watchdog timer count (32768)
BCLK
Example:
When BCLK is 12 MHz and the prescaler divide ratio is set to 16, the monitor timer cycle is approximately 43.69
ms.
The watchdog timer is initialized by writing to the watchdog timer start register (address 000E16), and when a
watchdog timer interrupt request is generated.
The prescaler is initialized only when the microcomputer is reset. After a reset, the watchdog timer and prescaler
are both stopped. The count is started by writing to the watchdog timer start register (address 000E16).
The watchdog timer and the prescaler stop in stop mode, wait mode, and hold state. After exiting these modes,
counting starts from the remaining value. Figure 1.42 shows the block diagram of the watchdog timer. Figure 1.43
shows the watchdog timer-related registers.
Watchdog Timer
69
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
BCLK
Write to the watchdog timer
start register
(address 000E
16
)
RESET
Watchdog timer
interrupt request
Watchdog timer
Set to
“7FFF
16
”
1/128
1/16
“CM07 = 0”
“WDC7 = 1”
“CM07 = 0”
“WDC7 = 0”
“CM07 = 1”
HOLD
1/2
Prescaler
Watchdog timer control register
Symbol Address When reset
WDC 000F16 000XXXXX2
FunctionBit symbol WR
b7 b6 b5 b4 b3 b2 b1 b0
High-order bit of Watchdog timer
WDC7
Bit name
Prescaler select bit 0 : Divided by 16
1 : Divided by 128
Watchdog timer start register
Symbol Address When reset
WDTS 000E16 Indeterminate
WR
b7 b0
Function
Reserved bit Must always be set to “0”
00
The Watchdog timer is initialized and starts counting after the first write instruction 
to this register after reset. Writing any value to this register resets the counter to 
7FFF16.
Figure 1.42. Block diagram of Watchdog timer
Figure 1.43. Watchdog timer control and start registers
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
70
Universal Serial Bus
Features
• USB Specification Revision 2.0 compliant
• Support of full-speed operation (12 Mbps)
• Support of all USB transfer types: ....................... Isochronous
................................................................. Bulk
................................................................. Control
................................................................. Interrupt
• Built-in 3.25 Kbyte FIFO as endpoint buffer: ........ Endpoint 0: IN/OUT 128-byte/128-byte
................................................................. Endpoint 1: IN/OUT Programmable
................................................................. Endpoint 2: IN/OUT Programmable
................................................................. Endpoint 3: IN/OUT Programmable
................................................................. Endpoint 4: IN/OUT Programmable
• 9 endpoints - control endpoint (EP0 - bidirectional) plus four IN and four OUT endpoints
• Control endpoint (EP0) continuous transfer mode
• Programmability of transfer type and buffer size for 8 of the 9 endpoints (EP1 – EP4 IN & OUT)
• Transfer type: ......................................... Bulk, Isochronous or Interrupt
Single or double buffer selectable
• Buffer size: ............................................. Maximum 1K bytes
When in double buffer mode, effective maximum buffer size up to 2 x 1K bytes
• Bulk endpoints continuous transfer mode
• SOF output and interrupt generation with artificial SOF capability (in the event of corrupt SOF
packet)
• 8- or 16-bit CPU access to the FIFO and registers
USB Interrupts
There are six USB interrupts in this device:
• EP0 Interrupt (multiple-trigger events)
• USB Function Interrupt (multiple sources)
• USB Reset Interrupt
• USB Resume Interrupt
• USB Suspend Interrupt
• USB Start-of-Frame (SOF) Interrupt
The first five interrupts are used to control the data flow and USB power consumption. The SOF interrupt is
used to monitor the transfer of isochronous (ISO) data. Setting the corresponding bit in the Interrupt
Control Register for each interrupt enables each of the six USB interrupts.
Universal Serial Bus
71
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
The USB Function Interrupt has multiple interrupt sources that can be enabled within the USB Function
Interrupt Enable Register (USBIE).
EP0 Interrupt
The EP0 interrupt is generated when one of the following events occur:
• A data set is successfully received
• A data set is successfully sent
• EP0CSR3 (DATA_END) flag is cleared. This event is maskable and the default is masked.
• A control transfer ends prematurely (i.e., the USB FCU sets the SETUP_END bit). See USB programming
note #1.
USB Function Interrupt
The USB Function interrupt can be triggered by:
• The interrupts from eight endpoints (EP1-EP4 IN/OUT). The interrupts indicate if a data set was either sent
or received.
• A data flow error from any of the nine endpoints (including EP0)
• The enabling of any IN endpoint (EP1-EP4 IN).
• The corruption of the final ACK of a Control Read transfer's Data Stage. See USB programming Note #2.
Each endpoint interrupt is enabled by setting the corresponding bit in the USB Interrupt Enable register
(USBIE).
Interrupt status flags associated with each source are contained in USB Interrupt Status register (USBIS).
USB Reset Interrupt
A USB Reset Interrupt is generated when the USB Function Control Unit (USB FCU) sees a SE0 present on
D+/D- for at least 2.5us. When a reset signal is detected by the USB FCU, an internal reset pulse is also
generated to reset all USB internal registers to the default values.
When the CPU recognizes a USB Reset Interrupt, it re-initializes the USB FCU to ensure that the USB
operation functions properly.
The USB Reset Interrupt Control register (RSTIC) contains the USB Reset Interrupt request bit and interrupt
priority select bits used to enable the interrupt and set the software priority level.
USB Resume Interrupt
A USB Resume Interrupt is generated when the USB FCU is in the suspend state and detects non-idle
signaling on the D+/D-.
The USB Resume Interrupt Control register (RSMIC) contains the USB Resume Interrupt request bit and
interrupt priority select bits used to enable the interrupt and set its software priority level.
USB SOF Interrupt
The USB SOF (Start-Of-Frame) Interrupt is used to control the transfer of isochronous data. The USB FCU
generates a USB SOF Interrupt request when a start-of-frame packet is received.
Because the start-of-frame packet could be corrupted, a new frame might start without successful reception
of the SOF packet. For this reason, an artificial SOF is provided. The frame timer signals a time out when a
SOF packet is not received within the allotted time. The device generates an SOF interrupt once every
frame. Setting bit 2 of the USB ISO Control Register to a “1” enables the artificial SOF function.
Register SOFIC contains the USB SOF Interrupt’s request bit and interrupt priority select bits that are used
to enable the interrupt and set its software priority level.
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
72
USB Suspend Interrupt
A USB Suspend Interrupt is generated when the USB FCU does not detect any bus activity on D+/D- (in J-
state) for at least 3ms.
The USB Suspend Interrupt Control register (SUSPIC) contains the USB Suspend Interrupt request bit and
interrupt priority select bits that are used to enable the interrupt and set its software priority level.
USB Endpoint FIFOs
The USB FCU has a built-in 3.25 K bytes FIFO as an endpoint buffer. The EP0 (control endpoint) FIFO
occupies a fixed location (from 3K – 3.25K) with fixed buffer sizes (128 bytes each) for its IN and OUT data
transfers. The other 8 endpoints (EP1 to EP4 IN and OUT) share a 3K bytes buffer. Each endpoint’s FIFO
size and starting location (64 bytes) are programmable by the user. The sum of the 8 endpoint FIFOs can
not exceed 3K bytes (3072 bytes).
Note: Throughout the USB Block specification, “data packet” is generally used when continuous mode is
disabled; “data set” (one or more data packets) is generally used when continuous mode is enabled. If a
description applies for both noncontinuous mode and continuous mode, “data set” is used.
Throughout the whole USB Block Specification, “FIFO” and “Buffer” are generally interchangeable terms.
EP0 FIFO Operation
The CPU writes data to the EP0 IN FIFO Data Register. The write pointer automatically increments by 2 in
word accessing mode or by 1 in byte accessing mode after a write. The CPU must only write data to the
EP0 IN FIFO Data Register and “1” to the SET_IN_BUF_RDY bit of the EP0 CSR when the IN_BUF_RDY
flag is a “0”. When a NULL packet is required to complete a control read request, the CPU must write “1” to
the SET_IN_BUF_RDY bit of EP0_CSR without writing data to the EP0 IN FIFO Data Register.
Continuous transfer modes are available for EP0 Control Transfers.
EP0 IN FIFO with control read continuous transfer mode disabled
The CPU writes “1” to the SET_IN_BUF_RDY bit of the EP0 CSR after the CPU finishes writing a data
packet to the FIFO, this updates the IN_BUF_RDY flag to “1”. The USB FCU updates the IN_BUF_RDY
flag to “0” after the packet has been successfully transmitted to the host.
EP0 IN FIFO with control read continuous transfer mode enabled
The CPU writes “1” to the SET_IN_BUF_RDY bit of the EP0 CSR after the CPU finishes writing a data
set (up to 128 bytes) to the FIFO. This updates the IN_BUF_RDY flag to “1”. The USB FCU sends out
data packets equal to the EP0 MAXP size one at a time, except for the last packet if the data set in the
FIFO is not a multiple of EP0 MAXP. In this case the USB FCU sends a short packet. The USB FCU
updates the IN_BUF_RDY flag to “0” after the data set has been successfully transmitted to the host.
The CPU reads data from EP0 OUT FIFO Data Register. The read pointer automatically increments by 2
in word accessing mode or by 1 in byte accessing mode after a read. The CPU must only read data from
the EP0 OUT FIFO when the OUT_BUF_RDY flag of the EP0_CSR is “1”.
When a SETUP packet is received, an EP0 interrupt is generated (both OUT_BUF_RDY and SETUP
flags are set) regardless of the continuous transfer mode bit setting.
EP0 OUT FIFO with control write continuous transfer mode disabled
The USB FCU updates the OUT_BUF_RDY flag to “1” after it has successfully received a data packet
from the host. The CPU writes “1” to CLR_OUT_BUF_RDY after the data packet has been unloaded from
the FIFO by the CPU (updates the OUT_BUF_RDY flag to a “0”).
Universal Serial Bus
73
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
EP0 OUT FIFO with control write continuous transfer mode enabled
The USB FCU updates the OUT_BUF_RDY flag to “1” after:
• It has successfully received a data set equal to 128 bytes or a short packet from the host
OR
• A control write status phase has started but there are pending OUT data packets in the buffer.
The CPU writes “1” to CLR_OUT_BUF_RDY after the data set has been unloaded from the FIFO by the
CPU (updates the OUT_BUF_RDY flag to “0”).
Special note when using continuous transfer mode in control read request
In continuous transfer mode, the CPU can write multiple data packets to the data buffer before setting
the SET_IN_BUF_RDY to “1”. The CPU must write the last data packet separately to the data buffer and
sets the SET_DATA_END bit. For example, if the buffer size=128 bytes, MAXP= 8 bytes, and the CPU
sends 64 bytes of data to the host, the CPU does the following:
• Writes 7x8=56 bytes to the buffer;
• Sets SET_IN_BUF_RDY=1;
• After the 7 packets are successfully sent to host, the IN_BUF_RDY flag changes from “1” to “0”;
• Writes the last 8 bytes of data to the buffer;
• Sets SET_IN_BUF_RDY=”1” and SET_DATA_END to “1”;
The CPU should not write all 64 bytes of data, and set the SET_IN_BUF_RDY and SET_DATA_END bits
to “1” at the same time.
Special note when using continuous transfer mode in control write request
Because the buffer can hold multiple data packets before generating an interrupt, two special cases
should be taken into consideration:
1. The SETUP_END flag usually indicates a premature completion of a control transfer. However, if the
data field of a control write is a multiple of MAXP but not a multiple of the buffer size, the SETUP_END
flag may be set without causing a premature completion of transfer. For example, if MAXP =8, buffer size
= 128, wLength = 192 (a multiple of MAXP but not the buffer size), the following occurs in continuous
mode:
After receiving 16 8-byte packets, (128 bytes) from the host, an EP0 interrupt is generated to indicate to
the CPU that data unloading can start.
When the host completes sending the remainder of the data field (eight 8-byte packets) an EP0 interrupt
is not generated because the buffer is not full and there is no short packet.
When the status phase starts (the host sends an IN token), OUT_BUF_RDY and SETUP_END are set.
The SETUP_END is set because the CPU is unaware of the end of the data phase, thus DATA_END is
not set. Whenever DATA_END is not set and the status stage starts, the protocol state machine will treat
it as a premature completion (data field is less than wLength) and sets the SETUP_END bit.
It is the users responsibility to determine the difference between a premature completion and a normal
completion (data field equals the wLength) when the CPU acknowledges a SETUP_END flag in continu-
ous mode.
2. The device usually returns a stall handshake when the host sends more data than specified in the
wLength field. However, if a host sends more data than specified in wLength in the middle of a continu-
ous transfer burst, the USB FCU returns ACK to every packet it receives if there are no errors. In this
case, when the firmware detects this kind of protocol error, it must set CLR_OUT_PKT_RDY to “1” and
set SEND_STALL to “1” so that the USB FCU returns STALL in the subsequent data or status phase. For
example, if MAXP = 8, buffer size = 128, wLength = 26, the following may occur:
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
74
CASE 1: The host sends three 8-byte packets and one 2-byte packet. When the core receives the last 2-
byte packet, the OUT_BUF_RDY flag is set (because of a short packet) indicating the CPU can unload
the data. At the end of unloading, the CPU should clear the OUT_BUF_RDY flag and set the
DATA_END. If the host sends more data after this point, the core returns STALL automatically.
CASE 2: The host sends 6 8-byte packets (anything greater than 3 for this example) and one 2-byte
packet (host may erroneously send 50 bytes instead of 26). The host ACKs each received packet
however, it does not automatically return a STALL because the DATA_END flag is not set when the
excessive packets are received. When the CPU retrieves the data and detects that the data field is
greater than the wLength, it sets the SEND_STALL bit for the core to return STALL.
EP1-4 IN (Transmit) FIFO Operation
The CPU writes data to the endpoint’s FIFO Data Register. The write pointer automatically increments by 2
in word accessing mode or increments by 1 in byte accessing mode after a write. The CPU must only write
data to the FIFO Data Register when the IN_BUF_STS1 flag of the corresponding EPx IN CSR is “0”. The
IN_BUF_STS0 & IN_BUF_STS1 flags are both “1” after a hardware reset or a USB reset, and become “0”
when the corresponding endpoint is first enabled (Endpoints 1-4 IN & OUT are disabled at reset).
The user can program the buffer size and starting location of each IN Endpoint. Users can assign a buffer
size up to 1024 bytes in units of 64 bytes to an endpoint. If double buffer mode is selected, the effective
buffer size is 2 x buffer size specified.
Continuous transfer mode is available for IN EP1-4 for Bulk Transfers only. When the continuous transfer
mode is enabled, it is the user’s responsibility to ensure the buffer size is a multiple of the MAXP value.
AUTO_SET function is available for IN EP1-4 for both noncontinuous and continuous modes. When this
function is enabled, if a short packet or a less than buffer size data set is to be transmitted to the host, the
CPU must write a “1” to the SET_IN_BUF_RDY bit to signify the packet (data set) is ready to send.
AUTO_SET and continuous transfer mode are disabled:
Single Buffer Mode:
The CPU writes a “1” to the SET_IN_BUF_RDY bit of the corresponding EPx IN CSR after the CPU
finishes writing a data packet to the buffer (updates the IN_BUF_STS1 & IN_BUF_STS0 flags from 002
to 112). The USB FCU updates the buffer status flags from 112 to 002 after the data packet has been
successfully transmitted to the host.
Double Buffer Mode:
The CPU writes “1” to the SET_IN_BUF_RDY bit of the corresponding EPx IN CSR after the CPU
finishes writing a data packet to the buffer (updates the IN_BUF_STS1 & IN_BUF_STS0 flags).
• If the buffer is immediately available to accept another data packet, the buffer status flags transition
from 002 to 012.
• If the buffer is not available to accept another data packet, the buffer status flags transition from 012 to
112.
The USB FCU updates the buffers status flags after a data packet has been successfully transmitted to
the host.
• If the buffer has one more data packet in it, the buffer status flags transition from 112 to 012.
• If the buffer has no more data packet in it, the buffer status flags transition from 012 to 002.
AUTO_SET is disabled and continuous transfer mode enabled:
Single Buffer Mode:
The CPU writes a “1” to the SET_IN_BUF_RDY bit of the corresponding EPx IN CSR after the CPU
finishes writing a data set up to its buffer size to the buffer (updates the IN_BUF_STS1 & IN_BUF_STS0
flags from 002 to 112). The USB FCU sends out data packets equal to the MAXP size one at a time,
Universal Serial Bus
75
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
except for the last packet, if the data set in the buffer is not a multiple of the MAXP, the USB FCU sends
a short packet.
The USB FCU updates the buffer status flags from 112 to 002 after the data set has been successfully
transmitted to the host.
Double Buffer Mode:
The CPU writes a “1” to the SET_IN_BUF_RDY bit of the corresponding EPx IN CSR after the CPU
finishes writing a data set up to its buffer size to the buffer (updates the IN_BUF_STS1 & IN_BUF_STS0
flags). The USB FCU sends out data packets equal to the MAXP size one at a time, except for the last
packet if the data in the buffer is not a multiple of the MAXP, the USB FCU sends a short packet.
• If the buffer is immediately available to accept another data set, the buffer status flags transition from
002 to 012.
• If the buffer is not available to accept another data set, the buffer status flags transition from 012 to 112.
The USB FCU updates the buffers status flags after a data set has been successfully transmitted to the
host.
• If the buffer has one more data set in it, the buffer status flags transition from 112 to 012.
• If the buffer has no more data set in it, the buffer status flags transition from 012 to 002.
AUTO_SET is enabled and continuous transfer mode disabled:
Single Buffer Mode:
After the CPU writes a data packet equal to the MAXP size to the buffer, the USB FCU updates the
corresponding EPx IN CSR’s IN_BUF_STS1 & IN_BUF_STS0 flags from 002 to 112 automatically without
the CPU writing ”1” to the SET_IN_BUF_RDY bit. The USB FCU updates the buffer status flags from 112
to 002 after the data packet has been successfully transmitted to the host.
If the data packet is less than the MAXP size, the CPU must write "1" to the SET_IN_BUF_RDY bit to
signify the data packet is ready to send.
Double Buffer Mode:
After the CPU writes a data packet equal to its MAXP size to the buffer, the USB FCU updates the
corresponding EPx IN CSR’s IN_BUF_STS1 & IN_BUF_STS0 flags.
• If the buffer is immediately available to accept another data packet, the buffer status flags transition
from 002 to 012.
• If the buffer is not available to accept another data packet, the buffer status flags transition from 012 to
112.
The USB FCU updates the buffers status flags after a data packet has been successfully transmitted to
the host.
• If the buffer has one more data packet in it, the buffer status flags transition from 112 to 012.
• If the buffer has no more data packet in it, the buffer status flags transition from 012 to 002.
• If the data packet is less than the MAXP size, the CPU must write “1” to the SET_IN_BUF_RDY bit to
signify the data packet is ready to send.
AUTO_SET and continuous transfer mode are enabled:
Single Buffer Mode:
After the CPU writes a data set equal to the buffer size to the buffer, the USB FCU updates the corre-
sponding EPx IN CSR’s IN_BUF_STS1 & IN_BUF_STS0 flags from 002 to 112 automatically without the
CPU writing ”1” to the SET_IN_BUF_RDY bit.
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
76
Table 1.35. Endpoint 1-4 IN buffer status
The USB FCU sends out data packets equal to the MAXP size one at a time, except for the last packet if
the data set in the buffer is not a multiple of its MAXP, the USB FCU sends a short packet. The USB FCU
updates the buffer status flags from 112 to 002 after the data set has been successfully transmitted to the
host.
If the data set is less than the buffer size, the CPU must write “1” to the SET_IN_BUF_RDY bit to signify
the data set is ready to send.
Double Buffer Mode:
After the CPU writes a data set equal to its buffer size to the buffer, the USB FCU updates the
IN_BUF_STS1 & IN_BUF_STS0 flags.
• If the buffer is immediately available to accept another data set, the buffer status flags transition from
002 to 012.
• If the buffer is not available to accept another data set, the buffer status flags transition from 012 to 112.
The USB FCU sends out data packets equal to the MAXP size one at a time, except for the last packet.
• If the data in the buffer is not a multiple of the MAXP, the USB FCU sends a short packet.
The USB FCU updates the buffers status flags after a data set has been successfully transmitted to the
host.
• If the buffer has one more data set in it, the buffer status flags transition from 112 to 012.
• If the buffer has no more data set in it, the buffer status flags transition from 012 to 002.
• If the data set is less than the buffer size, the CPU must write “1” to the SET_IN_BUF_RDY bit to signify
the data set is ready to send.
IN Endpoint FIFO Flush
A software or a hardware flush causes the USB FCU to act (in both continuous and noncontinuous
transfer modes) as if a data set has been successfully transmitted out to the host. When there is one
data set in the buffer, a flush causes the buffer to be empty. When there are two data sets in the buffer, a
flush causes the older data set to be flushed out from the buffer. A flush also updates the buffer status
flags of the corresponding EPx IN CSR.
The Endpoint 1-4 IN buffer status can be obtained from the two status bits of the EPx IN CSR of the
corresponding endpoint as shown in Table 1.35.
IN_BUF_STS1 IN_BUF_STS0 Buffer Status
00 No data set in the IN buffer
01Single buffer mode: N/A
Double buffer mode: One data set in the IN Buffer
10Single buffer mode: N/A
Double buffer mode: N /A
11Single buffer mode: One data set in the IN buffer
Double buffer mode: Two data sets in the IN buffer
Universal Serial Bus
77
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
EP1-4 OUT (Receive) FIFOs
The CPU reads data from the endpoint’s FIFO Data Register. The read pointer automatically increments by
2 in word accessing mode or by 1 in byte accessing mode after a read. The CPU must only read data from
the FIFO Data Register when the OUT_BUF_STS1 flag of the corresponding EPx OUT CSR is a “1”.
The user can program each OUT endpoint’s buffer size and starting location, and assign a buffer size up to
1024 bytes in units of 64 bytes to an endpoint. If double buffer mode is selected, the effective buffer size is
2 x buffer size specified.
Continuous transfer mode is available for OUT EP1-4 bulk transfers only. When the continuous transfer
mode is enabled, the user is responsible for ensuring that the buffer size is a multiple of the MAXP value.
Also, the user must ensure that the last data set from the host either contains a short packet or is equal to
the buffer size, otherwise there is no interrupt or status that will signify that the last data set was received.
AUTO_CLR function is available for OUT EP1-4.
AUTO_CLR and continuous transfer mode are disabled:
Single Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
from 002 to 112 after it has successfully received a data packet from the host.
The CPU writes “1” to the CLR_OUT_BUF_RDY bit after the data packet has been unloaded from the
buffer by the CPU (updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags from 112 to 002).
Double Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
after it has successfully received a data packet from the host.
• If the buffer has only one data packet, the buffer status flags transition from 002 to 102.
• If the buffer has two data packets, the buffer status flags transition from 102 to 112.
The CPU writes “1” to the CLR_OUT_BUF_RDY bit after a data packet has been unloaded from the
buffer by the CPU (updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags).
• If the buffer has one more data packet in it, the buffer status flags transition from 112 to 102.
• If the buffer has no more data packet in it, the buffer status flags transition from 102 to 002.
AUTO_CLR is disabled and continuous transfer mode enabled:
Single Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
from 002 to 112 after it has successfully received from the host a data set equal to the buffer size, or a
short packet.
The CPU writes “1” to the CLR_OUT_BUF_RDY bit after the data set has been unloaded from the buffer
by the CPU (updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags from 112 to 002 ).
Double Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
after it has successfully received a data set equal to its buffer size or a short packet from the host..
• If the buffer has only one data set, the buffer status flags transition from 002 to 102 .
• If the buffer has two data sets, the buffer status flags transition from 102 to 112 .
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
78
The CPU writes a “1” to the CLR_OUT_BUF_RDY bit after a data set has been unloaded from the buffer
by the CPU (updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags).
• If the buffer has one more data set in it, the buffer status flags transition from 112 to 102 .
• If the buffer has no more data set in it, the buffer status flags transition from 102 to 002 .
AUTO_CLR is enabled and continuous transfer mode disabled:
Single Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
from 002 to 11 2 after it has successfully received a data packet from the host.
The USB FCU updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags from 112 to 002 automatically
when the data packet has been unloaded from the buffer by the CPU without the CPU writing a “1” to the
CLR_OUT_BUF_RDY bit.
Double Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
after it has successfully received a data packet from the host.
• If the buffer has only one data packet, the buffer status flags transition from 002 to 102 .
• If the buffer has two data packets, the buffer status flags transition from 102 to 112 .
The USB FCU updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags automatically when a data packet
has been unloaded from the buffer by the CPU without the CPU writing a “1” to the CLR_OUT_BUF_RDY
bit.
• If the buffer has one more data packet in it, the buffer status flags transition from 112 to 102 .
AUTO_CLR is enable and continuous transfer mode enabled:
Single Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
from 002 to 112 after it has successfully received a data set equal to its buffer size or a short packet from
the host.
The USB FCU updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags from 112 to 002 automatically
when the data set has been unloaded from the buffer by the CPU without the CPU writing a “1” to the
CLR_OUT_BUF_RDY bit.
Double Buffer Mode:
The USB FCU updates the corresponding EPx OUT CSR’s OUT_BUF_STS1 & OUT_BUF_STS0 flags
after it has successfully received a data set equal to its buffer size or a short packet from the host.
• If the buffer has only one data set, the buffer status flags transition from 002 to 102 .
• If the buffer has two data sets, the buffer status flags transition from 102 to 112 .
The USB FCU updates the OUT_BUF_STS1 & OUT_BUF_STS0 flags automatically when a data set has
been unloaded from the buffer by the CPU without the CPU writing a “1” to the CLR_OUT_BUF_RDY bit.
• If the buffer has one more data set in it, the buffer status flags transition from 112 to 102.
• If the buffer has no more data set in it, the buffer status flags transition from 102 to 002.
Universal Serial Bus
79
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
OUT Endpoint FIFO Flush
A software flush causes the USB FCU to act as if a data set has been unloaded from the buffer. The user
must only set the flush bit when OUT_BUF_STS1 = 1, which indicates that one or two data sets have
been received. When there is one data set in the buffer, a flush causes the buffer to empty. When there
are two data sets in the buffer, a flush causes the older data set to be flushed out from the buffer. A flush
also updates the buffer status flags of the corresponding EPx OUT CSR.
The status of Endpoint 1-4 OUT buffers can be obtained from the two status bits of the EPx OUT CSR of
the corresponding endpoint as shown in Table 1.36.
OUT_BUF_STS1 OUT_BUF_STS0 Buffer Status
0 0 No data set in the OUT buffer
01
Single buffer mode: N/A
Double buffer mode: N/A
10
Single buffer mode: N/A
Double buffer mode: One data set in the OUT buffer
11
Single buffer mode: One data set in the OUT buffer
Double buffer mode: Two data sets in the OUT buffer
Table 1.36. Endpoints 1-4 OUT buffer status
Interrupt Endpoints
Any endpoint can be used for interrupt transfers. For normal interrupt transfers, the interrupt transactions
behave the same as bulk transactions, i.e., no special setting is required.
The IN endpoints may be used to communicate rate feedback information for certain types of isochronous
functions. Setting the INTPT bit in the IN CSR register of the corresponding IN CSR enables this function.
When the INTPT bit is set, the data toggle bit changes after each packet is sent regardless of the presence
or type of handshake that is returned from the host.
The operation sequence for an IN endpoint used to communicate rate feedback information is listed in the
following steps.
1. Set single buffer mode for the endpoint in use;
2. Set INTPT bit of the IN CSR;
3. Load interrupt status information and set SET_IN_BUF_RDY bit in the IN CSR;
4. Repeat step 3 for all subsequent interrupt status updates.
When an interrupt endpoint is used for rate feedback, the device always has data to send back to the host,
even if the data conveys that everything is ‘fine’. Therefore, the device never NAKs an IN token from the
host. The device always sends out the data in the FIFO in response to an IN token regardless of the IN
buffer status bits.
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
80
USB Special Function Registers
The MCU controls USB operation through the use of special function registers. Some USB-related special
function registers have a mix of read/write, read only, and write only register bits. Additionally, the bits may
be configured to allow the user to write only “0” or “1” to individual bits.
• When accessing these registers, writing “0” to a register that can only be set to “1” by the CPU has no
effect on that register bit.
• Writing “1” to a register that can only be set to “0” by the CPU has no effect on that register bit.
All USB SFRs, with the exceptions of Endpoint FIFO data registers, USBAD, and USBC can be accessed
by word or by byte at an even or odd address. Endpoint FIFO Data Registers can be accessed by either
word or by byte at even addresses only.
The contents of all USB Special Functions Registers, including USB Attach/Detach and USB Control, are
preserved after a software reset.
USB Attach/Detach Register
The USB Attach / Detach Register is shown in Figure 1.44. The register is used to attach and detach the
USB function from a USB host without physically disconnecting the USB cable. This functionality is enabled
by setting P90_SECOND to a “1”. Doing this forces P90 to operate as a pull-up for D+ (through an external
1.5k ohm resistor). The port driver is tri-stated and a “1” is always read from the port bit in this mode. When
the ATTACH/DETACH bit is a “1” (and P90_SECOND is a “1”), P90 is driven with the voltage on UVcc,
causing D+ to be pulled up and the host to detect an attach. When the ATTACH/DETACH bit is a “0” (and
P90_SECOND is a “1”), P90 is tri-stated, causing D+ to be pulled down (through the cable and 15k ohm
resistor on the host/hub side) and a detach to be registered by the host. A 1.5k ohm pull-up resistor must be
connected externally from P90 to D+ when this functionality is used. When it is not used, the 1.5k ohm
resistor should be placed between UVcc and D+.
See "Vbus Detect" for information on the vbus detect enable bit.
Figure 1.44. USB Attach/Detach register (USBAD)
USB Attach/Detach Register
Symbol Address When reset
USBAD 001F16 0016
Bit nameBit symbol
b7 b6 b5 b4 b3 b2 b1 b0
0 : Normal mode for Port 9
0
1 : Forces Port 90 to operate as pull up for D+.
P90-
second
Function
Reserved Must always be set to "0"
Port 90-Second
Attach/
Detach Attach/Detach 0 : Tri-states, P90causing the host to detect a detach
1 : Drives P90 with voltage on UVcc, causing the host
to detect an attach
WR
0
0
0
0
0
VBDT Vbus detect enable 0 : Disabled
1 : Enabled
Universal Serial Bus
81
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
USB Control Register
The USB Control Register, shown in Figure 1.45, is used to control the USB FCU. This register is not
reset by USB reset signaling. After the USB is enabled (USBC7 set to “1”), a minimum delay of 250ns
(three 12 MHz clock periods) is needed before performing any other USB register read/write operations.
• USBC5 (USB Clock Enable):
The USB clock enable bit is used to enable or disable the USB clock (fUSB). This clock is derived from
the Frequency Synthesizer and is required for USB operation.
• USBC6 (SOF port select):
The SOF port select bit enables or disables outputting a SOF signal on the P92/SOF pin. When this bit is
set to "1", an active low pulse is output each time a start of frame packet is detected on the USB. The
output pulse width is 166ns (two 12MHz USB clock cycles).
• USBC7 (USB Enable):
The USB enable bit is used to enable or disable the USB block. Make sure the USB clock is enabled
before setting this bit to "1".
Figure 1.45. USB Control register (USBC)
Figure 1.46. USB Function Address register (USBA)
USB Function Address Register
The USB Function Address Register, shown in Figure 1.46, maintains the 7-bit USB address assigned by
the host. The USB FCU uses this register value to decode USB token packet addresses. At reset, when the
device is not yet configured, the value is 0016. (For the procedures on how to update this register, refer to
Application Notes USB Consecutive Set Address)
Bit Symbol Bit Name Function R W
Reserved
USBC5
USBC6
USBC7
O O
O O
Symbol
USBC Address
000C16
When reset
0016
USB Control register
b7 b5b6 b4 b3 b2 b1 b0
Must always be set to "0"
0 : Disable
1 : Enable
0 : Disable (Note 1)
1 : Enable
0 : Disable (Note 2)
1 : Enable
O O
USB clock enable bit
USB SOF port select bit
USB enable bit
O O
Note 1: P92 is used as GPI/O pin.
Note 2: All USB internal registers are held at their default values.
0
0000
Bit Symbol Bit Name Function R W
Must always be "0" O O
Symbol
USBA
Address
0280
16
When reset
0000
16
USB Function Address register
b7
(b15) (b8)
b0
FUNAD6-0
b7 b0
00000000
Function address 7-bit programmable
function address O O
Reserved
0
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
82
Power Management Register
The USB Power Management Register, shown in Figure 1.47, is used for power management in the USB
FCU.
SUSPEND State Flag:
When the USB FCU does not detect any bus activity on D+/D- (in the J-state) for at least 3ms, it updates
the Suspend State Flag and generates an interrupt. This flag is cleared when active signaling from the
host is detected on D+/D- (The USB FCU generates a resume interrupt), or the CPU sets the Remote
Wake-up Bit while in suspend state and it is subsequently cleared by the CPU. If the USB clock was
disabled during the suspend state, the SUSPEND state flag is not cleared until after the USB clock is re-
enabled.
WAKEUP Control Bit:
The CPU writes a “1” to the WAKEUP Control Bit for remote wake-up. While this bit is set and the USB
FCU is in suspend mode, resume signaling is sent to the host. The CPU must keep this bit set for a
minimum of 1ms and a maximum of 15ms before writing a “0” to this bit.
USB Function Interrupt Status Register
USB Function Interrupt Status register, shown in Figure 1.48, is used to indicate the condition that caused a
USB function interrupt to the CPU. A “1” indicates the corresponding condition caused an interrupt.
INTST0, INITST2, INTST4 or INTST6 is set to “1” by the USB FCU when:
• The endpoint is enabled from a disabled state;
• A data set is successfully sent;
• A hardware autoflush takes place or the CPU writes “1” to INxCSR6 (FLUSH) if there are one or two
data sets in the buffer. This causes the EP1-4 IN buffer status flag to change states.
INTST1, INTST3, INTST5 or INTST7 is set to “1” by the USB FCU when:
• A data set is successfully received.
INTST8 is an Error Interrupt Status flag, which indicates that an error has been encountered at any end-
point. This flag is set to “1” by the USB FCU when:
• EP0CSR4 (FORCE_STALL) flag is set;
• EP0CSR5 (SETUP_END) flag is set;
• INxCSR2 (UNDER_RUN) flag is set on any EP1-4 IN endpoint;
Figure 1.47. USB Power Management register (USBPM)
Bit Symbol Bit Name Function R W
Must always be "0"
O O
Symbol
USBPM Address
0282
16
When reset
0000
16
USB Power Management register
b7
(b15) (b8) b0
SUSPEND
b7 b0
00000000
Suspend state flag 0 : Not in suspend state
1 : In suspend state O O
Reserved
0
WAKEUP Remote wakeup 0 : End remote wakeup signal
1 : Remote wakeup signaling if SUSPEND="1"
O O
00000
Note: Read onl
y
Note
Universal Serial Bus
83
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.48. USB Interrupt Status register (USBIS)
• OUTxCSR2 (OVER_RUN) flag is set on any EP1-4 OUT endpoint;
• OUTxCSR3 (FORCE_STALL) flag is set on any EP1-4OUT endpoint;
• OUTxCSR4 (DATA_ERR) flag is set on any EP1-4 OUT endpoint.
USB Function Interrupt Clear Register
The USB Function Interrupt Clear register, shown in Figure 1.49, is used by the CPU to clear the USB
Function Interrupt Status bits. The CPU writes a “1” to clear a corresponding USB Function Interrupt Status
flag.
Figure 1.49. USB Interrupt Clear register (USBIC)
Bit Symbol Bit Name Function R W
Must always be "0"
Symbol
USBIC Address
0286
16
When reset
0000
16
USB Interrupt Clear register
b7
(b15) (b8) b0
INTCL0
b7 b0
00000
0 : No action
1 : Clear interrupt status flag X O
0
X O
Note: Alwa
y
s read "0"
Note
INTCL1
INTCL2
INTCL3
INTCL4
INTCL5
INTCL6
INTCL7
INTCL8
Clear EP1 IN interrupt status flag
Clear EP1 OUT interrupt status flag
Clear EP2 IN interrupt status flag
Clear EP2 OUT interrupt status flag
Clear EP3 IN interrupt status flag
Clear EP3 OUT interrupt status flag
Clear EP4 IN interrupt status flag
Clear EP4 OUT interrupt status flag
Reserved
Clear error interrupt status flag
0
Bit Symbol Bit Name Function R W
Must always be "0"
Symbol
USBIS
Address
0284
16
When reset
0000
16
USB Interrupt Status register
b7
(b15) (b8)
b0
INTST0
b7 b0
00000
0 : No interrupt request
1 : Interrupt request issued
O X
0
O X
INTST1
INTST2
INTST3
INTST4
INTST5
INTST6
INTST7
INTST8
EP1 IN interrupt status flag
EP1 OUT interrupt status flag
EP2 IN interrupt status flag
EP2 OUT interrupt status flag
EP3 IN interrupt status flag
EP3 OUT interrupt status flag
EP4 IN interrupt status flag
EP4 OUT interrupt status flag
Reserved
Error interrupt status flag
0
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
84
USB Function Interrupt Enable Register
The USB Function Interrupt Enable register, shown in Figure 1.50 is used to enable the corresponding
interrupt status conditions that can generate a USB Function interrupt. When the bit of a corresponding
interrupt condition is “0”, it does not generate a USB function interrupt. When the bit is a “1”, it can generate
a USB Function interrupt.
Figure 1.51. USB Frame Number register (USBFN)
Figure 1.50. USB Interrupt Enable (USBIE)
USB Frame Number Register
The USB Frame Number Register, shown in Figure 1.51, contains the 11-bit frame number received from
the host.
Bit Symbol Bit Name Function R W
Must always be "0" O X
Symbol
USBFN Address
028A16
When reset
000016
USB Frame Number register
b7
(b15) (b8) b0
FN10-0
b7 b0
0000
11-bit frame number
issued with an SOF packet O X
Reserved
0
Frame number bit 0-10
Bit Symbol Bit Name Function R W
Must always be "0"
Symbol
USBIE Address
0288
16
When reset
01FF
16
USB Interrupt Enable register
b7
(b15) (b8) b0
INTEN0
b7 b0
00000
0 : Disabled
1 : Enabled O O
0
O O
INTEN1
INTEN2
INTEN3
INTEN4
INTEN5
INTEN6
INTEN7
INTEN8
EP1 IN interrupt enable bit
EP1 OUT interrupt enable bit
EP2 IN interrupt enable bit
EP2 OUT interrupt enable bit
EP3 IN interrupt enable bit
EP3 OUT interrupt enable bit
EP4 IN interrupt enable bit
EP4 OUT interrupt enable bit
Reserved
Error interrupt enable bit
0
Universal Serial Bus
85
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
USB ISO Control Register
The USB ISO Control Register, shown in Figure 1.52, contains the isochronous data transfer control and
status information.
• ISO_UPD
The ISO_UPD bit is a global bit for endpoints 1-4 and works with IN isochronous pipes only.
When ISO_UPD = “0”, a data packet in an endpoint’s IN buffer is always 'ready to transmit' when it
receives the next IN token from the host (with matched address and endpoint number), if the CPU writes
“1” to the corresponding endpoint’s SET_IN_BUF_RDY bit, or in AUTO_SET case, a data packet equal
to EPx’s MAXP value has been written to the FIFO.
When ISO_UPD = “1” and the ISO bit of the corresponding endpoint’s IN CSR is set, the internal ‘ready
to transmit’ signal to the transmit control logic is not activated when the CPU writes "1" to the correspond-
ing endpoint's SET_IN_BUF_RDY bit, or in the AUTO_SET case, a data packet equal to EPx’s MAXP
value has been written to the FIFO. Instead it is activated when the next SOF is received, thus the data
loaded in frame n is transmitted out in frame n+1.
• AUTO_FL
When AUTO_FL = “1”, ISO_UPD = “1”, IN endpoint’s ISO bit is set, and the IN endpoint’s IN_BUF_STS1
& IN_BUF_STS0 are “1”s at the time the USB FCU detects a SOF (from the host or from artificial SOF), it
automatically flushes the oldest packet from the IN buffer. In this case, IN_BUF_STS1 & IN_BUF_STS0
are “1”s and indicate that two data packets are in the IN buffer. Double buffering is required for ISO
transfer.
• ART_SOF_ENA
An artificial SOF function enable bit.
• ART_SOF_SET
Artificial SOF function status flag. When this flag is “1”, it indicates that an artificial SOF will be generated
by the device because of a missing or corrupt SOF packet (when the SOF enable bit is set to "1"). A
corrupt SOF packet is any SOF having an error in its 8-bit Pakcet ID (PID) field.
• CLR_ART_SOF
The CPU writes “1” to this bit to clear the ART_SOF_SET flag.
Figure 1.52. USB ISO Control register (USBISOC)
Bit Symbol Bit Name Function R W
O O
Symbol
USBISOC Address
028C
16
When reset
0000
16
USB ISO Control register
b7
(b15) (b8) b0b7 b0
00000000
0 : Hardware auto flush disabled
1 : Hardware auto flush enabled
0 : ISO update disabled
1 : ISO update enabled
0 : Artificial SOF disabled
1 : Artificial SOF enabled
0 : Not generated by device (Note 1)
1 : Generated by the device
0 : No action (Note 2)
1 : Clear ART_SOF_SET flag
Must always be set to "0"
O O
AUTO_FL
ISO_UPD
ART_SOF_ENA
ART_SOF_SET
CLR_ART_SOF
Reserved
0
O O
00
Auto flush
ISO Update
Artificial SOF enable
Artificial SOF set flag
Clear artificial SOF set flag
O O
O X
O O
Note 1: Read only
Note 2: Alwa
y
s read "0"
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
86
USB DMAx Request Register (x = 0 to 3)
The USB DMAx Request Register, shown in Figure 1.54, selects which USB EPx FIFO read/write requests
are used as the DMAC channels 0 to 3 request source. Each USB DMAx Request Registers should have
only one bit set at any given time. When multiple bits are set, no request is selected.
Bit Symbol Bit Name Function R W
Must always be "0"
Symbol
USBDMAx
(x=0 to 3) Address
0290
16
, 0292
16
,
0294
16
, 0296
16
When reset
0000
16
USB DMAx Request registers
b7
(b15) (b8) b0
DMAxRO
DMAxR1
DMAxR2
DMAxR3
DMAxR4
DMAxR5
DMAxR6
DMAxR7
DMAxR8
DMAxR9
b7 b0
0000
EP0 IN FIFO write request select bit
EP1 IN FIFO write request select bit
EP2 IN FIFO write request select bit
EP3 IN FIFO write request select bit
EP4 IN FIFO write request select bit
EP0 OUT FIFO read request select bit
EP1 OUT FIFO read request select bit
EP2 OUT FIFO read request select bit
EP3 OUT FIFO read request select bit
EP4 OUT FIFO read request select bit
O O
Reserved
0
O O
0 : Not selected
1 : Selected
0
Bit Symbol Bit Name Function R W
Must always be "0"
Symbol
USBEPEN Address
028E16
When reset
000016
USB Endpoint Enable register
b7
(b15) (b8) b0
EP1_OUT
b7 b0
00000
EP1 OUT enable 0 : Disabled
1 : Enabled O O
0
O O
EP1_IN
EP2_OUT
EP2_IN
EP3_OUT
EP3_IN
EP4_OUT
EP4_IN
EP1 IN enable
EP2 OUT enable
EP2 IN enable
EP3 OUT enable
EP3 IN enable
EP4 OUT enable
EP4 IN enable
Reserved
00
USB Endpoint Enable Register
The USB Endpoint Enable Register, shown in Figure 1.53, is used to enable/disable an individual
endpoint. EP0 is always enabled and cannot be disabled by firmware. All endpoints are disabled after
reset.
Figure 1.53. USB Endpoint Enable register (USBEPEN)
Figure 1.54. USB DMAx Request register (x=0 to 3)
Universal Serial Bus
87
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
USB Endpoint 0 CSR
The Endpoint 0 CSR (Control & Status register), shown in Figure 1.55, contains the control and status
information for EP0.
• EP0CSR0 (OUT_BUF_RDY):
A status flag, “1” indicates a SETUP packet or an OUT data set is in the OUT buffer, ready for the CPU to
unload.
During the data phase, if noncontinuous mode is set, the OUT_BUF_RDY bit is "1" when:
A data packet is received from the host
During the data phase, if continuous mode is set, the OUT_BUF_RDY bit is "1" when:
A data set equal to 128 bytes is received from the host
A short packet is received from the host
A control write status phase has started with pending OUT data packets in the buffer.
• EP0CSR1 (IN_BUF_RDY):
A status flag, “1” indicates a data set is in the IN buffer, ready for transmission. The USB FCU clears this
bit after the data set is successfully transmitted to the host, or the EP0CSR5 (SETUP_END) bit is set.
• EP0CSR2 (SETUP):
A status flag, “1” indicates a SETUP packet has been received. The SETUP Flag is a subset of the
OUT_BUF_RDY flag.
• EP0CSR3 (DATA_END):
A status flag, “1” indicates the CPU sets the DATA_END bit. The USB FCU clears this flag after the
status phase has started or a new SETUP is received. This flag is a maskable flag. If DATA_END Flag
Mask is a “1” (default), this DATA_END flag is always a “0” and no EP0 interrupt is caused by the
DATA_END flag being cleared.
• EP0CSR4 (FORCE_STALL):
A status flag, “1” indicates a protocol error when one of the following occurs:
Host sends an IN token in the absence of a SETUP stage
Host sends a bad data toggle in the STATUS stage, (i.e. DATA0 is used)
Host sends a bad data toggle in the SETUP stage, (i.e. DATA1 is used)
Host requests more data than specified in the SETUP state, (i.e. IN token comes after DATA_END bit
is set)
Host sends more data than specified in the SETUP state, (i.e. OUT token comes after DATA_END bit
is set)
Host sends a larger data packet than the MAXP size
All of the conditions stated (except bad data toggle in the SETUP stage) cause the device to send a
STALL handshake for the current IN/OUT transaction. For the bad data toggle in the SETUP stage, the
device sends ACK for the SETUP stage and then sends STALL for the next IN/OUT transaction. A
STALL handshake caused by the above conditions lasts for one transaction and terminates the ongoing
control transfer. Any packet after the STALL handshake will be seen as the beginning of a new control
transfer.
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
88
• EP0CSR5 (SETUP_END):
A status flag, “1” indicates a premature completion of a control transfer when one of the following
events occurs:
A control transfer ends before the specific length of data is transferred during the data phase (status
phase starts before DATA_END bit is set)
A new SETUP is received before successfully completing the status phase of the previous control
transfer.
• EP0CSR6 (CLR_OUT_BUF_RDY):
The CPU writes a “1” to this bit after unloading a data set from the buffer. Writing a “1” to this bit clears
the OUT_BUF_RDY status flag.
• EP0CSR7 (SET_IN_BUF_RDY):
The CPU writes a “1” to this bit after loading a data set to the buffer. Writing a “1” to this bit sets the
IN_BUF_RDY status flag.
• EP0CSR8 (CLR_SETUP):
The CPU writes a “1” to this bit to clear the SETUP status flag.
• EP0CSR9 (SET_DATA_END):
The CPU writes a “1” to this bit when it writes (IN data phase) the last data packet to the buffer or reads
(OUT data phase) the last data packet from the buffer. The CPU sets this bit at the same time (using the
same instruction) as it sets the CLR_OUT_BUF_RDY bit or sets the SET_IN_BUF_RDY bit for the last
data set. Writing a “1” to this bit sets the DATA_END status flag.
• EP0CSR10 (CLR_FORCE_STALL):
The CPU writes a “1” to this bit to clear the FORCE_STALL status flag.
• EP0CSR11 (CLR_SETUP_END):
The CPU writes a “1” to this bit to clear the SETUP_END status flag.
• EP0CSR12 (SEND_STALL):
The CPU writes a “1” to this bit when it decodes an invalid or unsupported request from the host. The
CPU should only write a “1” to this bit at the same time it writes a “1” to EP0CSR6
(CLR_OUT_BUF_RDY). When this bit is a “1”, the USB FCU returns STALL handshakes for all subse-
quent IN/OUT transactions. The CPU writes a “0” to clear it after it receives a new SETUP packet. It is up
to the firmware to decide what SETUP packet should lead the clearing of the SEND_STALL bit.
• EP0CSR13 (DATA_END_MASK):
This bit is for the CPU to mask or unmask the clearing of DATA_END as an EP0 interrupt source –
default is masked (clearing of DATA_END does not cause an EP0 interrupt).
Universal Serial Bus
89
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.55. USB Endpoint 0 Control and Status register (EP0CS)
USB Endpoint 0 MAXP Register
The USB Endpoint 0 MAXP Register, shown in Figure 1.56, indicates the maximum packet size (MAXP) of
an EP0 IN/OUT packet. The default value for EP0 MAXP is 8 bytes. It also contains the enable bits for
Control write continuous transfer and control read continuous transfer.
Bit Symbol Bit Name Function R W
Must always be "0"
Symbol
EP0CS Address
0298
16
When reset
2000
16
USB Endpoint 0 Control and Status register
b7
(b15) (b8) b0
EP0CSR0
EP0CSR1
EP0CSR2
EP0CSR3
EP0CSR4
EP0CSR5
EP0CSR6
EP0CSR7
EP0CSR8
EP0CSR9
EP0CSR10
EP0CSR11
EP0CSR12
EP0CSR13
b7 b0
OUT_BUF_RDY flag
IN_BUF_RDY flag
SETUP flag
DATA_END flag
FORCE_STALL flag
SETUP_END flag
CLR_OUT_BUF_RDY
SET_IN_BUF_RDY
CLR_SETUP
SET_DATA_END
CLR_FORCE_STALL
CLR_SETUP_END
SEND_STALL
DATA_END_MASK
O X
Reserved
0
O O
0 : No setup packet or data set ready for unload
1 : Setup packet or data set ready for unload
O X
O X
O X
O X
O X
O O
O O
O O
O O
O O
O O
O O
O O
0 : No data set ready for transmit
1 : Data set ready for transmit
0 : No setup packet ready for unload
1 : Data set ready for transmit
0 : DATA_END not set by CPU or DATA-END is set by CPU
then status phase starts
1 : DATA-END set by CPU
0 : No protocol violation detected
1 : Protocol violation detected
0 : No premature completion of control transfer
1 : Premature completion of control transfer
0 : No action
1 : Data set unloaded from the OUT buffer
0 : No action
1 : Data set loaded in IN buffer (sets IN_BUF_RDY flag)
0 : No action
1 : Clears SETUP flag
0 : No action
1 : Last data pcket transferred to/from buffer
0 : No action
1 : Clears FORCE_STALL flag
0 : No action
1 : Clears SETUP_END flag
0 : No EP0 STALL by CPU
1 : EP0 STALL by CPU
0 : Clearing DATA_END event causing EP0 interrupt is
unmasked
1 : Clearing DATA_END event causing EP0 interrupt is
masked
Note
Note
Note
Note
Note
Note
Note: Alwa
y
s read a "0"
0
Figure 1.56. USB Endpoint 0 MAXP register (EP0MP)
Bit Symbol Bit Name Function R W
Must always be "0"
O O
Symbol
EP0MP Address
029A
16
When reset
0008
16
USB Endpoint 0 MAXP register
b7
(b15) (b8) b0
EP0MP6-0
b7 b0
000000
Maximum packet size O O
0
WRT_CONT
RD_CONT
Reserved
Control Write continuous transfer mode
Control Read continuous transfer mode
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
O O
O O
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
90
USB Endpoint 0 WRT CNT Register
The USB Endpoint 0 WRT CNT Register, shown in Figure 1.57, contains the number of bytes of the
current data set in the OUT buffer. The USB FCU sets the value in the WRT_CNT Register after having
successfully received a data set from the host. The CPU reads the register to determine the number of
bytes to be read from the buffer. The WRT_CNT value does not decrement upon a CPU read from the
FIFO Data Register. The WRT_CNT value is cleared when the CPU writes a "1" to the
CLR_OUT_BUF_RDY bit of the EP0 CSR.
Figure 1.57. USB Endpoint 0 write count register (EP0WC)
USB Endpoint x IN CSR (x = 1 to 4)
The USB Endpoint x IN control status register, shown in Figure 1.58, contains control and status informa-
tion of the respective IN EP 1-4.
• INxCSR0 (IN_BUF_STS0) and INxCSR1 (IN_BUF_STS1):
Two status flags, indicate the current status of the IN buffer. These two flags are “1”s after reset, and
become “0”s when the respective endpoint is enabled from a disabled state. The buffer status flags get
updated when one of the following events occurs:
1. The USB FCU successfully sends out a data set to the host.
2. The CPU loads a data set to the buffer (writes a “1” to SET_IN_BUF_RDY).
3. The CPU writes a “1” to the FLUSH bit or a hardware auto flush takes place.
• INxCSR2 (UNDER_RUN):
A status flag, “1” indicates an under run has occurred in an isochronous data transfer. The USB FCU
updates this flag to a “1” at the beginning of an IN token if no data packet is in the buffer.
• INxCSR3 (SET_IN_BUF_RDY):
The CPU writes a “1” to this bit after loading a data set to the buffer. The CPU can only load data to the
buffer and set this bit when INxCSR1 (IN_BUF_STS1) is a “0”.
• INxCSR4 (CLR_UNDER_RUN):
The CPU writes a “1” to this bit to clear the UNDER_RUN status flag.
• INxCSR5 (TOGGLE_INIT):
The CPU writes a “1” to this bit to initialize the data sequence, force the next packet’s data PID to a
DATA0 for transmission. Setting the TOGGLE_INT bit also resets the FIFO read/write pointers.
Bit Symbol Bit Name Function R W
Must always be "0" O O
Symbol
EP0WC Address
029C
16
When reset
0000
16
USB Endpoint 0 Write Count register
b7
(b15) (b8) b0
EP0WC7-0
b7 b0
0000000
Receive byte count O X
Reserved
0
Universal Serial Bus
91
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
• INxCSR6 (FLUSH):
The CPU writes a “1” to this bit to flush the IN buffer.
When there is one data set in the IN buffer, a flush causes the IN buffer to be empty.
When there are two data sets in the IN buffer, a flush causes the older data set to be flushed out from
the IN buffer.
The USB FCU updates the buffer status bits the same way as a data set is transmitted to the host when it
sees a FLUSH. Setting the FLUSH bit during transmission could produce unpredictable results.
• INxCSR7 (INTPT):
The CPU writes a “1” to this bit to initialize the endpoint as a rate feedback interrupt endpoint.
• INxCSR8 (ISO):
The CPU writes a “1” to this bit to set the endpoint as an isochronous data transfer endpoint.
• INxCSR9 (SEND_STALL):
The CPU writes a “1” to this bit when the endpoint is stalled (transmitter halt). The USB FCU returns
STALL handshakes while this bit is set. The CPU writes a “0” to clear this bit, If the STALL condition no
longer exists.
• INxCSR10 (AUTO_SET):
The CPU writes a “1” to this bit to enable the AUTO_SET function. AUTO_SET takes place only when a
data packet that is equal to MAXP (or data set that is equal to BUF_SIZ, in continuous mode) is loaded to
the buffer. See “IN (Transmit) FIFO” operation for details.
Figure 1.58. USB Endpoint x IN Control & Status register (EPxICS)
Bit Symbol Bit Name Function R W
Symbol
EPxICS (x = 1 - 4)
Address
029E
16
, 02A4
16
,
02AA
16
, 02B0
16
When reset
0003
16
USB Endpoint x IN Control and Status register
b7
(b15) (b8) b0
INxCSR0
INxCSR1
INxCSR2
INxCSR3
INxCSR4
INxCSR5
INxCSR6
INxCSR7
INxCSR8
INxCSR9
INxCSR10
Reserved
b7 b0
IN_BUF_STS0 flag
IN_BUF_STS1 flag
UNDER-RUN flag
SET_IN_BUF_RDY
CLR_UNDER_RUN
TOGGLE_INT
FLUSH
INTPT
ISO
SEND_STALL
AUTO_SET
O X
0
O O
O X
O O
O O
O O
O O
O O
O O
O O
O O
These two bits indicate the EPx IN buffer status
Bit1 Bit0
0 0 : No data set in the IN buffer
0 1 : Single buffer mode: N/A
Double buffer mode: one data set in the IN buffer
1 0 : Single buffer mode: N/A
Double buffer mode: N/A
1 1 : Single buffer mode: one data set in the IN buffer
Double buffer mode: two data sets in the IN buffer
0 : No underrun detected
1 : Underrun detected
0 : No action
1 : Data set loaded to the IN buffer (updates IN buffer status flags)
0 : No action
1 : Clears UNDER_RUN flag
0 : No action
1 : Initialize the next data PID as a DATA0 for transmission
0 : No action
1 : Flush out one data set
0 : Select non-rate feedback interrupt transfer
1 : Select rate feedback interrupt transfer
0 : Select non-isochronous endpoint
1 : Select isochronous endpoint
0 : No STALL by CPU
1 : STALL by CPU
0 : AUTO_SET disabled
1 : AUTO_SET enabled
Must always be set to "0"
Note
Note
Note
Note
Note: Alwa
y
s read a "0"
0000
O X
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
92
Figure 1.60. USB Endpoint x IN FIFO Configuration register (EPxIFC)
Bit Symbol Bit Name Function R W
O O
Symbol
EPxIFC (x = 1 - 4) Address
02A216, 02A816,
02AE16, 02B416
When reset
000016
USB Endpoint x IN FIFO Configuration register
b7
(b15) (b8) b0
BUF_NUM
BUF_SIZ
DBL_BUF
CONTINUE
Reserved
b7 b0
000
FIFO buffer
start number
FIFO buffer size
Double buffer mode
Continuous transfer
mode
O O
0
Select the starting number for the EPx IN FIFO
(in units of 64 bytes)
000000 : buffer starting location = 0
000001 : buffer starting location = 64
000010 : buffer starting location = 128
......
101111 : buffer starting location = 3008 (last starting number)
Select the buffer size for the EPx IN FIFO
(in units of 64 bytes)
0000 : buffer size = 64
0001 : buffer size = 128
0010 : buffer size = 192
......
1111 : buffer size = 1024 (largest buffer size)
0 : Disabled
1 : Enabled
0 : Disabled (Note)
1 : Enabled
Must always be set to "0"
O O
O O
O O
Note: Valid for bulk transfer t
yp
e onl
y
USB Endpoint x IN MAXP Register (x = 1 to 4)
The USB Endpoint x IN MAXP Register, shown in Figure 1.59, indicates the maximum packet size (MAXP)
of EPx IN packet. The default values for all EPx IN MAXP are 0 bytes.
Figure 1.59. USB Endpoint x IN MAXP register (EPxIMP)
USB Endpoint x IN FIFO configuration Register (x = 1 to 4)
The USB Endpoint x IN FIFO Configuration Register, shown in Figure 1.60, is used to select various FIFO
configurations. When the double buffer bit is set, the effective buffer size = 2 x BUF_SIZ. Therefore other
EP FIFO buffer’s starting locations have to be 2 x BUF_SIZ apart.
The user should ensure:
• Buffer Starting Location + Buffer Size do not exceed the 3K byte boundary.
• Endpoint buffers do not overlap with each other.
Bit Symbol Bit Name Function R W
Must always be "0" O O
Symbol
EPxIMP ( x = 1 - 4) Address
02A0
16
, 02A6
16
,
02AC
16
, 02B2
16
When reset
0000
16
USB Endpoint x IN MAXP register
b7
(b15) (b8) b0
IMAXP9-0
b7 b0
00000
Maximum packet size O O
Reserved
0
Universal Serial Bus
93
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
USB Endpoint x OUT CSR (x = 1 to 4)
The USB Endpoint x OUT CSR (Control and Status Register), shown in Figure 1.61, contains control and
status information for the respective OUT EP 1-4.
• OUTxCSR0 (OUT_BUF_STS0) and OUTxCSR1 (OUT_BUF_STS1):
Two status flags, indicate the current status of the OUT buffer. The buffer status flags are updated when
one of the following events occurs:
1. The USB FCU successfully receives a data set from the host.
2. The CPU unloads a data set from the buffer (writes a “1” to CLR_OUT_BUF_RDY).
3. The CPU writes a “1” to the FLUSH bit.
• OUTxCSR2 (OVER_RUN):
A status flag, “1” indicates an over run has occurred in an isochronous data transfer. The USB FCU
updates this flag to a “1” at the beginning of an OUT token when two data packets are already present in
the buffer.
• OUTxCSR3 (FORCE_STALL):
A status flag, “1” indicates that the USB FCU detected a Packet size larger than MAXP violation. The
USB FCU returns a STALL as a handshake packet for the current transaction.
• OUTxCSR4 (DATA_ERR):
A status flag, “1” indicates a data error (bit stuffing or CRC error) has occurred in an OUT isochronous
data packet.
• OUTxCSR5 (CLR_OUT_BUF_RDY):
The CPU writes a “1” to this bit after unloading a data set from the buffer. The CPU can only unload data
from the buffer and set this bit when OUTxCSR1 (OUT_BUF_STS1) is a “1”.
• OUTxCSR6 (CLR_OVER_RUN):
The CPU writes a “1” to this bit to clear the OVER_RUN status flag.
• OUTxCSR7 (CLR_FORCE_STALL):
The CPU writes a “1” to this bit to clear the FORCE_STALL status flag.
• OUTxCSR8 (CLR_DATA_ERR):
The CPU writes a “1” to this bit to clear the DATA_ERR status flag.
• OUTxCSR9 (TOGGLE_INIT):
The CPU writes a “1” to this bit to initialize the data sequence, and force the next packet’s data PID to a
DATA0 for reception.
• OUTxCSR10 (FLUSH):
The CPU writes a “1” to this bit to flush the OUT buffer. This bit must only be set to a “1” when the
OUT_BUF_STS1 flag is a “1”.
When there is one data set in the OUT buffer, a flush causes the OUT buffer to be empty.
When there are two data sets in the OUT buffer, a flush causes the older packet to be flushed from the
OUT buffer.
The USB FCU updates the buffer status flags the same way as a data set is unloaded from the host
when it sees a FLUSH. Setting the FLUSH bit during reception could produce unpredictable results.
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
94
Figure 1.61. USB Endpoint x OUT Control and Status register (EPxOCS)
Bit Symbol Bit Name Function R W
Symbol
EPxOCS (x = 1 - 4)
Address
02B6
16
, 02BE
16
,
02C6
16
, 02CE
16
When reset
0000
16
USB Endpoint x OUT Control and Status register
b7
(b15) (b8) b0
OUTxCSR0
OUTxCSR1
OUTxCSR2
OUTxCSR3
OUTxCSR4
OUTxCSR5
OUTxCSR6
OUTxCSR7
OUTxCSR8
OUTxCSR9
OUTxCSR10
OUTxCSR11
OUTxCSR12
OUTxCSR13
Reserved
b7 b0
OUT_BUF_STS0 flag
OUT_BUF_STS1 flag
OVER-RUN flag
FORCE_STALL flag
DATA_ERR flag
CLR_OUT_BUF_RDY
CLR_OVER_RUN
CLR_FORCE_STALL
CLR_DATA_ERR
TOGGLE_INIT
FLUSH
ISO
SEND_STALL
AUTO_CLR
O X
0
O O
O X
O X
O X
O O
O O
O O
O O
O O
These two bits indicate the EPx OUT buffer status:
Bit1 Bit0
0 0 : No data set in the OUT buffer
0 1 : Single buffer mode: N/A
Double buffer mode: N/A
1 0 : Single buffer mode: N/A
Double buffer mode: one data set in the OUT buffer
1 1 : Single buffer mode: one data set in the OUT buffer
Double buffer mode: two data sets in the OUT buffer
0 : No over run detected
1 : Over run detected
0 : No packet size larger than MAXP violation detected
1 : Packet size larger than MAXP violation detected
0 : No data error detected
1 : Data error detected
0 : No action
1 : Data set unloaded from the OUT buffer (updates status flags)
0 : No action
1 : Clears OVER_RUN flag
0 : No action
1 : Clears FORCE_STALL flag
0 : No action
1 : Clears DATA_ERR flag
0 : No action
1 : Initialize the next data PID as a DATA0 for reception
0 : No action
1 : Flush out one data set
0 : Select non-isochronous endpoint
1 : Select isochronous endpoint
0 : No STALL by CPU
1 : STALL by CPU
0 : AUTO_CLR disabled
1 : AUTO_CLR enabled
Must always be set to "0"
Note
Note
Note: Always read a "0" when writing to this bit
0
O X
O O
Note
O O
Note
O O
Note
O O
Note
• OUTxCSR11 (ISO):
The CPU writes “1” to this bit to set the endpoint as an isochronous data transfer endpoint.
• OUTxCSR12 (SEND_STALL):
The CPU writes “1” to this bit when the endpoint is stalled (receiver halt). The USB FCU returns STALL
handshakes while this bit is set. The CPU writes “0” to clear this bit, if the STALL condition no longer
exists.
• OUTxCSR13 (AUTO_CLR):
The CPU writes “1” to this bit to enable the AUTO_CLR function. AUTO_CLR takes place when a data
packet (or a data set, in continuous mode) is unloaded from the buffer, even if the data packet is less
than MAXP (or data set is less than BUF_SIZ, in continuous mode). See “OUT (Receive) FIFO” operation
for details.
Universal Serial Bus
95
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
USB Endpoint x OUT MAXP Register (x = 1 to 4)
The USB Endpoint x OUT MAXP register, shown in Figure 1.62, indicates the maximum packet size (MAXP)
of EPx OUT packet. The default values for all EPx OUT MAXP are 0 bytes.
Bit Symbol Bit Name Function R W
Must always be "0" O O
Symbol
EPxOMP (x = 1 - 4) Address
02B8
16
, 02C0
16
,
02C8
16
, 02D0
16
When reset
0000
16
USB Endpoint x OUT MAXP register
b7
(b15) (b8) b0
OMAXP9-0
b7 b0
00000
Maximum packet size O O
Reserved
0
Figure 1.62. USB Endpoint x OUT MAXP register (EPxOMP)
USB Endpoint x OUT WRT CNT Register (x = 1 to 4)
The USB Endpoint x OUT WRT CNT Register, shown in Figure 1.63, contains the number of bytes of the
current data set in the OUT buffer. The USB FCU sets the value in the WRT_CNT Register after having
successfully received a data set from the host. The CPU reads the register to determine the number of
bytes to be read from the buffer. The WRT_CNT value does not decrement upon a CPU read of the FIFO
Data Register. The WRT_CNT value is cleared (in double buffer mode, the WRT_CNT value corresponding
to the dataset being unloaded is cleared) when the CPU writes "1" to the CLR_OUT_BUF_RDY bit of the
OUT CSR or in AUTO_CLR mode, when the data set is unloaded from the buffer.
Figure 1.63. USB Endpoint x OUT WRT CNT register (EPxWC)
Bit Symbol Bit Name Function R W
Must always be "0" O O
Symbol
EPxWC (x = 1 - 4) Address
02BA
16
, 02C2
16
,
02CA
16
, 02D2
16
When reset
0000
16
USB Endpoint x OUT WRT CNT register
b7
(b15) (b8) b0
WCNT10-0
b7 b0
0000
Receive byte count O X
Reserved
0
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
96
Bit Symbol Bit Name Function R W
Symbol
EPxI (x = 0 - 4) Address
02E016, 02E416,
02E816, 02EC16, 02F016
When reset
N/A
USB Endpoint x IN FIFO Data register
b7
(b15) (b8) b0
DATA_15-0
b7 b0
EP0 IN FIFO Data X O
Note 1: Data is undefined if this register is read.
Note 2: Write only to this register with a Word command or a Byte command to the lower 8 bits.
Do not write a b
y
te of data to the u
pp
er 8 bits.
(
b8 - b15
)
USB Endpoint x OUT FIFO configuration Register (x = 1 to 4)
The USB Endpoint x OUT FIFO Configuration Register, shown in Figure 1.64, is used to select various
FIFO configurations. When double buffer bit is set, the effective buffer size = 2 x BUF_SIZ. Therefore other
EP FIFO buffer’s starting locations have to be 2 x BUF_SIZ apart.
The user should ensure:
Buffer Starting Location + Buffer Size do not exceed the 3K byte boundary.
Endpoint buffers do not overlap with each other.
Figure 1.64. USB Endpoint x OUT FIFO register (EPxOFC)
USB Endpoint x IN FIFO Data Registers (x = 0 to 4)
The USB Endpoint x IN FIFO Data Registers, shown in Figure 1.65 are the USB IN (transmit) FIFO data
registers. The CPU writes data to these registers for the respective Endpoint IN FIFO.
Bit Symbol Bit Name Function R W
O O
Symbol
EPxOFC (x = 1 - 4) Address
02BC
16
, 02C4
16
,
02CC
16
, 02D4
16
When reset
0000
16
USB Endpoint x OUT FIFO Configuration register
b7
(b15) (b8) b0
BUF_NUM
BUF_SIZ
DBL_BUF
CONTINUE
Reserved
b7 b0
000
FIFO buffer
start number
FIFO buffer size
Double buffer mode
Continuous transfer
mode
O O
0
Select the starting number for the EPx OUT FIFO
(in units of 64 bytes)
000000 : buffer starting location = 0
000001 : buffer starting location = 64
000010 : buffer starting location = 128
......
101111 : buffer starting location = 3008 (last starting number)
Select the buffer size for the EPx OUT FIFO
(in units of 64 bytes)
0000 : buffer size = 64
0001 : buffer size = 128
0010 : buffer size = 192
......
1111 : buffer size = 1024 (largest buffer size)
0 : Disabled
1 : Enabled
0 : Disabled (Note)
1 : Enabled
Must always be set to "0"
O O
O O
O O
Note: Valid for bulk transfer type only
Figure 1.65. USB Endpoint x IN FIFO Data register (EPxI)
Vbus Detect
97
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
USB Endpoint x OUT FIFO Data Register (x = 0 to 4)
The USB Endpoint x OUT FIFO Data Registers, shown in Figure 1.66 are the USB OUT (receive) FIFO data
registers. The CPU reads data from these registers for the respective Endpoint OUT FIFO.
Figure 1.66. USB Endpoint x OUT FIFO Data register (EPxO)
Bit Symbol Bit Name Function R W
Symbol
EPxO (x = 0 - 4) Address
02E2
16
, 02E6
16
,
02EA
16
, 02EE
16,
02F2
16
When reset
N/A
USB Endpoint x OUT FIFO Data register
b7
(b15) (b8) b0
DATA_15-0
b7 b0
EP0 OUT FIFO Data O X
Note 1: Writing to this register might cause a system error.
Note 2: Read only from this register with a Word command or a Byte command to the lower 8
bits. Do not read a b
y
te of data from the u
pp
er 8 bits.
(
b8 - b15
)
Universal Serial Bus
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
98
VbusDTCT
D+
D-
Vss
Vbus
D+
D-
GND
Vcc
UVcc
Vcc
M30245
To USB circuitry
Note: Not all necessary components are sh
o
Vbus Detect
The Vbus Detect function will detect when the USB host is powered-up during USB self-powered opera-
tion. Self-powered operation means the microcontroller has a power source external to the USB. This type
of connection requires the need to monitor when the USB host powers-up or powers-down. The other
power mode, called Bus-powered mode, means the microcontroller is powered directly from the USB Vbus
connection. This type of connection does not require the Vbus detect function because the microcontroller
is actually powered from the USB so you know the USB host is already powered-up.
The VbusDTCT pin is used for the Vbus detect function. When operating the USB in self-powered mode,
connect the Vbus line from the USB connector to the VbusDTCT pin. The Vbus detect function can be
enabled or disabled in the USB attach/detach register (bit 7 at address 001F16). Each time the USB host
powers up or powers down, a Vbus detect interrupt will be generated. This interrupt can be enabled or
disable using the Vbus detect interrupt control register (address 005C16). When a Vbus detect interrupt is
received, the Vbus detect state bit located in the Port 9 data register (bit 1 at address 03F116) should be
read to determine if the Vbus is powered up or not.
Figure 1.67 is an example of the USB self-powered mode connection. Figure 1.68 shows the Vbus-related
registers.
Figure 1.67. USB self-powered mode connection example
Figure 1.68. Vbus-related memory map
Address
Register name
Acronym
001F16 USB Attach/Detach register USBAD
005F16 Vbus detect interrupt control register VBDIC
03F116 Port P9 P9
~
~
~
~
~
~
~
~
Vbus Detect
99
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
To avoid receiving a false Vbus detect interrupt at start-up, the Vbus detect should be enabled before
enabling the Vbus detect interrupt. Use the following procedure when enabling the Vbus detect function:
1) Enable Vbus detect by setting the Vbus detect enable bit to "1" (bit 7 at address 001F16).
2) Clear the Vbus detect interrupt by setting the Vbus detect interrupt request bit to "0" (bit 3 at address
005C16).
3) Enable the Vbus detect interrupt by setting the Vbus detect interrupt priority level greater than "000"
(bits 2-0 at address 005C16)
Figure 1.69 shows the Vbus detect interrupt timing
Figure 1.69. Vbus detect interrupt timing
VbusDTCT
Vbus detect
enable bit
Vbus detect
interrupt request bit
Cleared when interrupt request is accepted or cleared by software
5V
0V
"1"
"0"
"1"
"0"
4V
1V
Note 1: Maximum time from Vbus detection to when interrupt request bit is set is 1mS.
Note 2: VbusDTCT guaranteed maximum pulse width rejected is 1uS.
Note 3. VbusDTCT guaranteed minimum pulse width accepted is 50uS.
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
100
Direct memory access controller
This microcomputer has four DMAC (direct memory access controller) channels that allow data to be sent to
memory without using the CPU. DMAC shares the same data bus with the CPU. The DMAC is given a higher right
of using the bus than the CPU, which leads to working the cycle stealing method. On this account, the operation
from the occurrence of a DMA transfer request signal to the completion of 1-word (16-bit) or 1-byte (8-bit) data
transfer can be performed at high speed. Figure 1.70 shows the DMAC block diagram. Table 1.37 shows the
DMAC specifications. Figure 1.71 to Figure 1.73 show the registers used by the DMAC.
Either a write signal to the software DMA request bit or an interrupt request signal can be used as the DMA
transfer request signal. But the DMA transfer is not affected by either the interrupt enable flag (I flag) or by the
interrupt priority level. The DMA transfer doesn’t affect any interrupts either.
If the DMAC is active (the DMA enable bit is set to 1), data transfer starts every time a DMA transfer request signal
occurs. If the cycle of the occurrences of DMA transfer request signals is higher than the DMA transfer cycle, there
can be instances in which the number of transfer requests doesn’t match the number of transfers. For details, see
the description of the DMA request bit.
Data bus low-order bits
DMA latch high-order bits DMA latch low-order bits
DMA2 source pointer SAR2(20)
DMA2 destination pointer DAR2 (20)
DMA2 forward address pointer (20) (Note)
Data bus high-order bits
Address bus
DMA3 destination pointer DAR3 (20)
DMA3 source pointer SAR3 (20)
DMA3 forward address pointer (20) (Note)
DMA2 transfer counter reload register TCR2 (16)
DMA2 transfer counter TCR2 (16)
DMA3 transfer counter reload register TCR3 (16)
DMA3 transfer counter TCR3 (16)
(addresses 0189
16
, 0188
16
)
(addresses 0199
16
, 0198
16
)
(addresses 0182
16
to 0180
16
)
(addresses 0186
16
to 0184
16
)
(addresses 0192
16
to 0190
16
)
(addresses 0196
16
to 0194
16
)
Note: Pointer is incremented by a DMA request.
DMA0 source pointer SAR0(20)
DMA0 destination pointer DAR0 (20)
DMA0 forward address pointer (20) (Note)
DMA1 destination pointer DAR1 (20)
DMA1 source pointer SAR1 (20)
DMA1 forward address pointer (20) (Note)
(addresses 0022
16
to 0020
16
)
(addresses 0026
16
to 0024
16
)
(addresses 0032
16
to 0030
16
)
(addresses 0036
16
to 0034
16
)
DMA0 transfer counter reload register TCR0 (16)
DMA0 transfer counter TCR0 (16)
DMA1 transfer counter reload register TCR1 (16)
DMA1 transfer counter TCR1 (16)
(addresses 0029
16
, 0028
16
)
(addresses 0039
16
, 0038
16
)
Figure 1.70. DMAC block diagram
101
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
Table 1.37. DMAC specifications
Item Specification
No. of channels 4 (cycle steal method)
Transfer memory space
From any address in the 1M bytes space to a fixed address
a fixed address to any address in the 1M bytes space
a fixed address to a fixed address (note that DMA related registers
[002016 to 003F16 and 018016 to 019F16] cannot be accessed)
Maximum No. of bytes transferred 128K bytes (with 16-bit transfers) or 64K bytes (with 8-bit transfers)
DMA request factors (Note)
Falling edge of INT0, INT1, INT2 or both edges
Timer A0 to Timer A4 interrupt requests
UART0-3 transfer and receive interrupt requests
A-D conversion interrupt request
Software triggers

Serial Sound Interface 0-1 transm it and receive interrupt
Channel priority High to low priority: DMA0, DMA1, DMA2, DMA3
Transfer unit 8 bits or 16 bits
Transfer address direction Forward/fixed (forward direction cannot be specified for both source and
destination si mu ltaneously)
Transf er mode
Single transfer mode
After the transfer counter underflows, the DMA enable bit is set to “0 ”
and the DMAC becomes inactive
Repeat transfer mode
After the transfer counter underflows, the value of the transfer counter
reload r egiste r is relo aded to the t rans fer cou nter. The DMAC remai ns
active unless a “0” is written to the DMA enable bit.
DMA interrupt request generation
timing When an underflow occurs in transfer counter
Active When the DMA enable bit is set to “1”, the DMAC is active.
When the DMAC is active, data transfer starts each time the DMA transfer
request signal occurs.
Inactive When the DMA enable bit is set to “0”, the DMAC is inactive
After the transfer counter underflows in single transfer mode.
Forward address pointer and reload
timing for transfer counter
When data transfer starts immediately after turning DMAC active, or when the
transfer counter underflows in repeat transfer mode, the value of the source
pointer or destination pointer (whichever is specified for forward direction) is
reloaded to the forward direction address pointer, and the value of the transfer
counter reload register is reloaded to the transfer counter.
Writing to register Registers specified for forward direction transfer are always write enabled.
Registers s pecif ied for fi xed ad dress t ransfer are wri te-enab led when the DM A
enable bit is “0”.
Reading the register Can be read at any tim e. Howev er, when the DMA enable bit is “1”, reading the
register set-up as the forward register is the same as reading the value of the
forward address pointer.
Note: DM A transfer is no t effective to any inter rupts. DMA transfer is no t affected by the interrupt enabl e flag (I flag) or
by the interrupt priority level.
DMA triggers
From
From
USB triggers, selectable by endpoint
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
102
Figure 1.71. DMAC register (1)
Bit Symbol Bit Name Function R W
DSEL0
DSEL1
DSEL2
DSEL3
DSEL4
b4 b3 b2 b1 b0
0 0 0 0 0 : Disabled
0 0 0 0 1 : INT0 (falling edge)
0 0 0 1 0 : INT0 (two edges)
0 0 0 1 1 : USB0
0 0 1 0 0 : Timer A0
0 0 1 0 1 : Timer A1
0 0 1 1 0 : Timer A2
0 0 1 1 1 : Timer A3
0 1 0 0 0 : Timer A4
0 1 0 0 1 : UART0 receive/ACK/SSI0 receive
0 1 0 1 0 : UART1 receive/ACK/SSI1 receive
0 1 0 1 1 : UART2 receive/ACK
0 1 1 0 0 : UART3 receive/ACK
0 1 1 0 1 : UART0 transmit/NACK/SSI0 transmit
0 1 1 1 0 : UART1 transmit/NACK/SSI1 transmit
0 1 1 1 1 : UART2 transmit/NACK
1 0 0 0 0 : UART3 transmit/NACK
1 0 0 0 1 : A/D
1 0 0 1 0 : Disabled
1 0 0 1 1 : DMA1
1 0 1 0 0 : DMA2
1 0 1 0 1 : DMA3
1 0 1 1 0 : Disabled
1 0 1 1 1 : Disabled
1 1 x x x : Disabled
O O
Symbol
DM0SL Address
03B8
16
When reset
00
16
DMA0 request cause select register (Note)
b7 b5b6 b4 b3 b2 b1 b0
Nothing is assigned. Write "0" when writing to these bits. The value is "0" when read.
DSR
O O
DMA request cause
select bits
O O
O O
O O
_ _
O O
Software DMA request bit Software trigger is always enabled
Write "1" to trigger DSR bit.
Bit Symbol Bit Name Function R W
DSEL0
DSEL1
DSEL2
DSEL3
DSEL4
b4 b3 b2 b1 b0
0 0 0 0 0 : Disabled
0 0 0 0 1 : INT1 (falling edge)
0 0 0 1 0 : INT1 (two edges)
0 0 0 1 1 : USB1
0 0 1 0 0 : Timer A0
0 0 1 0 1 : Timer A1
0 0 1 1 0 : Timer A2
0 0 1 1 1 : Timer A3
0 1 0 0 0 : Timer A4
0 1 0 0 1 : UART0 receive/ACK/SSI0 receive
0 1 0 1 0 : UART1 receive/ACK/SSI1 receive
0 1 0 1 1 : UART2 receive/ACK
0 1 1 0 0 : UART3 receive/ACK
0 1 1 0 1 : UART0 transmit/NACK/SSI0 transmit
0 1 1 1 0 : UART1 transmit/NACK/SSI1 transmit
0 1 1 1 1 : UART2 transmit/NACK
1 0 0 0 0 : UART3 transmit/NACK
1 0 0 0 1 : A/D
1 0 0 1 0 : DMA0
1 0 0 1 1 : Disabled
1 0 1 0 0 : DMA2
1 0 1 0 1 : DMA3
1 0 1 1 0 : Disabled
1 0 1 1 1 : Disabled
1 1 x x x : Disabled
O O
Symbol
DM1SL Address
03BA
16
When reset
00
16
DMA1 request cause select register (Note)
b7 b5b6 b4 b3 b2 b1 b0
Nothing is assigned. Write "0" when writing to these bits. The value is "0" when read.
DSR
O O
DMA request cause
select bits
O O
O O
O O
_ _
O O
Software DMA request bit Software trigger is always enabled
Write "1" to trigger DSR bit.
Note: Software is always enabled.
Note: Software is always enabled.
103
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
Figure 1.72. DMAC register (2)
Bit Symbol Bit Name Function R W
DSEL0
DSEL1
DSEL2
DSEL3
DSEL4
b4 b3 b2 b1 b0
0 0 0 0 0 : Disabled
0 0 0 0 1 : INT2 (falling edge)
0 0 0 1 0 : INT2 (two edges)
0 0 0 1 1 : USB2
0 0 1 0 0 : Timer A0
0 0 1 0 1 : Timer A1
0 0 1 1 0 : Timer A2
0 0 1 1 1 : Timer A3
0 1 0 0 0 : Timer A4
0 1 0 0 1 : UART0 receive/ACK/SSI0 receive
0 1 0 1 0 : UART1 receive/ACK/SSI1 receive
0 1 0 1 1 : UART2 receive/ACK
0 1 1 0 0 : UART3 receive/ACK
0 1 1 0 1 : UART0 transmit/NACK/SSI0 transmit
0 1 1 1 0 : UART1 transmit/NACK/SSI1 transmit
0 1 1 1 1 : UART2 transmit/NACK
1 0 0 0 0 : UART3 transmit/NACK
1 0 0 0 1 : A/D
1 0 0 1 0 : DMA0
1 0 0 1 1 : DMA1
1 0 1 0 0 : Disabled
1 0 1 0 1 : DMA3
1 0 1 1 0 : Disabled
1 0 1 1 1 : Disabled
1 1 x x x : Disabled
O O
Symbol
DM2SL Address
03B016
When reset
0016
DMA2 request cause select register (Note)
b7 b5b6 b4 b3 b2 b1 b0
Nothing is assigned. Write "0" when writing to these bits. The value is "0" when read.
DSR
O O
DMA request cause
select bits
O O
O O
O O
_ _
O O
Software DMA request bit Software trigger is always enabled
Write "1" to trigger DSR bit.
Bit Symbol Bit Name Function R W
DSEL0
DSEL1
DSEL2
DSEL3
DSEL4
b4 b3 b2 b1 b0
0 0 0 0 0 : Disabled
0 0 0 0 1 : INT0 (falling edge)
0 0 0 1 0 : INT0 (two edges)
0 0 0 1 1 : USB3
0 0 1 0 0 : Timer A0
0 0 1 0 1 : Timer A1
0 0 1 1 0 : Timer A2
0 0 1 1 1 : Timer A3
0 1 0 0 0 : Timer A4
0 1 0 0 1 : UART0 receive/ACK/SSI0 recieve
0 1 0 1 0 : UART1 receive/ACK/SSI1 receive
0 1 0 1 1 : UART2 receive/ACK
0 1 1 0 0 : UART3 receive/ACK
0 1 1 0 1 : UART0 transmit/NACK/SSI0 transmit
0 1 1 1 0 : UART1 transmit/NACK/SSI1 transmit
0 1 1 1 1 : UART2 transmit/NACK
1 0 0 0 0 : UART3 transmit/NACK
1 0 0 0 1 : A/D
1 0 0 1 0 : DMA0
1 0 0 1 1 : DMA1
1 0 1 0 0 : DMA2
1 0 1 0 1 : Disabled
1 0 1 1 0 : Disabled
1 0 1 1 1 : Disabled
1 1 x x x : Disabled
O O
Symbol
DM3SL Address
03B216
When reset
0016
DMA3 request cause select register (Note)
b7 b5b6 b4 b3 b2 b1 b0
Nothing is assigned. Write "0" when writing to these bits. The value is "0" when read.
DSR
O O
DMA request
cause select bits
O O
O O
O O
_ _
O OSoftware DMA request bit Software trigger is always enabled
Write "1" to trigger DSR bit.
Note: Software is always enabled.
Note: Software is always enabled.
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
104
Figure 1.73. DMAC register (3)
b7 b3 b0 b7 b0b7 b0
(b23) (b19) (b16)(b15) (b8)
DMAi source pointer (i=0-3)
Symbol
SAR0
SAR1
SAR2
SAR3
Address
0022
16
to 0020
16
0032
16
to 0030
16
0182
16
to 0180
16
0192
16
to 0190
16
When reset
Indeterminate
Indeterminate
Indeterminate
Indeterminate
Function Transfer count
specification
Source pointer
stores the source address
Nothing is assigned.
Write "0" when writing to these bits. The value is "0" if read.
00000
16
to FFFFF
16
R W
O O
_ _
Bit Name Function R W
DMBIT
DMASL
DMAS
DMAE
DSD
DAD
0 : 16 bits
1 : 8 bits
0 : Single transfer
1 : Repeat transfer
0 : DMA not requested
1 : DMA requested
0 : Disabled
1 : Enabled
0 : Fixed
1 : Forward
0 : Fixed
1 : Forward
O O
Symbol
DMiCON (i=0-3) Address
002C
16
, 003C
16
,
018C
16
, 019C
16
When reset
00000X00
2
DMAi control register
b7 b5b6 b4 b3 b2 b1 b0
Nothing is assigned. Write "0" when writing to these bits. The value is "0" when read.
O O
Transfer unit select bit
Repeat transfer mode select bit
DMA request bit (Note 1)
DMA enable bit
Source address direction select
bit (Note 3)
Destination address direction
select bit (Note 3)
O O
O O
O O
_ _
O O
Note 1: DMA request can be cleared by resetting the bit.
Note 2: This bit can only be set to "0".
Note 3: Source address direction select bit and destination address direction select bit cannot
be set to "1" simultaneously.
Bit Symbol
(b15) (b8)
DMAi transfer counter (i=0-3)
Symbol
TCR0
TCR1
TCR2
TCR3
Address
0029
16
to 0028
16
0039
16
to 0038
16
0189
16
to 0188
16
0199
16
to 0198
16
When reset
Indeterminate
Indeterminate
Indeterminate
Indeterminate
Function Transfer count
specification
Transfer counter
Set a value one less than the transfer count 0000
16
to FFFF
16
R W
O O
b7 b3 b0 b7 b0b7 b0
(b23) (b19) (b16)(b15) (b8)
DMAi destination pointer (i=0-3)
Symbol
DAR0
DAR1
DAR2
DAR3
Address
0026
16
to 0024
16
0036
16
to 0034
16
0186
16
to 0184
16
0196
16
to 0194
16
When reset
Indeterminate
Indeterminate
Indeterminate
Indeterminate
Function Transfer count
specification
Destination pointer
stores the destination address
Nothing is assigned.
Write "0" when writing to these bits. The value is "0" if read.
00000
16
to FFFFF
16
R W
O O
_ _
b7 b0b7 b0
(Note 2)
105
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
Transfer modes
Single transfer mode
DMA transfer occurs until the tranfer counter underflows. Afterward, the DMA becomes inactive
Repeat transfer mode
The DMA remains active even after the transfer counter underflows. The transfer counter and forward
direction address pointer are reloaded after each transfer counter underflow. The DMA becomes inactive
when "0" is written to the DMA enable bit.
DMA enable bit
Setting the DMA enable bit to “1” makes the DMAC active. The DMAC carries out the following operations
at the time data transfer starts immediately after DMAC is turned active.
(1) Reloads the value of one of the source pointer and the destination pointer - the one specified for the
forward direction - to the forward direction address pointer.
(2) Reloads the value of the transfer counter reload register to the transfer counter.
Thus overwriting “1” to the DMA enable bit with the DMAC being active carries out the operations given
above, so the DMAC operates again from the initial state at the instant “1” is overwritten to the DMA enable
bit.
DMA request bit
The DMAC can generate a DMA transfer request signal triggered by a factor chosen in advance out of
DMA request factors for each channel.
DMA request factors include the following.
• Factors effected by using the interrupt request signals from the built-in peripheral functions and software
DMA factors (internal factors) effected by a program.
• External factors effected by utilizing the input from external interrupt signals.
For the selection of DMA request factors, see the descriptions of the DMAi request cause select registers.
The DMA request bit turns to “1” if the DMA transfer request signal occurs regardless of the DMAC’s state
(regardless of whether the DMA enable bit is set “1” or to “0”). It turns to “0” immediately before data
transfer starts.
In addition, it can be set to “0” by use of a program, but cannot be set to “1”.
There can be instances in which a change in DMA request factor selection bit causes the DMA request bit
to turn to “1”. Make sure to set the DMA request bit to “0” after the DMA request factor selection bit is
changed.
The DMA request bit turns to “1” if a DMA transfer request signal occurs, and turns to “0” immediately
before data transfer starts. If the DMAC is active, data transfer starts immediately, so the value of the DMA
request bit, if read by use of a program, turns out to be “0” in most cases. To examine whether the DMAC
is active, read the DMA enable bit.
The timing changes of the DMA request bit are discussed in the following section.
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
106
Internal factors
Except the DMA request factors triggered by software, the timing for the DMA request bit to turn to “1” due
to an internal factor is the same as the timing for the interrupt request bit of the interrupt control register to
turn to “1” due to several factors.
Turning the DMA request bit to “1” due to an internal factor is timed to be effected immediately before the
transfer starts.
External factors
An external factor is a DMA request caused from the INTi pin input edge ("i" reflects the DMAC channel
used).
Selecting the INTi pins as external factors using the DMA request factor selection bit causes input from
these pins to become the DMA transfer request signals.
The timing for the DMA request bit to turn to “1” when an external factor is selected synchronizes with the
signal’s edge applicable to the function specified by the DMA request factor selection bit (synchronizes with
the trailing edge of the input signal to each INTi pin, for example).
With an external factor selected, the DMA request bit is timed to turn to “0” immediately before data transfer
starts similarly to the state in which an internal factor is selected.
Priorities of the channels and DMA transfer timing
If a DMA transfer request signal falls on a single sampling cycle (a sampling cycle means one period from
the leading edge to the trailing edge of BCLK), the DMA request bits of applicable channels concurrently
turn to “1”. If the channels are active at that moment, DMA0 is given a high priority to start data transfer.
When DMA0 finishes data transfer, it gives the bus right to the CPU. When the CPU finishes single bus
access, then DMA1 starts data transfer and gives the bus right to the CPU. The DMA priority levels are:
DMA0 > DMA1 > DMA2 > DMA3
Figure 1.74 is an example of DMA transfer effected by external factors when DMA0 and DMA1 requests
occur in the same sampling cycle.
Figure 1.74. An example of DMA transfer by external factors
BCLK
DMA0
DMA1
DMA0
request bit
DMA1
request bit
CPU
INT0
INT1
Bus
control
Example of DMA transmission that is carried out in minimum cycles
at the time DMA transmission occur concurrently.
///////////////// //////////////
///////////
/////// ///////////
107
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
Transfer cycle
The transfer cycle consists of the bus cycle in which data is read from memory or from the SFR area
(source read) and the bus cycle in which the data is written to memory or to the SFR area (destination
write). The number of read and write bus cycles depends on the source and destination addresses. In
memory expansion mode and microprocessor mode, the number of read and write bus cycles also de-
pends on the level of the BYTE pin. Also, the bus cycle is longer when software waits are inserted.
Effect of source and destination addresses
When 16-bit data is transferred on a 16-bit data bus, and the source and destination both start at odd
addresses, there are one more source read cycle and destination write cycle than when the source and
destination both start at even addresses.
Effect of BYTE pin level
When transferring 16-bit data over an 8-bit data bus (BYTE pin = “H”) in memory expansion mode and
microprocessor mode, the 16 bits of data are sent in two 8-bit blocks. Therefore, two bus cycles are re-
quired for reading the data and two are required for writing the data. Also, in contrast to when the CPU
accesses internal memory, when the DMAC accesses internal memory (internal ROM, internal RAM, and
SFR), these areas are accessed using the data size selected by the BYTE pin.
Effect of software wait
When the SFR area or a memory area with a software wait is accessed, the number of cycles is increased
for the wait by 1 bus cycle. The length of the cycle is determined by BCLK.
Figure 1.75 shows the example of the transfer cycles for a source read. For convenience, the destination
write cycle is shown as one cycle and the source read cycles for the different conditions are shown. In
reality, the destination write cycle is subject to the same conditions as the source read cycle, with the
transfer cycle changing accordingly. When calculating the transfer cycle, remember to apply the respective
conditions to both the destination write cycle and the source read cycle. For example, if data is being
transferred in 16-bit units on an 8-bit bus (2), two bus cycles are required for both the source read cycle and
the destination write cycle.
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
108
BCLK
Address
bus
RD
WR
Data
bus
CPU use
CPU use CPU use
CPU useSource
Source
Destination
Destination
(1) 8-bit transfers
16-bit transfers from even address and the source address is even.
BCLK
Address
bus
RD
WR
Data
bus
CPU use
CPU use CPU use
CPU useSource
Source
Destination
Destination
(3) One wait is inserted into the source read under the conditions in (1)
BCLK
Address
bus
RD
WR
Data
bus
CPU use
CPU use CPU use
CPU useSource
Source
Destination
Destination
Source + 1
Source + 1
(2) 16-bit transfers and the source address is odd
BCLK
Address
bus
RD
WR
Data
bus
CPU use
CPU use CPU use
CPU useSource
Source
Destination
Destination
Source + 1
Source + 1
(4) One wait is inserted into the source read under the conditions in (2)
Note : The same timing changes occur with the respective conditions at the destination as at the source.
Dummy
cycle
Dummy
cycle
Dummy
cycle
Dummy
cycle
Dummy
cycle
Dummy
cycle
Dummy
cycle
Dummy
cycle
Transferring 16-bit data on an 8-bit data bus (In this case, there are two destination write cycles)
(When 16-bit data is transferred on an 8-bit data bus, there are two destination write cycles)
Figure 1.75. Example of the transfer cycles for a source read
109
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
DMAC
Coefficient j, k
Transfer unit Bus width Access
address
Single-chip mode Memory expansion mode
No. of read
cycles No. of write
cycles No. o f read
cycles No. of write
cycles
8-bit transfers
(DMBIT = “1”)
16-bit
(BYTE = “L”) Even1111
Odd1111
8-bit (BYTE = “H”) Even__11
Odd__11
16-bit transfers
(DMBIT = “0”)
16-bit (BYTE=”H”) Even1111
Odd2222
8-bit (BYTE = “H”) Even__22
Odd__22
Internal memory External memory
Internal ROM/RAM
No wait Internal ROM/RAM
With wait SF R area Separa te bus No
wait Separate bus
With wait
12212
Transfer cycle calculations
Any combination of even or odd transfer read and write addresses is possible. Table 1.38 shows the
number of DMAC transfer cycles.
The number of DMAC transfer cycles calculation is:
No. of transfer cycles per transfer unit = No. of read cycles x j + No. of write cycles x k
Table 1.38. DMA transfer cycles
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
110
Timer A
Except in event counter mode, Timers A0 through A4 all have the same function. Use the Timer Ai mode register
(i = 0 to 4) bits 0 and 1 to choose the desired mode.
Timer A has four operation modes listed as follows:
• Timer mode: The timer counts an internal count source.
• Event counter mode: The timer counts pulses from an external source or a timer over flow.
• One-shot timer mode: The timer stops counting when the count reaches “000016”.
• Pulse width modulation (PWM) mode: The timer outputs pulses of a given width.
Figure 1.76 and Figure 1.77 show block diagrams of Timer A. Figure 1.78 to Figure 1.80 show the Timer A-related
registers.
Figure 1.76. Timer A block diagram (1)
Count start flag
(Address 038016)
Up count/down count
TAi
Addresses TAj TAk
Timer A0 0387
16
0386
16
Timer A4 Timer A1
Timer A1 0389
16
0388
16
Timer A0 Timer A2
Timer A2 038B
16
038A
16
Timer A1 Timer A3
Timer A3 038D
16
038C
16
Timer A2 Timer A4
Timer A4 038F
16
038E
16
Timer A3 Timer A0
Always count down except
in event counter mode
Reload register (16)
Counter (16)
Low-order
8 bits High-order
8 bits
Clock source
selection
Timer
(gate function)
Timer
One shot
PWM
f1
f8
f32
External
trigger
TAiIN
(i = 0 to 4)
Event counter
fC32
Clock selection
TAj overflow
(j = i - 1. Note, however, that j = 4 when i = 0)
Pulse output
Toggle flip-flop
TAiOUT
(i = 0 to 4)
Data bus low-order bits
Data bus high-order bits
Up/down flag
Down count
(Address 038416)
TAk overflow
(k = i + 1. Note, however, that k = 0 when i = 4)
Polarity
selection
Timer A
111
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.77. Timer A block diagram (2)
• Timer mode
• One-shot mode
• PWM mode
• Timer mode
• One-shot mode
• PWM mode
• Timer mode
• One-shot mode
• PWM mode
• Timer mode
• One-shot mode
• PWM mode
• Timer mode
• One-shot mode
• PWM mode
• Event counter mode
• Event counter mode
• Event counter mode
• Event counter mode
• Event counter mode
TA0 IN
TA1 IN
TA2 IN
TA3 IN
TA4 IN
Timer A0
Timer A1
Timer A2
Timer A3
Timer A4
f1 f8 f32 fC32
Timer A0 interrupt
Timer A1 interrupt
Timer A2 interrupt
Timer A3 interrupt
Timer A4 interrupt
Noise
filter
Noise
filter
Noise
filter
Noise
filter
Noise
filter
1/32 fC32
1/8
1/4
f1
f8
f32
XIN XCIN
Clock prescaler reset flag (bit 7
at address 038116) set to “1”
Reset
Clock prescaler
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
112
Figure 1.78. Timer A-related registers (1)
Function R W
Timer Ai register (i = 0 to 4) (Note 1)
b7 b8)
(b15 b0
O O
O O
X O
X O
X O
16-bit counter (set to divide ratio)
16-bit counter (set to divide ratio) (Note 2)
16-bit counter (set to one-shot width)
(Note 6)
16-bit PWM (set to PWM pulse "H" width)
(Note 4, 7)
Low-order bits: 8-bit prescaler
(set to PWM period) (Notes 5, 7)
High-order bits : 8-bit PWM
(set to PWM pulse "H" width) (Notes 5, 7)
0000
16
to FFFF
16
Values that can be set
0000
16
to FFFF
16
0000
16
to FFFF
16
0000
16
to FFFF
16
00
16
to FE
16
(Both high-order and
low-order addresses) (Note 3)
Note 1 : Read and write data in 16-bit units.
Note 2 : Counts pulses from an external source or timer overflow.
Note 3 : Use MOV instruction to write to this register.
Note 4 : When setting value is n, PWM period and "H" width of PWM pulses are:
PWM period : (2
16
- 1)/fi
PWM pulse "H" width : n/fi
Note 5 : When setting value of high-order address is n and setting value of low-
order address is m, PWM period and "H" width of PWM pulse are:
PWM period : (2
8
- 1) X (m + 1)/fi
PWM pulse "H" width : (m + 1)n/fi
Note 6 : When the Timer Ai register is set to "0000
16
", the counter does not
operate and the Timer Ai interrupt request is not generated. When the
pulse is set to output, the pulse is not output from the TAiOUT pin.
Note 7 : When the Timer Ai register is set to "0000
16
", the pulse width modulator
does not operate and the output level of the TAiOUT pin remains "L"
level, therefore the Timer Ai interrupt request is not generated. This also
occurs in the 8-bit pulse width modulator mode when the significant 8
high-order bits in the Timer Ai register are set to "00
16
".
b7 b0
Symbol
TA0
TA1
TA2
TA3
TA4
Address
0387
16
, 0386
16
,
0389
16
, 0388
16
,
038B
16
, 038A
16
,
038D
16
, 038C
16
,
038F
16
, 038E
16
When reset
Indeterminate
Indeterminate
Indeterminate
Indeterminate
Indeterminate
(Note 3)
(Note 3)
Bit Symbol Bit Name Function R W
TA1TGL Timer A1 event/trigger
select bit
Symbol
TRGSR Address
0383
16
When reset
00
16
Trigger select register
b7 b5b6 b4 b3 b2 b1 b0
O O
TA1TGH
TA2TGL
TA2TGH
TA3TGL
TA3TGH
TA4TGL
TA4TGH
O O
O O
O O
O O
O O
O O
O O
Timer A2 event/trigger
select bit
Timer A3 event/trigger
select bit
Timer A4 event/trigger
select bit
0 0 : Input on TA1
IN
is selected (Note)
0 1 : Invalid
1 0 : TA0 overflow is selected
1 1 : TA2 overflow is selected
b1 b0
0 0 : Input on TA2
IN
is selected (Note)
0 1 : Invalid
1 0 : TA1 overflow is selected
1 1 : TA3 overflow is selected
b3 b2
0 0 : Input on TA3
IN
is selected (Note)
0 1 : Invalid
1 0 : TA2 overflow is selected
1 1 : TA4 overflow is selected
b5 b4
0 0 : Input on TA4
IN
is selected (Note)
0 1 : Invalid
1 0 : TA3 overflow is selected
1 1 : TA0 overflow is selected
b7 b6
Note: Set the corres
p
ondin
g
p
ort direction re
g
ister to "0"
Timer mode
Event counter
mode
One-shot
timer mode
16-bit PWM
8-bit PWM
Mode
Timer A
113
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.79. Timer A-related registers (2)
Bit Symbol Bit Name Function R W
TA0S Timer A0 count start flag
Symbol
TABSR Address
0380
16
When reset
XXX00000
16
Count start flag
b7 b5b6 b4 b3 b2 b1 b0
O O
TA1S
TA2S
TA3S
TA4S
O O
O O
O O
O O
_ _
Timer A1 count start flag
Timer A2 count start flag
Timer A3 count start flag
Timer A4 count start flag
0 : Stops counting
1 : Starts counting
Bit Symbol Bit Name Function R W
TMOD0 Operation mode
select bit
Symbol
TAiMR (i=0 to 4) Address
0396
16
to 039A
16
When reset
00000X00
2
Timer Ai mode register (i = 0 to 4)
b7 b5b6 b4 b3 b2 b1 b0
O O
TMOD1 O O
O O
O O
O O
O O
O O
0 0 : Timer mode
0 1 : Event counter mode
1 0 : One-shot timer mode
1 1 : PWM mode
b1 b0
MR0
MR1
MR2
MR3
TCK0
TCK1
Function varies with each mode
operation
Count source select bit Function varies with each mode
operation
Bit Symbol Bit Name Function R W
CPSR Clock prescaler reset flag 0 : No effect
1 : Reset
(The value is "0" when read) O O
Symbol
CPSRF Address
0381
16
When reset
0XXXXXXX
2
Clock prescaler reset flag
b7 b5b6 b4 b3 b2 b1 b0
Nothing is assigned. Write "0" when writing to these bits. The
value is indeterminate if read.
_ _
O O
Nothing is assigned. Write "0" when writing to these bits.
The value is indeterminate if read.
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
114
Figure 1.80. Timer A-related register (3)
Bit Symbol Bit Name Function R W
TA0UD Timer A0 up/down flag
Symbol
UDF Address
0384
16
When reset
00
16
Up/down flag (Note)
b7 b5b6 b4 b3 b2 b1 b0
O O
TA1UD
TA2UD
TA3UD
TA4UD
TA2P
TA3P
TA4P
O O
O O
O O
O O
O
O
O
Timer A1 up/down flag
Timer A2 up/down flag
Timer A3 up/down flag
Timer A4 up/down flag
Timer A2 two-phase pulse
signal processing select bit
0 : Down count
1 : Up count
Timer A3 two-phase pulse
signal processing select bit
Timer A4 two-phase pulse
signal processing select bit
This specification becomes valid
when the up/down flag content is
selected for up/down switching cause
0 : Disabled
1 : Enabled
When not using the two-phase pulse
signal processing function, set the
select bit to "0"
Note : Use MOV instruction to write to this register
Bit Symbol Bit Name Function R W
TA0OS O O
Symbol
ONSF Address
0382
16
When reset
00
16
One-shot start flag
b7 b5b6 b4 b3 b2 b1 b0
0 0 : Input on TA0
IN
is selected (Note 2)
0 1 : Invalid
1 0 : TA4 overflow is selected
1 1 : TA1 overflow is selected
O O
TA1OS
b1 b0
TA2OS
TA3OS
TA4OS
TA0TGL
TA0TGH
O O
O O
O O
O O
O O
Timer A0 event/trigger
select bit
Timer A0 one-shot start flag
Timer A1 one-shot start flag
Timer A2 one-shot start flag
Timer A3 one-shot start flag
Timer A4 one-shot start flag
0 : Invalid
1 : Timer start (Note 1)
Note 1 : The value is "0" when read.
Note 2 : Set the corresponding port direction register to "0".
Reserved Always set to "0" O O
0
_
_
_
Timer A
115
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Timer mode
In this mode, the timer counts an internally generated count source. Timer A in timer mode specifications
are shown in Table 1.39. Figure 1.81 shows the Timer Ai mode register in timer mode.
Table 1.39. Timer mode specifications
Item Specification
Count source f1, f8, f32, fc32
Count operation Down count
When the timer underflows, it loads the reload register contents before continuing counting
Divide ratio 1/(n+1) n: Set value
Count start condition Count start flag is set (= 1)
Count stop condition Count start flag is reset (= 0)
Interrupt request
generation timing When the timer underflows
TAi
IN
pin function Programmable I/O port or gate input.
TAi
OUT
pin function Programmable I/O port or pulse output.
Read from timer Count value can be read out by reading Timer Ai register
Write to timer
When counting is stopped and a value is written to Timer Ai register, it is written to both the
reload register and counter
When countin g is in progres s and a val ue is writ ten to Timer Ai registe r, it is written onl y to the
reload register (to be transferred to counter at the next reload time)
Select function Gate function-Counting can be started and stopped by TAi
IN
pin's input signal
Pulse output function-Each time the timer underflows, the TAi
OUT
pin's polarity is reversed
Figure 1.81. Timer Ai mode register in timer mode
Bit Symbol Bit Name Function R W
TMOD0 Operation mode
select bit
Symbol
TAiMR (i=0 to 4) Address
0396
16
to 039A
16
When reset
00000X00
2
Timer Ai mode register (i = 0 to 4)
b7 b5b6 b4 b3 b2 b1 b0
O O
TMOD1 O O
O O
O O
O O
O O
O O
0 0 : Timer mode
b1 b0
MR0
MR1
MR2
Count source select bit
Gate function select bit
0 X : Gate funciton not available
(TAi
IN
pin is a normal port pin) (Note 1)
1 0 : Timer counts only when TAi
IN
pin
is held "L" (Note 2)
1 1 : Timer counts only when TAi
IN
pin
is held "H" (Note 2)
b4 b3
0 0 : f1
0 1 : f8
1 0 : f32
1 1 : fc32
b7 b6
MR3
TCK0
TCK1
0 (Set to "0" in timer mode)
Note 1: X value can be "0" or "1"
Note 2: Set the corresponding port direction register to "0".
Pulse output function
select bit
0 : Pulse is not output
(TAi
OUT
pin is a normal port pin)
1 : Pulse is output
(TAi
OUT
pin is a pulse output pin)
O O
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
116
Event counter mode
In this mode, the timer counts an external signal or an internal timer’s overflow. Timers A0 and A1 can
count a single-phase external signal. Timers A2, A3, and A4 can count a single-phase and a two-phase
external signal. Table 1.40 lists timer specifications when counting a single-phase external signal. Table
1.41 lists timer specifications when counting a two-phase external signal. Figure 1.82 shows the Timer Ai
mode register in event counter mode (excluding two-phase pulse signal processing). Figure 1.83 shows
the Timer Ai mode register in event counter mode when using two-phase pulse signal processing.
Table 1.40. Event counter mode specifications (excluding two-phase pulse signal)
Note: This does not apply when the free-run function is selected
Item Specification
Coun t source External signals input to TAi
IN
pin (effective edge can be selected by software)
TAj overflow
Count operation Up count or down count can be selected by external signal or software.
When the timer overflows or underflows, it reloads the reload register contents before count-
ing contin ues . (Note)
Divide ratio 1/(FFFF
16
- n + 1) for up count
1/(n + 1) for down count n: Set value
Count start condition Count start flag is set (= 1)
Count stop condition Count start flag is reset (= 0)
Interrupt request
generation timing The timer overflows or underflows
TAi
IN
pin function Programmable I/O port or count source input
TAi
OUT
pin function Programmable I/O port, pulse output, or up/down count select input.
Read from timer Count value can be read out by reading Timer Ai register
Write to timer
When counting is stopped and a value is written to Timer Ai register, it is written to both the
reload register and counter
When countin g is in progres s and a val ue is writ ten to Timer Ai registe r, it is written onl y to the
reload register (to be transferred to the counter at the next reload time)
Select function
Free-run count function
Even when the timer overflows or underflows, the reload register content is not reloaded.
Pulse output function
Each time the timer overflows or underflows, the TAi
OUT
pin's polarity is reversed
Timer A
117
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.41. Timer specifications in event counter mode (when processing two-phase pulse signal)
Note 1: This does no t apply when the fr ee-run functi on is selected.
Note 2: Timer A3 is select able. Timer A2 is fixed to normal pr oc essing operati on and Timer A4 is fixed to mu lti ply -by -4
operation.
Item Specification
Count Source Two-phase pulse signals input to TAi
IN
or TAi
OUT
pin
Count operation Up count or down count can be selected by two-phase pulse signal
When the ti mer ov erflows or underfl ows, the reloa d regis ter co ntent i s loaded and t he tim er
starts over again (Note 1)
Divide ratio 1/ (FFFF
16
- n + 1) for up count
1/ (n+1) for down count n: Set value
Count start condition Count start flag is set (=1)
Count stop condition Count start flag is reset (=0)
Interrupt request
generation timing Timer overflow or underflows
TAi
IN
pin function Two-phase pulse input
TAi
OUT
pin function Two-phase pulse input
Read from timer Count value can be read out by reading Timer A2, A3, or A4 register
Writer to timer
When counting i s stop ped and a value is writte n to T i mer A2, A3 , or A4 register, it is written
to both the reload register and counter
When counting is in progress and a value is written to Ti mer A2, A3, or A4 register, it is
written only to the reload register (to be transferred to the counter at the next reload time).
Select function
Normal processing operation (Timer A2 and A3)
The timer counts up rising edges or counts down falling edges on the TAi
IN
pin when the
input signal on the TAi
OUT
pin is "H"
Multiply-by-4 processing operation (Timer A3 and Timer A4)
If the phase relationship is such that the TAi
IN
pin goes "H" when the input signal on the
TAi
OUT
pin is "H ", the tim er counts up ris ing and falling edges on the TAi
OUT
and T Ai
IN
pins .
If the phase relationship is such that the TAi
IN
pin goes "L" when the input signal on the
TAi
OUT
pin is "H", the timer counts down rising and falling edges on the TAi
OUT
and TAi
IN
pins.
TAi
OUT
TAi
IN
(i=2,3)
Up
count
Up
count
Up
count Down
count Down
count Down
count
Count up all edges Count down all edges
Count down all edgesCount up all edges
TAi
OUT
TAi
IN
(i=3,4)
(Note 2)
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
118
Figure 1.82. Timer Ai mode register in event counter mode (not using two-phase processing)
Bit Symbol Bit Name Function R W
TMOD0 Operation mode
select bit
Symbol
TAiMR (i=0 to 4) Address
0396
16
to 039A
16
When reset
00000X00
2
Timer Ai mode register (i = 0 to 4)
b7 b5b6 b4 b3 b2 b1 b0
O O
TMOD1 O O
O O
O O
O O
0 1 : Event counter mode (Note 1)
b1 b0
MR0
Two-phase pulse signal
processing operation
select bit (Note 4)
Pulse output function
select bit
Count polarity select bit
(Note 2) 0 : Counts external signals falling edges
1 : Counts external signals rising edges
0 (Set to "0" when not using two-phase
pulse signal processing)
MR3
TCK0
TCK1
0 (Set to "0" in event counter mode)
Note 1: Count source is selected by the event/trigger select bit (addresses 0382
16
, 0383
16
) in
event counter mode.
Note 2: This bit is valid only when counting an external signal.
Note 3: Set the corresponding port direction register to "0".
Note 4: This bit is valid for Timer A3 mode registers. Timer A2 is fixed to normal processing
operation and Timer A4 is fixed to multiply-by-4 processing operation.
MR1
MR2 Up/down switching
cause select bit 0 : Up/down flag data
1 : TAi
OUT
pin's input signal (Note 3) O O
O O
Count operation type
select bit 0 : Reload type
1 : Free-run type
0 : Pulse is not output
(TAi
OUT
pin is a normal port pin)
1 : Pulse is output
(TAi
OUT
pin is a pulse output pin) O O
Bit Symbol Bit Name Function R W
TMOD0 Operation mode
select bit
Symbol
TAiMR (i=0 to 4) Address
039616 to 039A16
When reset
00000X002
Timer Ai mode register (i = 0 to 4)
b7 b5b6 b4 b3 b2 b1 b0
O O
TMOD1 O O
O O
O O
O O
0 1 : Event counter mode (Note 1)
b1 b0
MR0
Two-phase pulse signal
processing operation
select bit (Notes 3, 4)
Pulse output function
select bit
Count polarity select bit
(Note 2) 0 (Set to "0" when using two-phase
pulse signal processing)
0 : Normal processing operation
1 : Multiply-by-4 operation
MR3
TCK0
TCK1
0 (Set to "0" in event counter mode)
Note 1: Count source is selected by the event/trigger select bit (addresses 038216, 038316) in
event counter mode.
Note 2: This bit is valid only when counting an external signal.
Note 3: This bit is valid for Timer A3 mode registers. Timer A2 is fixed to normal processing
operation and Timer A4 is fixed to multiply-by-4 processing operation.
Note 4: When performing two-phase pulse signal processing, make sure the two-phase pulse
signal processing operation select bit (address 038416) is set to "1". Also be sure to
always set the event/trigger select bit (address 038316) to "00".
MR1
MR2 Up/down switching
cause select bit 0 (Set to "1" when using two-phase
pulse signal processing) O O
O O
Count operation type
select bit 0 : Reload type
1 : Free-run type
O O
0 (Set to "0" when using two-phase
pulse signal processing)
Figure 1.83. Timer Ai mode register in event counter mode (using two-phase processing)
Timer A
119
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Item Specification
Count source f1, f8, f32, fc32
Coun t operation The timer counts down
When the count reaches 0000
16
, the timer stops counting after reloading a new count
If a trigger occurs when counting, the timer reloads a new count and restarts counting
Divide ratio 1/n n: Set value
Count start condition An external trigger is input
The timer overflows
The one-shot flag is set (=1)
Count stop condition A new count is reloaded after the count has reached 0000
16
The count start flag is reset (=0)
Interrupt request
generation timing The co unt reac hes 0000
16
TAi
IN
pin function Programmable I/O port or trigger input.
TAi
OUT
pin function Programmable I/O port or pulse output.
Read from timer When Timer Ai register is read, the value is indeterminate.
Write to timer
When counting has stopped and a value is written to Timer Ai, it is also written to the reload
register and counter.
When counting is in pr og ress and a valu e is writt en to Timer Ai, it is written to only the reload
register (Transferred to the counter at next reload time)
Bit Symbol Bit Name Function R W
TMOD0 Operation mode
select bit
Symbol
TAiMR (i=0 to 4) Address
0396
16
to 039A
16
When reset
00000X00
2
Timer Ai mode register (i = 0 to 4)
b7 b5b6 b4 b3 b2 b1 b0
O O
TMOD1 O O
O O
O O
O O
1 0 : One shot timer mode
b1 b0
MR0 Pulse output function
select bit
External trigger
select bit (Note 1) 0 : Falling edge of TAi
IN
input signal (Note 2)
1 : Rising edge of TAi
IN
input signal (Note 2)
MR3
TCK0
TCK1
0 (Set to "0" in one-shot timer mode)
Note 1: Valid only when the TAi
IN
pin is selected by the event trigger select bit
(addresses 0382
16
, 0383
16
).
Note 2: Set the corresponding port direction register to "0".
MR1
MR2 Trigger select bit 0 : One-shot start flag is valid
1 : Selected by event/trigger select register O O
O O
Count operation type
select bit
b7 b6
0 0 : f1
0 1 : f8
1 0 : f32
1 1 : fc32
0 : Pulse is not output
(TAi
OUT
pin is a normal port pin)
1 : Pulse is output
(TAi
OUT
pin is a pulse output pin) O O
One-shot timer mode
In this mode, the timer operates only once. Table 1.42 shows the timer specifications for Timer A in one-
shot timer mode. When a trigger occurs, the timer starts counting down until it reaches 000016. Figure 1.84
shows the Timer Ai mode register in one-shot timer mode.
Table 1.42. Timer specifications in one-shot timer mode
Figure 1.84. Timer Ai mode register in one-shot timer mode
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
120
Pulse width modulation (PWM) mode
In this mode, the timer outputs pulses of a given width in succession. Table 1.43 shows the timer specifica-
tion for Timer in pulse width modulation mode. In this mode, the counter functions as either a 16-bit pulse
width modulator or an 8-bit pulse width modulator. Figure 1.85 shows the Timer Ai mode register in pulse
width modulation mode. Figure 1.86 shows an example of how a 16-bit pulse width modulator operates.
Figure 1.87 shows an example of how an 8-bit pulse width modulator operates.
Table 1.43. Timer specifications in pulse width modulation mode
Item Specification
Count source f1, f8, f32, fc32
Count operation The timer counts down (operating as an 8-bit or a 16-bit pulse width modulator)
The timer reloads a new count at a rising edge of the PWM pulse and continues counting
The timer is not affected by a trigger that occurs when counting
16-bit PWM High level width n/fi n=Set value
Cycle time (2
16
-1)/fi fixed
8-bit PWM High level width n X (m+1)/fi n: values set to Timer Ai register's high-order address
Cycle time (2
8
-1)X(m+1)/fi m:values set to Timer Ai register's low-order address
Count start condition External trigger is input
The timer overflows
The count start flag is set (=1)
Count stop condition The count start flag is reset (=0)
Interrupt request
generation timing PWM pulse goes "L"
TAi
IN
pin function Programmable I/O port or trigger input
TAi
OUT
pin function Pulse output Two-phase pulse input.
Read from timer When Timer Ai is read, the value is indeterminate.
Write to timer
When counting has stopped and a value is written to Timer Ai, it is written to both the reload
register and counter.
When counting is in progress and a value is written to Timer Ai, it is written to only the reload
register (Transferred to the counter at next reload time)
Timer A
121
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.85. Timer Ai mode register in pulse width modulation mode
Bit Symbol Bit Name Function R W
TMOD0
TMOD1
MR0
MR1
MR2
MR3
TCK0
TCK1
Operation mode
select bit
Symbol
TAiMR (i=0 to 4) Address
0396
16
to 039A
16
When reset
00000X00
2
Timer Ai mode register (i = 0 to 4)
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
1 1 : Pulse width modulator (PWM) mode
b1 b0
External trigger
select bit (Note 1) 0 : Falling edge of TAi
IN
input signal (Note 2)
1 : Rising edge of TAi
IN
input signal (Note 2)
Note 1: Valid only when the TAi
IN
pin is selected by the event trigger select bit
(addresses 0382
16
, 0383
16
).
Note 2: Set the corresponding port direction register to "0".
Trigger select bit 0 : Count start flag is valid
1 : Selected by event/trigger select register
O O
O O
Count operation type
select bit
b7 b6
0 0 : f1
0 1 : f8
1 0 : f32
1 1 : fc32
O O
16/8 PWM mode
select bit 0 : Functions as a 16-bit PWM
1 : Functions as an 8-bit PWM
1 ( Must always be "1" in PWM mode)
Figure 1.86. Example of a 16-bit pulse width modulator operation
(2 – 1)
16
Count source
TA
iIN
pin
input signal
PWM pulse output
from TA
iOUT
pin
Condition : Reload register = 0003
16
, when external tr igger
(rising
edge of TAi
IN
pin input signal) is selected
Trigger is not generated by this signal
“H”
“H”
“L”
“L”
Timer Ai interrupt
request bit
“1”
“0”
Cleared to “0” when interrupt request is accepted, or cleared by software
f
i
: Frequency of count source
(f
1
, f
8
, f
32
, f
C32
)
16
to FFFE
16
n/fi
Note: n = 0000
/fi
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
122
Figure 1.87. Example of an 8-bit pulse width modulator operation
Count source (Note1)
TA
iIN
pin input signal
Underflow signal of
8-bit prescaler (Note2)
PWM pulse output
from TA
iOUT
pin
"H"
"H"
"H"
"L"
"L"
"L"
"1"
"0"
Timer Ai interrupt
request bit
Cleared to "0" when interrupt request is accepted, or cleared by software
f
i
: Frequency of count source
(f
1
, f
8
, f
32
, f
C32
)
Note 1: The 8-bit prescaler counts the count source.
Note 2: The 8-bit pulse width modulator counts the 8-bit prescaler's underflow signal.
Condition : Reload register high-order 8 bits = 0216
Reload register low-order 8 bits = 0216
External trigger (falling edge of TAi
IN
pin input signal) is selected
(m
+ 1)) / fi
((2 - 1) x
8
Note 3: m = 0016 to FE16; n = 0016 to FE16
(m + 1) / fi
(n x (m + 1)) / fi
Timer A
123
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Precautions
Timer mode
The value of the counter can be read, with arbitrary timing, by reading the Timer Ai register while a count is
in progress.
Reading the Timer Ai register with the reload timing gets “FFFF16”.
After setting a value in the Timer Ai register, a proper value can be read with the counter stopped before it
starts counting .
Event counter mode
The value of the counter can be read, with arbitrary timing, by reading the Timer Ai register while a count is
in progress.
Reading the Timer Ai register with the reload timing gets “FFFF16” by underflow or “000016” by overflow.
After setting a value in the Timer Ai register, a proper value can be read with the counter stopped before it
starts counting .
Reset the timer when counting has stopped in free run type.
If using “Free-Run type”, the timer register contents may be unknown when counting begins. Set the timer
value immediately after counting has started.
Example if the up/down count is not switched:
• Enable the “Reload” function and write to the timer register before counting begins.
• Rewrite the value to the timer register immediately after counting has started.
• If counting up, rewrite “000016” to the timer register.
• If counting down, rewrite “FFFF16” to the timer register. This will cause the same operation as “Free-Run
type”.
Example if the up/down count is switched:
• Use the “Reload type” operation until the first count pulse is input.
• Switch to “Free-Run type”.
One-shot timer mode
Setting the count start flag to “0” while a count is in progress causes as the following:
• The counter stops counting and a content of reload register is reloaded.
• The TAiOUT pin outputs “L” level.
• The interrupt request generated and the Timer Ai interrupt request bit goes to “1”.
The output from the one-shot timer synchronizes with the count source generated internally. Therefore,
when an external trigger has been selected, a delay of one cycle of count source (maximum) occurs
between the trigger input to the TAiIN pin and the one-shot timer output.
Timer A
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
124
The Timer Ai interrupt request bit goes to “1” if the timer’s operation mode is set using any of the following
procedures:
• Selecting one-shot timer mode after reset.
• Changing operation mode from timer mode to one-shot timer mode.
• Changing operation mode from event counter mode to one-shot timer mode.
Therefore, to use Timer Ai interrupt (interrupt request bit), set Timer Ai interrupt request bit to “0” after the
above listed changes have been made.
If a trigger occurs while a count is in progress, after the counter performs one down count following the
reoccurrence of a trigger, the reload register contents are reloaded, and the count continues.
To generate a trigger while a count is in progress, generate the second trigger after a period longer than
one cycle of the timer’s count source after the previous trigger occurred.
Pulse modulation mode
The Timer Ai interrupt request bit becomes “1” if setting operation mode of the timer in compliance with any
of the following procedures:
• Selecting PWM mode after reset.
• Changing operation mode from timer mode to PWM mode.
• Changing operation mode from event counter mode to PWM mode.
Therefore, to use Timer Ai interrupt (interrupt request bit), set Timer Ai interrupt request bit to “0” after the
above listed changes have been made.
Setting the count start flag to “0” while PWM pulses are being output causes the counter to stop counting. If
the TAiOUT pin is outputting an “H” level in this instance, the output level goes to “L”, and the Timer Ai
interrupt request bit goes to “1”. If the TAiOUT pin is outputting an “L” level in this instance, the level does
not change, and the Timer Ai interrupt request bit does not becomes “1”.
Serial Communication
125
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Serial Communication
Serial I/O is configured as four channels: UART0 to UART3.
UART0 to UART3 have an exclusive timer to generate a transfer clock so they can operate independently of one
another.
Figure 1.88 shows the block diagram of UARTi (i = 0 to 3).
UARTi has two operation modes:
• Clock synchronous serial I/O mode
• Clock asynchronous serial I/O (UART) mode.
The contents of the serial I/O mode select bits (bits 0 to 2 at address 03A816, 036816, 033816, 032816) determine
whether UARTi is used as a clock synchronous serial I/O or as a UART. It also has the bus collision detection
function that generates an interrupt request if the TxD pin and RxD pin are in different levels.
Figure 1.89 to Figure 1.93 show the UARTi related-registers.
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
126
Figure 1.88. UARTi block diagram
ni : Values set to UARTi bit rate generator (UiBRG)
RxDi
Reception
control circuit
Transmission
control circuit
1 / (ni+1)
1/16
1/16
1/2
Bit rate
generator
Clock synchronous type
(when internal clock is selected)
UART reception
Clock synchronous type
UART transmission
Clock synchronous type
Clock synchronous type
(when internal clock is selected)
Clock synchronous type
(when external clock is
selected)
Receive
clock
Transmit
clock
CLKi
C
TSi / RTSi
f
1
f
8
f
32
Vcc
RTSi
CTSi
TxDi
RxD polarity
reversing circuit TxD
polarity
reversing
circuit
CTS/RTS disabled
CTS/RTS disabled
CTS/RTS
selected
CLK
polarity
reversing
circuit
Internal
External
Clock source selection Transmit/
receive
unit
(Note)
Note :UART 2 is not CMOS output but N channel open drain output.
SP SP
PAR
2SP
1SP
UART
UART
(7 bits)
UART
(8 bits)
UART(7 bits)
UART
(9 bits)
Clock
synchronous
type
Clock
synchronous type
Data bus low-order bits
TxDi
UARTi transmit register
PAR
disabled
PAR
enabled
D
8
D
7
D
6
D
5
D
4
D
3
D
2
D
1
D
0UARTItransmit buffer
register
UART
(8 bits)
UART
(9 bits)
Clock
synchronous type
UARTi receive
buffer register
UARTi receive register
2SP
1SP
UART
(7 bits)
UART
(8 bits) UART(7 bits)
UART
(9 bits)
Clock
synchronous type
Clock
synchronous type
R
xDi
UART
(8 bits)
UART
(9 bits)
Address 03AF
16
Address 03AE
16
Address 036F
16
Address 036E
16
Address 033F
16
Address 033E
16
Address 032F
16
Address 032E
16
Address 03AB
16
Address 03AA
16
Address 036B
16
Address 036A
16
Address 033B
16
Address 033A
16
Address 032B
16
Address 032A
16
Data bus high-order bits
D
7
D
6
D
5
D
4
D
3
D
2
D
1
D
0
D
8
0000000
SP SP
PAR
"0"
Reverse
No reverse
Error signal
output circuit
RxD data
reverse circuit
Error signal output
enable
Error signal output
disable
Reverse
No reverse
Logic reverse circuit + MSB/LSB conversion circuit
Logic reverse circuit + MSB/LSB conversion circuit
PAR
enabled
PAR
disabled
UART
Clock
synchronous
type
TxD data
reverse circuit
SP : Stop bit
PAR : Parity bit
i : 0 to 3
Serial Communication
127
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.89. Serial I/O-related registers (1)
Bit Symbol Function
(clock synchronous serial I/O mode) Function
(UART mode) R W
_ _
Symbol
U0TB
U1TB
U2TB
U3TB
Address
03AB16, 03AA16
036B16, 036A16
033B16, 033A16
032B16, 032A16
When reset
Indeterminate
Indeterminate
Indeterminate
Indeterminate
UARTi transmit buffer register (i= 0 to 3) (Note)
b7
(b15) (b8) b0b7 b0
Transmit data X O
Nothing is assigned.
Write "0" when writing to these bits. The values are indeterminate when read.
Bit
Symbol
Function
(clock synchronous
serial I/O mode)
Function
(UART mode) R W
_ _
Symbol
U0RB
U1RB
U2RB
U3RB
Address
03AF16, 03AE16
036F16, 036E16
033F16, 033E16
032F16, 032E16
When reset
Indeterminate
Indeterminate
Indeterminate
Indeterminate
UARTi receive buffer register (i= 0 to 3) (Note)
b7
(b15) (b8) b0b7 b0
O X
Nothing is assigned.
Write "0" when writing to these bits. The values are indeterminate when read.
Note: Use MOV instruction to write to this register.
ABT
OER
FER
PER
SUM
Arbitration lost detecting flag
(Note 1)
Overrun error flag (Note 2)
Framing error flag (Note 2)
Parity error flag (Note 2)
Error sum flag (Note 2)
0 : Not detected
1 : Detected
0 : No overrrun error
1 : Overrun error
Invalid
Invalid
Invalid
Invalid
0 : No overrun error
1 : Overrun error
0 : No framing error
1 : Framing error
0 : No parity error
1 : Parity error
0 : No error
1 : Error
Receive data Receive data
O O
O X
O X
O X
O X
Bit name
Note 1: Only "0" can be written to this bit.
Note 2: Bits 15 to 12 are set to "00002" when the serial I/O mode select bit (bits 0 to 2 at
addresses 03A816, 036816, 033816, 032816) are set to "0002" or the receive enable bit is
set to "0".
Bits 14 and 13 are also set to "0" when the lower byte of the UARTi receive buffer
register (addresses 03AE16, 036E16, 033E16, 032E16) is read.
Transmit data
X O
Transmit data (9th bit)
Receive data (9th bit) O X
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
128
Figure 1.90. Serial I/O-related registers (2)
Bit Symbol Function
(clock synchronous
serial I/O mode) Function
(UART mode) R W
Symbol
UiMR (i = 0 to 3) Address
03A816, 036816, 033816, 032816
UARTi transmit/receive mode register (i= 0 to 3)
b7 b0
O O
Note 1: Set the corresponding port direction register.
Note 2: Normally set to "0".
When reset
0016
Bit Name
SMD0
SMD1
SMD2
CKDIR
STPS
PRY
PRYE
IOPOL
Serial I/O mode
select bit
Internal/external
clock select bit
Stop bit length
select bit
Odd/even parity
select bit
Parity enable bit
TxD, RxD input/
output polarity
switch bit (Note 2)
0 0 0: Serial I/O invalid
0 0 1: Serial I/O mode
0 1 0: I2C mode
Inhibited except in cases
listed above
0 : Internal clock
1 : External clock (Note 1)
Invalid
Invalid
Invalid
0 : Normal
1 : Reversed
0 0 0: Serial I/O invalid
1 0 0: Transfer data 7 bits long
1 0 1: Transfer data 8 bits long
1 1 0: Transfer data 9 bits long
Inhibited except in cases listed
above
0 : Internal clock
1 : External clock (Note 1)
0 : One stop bit
1 : Two stop bits
Valid when bit 6 = "1"
0 : Odd parity
1 : Even parity
0 : Parity disabled
1 : Parity enabled
b2 b1 b0
b2 b1 b0
O O
O O
O O
O O
O O
O O
O O
When reset
Indeterminate
Bit Symbol Function Values that can be set R W
Symbol
UiBRG (i = 0 to 3) Address
03A916, 036916, 033916, 032916
UARTi bit rate generator (i= 0 to 3) (Notes 1, 2)
b7 b0
X O
Assuming that set values = n, BRGi divides
the count source by n + 1
Note 1: Use MOV instruction to write to this register
Note 2: Write a value to this register while transmit/receive is stopped.
0016 to FF16
b1b2
b3b4b5b6
Serial Communication
129
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.91. Serial I/O-related registers (3)
Bit Symbol Function
(clock synchronous
serial I/O mode)
Function
(UART mode) R W
Symbol
UiC1 (i = 0 to 3) Address
03AD16, 036D16, 033D16, 032D16
UARTi transmit/receive control register 1 (i= 0 to 3)
O O
When reset
0216
Bit Name
TE
TI
RE
RI
UiIRS
UiRRM
UiLCH
UiERE
Transmit enable bit
Transmit buffer empty
flag
Receive enable bit
Receive complete flag
UARTi transmit interrupt
cause select bit
UARTi continuous
receive mode enable bit
Data logic select bit
Error signal output
enable bit
0 : Transmit disabled
1 : Transmit enable
0 : Data present in transmit
buffer register
1 : No data present in
transmit buffer register
0 : Receive disabled
1 : Receive enabled
0 : Data packet in receive
buffer register
1 : No data packet in
receive buffer register
0 : Transmit buffer empty
(TI =1)
1 : Transmit buffer
completed ( TXEPT =1)
0 : Continuous receive
mode disabled
1 : Continuous receive
mode enabled
0 : No reverse
1 : Reverse
O X
O O
O O
O X
O O
O O
O O
Set to "0"
0 : Output disabled
1 : Output enabled
Bit
Symbol
Function
(clock synchronous
serial I/O mode) Function
(UART mode) R W
Symbol
UiC0 (i = 0 to 3) Address
03AC16, 036C16, 033C16, 032C16
UARTi transmit/receive control register 0 (i= 0 to 3)
O O
Note 1: Set the corresponding port direction register to "0".
Note 2: UART2 transfer pin (TxD2:P7
0
and SCL2:P7
1
) is N-channel open drain output. It cannot
be set to CMOS output.
Note 3: Valid only in clock synchronous serial I/O mode and 8-bit UART mode.
Note 4: The corresponding port register and port direction register are invalid.
When reset
0816
Bit Name
CLK0
CLK1
CRS
TXEPT
CRD
NCH
(Note 2)
CKPOL
UFORM
BRG count source
select bit
CTS/RTS function
select bit
Transmit register
empty flag
CTS/RTS disable bit
Data output select bit
CLK polarity select bit
Transfer format
select bit (Note 3)
0 0 : f1 is selected
0 1 : f8 is selected
1 0 : f32 is selected
1 1 : Invalid
Valid when bit 4 = "0"
0 : CTS is selected (Note 1)
1 : RTS is selected (Note 4)
0 : Data present in transmit register
1 : No data present in transmit register
0 : CTS/RTS function enabled
1 : CTS/RTS function disabled
0 : TxDi/SDAi and SCLi pin is CMOS output
1 : TxDi/SDAi and SCLi pin is N-channel open drain output
0 : Transmit data is output at falling edge of
transfer clock and receive data is input at
rising edge
1 : Transmit data is output at rising edge of
transfer clock and receive data is input at
falling edge
0 : LSB first
1 : MSB first
b1 b0
O O
O O
O X
O O
O O
O O
O O
Set to "0"
b7 b0
b1b2
b3b4b5b6
b7 b0
b1b2
b3b4b5b6
Set to "0"
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
130
Figure 1.92. Serial I/O-related registers (4)
Bit Symbol Function
(clock synchronous
serial I/O mode)
Function
(UART mode) R W
Symbol
UiSMR (i = 0 to 3) Address
03A7
16
, 0367
16
, 0337
16
, 0327
16
UARTi special mode register (i= 0 to 3)
O O
Note 1: Only "0" may be written
Note 2: UART0 Timer A3 underflow signal, UART1: Timer A4 underlfow signal, UART2 :Timer A0
underflow signal.
When reset
00
16
Bit Name
IICM
ABC
BBS
LSYN
ABSCS
ACSE
SSS
I2C mode select bit
Arbitration lost detecting
flag control bit
Bus busy flag
SCLL sync output
enable bit
Bus collision detect
sampling clock
select bit
Auto-clear function
select bit of transmit
enable bit
Transmit start condition
select bit
0 : Normal mode
1 : I
2
C mode
0 : Update per bit
1 : Update per byte
0 : STOP detected
1 : START detected
0 : Disabled
1 : Enabled
Set to "0"
Set to "0"
Set to "0"
O O
O O
O O
O O
O O
_ _
O O
Set to "0"
Set to "0"
Set to "0" (Note 1)
Set to "0"
0 : Rising edge of transfer clock
1 : Timer Ai underflow signal
(Note 2)
0 : No auto clear function
1 : Auto clear when bus occurs
0 : Ordinary
1 : Falling edge of RxDi
Bit Symbol Function R W
Symbol
UiSMR2 (i = 0 to 3) Address
03A6
16
, 0366
16
, 0336
16
, 0326
16
UARTi special mode register 2 (i= 0 to 3)
When reset
00
16
Bit Name
IICM2
CSC
SWC
ALS
STC
SWC2
SDHI
I2C mode select bit 2
Clock synchronous bit
SCL wait output bit
SDA output stop bit
UARTi initialize bit
SCL Wait output bit 2
SDA output inhibit bit
0 : NACK/ACK interrupt (DMA source-ACK)
Transfer to receive buffer at the rising edge
of last bit of receive clock. Receive interrupt
occurs at the rising edge of last bit of receive
clock.
1 : UART transfer/receive interrupt (DMA
source-UART receive) Transfer to receive
buffer at the falling edge of last bit of receive
clock. Receive interrupt occurs at the falling
edge of last bit of receive clock
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
0 : UARTi clock
1 : 0 output
0 : Disabled
1 : Enabled (high impedance)
O O
O O
O O
O O
O O
O O
O O
_ _
b7 b0
b1b2
b3b4b5b6
b7 b0
b1b2
b3b4b5b6
Nothing is assigned.
Write "0" when writing to this bit. The value is indeterminate if read.
Nothing is assigned.
Write "0" when writing to this bit. The value is indeterminate if read.
Serial Communication
131
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.93. Serial I/O-related registers (5)
Bit Symbol Function R W
Symbol
UiSMR3 (i = 0 to 3) Address
03A5
16
, 0365
16
, 0335
16
, 0325
16
UARTi special mode register 3 (i= 0 to 3)
Note 1: Set SS function after setting CTS/RTS disable bit (bit 4 of UARTi transfer/receive control register 0)
Note 2: Only "0" may be written.
Note 3: These bits are used for SDAi (TxDi) output digital delay when using UARTi for I
2
C interface.
Otherwise, set these to "000".
Note 4: When external clock is selected, delay is increased by approximately 100ns.
When reset
00
16
Bit Name
SSE
CKPH
DINC
NODC
ERR
DL0
DL1
DL2
SS port function enable
bit (Note 1)
Clock phase set bit
Serial input port set bit
Clock output select bit
Fault error flag
SDA (TxDi) digital delay
time set bit (Notes 3,4)
0 : SS function disabled
1 : SS function enabled
0 : No clock delay
1 : Clock delay
0 : Select TxDi and RxDi (master mode)
1 : Select STxDi and SRxDi (slave mode)
0 : CLKi is CMOS output
1 : CLKi is N-channel open drain output
0 : No fault error
1 : Fault error (Note 2)
0 0 0 : No delay
0 0 1 : 2-cycle of 1/f(Xin)
0 1 0 : 3-cycle of 1/f(Xin)
0 1 1 : 4-cycle of 1/f(Xin)
1 0 0 : 5-cycle of 1/f(Xin)
1 0 1 : 6-cycle of 1/f(Xin)
1 1 0 : 7-cycle of 1/f(Xin)
1 1 1 : 8-cycle of 1/f(Xin)
O O
O O
O O
O O
O O
O O
O O
O O
b7 b6 b5
Bit Symbol Function R W
Symbol
UiSMR4 (i = 0 to 3) Address
03A4
16
, 0364
16
, 0334
16
, 0324
16
UARTi special mode register 4 (i= 0 to 3)
When reset
00
16
Bit Name
STAREQ
RSTAREQ
STPREQ
STSPSEL
ACKD
ACKC
SCLHI
SWC9
Start condition generate
bit (Note)
Restart condition
generate bit (Note)
Stop condition generate
bit (Note)
SCL, SDA output select
bit
ACK data bit
ACK data output enable
bit
SCL output stop enable
bit
SCL wait output bit 3
0 : Clear
1 : Start
0 : Clear
1 : Start
0 : Clear
1 : Start
0 : Ordinal block
1 : Start/stop condition generate block
0 : ACK
1 : NACK
0 : SI /O data output
1 : ACKD output
0 : Disabled
1 : Enabled
0 : SCL "L" hold disabled
1 : SCL "L" hold enabled
O O
O O
O O
O O
O O
O O
O O
O O
Note: These bits automaticall
y
become "0" when a start condition is
g
enerated.
b7 b0
b1b2
b3b4b5b6
b7 b0
b1b2
b3b4b5b6
to "1".
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
132
Clock synchronous serial I/O mode
The clock synchronous serial I/O mode uses a transfer clock to transmit and receive data. Table 1.44 list
the specifications of the clock synchronous serial I/O mode.
Table 1.44. Clock synchronous serial I/O mode specifications
Note 1: "m" denotes the value 00
16
to FF
16
that is set in the UART bit rate generator.
Note 2: If an overrun error occurs, the UART i receive buffer will have the next data written in. Note
also that the UARTi receive interrupt request bit will not change.
Item Specification
Transfer data format Transfer data length: 8-bits
Transfer clock
W hen internal clock is selected (bit 3 at address 03A8
16
, 0368
16
, 0338
16
, 0328
16
="0"):
fi/2(m+1) (Note 1) fi = f1, f8, f32
W hen external clock is selected (bit 3 at 03A8
16
, 0368
16
, 0338
16
, 0328
16
= "1"):
Input from CLKi pin
Transfer/receive control CTS function/RTS function/CTS, RTS function not used
Transfer start condition
To start transfer, the following criteria must be met:
-Transmit enable bit (bit 0 at 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "1"
-Transmit buffer empty flag (bit 1 at 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "0"
-When CTS function selected, CTS input level = "L"
Furthermore, if external clock is selected, the following requirements must also be met:
-CLKi polarity select bit (bit 6 at 03AC
16
, 036C
16
, 033C
16
, 032C
16
)="0": CLKi input level = "H"
-CLKi polarity select bit (bit 6 at 03AC
16
, 036C
16
, 033C
16
, 032C
16
)="1": CLKi input level = "L"
Receive start condition
To start reception, the following requirement must be met:
-Receive enable bit (bit 2 at 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "1"
-Transmit enable bit (bit 0 at 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "1"
-Transmit buffer empty flag (bit 1 at 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "0"
Furthermore, if external clock is selected, the following requirement must be met:
-CLKi polarity select bit (bit 6 at 03AC
16
, 036C
16
, 033C
16
, 032C
16
)="0": CLKi input level = "H"
-CLKi polarity select bit (bit 6 at 03AC
16
, 036C
16
, 033C
16
, 032C
16
)="1": CLKi input level = "L"
Interrupt request generation
timing
When transmitting:
-Transmit interrupt cause select bit (bit 4 at 3AD
16
, 036D
16
, 033D
16
, 032D
16
) = "0": Interrupt requested
when data transfer from UARTi transfer buffer register to UARTi transmit register is complete
-Transmit interrupt cause select bit (bit 4 at 3AD
16
, 036D
16
, 033D
16
, 032D
16
) = "1": Interrupt requested
when data transmission from UARTi transmit register is complete
When receiving:
-Interrupt requested when data transfer from UART i receive register to UARTi receive buffer register is
completed.
Error detection Overrun error (Note 2)
This error occurs when the next data is ready before contents of UARTi rece ive buffer register are
read out
Select function
CLK polarity selection
Whether transmit data is output/input at the rising edge or falling edge or the transfer clock can be
selected
LSB fi rst/ MS B first selection
Whether transmission/reception begins with bit 0 or bit 7 can be selected
Cont inuous receive mode selection
Reception is enabled simul taneously by a read form the receive buffer register
S witching serial data log
Reverse data when writing to the transmission buffer register or reading the reception buffer register
can selected
TxD, RxD, I/O polarity reverse
This function reverses the TxD port output and RxD port input. All I/O data level is reversed.
Serial Communication
133
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.45 lists the functions of the input/output pins during clock synchronous serial I/O mode. Note that
for a period from when the UARTi operation mode is selected to when transfer starts, the TxDi pin outputs
a “H”. (If the N-channel open drain is selected, this pin is in floating state.)
Figure 1.94. shows the typical transmit receive timings in clock synchronous serial I/O mode.
Table 1.45. Input/output pin functions in clock synchronous serial I/O mode
Pin name Function Method of selection
TxDi (P63, P67,
P70, P74)Serial data
output Outputs dummy data when receiving only.
RxDi (P62, P66,
P71, P75)Serial data inpu t Port P62, P66, P71 and P75 directio n registe r (bits 2 and 6 at address 03EE16, bit 1 a nd 5
at address 03EF16) = "0". Can only be used when transmitting.
CLKi (P61, P65,
P72, P76)
Transfer clock
output Internal/extern al clock s elect bit (bi t 3 at addresse s 03A816, 0368 16, 033816, 032816) = "0"
Transfer clock
input
Inter nal/extern al clock sele ct bit (bi t 3 at addresse s 03A816, 0368 16, 033816, 032816) = "1 "
Port P61, P65, P72and P76 direction registe r (bits 1 and 5 at ad dress 03EE16, bit 2 an d 6
at address 03EF16) = "0"
CTSi/RTSi
(P60, P64, P73,
P77)
CTS input
CTS/RTS disable bit (bit 4 at address 03AC16, 036C16, 033C16, 032C16) = "0"
CTS/RTS function select bit (bit 2 at address 03AC16, 036C16, 033C16, 032C16) = "0"
Port P60, P64, P73 and P77 direction register (bits 0 and 4 at address 03EE16, bit s 3 a nd
7 at address 03EF16) = "0"
RTS out put CTS/RTS disable bit (bit 4 at addresses 03AC 16, 036C16, 033C16, 032C16) = "0"
CTS/RTS function select bit (bit 2 at address 03AC16, 036C16, 033C16, 032C16) = "1"
Programmable
I/O port CTS/RTS disable bit (bit 4 at address 03AC16, 036C16, 033C16, 032C16) = "1"
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
134
Figure 1.94. Typical transmit/receive timing in clock synchronous serial I/O mode
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
Tc
T
CLK
Stopped pulsing because transfer enable bit = “0
Data is set in UARTi transmit buffer register
Tc = TCLK = 2(m + 1) / fi
fi: frequency of BRGi count source (f
1
, f
8
, f
32
)
m: value set to BRGi
Transfer clock
Transmit enable
bit (TE)
Transmit buffer
empty flag (Tl)
CLKi
TxDi
Transmit
register empty
flag (TXEPT)
“H”
“L”
“0”
“1”
“0”
“1”
“0”
“1”
CTSi
The above timing applies to the following settings:
• Internal clock is selected.
• CTS function is selected.
• CLK polarity select bit = “0”.
Transmit interrupt cause select bit = “0”.
Transmit interrupt
request bit (IR)
“0”
“1”
Stopped pulsing because CTS = “H”
Dummy data is set in UARTi transmit buffer register
Transmit enable
bit (TE)
Transmit buffer
empty flag (Tl)
CLKi
RxDi
Receive complete
flag (Rl)
RTSi
“H”
“L”
“0”
“1”
“0”
“1”
“0”
“1”
Receive enable
bit (RE)
“0”
“1”
Receive data is taken in
Transferred from UARTi transmit buffer register to UARTi transmit register
Read out from UARTi receive buffer register
The above timing applies to the following settings:
• External clock is selected.
• RTS function is selected.
• CLK polarity select bit = “0”.
f
EXT
: fre
q
uenc
y
of external clock
Transferred from UARTi receive register
to UARTi receive buffer register
Receive interrupt
request bit (IR)
“0”
“1”
Shown in ( ) are bit symbols.
Transferred from UARTi transmit buffer register to UARTi transmit register
The following conditions are met when the CLKi
input before data reception = “H”
Transmit enable bit “1”
• Receive enable bit “1”
• Dummy data write to UARTi transmit buffer register
Shown in ( ) are bit symbols.
Cleared to “0” when interrupt request is accepted, or cleared by software
Cleared to “0” when interrupt request is accepted, or cleared by software
1 / fEXT
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D
0
D
1
D
2
D
3
D
4
D
5
D
0
D
1
D
2
D
3
D
4
D
5
D
7
D
6
Over run error
flag(OER)
D
6
“0”
“1”
Example of transmit timing when internal clock is selected
Example of receive timing when external clock is selected
Serial Communication
135
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Polarity select function
As shown in Figure 1.95 the CLK polarity select bit (bit 6 at addresses 03AC16, 036C16, 033C16, 032C16)
allows selection of the polarity of the transfer clock.
Figure 1.95. Transfer clock polarity
When CLK polarity select bit = “1”
Note 2: The CLK pin level when not 
 transferring data is “L”.
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D
0
D
0
T
X
D
i
R
X
D
i
CLK
i
When CLK polarity select bit = “0”
Note 1: The CLK pin level when not
transferring data is “H”.
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D
0
T
X
D
i
R
X
D
i
CLK
i
LSB first/MSB first select function
As shown in Figure 1.96, when the transfer format select bit (bit 7 at addresses 03AC16, 036C16, 033C16,
032C16) = “0”, the transfer format is “LSB first”; when the bit = “1”, the transfer format is “MSB first”.
LSB first
When transfer format select bit = “0”
D0
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
D
1
D
2
D
3
D
4
D
5
D
6
D
7
T
X
D
i
R
X
D
i
CLK
i
When transfer format select bit = “1”
D
6
D
5
D
4
D
3
D
2
D
1
D
0
D
7
D
7
D
6
D
5
D
4
D
3
D
2
D
1
D
0
T
X
D
i
R
X
D
i
CLK
i
MSB first
Note: Signals shown apply when the CLK polarity select bit = “0”.
Figure 1.96. Transfer format
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
136
Continuous receive function
If the continuous receive mode enable bit (bit 5 at address 03AD16, 036D16, 033D16, 032D16) is set to “1”,
the unit is placed in continuous receive mode. In this mode, when the receive buffer is read out, the unit
simultaneously goes to a receive enable state without having to set dummy data back to the transmit buffer
register again.
Serial data logic switch function
When the data logic select bit (bit 6 at address 03AD16, 036D16, 033D16, 032D16) = “1”, and writing to the
transmit buffer register or reading from the receive buffer register, data are inverted. Figure 1.97 shows the
example of serial data logic switch timing.
Figure 1.97. Serial data logic switch timing
D0 D1 D2 D3 D4 D5 D6 D7
D0 D1 D2 D3 D4 D5 D6 D7
Transfer clock
TxD
i
(no reverse)
TxDi
(reverse)
“H”
“L”
“H”
“L”
“H”
“L”
•When LSB first
Serial Communication
137
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Clock asynchronous serial I/O (UART) mode
UART mode allows transmitting and receiving data after setting the desired transfer rate and transfer data
format. Table 1.46 lists the specifications of the UART mode.
Table 1.46. Specifications of clock asynchronous serial I/O mode
Note 1: 'm' denotes the value 00
16
to FF
16
that is set to the UARTi bit rate generator.
Note 2: fEXT is input from the CLKi pin.
Note 3: If an overrun error occurs, the next data will be written to the UARTi receive buffer. Also,
the UARTi receive interrupt request bit will not change.
Item Specification
Transfer data format
Character bit (transfer data): 7 bits, 8 bits, or 9 bits as selected
Start bit: 1 bit
Parity bit: odd, even, or neither is selected
Stop bit: 1 bit or 2 bits as selected
Transfer clock
When internal clock is selected (bit 3 at address 03A8
16
, 0368
16
, 0338
16
, 0328
16
= "0"): fi/
16(m+1) (Note 1) fi = f1, f8, f32
Whe n external clock i s selected (bit 3 at address 03A8
16
, 0368
16
, 0338
16
, 0328
16
= "1"):
fEXT/16/(m+1) (Notes 1, 2)
Transmit/receive control CTS function, RTS function, CTS/RTS function chosen to be invalid
Tran smit st a r t conditi on
To start transmission, the following requirements must be met:
-Transmit enable bit (bit 0 at addresses 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "1"
-Transmit buffer empty flag (bit 1 at address 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "0"
-When CTS function is selected CTS input level = "1"
Receive star t conditi on To start receive, the following conditions must be met:
-Receive enable bit (bit 2 at addresses 03AD
16
, 036D
16
, 033D
16
, 032D
16
) = "1"
-Start bit detection
Interrupt request
generation timing
When transmitting
-Transmit interrupt cause select bits (bit 4 at address 03AD
16
, 036D
16
, 033D
16
, 032D
16
) =
"0": Interrupts requested when data transfer from UARTi transfer buffer register to UARTi
transmit register is complete.
-Transmit interrupt cause select bits (bit 4 at address 03AD
16
, 036D
16
, 033D
16
, 032D
16
) =
"1": Interrupts requested when data transmission from UARTi transfer register is complete.
When receiving
-Interrupts requested when data transfer from UARTi receive register to UARTi receive
buffer register is complete.
Error detect ion
Overrun error (Note 3)
This error occurs when the next data is ready before the contents of UARTi receive buffer
register are read out.
F raming error
This error occurs when the number of stop bits set is not detected
Parity error
If parity is enabled this error occurs when the number of "1"s in parity and character bits
does not match the number of "1"s set
Error sum flag
This flag is set (=1) when any overrun, framing, and parity error occurs
Select function
Serial data logic switch
This function reverses the logic of transferred data. Start bit, parity bit and stop bit are not
reversed.
TxD, RxD I/O polarity switch
This function reverses the TxD port output and RxD port input. All I/O data levels are
reversed.
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
138
Table 1.47 lists the functions of the input/output pins during UART mode. Note that the period from when
the UARTi operation mode is selected to when transfer starts, the TxDi pin outputs an “H”. (If the N-
channel open drain is selected, this pin is in floating state.) Figure 1.98 shows typical transmit timings in
UART mode. Figure 1.99 shows typical receive timings in UART mode.
Table 1.47. Input/output pin functions in UART mode
Pin name Function Method of selection
TxDi (P6
3
, P6
7
,
P7
0
, P7
4
)Serial data
output
RxDi (P6
2
, P6
6
,
P7
1
, P7
5
)Serial data input Port P6
2
, P6
6
, P7
1
and P7
5
direction register (bits 2 and 6 at address 03EE
16
, bit 1 and
5 at address 03EF
16
) = “0”. Can be used as an input port when performing
transmission only.
CLKi (P6
1
, P6
5
,
P7
2
, P7
6
)
Programmable
I/O port Internal /ex tern al clo ck sel ec t bit (bit 3 at ad dres se s 03 A8
16
, 0368
16
, 0338
16
, 0328
16
)
= “0”
Transfer clock
input
Inter nal /ex tern al clo ck sel ec t bit (bit 3 at ad dres se s 03 A8
16
, 0368
16
, 0338
16
, 0328
16
)
= “1”
Port P6
1
, P6
5
, P7
2
and P7
6
direction register (bits 1 and 5 at address 03EE
16
, bit 2
and 6 at address 03EF
16
) = “0”
CTSi/RTSi
(P6
0
, P6
4
, P7
3
,
P7
7
)
CTS input
CTS/RTS disable bit (bit 4 at address 03AC
16
, 036C
16
, 033C
16
, 032C
16
) = “0”
CTS/RTS func tio n se lec t bi t (bit 2 at addres s 03AC
16
, 036C
16
, 033C
16
, 032C
16
) = “0”
Port P6
0
, P6
4
, P7
3
and P7
7
direction register (bits 0 and 4 at address 03EE
16
, bit s 3
and 7 at address 03EF
16
) = “0”
RTS out put CTS/RTS disable bit (bit 4 at addres s es 03AC
16
, 036C
16
, 033C
16
, 032C
166
) = “0”
CTS/RTS func tio n se lec t bi t (bit 2 at addres s 03AC
16
, 036C
16
, 033C
16
, 032C
16
) = “1”
Programmable
I/O port CTS/RTS disable bit (bit 4 at address 03AC
16
, 036C
16
, 033C
16
, 032C
16
) = “1”
Serial Communication
139
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.98. Typical transmit timings in UART mode
Transmit enable
bit(TE)
Transmit buffer
empty flag(TI)
Transmit register
empty flag (TXEPT)
Start
bit Parity
bit
TxDi
CTSi
The above timing applies to the following settings :
• Parity is enabled.
• One stop bit.
• CTS function is selected.
Transmit interrupt cause select bit = “1”.
“1”
“0”
“1”
“L”
“H”
“0”
“1”
Tc = 16 (m + 1) / fi or 16 (m + 1) / fEXT
fi : frequency of BRGi count source (f
1
, f
8
, f
32
)
f
EXT
: frequency of BRGi count source (external clock)
m : value set to BRGi
Transmit interrupt
request bit (IR)
“0”
“1”
Cleared to “0” when interrupt request is accepted, or cleared by software
Transmit enable
bit(TE)
Transmit buffer
empty flag(TI)
TxDi
Transmit register
empty flag (TXEPT)
“0”
“1”
“0”
“1”
“0”
“1”
The above timing applies to the following settings :
• Parity is disabled.
Two stop bits.
• CTS function is disabled.
Transmit interru
p
t cause select bit = “0”.
Transfer clock
Tc
Tc = 16 (m + 1) / fi or 16 (m + 1) / fEXT
fi : frequency of BRGi count source (f
1
, f
8
, f
32
)
f
EXT
: frequency of BRGi count source (external clock)
m : value set to BRGi
Transmit interrupt
request bit (IR)
“0”
“1”
Shown in ( ) are bit symbols.
Shown in ( ) are bit symbols.
Tc
Transfer clock
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST PD
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
SP ST PSP D
0
D
1
ST
Stopped pulsing because transmit enable bit = “0”
Stop
bit
Transferred from UARTi transmit buffer register to UARTi transmit register
Start
bit
The transfer clock stops momentarily as CTS is “H” when the stop bit is checked.
The transfer clock starts as the transfer starts immediately CTS changes to “L”.
Data is set in UARTi transmit buffer register
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST SP
D
8
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST D
8
D
0
D
1
ST
SPSP
Transferred from UARTi transmit buffer register to UARTi transmit register
Stop
bit Stop
bit
Data is set in UARTi transmit buffer register.
“0”
SP
Cleared to “0” when interrupt request is accepted, or cleared by software
Example of transmit timing when transfer data is 8 bits long (parity enabled, one stop bit)
Example of transmit timing when transfer data is 9 bits long (parity disabled, two stop bits)
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
140
Figure 1.99. Typical receive timing in UART mode
D
0
Start bit
Sampled "L" Receive data taken in
BRGi count
source
Receive enable bit
RxDi
Transfer clock
Receive
complete flag
RTSi
Stop bit
"1"
"0"
"0"
"1"
"H"
"L"
The above timing applies to the following settings :
Parity is disabled.
One stop bit.
RTS function is selected.
Receive interrupt
request bit "0"
"1"
Transferred from UARTi receive register to
UARTi receive buffer register
Reception triggered when transfer clock
is generated by falling edge of start bit
D
7
D
1
Cleared to "0" when interrupt request is accepted, or cleared by software
Becomes "L" by reading the receive buffer
Example of receive timings when transfer data is 8 bits long (parity disabled, one stop bit)
Serial data logic switch function
When the data logic select bit (bit 6 of address 03AD16, 036D16, 033D16, 032D16) is set to "1", data is
inverted when writing to the transmission buffer register or reading the reception buffer register. Figure
1.100 shows an example of timing for switching serial data logic.
ST : Start bit
P : Parity bit
SP : Stop bit
D0 D1 D2 D3 D4 D5 D6 D7 P SPST
SPST D3 D4 D5 D6 D7 PD0 D1 D2
Transfer clock
TxD
i
(no reverse)
TxD
i
(reverse)
“H”
“L”
“H”
“L”
“H”
“L”
• When LSB first, parity enabled, one stop bit
Figure 1.100. Timing for switching serial data logic
Serial Communication
141
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
TxD, RxD I/O polarity reverse function
This function reverses the TxD pin output and RxD pin input. The level of any data input or output including
the start bit, stop bits and parity bit, is reversed. Set this function to “0”, (not to reverse) for normal use.
Bus collision detection function
This function samples the output level of the TxD pin and the input level of the RxD pin at the rising edge of
the transfer clock. If their values are different, then an interrupt request occurs. Figure 1.101 shows an
example of detection timing of a bus collision in UART mode.
Figure 1.101. Detection timing of a bus collision in UART mode
ST : Start bit
SP : Stop bit
ST
ST
SP
SP
Transfer clock
TxD
i
RxDi
Bus collision detection 
interrupt request signal
“H”
“L”
“H”
“L”
“H”
“L”
“1”
“0”
Bus collision detection 
interrupt request bit
“1”
“0”
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
142
UART mode (compliant with the SIM interface)
The SIM interface is used for connecting the microcomputer with a memory card IC or a similar device.
Adding some extra settings in UART mode allows the user to effect this function. Table 1.48 shows the
specifications of UART mode compliant with SIM interface. Figure 1.102 shows typical transmit/receive
timing in UART mode compliant with SIM interface.
Table 1.48. Specifications of UART mode compliant with the SIM interface
Note 1: 'm' denotes the value 0016 to FF16 that is set to the UARTi bit rate generator
Note 2: fEXT is input from the CLKi pin.
Item Specification
Transfer data format
Transfer data 8-bit UA R T mo de (bit s 2 to 0 of addres s 03 A816, 036816, 033816, 032816 = "10 12")
One stop bit (bit 4 of addresses 03A816, 036816, 033816, 032816 = "0")
With the direct format:
-Set parity to "even" (bits 5 and 6 of addresses 03A816, 036816, 033816, 032816 = "1")
-Set data logic to "direct" (bit 6 of address 03AD16, 036D16, 033D16, 032D16 = "0")
-Set transfer format to LSB (bit 7 of address 03AC16, 036C16, 033 C16, 032C16 = "0")
With the inverse format:
-Set parit y to "o dd" (bit 5 and 6 of address 03A816, 036816, 0338 16, 032816 = "0" and "1" respec-
tively)
-Set data logic to "inverse" (bit 6 of address 03AD16, 036D16, 033D16, 032D16 = "1")
-Set transfer format to MSB (bit 7 of address 03AC16, 036C16, 033C16, 032C16 = "1")
Transfer clock
With the internal clock selected (bit 3 of address 03A816, 036816, 033816, 032816 = "0"): fi/
16(m+1) (Note 1): fi=f1, f8, f32
With an external clock selected (bit 3 of address 03A816, 036816, 033816, 032816 = "1"): fEXT/
16(m+1) (Notes 1,2)
Transmit/receive
control Disable the CTS and RTS function (bit 4 of address 03AC16, 036C16, 033C16, 032C16 = "1")
Other settings
Set transmission interrupt factor to ì transmission completedî (bit 4 of address 03AD16, 036D16,
033D16, 032D16 = "1")
Set N-channel open drain output to TxD pin in UART0, 1, 3 (bit 5 of address 03AC
16
,
036C16, 032C16 = "1")
Tran sm it st a r t
condition Transmit enable bit (bit 0 of address 03AD16, 036 D16, 033D16, 032D16 = "1")
Transmit buffer empty flag (bit 1 of address 03AD16, 036D16, 033D16, 032D16 = "0")
Receive st a r t conditi on Receive enable bit (bit 2 of address 03AD16, 036D16, 033D16, 032D16 = "1")
Detection of a start bit
Interrupt request
generation timing
When transmitting
-When data transmission from the UART0 to UART3 transfer register is completed (bit 4 of
address 03AD 16, 036D16, 033D16, 032D16 = "1")
When receiving
-When data transfer from the UART0 to UART3 receive register to the UART0 to UART3
receive buffer register is completed .
Error detection
Overrun error (See UART spec if ic atio ns )
Framing error (See UART specifications)
Parity error (See UART specif ic ati ons )
-On the reception side, an "L" level is output from the TxDi pin by use of the pa rity error signal
output fun ctions (bi t 7 o f ad dress 03AD16, 03 6D 16, 033 D16, 032D16 = "1") when a p arit y e rror i s
detected.
-On the transmission side, a parity error is detected by the level of input to the RxDi pin when a
transmit interrupt occurs
The error sum flag (See UART specifications)
Serial Communication
143
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.102. Typical transmit/receive timing in UART mode compliant with the SIM interface
T
ransmit enable
bit(TE)
T
ransmit buffer
e
mpty flag(TI)
T
ransmit register
e
mpty flag (TXEPT)
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST P
Start
bit Parity
bit
The above timing applies to the following settings :
Parity is enabled.
One stop bit.
Transmit interrupt cause select bit = "1".
"0"
"1"
"0"
"1"
"0"
"1"
Tc = 16 (n + 1) / fi or 16 (n + 1) / f
EXT
fi : frequency of BRGi count source (f
1
, f
8
, f
32
)
f
EXT
: frequency of BRGi count source (external clock)
n : value set to BRGi
T
ransmit interrupt
request bit (IR)
"0"
"1"
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST P
Shown in ( ) are bit symbols.
Tc
T
ransfer clock
SP
Stop
bit
Data is set in UARTi transmit buffer register
SP
A "L" level returns from SIM card due
to the occurrence of a parity error.
The level is detected by the
interrupt routine.
The level is detected by
the interrupt routine.
Receive enable
b
it (RE)
R
eceive complete
f
lag (RI)
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST P
Start
bit Parity
bit
T
xD
i
The above timing applies to the following settings :
Parity is enabled.
One stop bit.
Transmit interrupt cause select bit = "0".
"0"
"1"
"0"
"1"
Tc = 16 (n + 1) / fi or 16 (n + 1) / f
EXT
fi : frequency of BRGi count source (f
1
, f
8
, f
32
)
f
EXT
: frequency of BRGi count source (external clock)
n : value set to BRGi
Receive interrupt
request bit (IR)
"0"
"1"
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST PSP
Shown in ( ) are bit symbols.
Tc
T
ransfer clock
SP
Stop
bit
A "L" level returns from TxD
2
due to
the occurrence of a parity error.
RxD
i
Read to receive buffer Read to receive buffer
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST P
S
ignal conductor level
(
Note 2)
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST PSP
SP
D
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST PD
0
D
1
D
2
D
3
D
4
D
5
D
6
D
7
ST PSP
SP
T
xD
i
RxD
i
S
ignal conductor level
(Note 2)
Note 2: Equal in waveform because TxDi and RxDi are connected.
Transferred from UARTi transmit buffer register to UARTi transmit register
Cleared to "0" when interrupt request is accepted, or cleared by software
Cleared to "0" when interrupt request is accepted, or cleared by software
Note 1: After writing to the transfer buffer at above timing, transmission starts at the timing of BRG overflow.
(Note 1)
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
144
Parity error signal function output
With the error signal output enable bit (bit 7 of addresses 03AD16, 036D16, 033D16, 032D16) set to “1”,
output an “L” level from the TxDi pin when a parity error is detected. When this occurs, the generation of a
transmit complete interrupt changes to the detection of a parity error signal. Figure 1.103 shows the output
timing of the parity error signal.
ST : Start bit
P : Parity bit
SP : Stop bit
D0 D1 D2 D3 D4 D5 D6 D7 P SPST
Hi-Z
Transfer
clock
RxDi
TxDi
Receive
complete flag
“H”
“L”
“H”
“L”
“H”
“L”
“1”
• LSB first
“0”
Figure 1.103. Parity error signal output timing
Direct format/inverse format
Connecting the SIM card allows switching between direct format and inverse format. If the direct format is
selected, D0 data is output from TxDi. If the inverse format is selected, D7 is inverted and output from TxDi.
Figure 1.104 shows the SIM interface format. Figure 1.105 shows an example of connect the SIM interface.
Connect TxDi and RxDi and apply pull-up.
Figure 1.104. SIM interface format
Figure 1.105. Connecting the SIM interface
P : Parity bit
D0 D1 D2 D3 D4 D5 D6 D7 P
Transfer
clcck
TxDi
(direct)
TxDi
(inverse) D7 D6 D5 D4 D3 D2 D1 D0 P
Microcomputer SIM card
TxD
i
RxD
i
(Note)
Note :Set TxD pin an N-channel open drain output and add a pull-up resistance.
Serial Communication
145
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
UARTi Special Mode Register
UARTi (i=0 to 3) operate the I2C interface (simple I2C bus) using the UARTi special mode register (address
03A716, 036716, 033716, 032716) and UARTi special mode register 2 (addresses 03A616, 036616, 033616,
and 032616). UARTi address special functions using UARTi special mode register 3 (address 03A516,
036516, 033516, and 032516).
I2C Bus interface mode
The I2C bus interface mode is provided with UARTi. When the I2C mode select bit (bit 0 in addresses
03A716, 036716, 033716, and 032716) is set to “1”, the I2C bus interface circuit is enabled.
To use the I2C bus, set the SCLi and the SDAi of the master and slave to output. Also for UART0, 1 and 3,
set the data output select bit (bit 5 in address 03AC16, 036C16, and 032C16) to N-channel open drain
output. Note: UART2 TxD and RxD (P70 and P71) are always N-channel open drain outputs and require
external pull-up resistors.
Table 1.49 shows the relationship of the I2C mode select bit to control. To use the chip in the clock synchro-
nized serial I/O mode or UART mode, always set this bit to “0”. Figure 1.106 shows a block diagram of I2C
mode.
Table 1.49. I2C features
Note 1: Wh en using I
2
C mode, set 0 1 0 in bits 2, 1, 0 of the UAR Ti tra ns mi t/rec ei ve mod e regi st er. Dis ab le th e CTS /
RTS function. Sele ct MSB first func tion .
Note 2: To switch from one factor to another:
1. Disable the interrupt of the corresponding number.
2. Switch to another factor.
3. Reset the interrupt request flag of the corresponding number.
4. Set the interrupt level of the corresponding number.
Note 3: Set an initial value of SDA transmission output when I
2
C mode (I
2
C mode select bit = "1") is valid and serial
I/O is invalid.
Function Normal mode (IICM=0) I
2
C mode (IICM=1) (Note 1)
1Cause of inte rrupt num ber 3 and 9
(Note 2) Bus collision detection Start condition detection or stop
condition detection
2Cause of interrupt number 13 and
15 (Note 2) UARTi transmit No acknowledgement detection
(NACK)
3Cause of interrupt number 2 and
21 (Note 2) UARTi receive Acknowledgment detection (ACK)
4 UARTi transmit output delay Not delayed Delayed
5P6
3
, P6
7
, P7
0
, P7
4
at the same
time UARTi is in use TxDi (output) SDAi (input/output) (Note 3)
6P6
2
, P6
6
, P7
1
, P7
5
at the same
time UARTi is in use RxDi (input) SCLi (input/output)
7P6
1
, P6
5
, P7
2
, P7
6
at the same
time UARTi is in use CLKi P6
1
, P6
5
, P7
2
, P7
6
8 DMA1 factor at the same time UARTi receive Acknowledgement detection (ACK)
9 Noise filter width 15 ns 50 ns
10 Reading P7
1
, P7
5
Reading the terminal when 0 is
assigned to the direction register
Reading the terminal regardless of
the value of the direction register
11 Initial value of UARTi output "H" level (when 0 is assigned to
CLKi polarity select bit)
The value set in la tch P7
0
, P7
4
when
the port is selected (Note 3)
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
146
Figure 1.106. I2C mode functional block diagram
Selector I/O
Timer
delay
UARTi
Reception register
External clock
Arbitration
Start condition detection
Stop condition detection
Falling edge
detection
UARTi transmission/
NACK interrupt
request
UARTi reception/ACK
interrupt request
DMAi request
9th pulse
Port reading
* With IICM set to 1, the port terminal is to be readable
even if 1 is assigned to P71 of the direction register.
L-synchronous
output enabling bit
Bus collision/start, stop
condition detection
interrupt request
Bus collision
detection
Noize
Filter
I/0
Noize
Filter
TXDi/SDA
RxDi/SCL
CLK
control
Internal clock
UARTi
Selector
UARTi
I/0
Timer
CLKi
Data register
D
TQ
DTQ
DTQ
NACK
ACK
UARTi
UARTi
R
IICM=1
IICM=0
IICM=1
IICM=0
IICM=1 and
IICM2=0
IICM=0
IICM=1
IICM=1
IICM=0
S
RQ
Bus
busy
IICM=1
IICM=0
ALS
R
S
SWC
Falling edge of 9th pulse
IICM=1 and
IICM2=0
IICM=0 or IICM2=1
IICM=0 or
IICM2=1
SWC2
SDHI
To DMAi
To DMAi
Selector
Transmission register
UARTi
Noize
Filter
Serial Communication
147
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
UARTi Special Mode Register
Bit 0 is the I2C mode select bit 1. When set to “1”, ports operate respectively as the SDAi data transmit/
receive pin, SCLi clock I/O pin and port. A delay circuit is added to SDAi transmission output, therefore after
SCLi is at “L” level, SDAi output changes. Port (SCLi) is designed to read pin level regardless of the content
of the port direction register. SDAi transmission output is initially set to port in this mode. Furthermore,
interrupt factors for the bus collision detection interrupt and UARTi transmission interrupt change respec-
tively to the start/stop condition detection interrupts, acknowledge non-detection interrupt and acknowledge
detection interrupt.
The start condition detection interrupt is generated when the falling edge at the SDAi pin is detected while
the SCLi pin is in “H” state. The stop condition detection interrupt is generated when the falling edge at the
SDAi pin is detected while the SCLi pin is in the “H” state.
The acknowledge non-detect interrupt is generated when the “H” level at the SDAi pin is detected at the 9th
rise of the transmission clock. The acknowledge detect interrupt is generated when the “L” level at the SDAi
pin is detected at the 9th fall of the transmission clock. Also, DMA transfer can be started when the ac-
knowledge is detected if UARTi transmission is selected as the DMAi request factor.
Bit 1 is the arbitration detection flag control bit. Arbitration detects a conflict between data transmitted at
SCLi rise and data at the SDAi pin. This detect flag is allocated to bit 11 in UARTi transmit buffer register
(addresses 036F16, 02EF16, 033F16, 032F16, 02FF16). It is set to “1” when a conflict is detected. With the
arbitration lost detect flag control bit, it can be selected to update the flag in units of bits or bytes. When this
bit is set to ‘1”, update is set to units of byte. If a conflict is still detected, the arbitration lost detect flag
control bit will be set to “1” at the 9th rise of the clock. When updating in units of byte, always clear (“0”
interrupt) the arbitration lost detect flag control bit after the first byte has been acknowledge but before the
next byte starts transmitting.
Bit 2 is the bus busy flag. It is set to “1” when the start condition is detected, and reset to ‘0” when the stop
condition is detected.
Bit 3 is the SCLi L synchronization output enable bit. When this bit is set to “1”, the port data register is set
to “0” in sync with the “L” level at the SCLi pin.
Bit 4 is the bus collision detection sampling clock select bit. The bus collision detection interrupt is gener-
ated when RxDi and TxDi level do not conflict with each other. When this bit is “0”, a conflict is detected in
sync with the rise of the transfer clock. When this bit is “1”, detection is made when Timer Ai (Timer
A3:UART0, Timer A4:UART1, Timer A0:UART2, Timer A3:UART3 and Timer A4:UART4) underflows. The
operation is shown in Figure 1.107.
Bit 5 is the transmission enable bit automatic clear select bit. By setting this bit to “1”, the transmission bit is
automatically reset to “0” when the bus collision detection interrupt factor bit is “1” (when a conflict is
detected).
Bit 6 is the transmit start condition select bit. By setting this bit to “1”, TxDi transmission starts in sync with
the rise at the RxDi pin.
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
148
Figure 1.107. Function timings
1. Bus collision detect sampling clock select bit (Bit 4 of the UARTi special mode register)
0: Rising edges of the transfer clock
CLKi
Timer Ai
1: Timer Ai overflow
2. Auto clear function select bit of transmt enable bit (Bit 5 of the UARTi special mode register)
CLKi
TxDi/RxDi
Bus collision
detect interrupt
request bit
Transmit
enable bit
3. Transmit start condition select bit (Bit 6 of the UARTi special mode register)
CLKi
TxDi Enabling transmission
CLKi
TxDi
RxDi
With "1: falling edge of RxD
i
" selected
0: In normal state
TxDi/RxDi
Serial Communication
149
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
UARTi Special Mode Register 2
Bit 0 is the I2C mode select bit 2. Table 1.50 lists the control changes by bit when the I2C mode select bit is
“1”. Start and stop condition detection timing characteristics are shown in Figure 1.108.
Table 1.50. Functions changed by I2C mode select bit 2
Function IICM2=0 IICM2=1
Interrupt numbers 13, 15, 17, 19
factor Acknowledge not detected (NACK) UARTi transfer (rising edge of the
last bit)
Interrupt number 2, 8, 10, 21 factor Acknowledge detected (ACK) UARTi receive (falling edge of the
last bit)
DMA factor Acknowledge detected (ACK) UARTi receive (fall ing edge of the
last bit)
Data transfer timing from UART
receive shift register to receive buffer Rising edge of the last bit of receive
clock Rising edge of the last bit of receive
clock
UART receive/ACK interrupt request
generati on tim ing Rising edge of the last bit of receive
clock Rising edge of the last bit of receive
clock
Set up time Hold time
SCL
SDA
(Start condition)
SDA
(Stop condition)
3 to 6 cyles < set up time (Note)
3 to 6 cycles < hold time (Note)
Note: Cycle number shows main clock input oscillation frequency f(Xin) cycle number.
Figure 1.108. Start/stop condition detect timing characteristics
Bit 1 is the clock synchronizing bit. When this bit is set to “1”, if the falling edge is detected at pin SCLi
while the internal SCL is “H”, the internal SCL is changed to “L”, the baud rate generator value is reloaded
and the L sector count starts. Also, while the SCLi pin is “L”, if the internal SCL changes from “L” to “H”,
baud rate generator stops counting. If the SCLi pin is “H”, counting restarts. Because of this function, the
UARTi transmit/receive clock takes the AND condition for the internal SCL and SCLi pin signals. This
function operates from the clock half period before the first rise of the UARTi clock to the 9th rise. To use
this function, select the internal clock as the transfer clock.
Bit 2 is the SCL wait output bit. When this bit is set to “1”, output from the SCLi pin is fixed to “L” at the
clock’s 9th fall. When set to “0”, the “L” output lock is released.
Bit 3 is the SDA output stop bit. When this bit is set to “1”, an arbitration lost generated. If the arbitration lost
detection flag is “1”, the SDAi pin simultaneously becomes high impedance.
Bit 4 is the UARTi initialize bit. While this bit is set to “1”, the following operations are performed when the
start condition is detected.
• The transmit shift register is initialized and the content of the transmission register is transmitted to the
transmission shift register. Transmission starts with the first bit of the next input clock. However, the UARTi
output value does not change when the start condition is detected. It also doesn’t change when the clock is
input and when the first bit of data is output.
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
150
• The receive shift register is initialized and reception starts with the first bit of the next input clock.
• The SCL wait output is set to “1”. The SCLi pin becomes “L” level at the fall of the 9th bit of the clock.
When UART transmit/receive is started using this function, the content of the transmit buffer available flag
does not change. Also, to use this function, select an external clock as the transfer clock.
Bit 5 is SCL wait output bit 2. When this bit is set to “1” and serial I/O is selected, an “L” level can be output
from the SCLi pin even during UART operation. When this bit is set to “0”, the “L” output from the SCLi pin
is cancelled and the UARTi clock is input and output.
Bit 6 is the SDA output disable bit. When this bit is set to “1”, the SDAi pin is forced to high impedance.
Overwrite this bit at the rise of the UART transfer clock. The arbitration lost detection flag may be set.
UARTi Special Mode Register 3
Bit 0 is the SS port function enable bit. Set this bit to "1" to enable the slave select output.
Bit 1 is the clock phase set bit. When both the I2C mode select bit (bit 0 of UiSMR) and the I2C mode
select bit 2 (bit 0 of UiSMR2) are “1”, functions changed by these bits are shown in Table 1.51 and Figure
1.109.
Bit 4 is the fault error flag. When this bit is "1", a fault error has been detected.
Bit 5 to 7 are the I2C SDAi digital delay setting bits. By setting these bits, it is possible to turn the SDAi
delay OFF or set the f(Xin) delay to 2 to 8 cycles.
Table 1.51. Functions changed by clock phase set bits
Function CKPH=0, IICM=1, IICM2=1 CKPH=1, IICM=1, IICM2=1
SCL initial and last value Initial value = "H", last value = "H" Initial value = "L", last value = "L"
Transfer interrupt factor Rising edge of 9th bit Falling edge of 10th bit
Data transfer times from UART
receive shift register to receive buffer
register Falling edge of 9th bit Two-times: falli ng edge of 9t h bit and
rising edge of 9th bit
CKPH= "1" (IICM=1, IICM2=1)
CKPH= "0" (IICM=1, IICM2=1)
(Internal clock, transfer data 9 bits long and MSB first selected.)
D6D5D4D3D2D1D8
D7
SDA
SCL
D0
Receive interrupt Transmit interrupt
Transfer to UiRB register
(Internal clock, transfer data 9 bits long and MSB first selected.)
D6D5D4D3D2D1D8
D7
SDA
SCL
D0
Receive interrupt Transmit interrup
t
Transfer to UiRB register
Figure 1.109. Function changed by clock phase set bits
Serial Communication
151
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Function STSPSEL=0 STSPSEL=1
SCL, SDA output Output of S I/O control circuit Out put of start/stop condition control
circuit
Start/stop condition interrupt factor Start/stop condition detection Completion of start/stop condition
generation
Slave mode (CKDIR = 1, STSPSEL = 0)
SCL
SDA
Start condition
detection interrupt Stop condition
detection interrupt
Master mode (CKDIR = 0, STSPSEL = 1)
SCL
SDA
Start condition
detection interrupt Stop condition
detection interrupt
STPREQ = 1
STAREQ =1
STSPSEL = 0
STSPSEL = 1
STSPSEL = 0
STSPSEL = 1
STSPSEL = 0
UARTi Special Mode Register 4
Bit 0 is the start condition generate bit. When the SCL, SDA output select bit (bit 3 of UiSMR4) is “1” and
this bit is “1”, the start condition is generated.
Bit 1 is the restart condition generate bit. When the SCL, SDA output select bit (bit 3 of UiSMR4) is “1” and
this bit is “1”, the restart condition is generated.
Bit 2 is the stop condition generate bit. When the SCL, SDA output select bit (bit 3 of UiSMR4) is "1" and
this bit is "1", the stop condition is generated.
Bit 3 is SCL, SDA output select bit. Table 1.52 shows the functions that are changed by this bit. Figure
1.110 shows the functions changed by SCL, SDA output select bit.
Bit 4 is ACK data bit. When the SCL, SDA output select bit (bit 3 of UiSMR4) is “0” and the ACK data output
enable bit (bit 5 of UiSMR4) is “1”, the content of ACK data bit is output to SDAi pin.
Bit 5 is ACK data output enable bit. When the SCL, SDA output select bit (bit 3 of UiSMR4) is “0” and this
bit is “1”, the content of ACK data bit is output to SDAi pin.
Bit 6 is SCL output stop bit. When this bit is “1”, SCLi output is stopped at stop condition detection. (High-Z
status).
Bit 7 is SCL wait output bit 3. When this bit is "1", SCLi output is fixed to "L" at the falling edge of the 10th
clock bit. When this bit is "0", SCLi output fixed to "L" is released.
Table 1.52. Functions changed by SCL, SDA output select bit
Figure 1.110. Functions changed by SCL, SDA output select bit
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
152
Figure 1.111. Example of serial bus communication control using SSi input pins
P13
P12
IC1
P77(SS3)
P74(TxD3)
P76(CLK3)
P75(RxD3)
IC2
P77(SS3)
P74(SRxD3)
P76(CLK3)
P75(STxD3)
IC3
P77(SS3)
P74(SRxD3)
P76(CLK3)
P75(STxD3)
M30245 (M) M30245 (S)
M30245 (S)
M :Master
S :Slave
Serial Interface Special Function (SPI mode)
UARTi can control communications on the serial bus using the SSi input pins. The master outputting the
transfer clock transfers data to the slave inputting the transfer clock. To prevent a bus collision, the master
floats the output pin of other slaves/masters using the SSi input pins. Figure 1.111 shows the SSi input pin
factors between the master and slave.
Slave mode (STxDi and SRxDi are selected, DINC=”1”)
When an “H” level signal is input to an SSi input pin, the STxDi and SRxDi pins both become high imped-
ance and the clock input is ignored. When an “L” level signal is input to an input pin, SSi clock input be-
comes effective and serial communications are enabled.
Master mode (TxDi and RxDi are selected, DINC=”0”)
The SSi input pins are used with a multiple master system. When an SSi input pin is “H” level, transmission
has priority and serial communications are enabled. When an “L” signal is input to an SSi input pin, another
master exists, and the TxDi, RxDi and CLKi pins become high impedance and the trouble error interrupt
request bit becomes “1”. Communications do not stop when a trouble error is generated during communica-
tions. To stop communications, set bit 0, 1, 2 of the UARTi transmit/receive mode register (addresses
03A816, 036816, 033816, and 032816) to “0”.
Serial Communication
153
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Master SS input
Clock output
(CKPOL=0, CKPH=0)
Clock output
(CKPOL=1, CKPH=0)
Data output timing
Data input timing
"H"
"L"
"H"
"L"
"H"
"L"
"H"
"L"
D
0
D
1
D
2
D
3
D
6
D
7
D
5
D
4
Clock output
(CKPOL=0, CKPH=1)
"H"
"L"
Clock output
(CKPOL=1, CKPH=1)
"H"
"L"
D
4
Figure 1.112. Transmit/receive timing in master mode (Internal clock)
Clock phase setting
With bit 1 of UARTi special mode register 3 and bit 6 of UARTi transmit/receive control register 0, four
combinations of transfer clock phase and polarity can be selected. Bit 6 of UARTi transmit/receive control
register 0 sets transfer clock polarity, whereas bit 1 of UiSMR3 register sets transfer clock phase. Transfer
clock phase and polarity must be the same between the master and slave involved in the transfer.
• Master (Internal clock) (DINC=0)
Figure 1.112 shows the transmit and receive timing.
• Slave (External clock) (DINC=1)
When “0” for CKPH bit (bit 1 of UiSMR3) is selected and SSi input pin is “H” level, output data is high
impedance. When an SSi input pin is “L” level, the serial transmission start condition is satisfied even
though output is indeterminate and serial transmission is synchronized with the clock. Figure 1.113 shows
the timing.
When “1” is selected for CLPH bit and SSi input pin is “H” level, output data is high impedance. When an
SSi input pin is “L” level, the first data is output and serial transmission is synchronized with the clock.
Figure 1.114 shows the timing.
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
154
Figure 1.113. Transmit/receive timing (CKPH=0) in slave mode (External clock)
Figure 1.114. Transmit/receive timing (CPKH=1) in slave mode (External clock)
High-
inpedance
SS input
Clock input
(CKPOL=0, CKPH=0)
Clock input
(CKPOL=1, CKPH=0)
Data output timing
Data input timing
"H"
"L"
"H"
"L"
"H"
"L"
"H"
"L"
High-
inpedance
D
0
D
1
D
2
D
3
D
4
D
6
D
7
D
5
Indeterminate
Note :UART2, (P7
0
, P7
1
) output is an N-channel open drain and needs to be pulled-up externally.
(Note)
High-
inpedance
SS input
Clock input
(CKPOL=0, CKPH=0)
Clock input
(CKPOL=1, CKPH=0)
Data output timing
Data input timing
"H"
"L"
"H"
"L"
"H"
"L"
"H"
"L" High-
inpedance
D
0D1D2D3D6D7D4D5
Note :UART2 (P70, P71) output is an N-channel open drain and needs to be pulled-up externally.
(Note)
Serial Sound Interface
155
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Serial Sound Interface
Serial Sound Interface is a synchronous serial data interface used primarily for transferring digital audio
data. This functional block is compatible with the I2S standard but also adds some extra configurability for
custom interfaces.
A channel is any single output of an audio system. For example, the left and right speakers are the two
channels of a simple stereo audio system. The bus has 4 lines:
• Continuous serial clock (SCK);
• Word (channel) select (WS);
• Serial data out (XMT);
• Serial data in (RX).
The channel being transmitted changes on every transition of WS. A Serial Sound Interface-based com-
munication system has two Serial Sound Interfaces and a master controller which generates both SCK and
WS. A Serial Sound Interface which generates the controls (SCK and WS) along with its transmit and
receive signals is operating as a master. A Serial Sound Interface which uses external control signals is
operating as a slave. The Serial Sound Interface on this device operates only as a slave.
Figure 1.115 shows a high level system diagram of a Serial Sound Interface setup and its associated
waveforms when configured for six channels.
Data transmission format
The transmitter/receiver must change channels on every WS transition. If the number of SCKs within a WS
high/low period exceeds the channel width (set by the user via mode bits), the transmitter continues to
transmit ‘0’s, while the receiver will stop receiving data until the next WS edge. However, if the number of
SCKs falls short, both the transmitter and the receiver will immediately switch to the next channel transmit
and receive, respectively. The Serial Sound Interface architecture is shown in Figure 1.116.
MSBMSB
LSB
LSB MSB MSB MSB MSB MSB MSBLSB
LSB LSB
LSB
LSB
CH6 CH1 CH2 CH3 CH4 CH5 CH6 CH1
SCK
WS
XMT
RX
SCK
WS
RX
XMT
WS
S
CK
Serial Sound
Interface Master Serial Sound
Interface Slave
Figure 1.115. Serial Sound Interface System diagram
Serial Sound Interface
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
156
Figure 1.116. Serial Sound Interface architecture
MCU Bus
Data Interface
Left buffer Right buffer
16/32 Bit 16/32 Bit
Shift register
Left buffer Right buffer
Data Interface
Interrupt
generator
Interrupt
generator Rate
Feedback
counter
Rate
Feedback
register
MCU Bus
XMIT
SCK
RX
Load on WS edge
Load
To ICU (DMATRIG)
Number of Interrupts
MCU write width
Byte
4
6
8
Word
2
3
4
Channel width
16
24
32
To ICU (DMATRIG)
Store
Store on WS edge
SCK WS
Shift register
Serial Sound Interface
157
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.117. Transmit and receive data (and WS) synchronized to SCK
The following features are supported via firmware controlled mode bits:
• Simultaneous transmit and receive (through separate transmit and receive pins) synchronized to the same
SCK and WS signals.
• Transmit/receive data and WS synchronized to the rising edge or the falling edge of SCK as shown in
Figure 1.117.
• Transmit and receive synchronized to the rising or the falling edge of WS as shown in Figure 1.118.
• Normal or delayed WS: WS transitions one SCK period before a channel change (normal mode) or
concurrently with a channel change (delayed mode) as shown in Figure 1.119.
• Automatic interrupt on a channel change and on every access to the data buffer (transmit/receive) until
each data buffer byte is accessed.
• Channel widths of 32, 24, and 16 bits.
• MSB or LSB first transmit and receive.
• Multiple receive formats: if the number of SCKs in a WS high/low period is less than the channel width, the
data can be placed either MSB or LSB justified as shown in Figure 1.120.
• Rate feedback: when used with the USB interface, the Serial Sound Interface can count the number of
WS’s or SCK’s per USB frame.
Data
SCK
WS
Data
WS
Data/WS synchronized to rising edge (SCKP = 1)
Data/WS synchronized to falling edge (SCKP = 0)
SCK
Serial Sound Interface
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
158
SCK
WS
Case I: XMTEM/RXEN goes high while WS is low
Channel 0 Channel 1
Falling edge synchronized start
Channel 0 Channel 1 Channel 2
XMTEN/RXEN
XMT/RX
WSP = 0
XMT/RX
WSP = 1
Rising edge synchronized start
SCK
WS
Case II: XTEN/RXEN goes high while WS is high
Channel 0 Channel 1 Channel 2
XMTEN/RXEN
XMT/RX
WSP = 0
Falling edge synchronized start
Channel 0 Channel 1
Rising edge synchronized start
XMT/RX
WSP = 1
Note 1: SCK must be active before XMTEM/RXEN.
Note 2: WS (min) pulse width is always greater than or equal to 3 SCK periods.
Figure 1.118. Transmit and receive data synchronized to WS
Data
SCK
LSB MSB MSB-1 MSB
LSB
R-channel
R-channel L-channel
WS
(Normal)
WS
(Delayed)
Note: R channel and L channel are used to indicate channel change on WS edge only.
(
Note)
Figure 1.119. WS normal or delayed transitions
Serial Communication
159
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Note:These example formats show the effects of the receiver settings on the received data when fewer than expected 
SCKs arrive for each channel. WS is shown 'LOW' for this example.
SCK
MSB first 
data on
RX line
WS
MSB first
MSB justified
Data buffer
MSB first
LSB justified
Data buffer
SCK
LSB first
data on 
RX line
WS
LSB first
MSB justified
Data buffer
LSB first
LSB justified
Data buffer
Channel width set to 24 bits (MCU mode bits)
21
22
23 54
23
432
10
40000
432
10
87654
012 18 19 0
Case I : MSB - first receive data (Note)
Case II : LSB - first receive data (Note)
16
23 22 21 20 19 18 17
16
19 18 17 15 14 13 12
16
23 22 21 20 19 18 17
000 0 23 22 21 20
432
10
00000
432
10
43210
16
23 22 21 20 19 18 17
16
19 18 17 15 14 13 12
16
23 22 21 20 19 18 17
000 0 19 18 17 16
Figure 1.120. Receiver setting effects
Serial Communication
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
160
Overview
The Serial Sound Interface is a serial data communication system. The parallel (MCU bus) to serial data
conversion is accomplished by the shift registers. Figure 1.121 shows a description of each component of
the Serial Sound Interface architecture. There are separate 32- bit shift registers for transmit and receive for
full duplex operation. Each shift register can be configured for 32, 24, or 16 bits as defined by the channel
width mode bits. The shift register loads (or stores for receiver) data from the data buffers on every WS
edge. The first load and bit-shift begins on the first “valid” edge of WS (as defined by the mode bits) after
the transmit/receive mode bits are set (see Figure 1.122). Therefore, the transmit data buffers must be
loaded prior to enabling the transmitter to ensure that the first transmit contains valid data.
Both the transmitter and receiver have their own set of data buffers. There are two data buffers (left and
right) so that, on special conditions when the MCU is handling a higher priority task, additional time is
available (channel width X TSCK) before there is data underflow or overflow. The shift register always loads
from or stores to the left buffer first and alternates between the two buffers on every edge of WS. The
placement of data within the buffers is described in detail in the Data Path section.
The interrupt generator is a state machine which controls the data interface. The state machine makes the
data transfer to or from the peripheral more efficient by generating interrupts until all the data needed for the
data buffer has been accessed. The interrupt can be set up to be a DMA trigger for more efficient data
transfer. The interrupt generator also tracks the read/write width (byte/word) so that no additional control is
needed. The interrupt is first generated when a data word is loaded from the data buffer to the shift register
(transmitter) or data are stored from the shift register into the data buffer (receiver). When the MCU is
finished accessing (as a response to the interrupt) another interrupt is generated if the data buffer has not
completely been accessed. For example, for a 24-bit transmitter, an interrupt is generated when the left
buffer is loaded into the shift register. If the MCU writes a byte of data to the transmit buffer address, 8 of
the 24 bits will be filled with new data. The interrupt generator triggers another interrupt causing the MCU to
write more data. If this write is a 16-bit operation, no further interrupts are generated until the right buffer is
loaded into the shift register. However, if the write operation is only 8 bit, then another interrupt is generated
immediately.
The data interface is used to simplify the data transfer process. The data buffer address is the same
regardless of the actual data buffer width. The interface places the incoming or outgoing data in the correct
position according to the channel width and the number of completed reads/writes for the data buffer.
The operation of the data interface is demonstrated in the example below which is the case of 24-bit audio
data with word writes. As previously explained, the state machine generates an interrupt when the left
channel is loaded into the shift register for transmission. When the first word write occurs, the data interface
places the data in the left buffer. Since 8 more bits are required to fully load the left buffer, another interrupt
is generated. The MCU writes another word of data, of which one byte is placed in the left buffer. However,
the remaining data is held in a temporary buffer within the data interface since the right channel may not be
loaded into the shift register yet. If the data is not held in a temporary buffer but written to the right buffer, it
would overwrite the untransmitted data in the right buffer. When the right buffer is eventually loaded into the
shift register for transmission, the state machine generates an interrupt to request additional data. An MCU
word write causes the data in the temporary buffer, as well as the data on the MCU data bus, to be placed
in the right buffer. No further interrupts are generated because all data buffers are filled.
Serial Sound Interface
161
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
The data interface for the receiver behaves slightly different for the same case. When the receive shift
register loads data into the left buffer, the state machine generates an interrupt. A word read from the MCU
causes 16 bits to be read. The other 8 bits are latched into a temporary buffer. Latching the data into a
temporary buffer empties the left buffer that provides additional time for the MCU to read the data without an
overflow condition occurring. Even though there are unread bits, no interrupt is generated because a word
read would read a byte from the right buffer which would be invalid data. The data in the right buffer is from
the previous receive cycle and therefore invalid for the read cycle. Thus, the complete read of the left buffer
is delayed until the right buffer is loaded by the receive shift register and the receive interrupts should be
assigned higher priority than transmit if the Serial Sound Interface is set up for both transmit and receive.
The Serial Sound Interface also contains a rate feedback mechanism which can be used to determine the
rate of data transfer via the Serial Sound Interface relative to the USB. It consists of a 16-bit counter with
either SCK or WS as the count source and a 16-bit register to store the count value. The count value is
loaded into the register on each negative edge of SOF pulse generated by the USB core. The counter is
also reset by the SOF pulse. The SOF pulse is a frame delimiter used in USB communication. Refer to the
USB section for details. The value read from the register is the count from the immediately preceding USB
frame.
Figure 1.121 shows the Serial Sound Interface rate feedback registers and Serial Sound Interface transmit
and receive data buffer registers. Figure 1.122. shows the Serial Sound Interface mode registers.
Figure 1.121. Serial Sound Interface related registers (1)
Function R W
Serial Sound Interface rate feedback register
b7 b8)
(b15 b0
O X
b7 b0
Symbol
SSIiRF (i = 0, 1)
Address
0319
16
, 0318
16
0379
16,
0378
16
When reset
0000
16
Rate feedback counter value
Function R W
Serial Sound Interface transmit buffer register
b7 b8)
(b15 b0 b7 b0
Symbol
SSIiTXB (i = 0, 1) Address
0315
16
, 0314
16
0375
16,
0374
16
Transmit data (Note) X O
Function R W
Serial Sound Interface receive buffer register
b7 b8)
(b15 b0 b7 b0
Symbol
SSIiRXB (i = 0, 1) Address
0317
16
, 0316
16
0377
16,
0376
16
Receive data (Note) O X
Note: Write only to even byte (8 bit) or entire word (16 bit).
Note: Read only from even byte (8 bit) or entire word (16 bit)
When reset
0000
16
When reset
0000
16
Serial Sound Interface
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
162
Figure 1.122. Serial Sound Interface related registers (2)
Serial Sound Interface mode register 0
Symbol
SSIiMR0 (i = 0, 1) Address
0310
16
, 0370
16
When reset
00
16
SSIEN
XMTEN
RXEN
RFBEN
CWID0
CWID1
RFMT0
RFMT1
Serial Sound Interface enable bit
Transmitter enable bit
Receiver enable bit
Rate feedback counter enable bit
Channel width select bit 0
Channel width select bit 1
Receiver format select bit 0
Receiver format select bit 1
0 : Disable
1 : Enable
0 : Disable
1 : Enable
0 : Disable
1 : Enable
0 : Disable
1 : Enable
0 0 : 32 bit
0 1 : 24 bit
1 0 : Reserved
1 1 : 16 bit
0 : LSB first
1 : MSB first
0 : LSB justified
1 : MSB justified
Bit symbol Bit name Function R W
b7 b0
b6 b5 b4 b3 b2 b1
O O
O O
O O
O O
O O
O O
O O
Serial Sound Interface mode register 1
Symbol
SSIiMR1 (i = 0, 1) Address
0311
16
, 0371
16
When reset
00
16
XMTFMT
Reserved
RFBSRC
SCKP
WSP
WSDLY
Reserved
Transmit format select bit
Rate feedback counter source
SCK polarity
WS polarity
WS delay
0 : LSB first
1 : MSB first
Always set to "0"
0 : SCK
1 : WS
0 : Negative edge
1 : Positive edge
0 : Negative edge
1 : Positive edge
0 : Delayed WS
1 : Normal WS
Always set to "0"
Bit symbol Bit name Function R W
b7 b0
b6 b5 b4 b3 b2 b1
O O
O O
O O
O O
O O
O O
O O
00
O O
b5 b4
0
Serial Sound Interface
163
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
FIFO ADDRESS
(offset from endpoint start address) FIFO DATA Comments
0 L7 - L0 Sample 0
1L15 - L8
2L23 - L16
3R7 - R0
4R15 - R8
6Sample 1
7
8
9
10
11
... ... ...
... Sample n
... ... ...
R23 - R16
5L7 - L0
L15 - L8
L23 - L16
R7 - R0
R15 - R8
R23 - R16
L7 - L0
Left Buffer Right Buffer
Byte 2 Byte 1 Byte 0 Byte 2 Byte 1 Byte 0
L23 - L16 L15 - L8 L7 - L0 R23 - R16 R15 - R8 R7 - R0
Data Path
The data path is designed to work with the USB on this device. Because the Serial Sound Interface is an
audio interface, the USB audio class device specifications are used to define the data path. USB audio data
can be multiple types: PCM, a-law, u-law, MPEG, AC-3, IEC 1937, etc. However, the data are always left
(MSB) justified. '0's are padded to the LSB end to meet byte boundaries or packet size requirements. The
USB data are transmitted as MSB first in standard formats. Therefore, for basic stereo data with 24-bit
resolution (L23 - L0 and R23 - R0) should arrive or set up in the USB FIFO. Table 1.53 lists the USB FIFO
data setup. Table 1.54 lists the Serial Sound Interface buffer data.
Table 1.53. USB FIFO data setup
Table 1.54. Serial Sound Interface buffer data
Serial Sound Interface
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
164
The USB FIFO is read using word accesses and each word is written to the transmit buffer. Table 1.55
lists the USB FIFO sequence operation. Note that DB refers to the MCU data bus.
Table 1.55. USB FIFO sequence operation
Data are placed in the buffer from the least significant byte to the most significant byte with the left buffer
written first. If the write operation is a word, the lower order data bus bits (DB7-DB0) are treated as more
significant than the higher order data bus bits (D15-DB8). This is compatible with the USB.
The same operation sequences occur for the receive buffer read. On a byte access, data are placed on the
bus with the most significant byte first. If the access is a word read, the lower order data bus bits (DB7-DB0)
are treated as more significant.
Precautions
Entering wait mode with the SSI active can produce unpredictable data transfers . Make sure to disable the
SSI transmitter and receiver before entering wait mode, and re-enable the transmitter and receiver after
exiting wait mode.
OPERATION Left Buffer Right Buffer
Byte 2 Byte 1 Byte 0 Byte 2 Byte 1 Byte 0
First Word Write
DB
7
- DB
0
DB
15
- DB
8
Second Word Write
DB
7
- DB
0
DB
15
- DB
8
Third Word Write DB
7
- DB
0
DB
15
- DB
8
(L23-L16) (L15-L8) (L7-L0) (R23-R16) (R15-R8) (R7-R0)
A-D Converter
165
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
A-D converter
The A-D converter consists of one 10-bit successive approximation A-D converter circuit with a capacitive cou-
pling amplifier. Pins P100 to P107 function as the analog signal input pins. Set the direction registers correspond-
ing to a pin with A-D conversion to input. The result of an A-D conversion is stored in the A-D registers of the
selected pins.
Table 1.56 shows the performance of the A-D converter. Figure 1.123 shows the block diagram of the A-D con-
verter, and Figure 1.124 and Figure 1.125 show the A-D converter-related registers.
Note 1: Does not depend on use of sample and hold function.
Note 2: When f(Xin) is over 10 M Hz, the ΦAD frequency mus t be s et under 10 MHz with the freq uen cy sel ect bit s (bi t s
7 at 03D616 and bit 4 at 03D716).
Without the sample and hold function, set the ΦAD to 250kHz or higher.
With the sample and hold function, set the ΦAD frequency to 1 MHz or higher.
Note 3: Set the port direction register to input.
Item Performance
A-D conversion method Successive approximation (capacitive coupling amplifier)
Analog input voltage
(Note 1) 0V to AVcc (Vcc)
Oper ati ng clock ΦAD
(Note 2) fAD, fAD/2, fAD/3, fAD/4 fAD=f(Xin)
Resolution 8-bit or 10-bit (selectable)
Non-linear accuracy
Operati ng mod es
One-shot mode
Repeat mode
Single sweep mode
Repeat sweep mode 0
Repeat sweep mode 1
Analog input pins 8 pins (AN0 to AN7)
A-D conversion start
condition
Software trigger
-A-D conversion starts when the A-D conversion start flag changes to "1"
External trig ger (ca n be retriggered )
-A-D conversion starts when ADTRG/P93 input changes from "H" to "L" (Note 3)
Conve rsi on sp eed per
pin
Without sample and hold function
8-bit resolution: 49 ΦAD cycles
10-bit resolution: 59 ΦAD cycles
With sampl e a nd hol d func tion
8-bit resolution: 28 ΦAD cycles
10-bit resolution: 33 ΦAD cycles
Table 1.56. A-D Converter performance
A-D Converter
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
166
Figure 1.123. A-D converter block diagram
AN0
AN1
AN2
AN3
AN4
AN5
AN6
AN7
AD register 0
AD register 1
AD register 2
AD register 3
AD register 4
AD register 5
AD register 6
AD register 7
Decoder
(03C116, 03C016)
(03C316, 03C216)
(03C516, 03C416)
(03C716, 03C616)
(03C916, 03C816)
(03CB16, 03CA16)
(03CD16, 03CC16)
(03CF16, 03CE16)
000
001
010
011
100
101
110
111
Successive 
conversion register
Resistor ladder
AD control register 0
(address 03D616)
AD control register 1
(address 03D716)
1/3
1/21/2 0
1
0
1
0
1
f
AD
ΦAD
ADCON0 :
CH2, CH1, CH0
P10
Comparator
Address
f
AD
f
AD/3
f
AD/2
f
AD/4
CKS0
CKS1
A-D Converter
167
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.124. A-D converter-related registers (1)
Bit Symbol Function R W
Symbol
ADCON0 Address
03D616
A-D control register 0 (Note 1)
Note 1: If the A-D control regsiter 0 is rewritten during A-D conversion, the conversion result is
indeterminate.
Note 2: When changing A-D operation mode, reset the analog input pin.
Note 3: This bit is disabled in single-sweep mode, repeat-sweep mode 0 and repeat-sweep mode 1.
Note 4: Set to "1" when ADTRG is selected.
Note 5: When f(XIN) exceeds 10 MHz, the ΦAD frequency must be set less than 10 MHz by dividing.
When reset
0016
Bit Name
CH0
CH1
CH2
MD0
MD1
TRG
ADST
CKS0
Analog input pin select
bit
A-D operation mode
select bit 0
Trigger select bit
A-D conversion start flag
Frequency select bit
(Note 5)
0 0 0 : AN0
0 0 1 : AN1
0 1 0 : AN2
0 1 1 : AN3 (Note 2, 3)
1 0 0 : AN4
1 0 1 : AN5
1 1 0 : AN6
1 1 1 : AN7
0 0 : One-shot mode
0 1 : Repeat mode (Note 2)
1 0 : Single sweep mode
1 1 : Repeat sweep mode 0
Repeat sweep mode 1
0 : Software trigger
1 : ADTRG trigger
0 : A-D conversion disabled
1 : A-D conversion enabled (Note 4)
0 : fAD/3 or fAD/4 is selected
1 : fAD/1 or fAD/2 is selected
O O
O O
O O
O O
O O
O O
O O
O O
b2 b1 b0
b4 b3
Bit Symbol Function R W
Symbol
ADCON1 Address
03D716
A-D control register 1 (Note 1)
Note 1: If the A-D control regsiter 1 is rewritten during A-D conversion, the conversion result is
indeterminate.
Note 2: This bit is invalid in one-shot mode and repeat mode. Channels shown in parentheses are
valid when repeat-sweep mode 1 (bit 2 = "1") is selected.
Note 3: When f(XIN) exceeds 10 MHz, the ΦAD frequency must be set less than 10 MHz by dividing.
When reset
0016
Bit Name
SCAN0
SCAN1
MD2
BITS
CKS1
VCUT
A-D sweep pin select bit
A-D operation mode select bit 1
8/10-bit mode select bit
Frequency select bit (Note 3)
Vref connect bit
0 0 : AN0, AN1 (AN0)
0 1 : AN0 to AN3 (AN0, AN1) (Note 2)
1 0 : AN0 to AN5 (AN0 to AN2)
1 1 : AN0 to AN7 (AN0 to AN3)
0 : Any mode other than repeat-sweep mode 1
1 : Repeat-sweep mode 1
0 : 8-bit mode
1 : 10-bit mode
0 : fAD/2 or fAD/4 is selected
1 : fAD/1 or fAD/3 is selected
0 : Vref not connected
1 : Vref connected
O O
O O
O O
O O
_ _
O O
O O
b1 b0
Nothing is assigned. Write "0" when writing to these bits.
The value is indeterminate when read.
b7 b0
b6 b5 b4 b3 b2 b1
b7 b0
b6 b5 b4 b3 b2 b1
A-D Converter
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
168
Figure 1.125. A-D converter-related registers (2)
Bit Symbol Function R W
Symbol
ADCON2 Address
03D4
16
A-D control register 2 (Note)
Note : If the A-D control register 2 is rewritten during A-D conversion, the conversion result is
indeterminate.
When reset
X00X0XX0
2
Bit Name
SMP A-D conversion method
select bit 0 : Without sample and hold
1 : With sample and hold
O O
O O
Reserved Must always be set to "0"
00 0
b7 b0
b6 b5 b4 b3 b2 b1
Function R W
_ _
Symbol
ADi (i = 0 to 7) Address
03C0
16
to 03CF
16
When reset
Indeterminate
A-D register i (i = 0 to 7)
b7
(b15) (b8) b0b7 b0
O X
Eight low-order bits of A-D conversion results
During 10-bit mode: Two high-order bits of A-D conversion results.
During 8-bit mode: The values are indeterminate when read.
Nothing is assigned.
Write "0" when writing to these bits. The values are indeterminate when read.
O X
_ _
Nothing is assigned. Write "0" when writing to these bits.
The value is indeterminate when read.
Nothing is assigned. Write "0" when writing to these bits.
The value is indeterminate when read.
Reserved Must always be set to "0"
Nothing is assigned. Write "0" when writing to this bit.
The value is indeterminate when read.
_ _
_ _
O O
A-D Converter
169
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.57. One-shot mode specifications
Repeat mode
In repeat mode, the pin selected using the analog input pin select bit is used for repeated A-D conversion.
Table 1.58 shows the specifications of repeat mode.
Item Specification
Function The pin selected by the analog input pin select bit is used for one A-D conversion.
Start condition Writing "1" to A-D conversion start flag, extern al trigger.
Stop condition End of A-D conversion (A-D conversion start flag changes to "0" except when external trig-
ger is selecte d)
Writing "0" to A-D conversion start flag.
Interrupt request
generati on tim ing End of A-D conversion.
Input pin One of AN0 to AN7, as selected.
A-D converter results Read A-D register corresponding to selected pin.
Table 1.58. Repeat mode specifications
Item Specification
Function The pin selected by the analog input pin select bit is used for repeated A-D conversion.
Start condition Writi ng "1" to A-D conversion start flag, extern al trigger.
Stop condition Writing "0" to A-D conversion start flag.
Interrupt request
generati on tim ing None generated.
Input pin One of AN0 to A N7, as selected.
A-D converter results Read A-D register corresponding to selected pin (at any time).
One-shot mode
In one-shot mode, the pin selected using the analog input pin select bit is used for one-shot A-D conver-
sion. Table 1.57 shows the specifications of one-shot mode.
A-D Converter
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
170
Single sweep mode
In single sweep mode, the pins selected using the A-D sweep pin select bit are used for one-by-one A-D
conversion. Table 1.59 shows the specifications of single sweep mode.
Table 1.59. Single sweep mode specifications
Item Specification
Function The pins sel ected by the A-D sweep pin select bit ar e used for one-by-one A-D conversion.
Start condition Writing "1" to A-D converter start flag, external trigger.
Stop condition End of A-D convers io n (A-D c on ve rsi on st a r t fl ag cha ng es to "0" exce pt when ex tern al trig-
ger is selecte d).
Writing "0" to A-D conversion start flag.
Interrupt request
generati on tim ing End of Sweep.
Input pin AN0 an d AN1 (2 pins), AN0 to AN3 (4 pins), AN0 to AN5 (6 pins), or AN0 to AN7 (8 pins).
A-D converter results Read A-D register corresponding to selected pin.
Repeat sweep mode 0
In repeat sweep mode 0, the pins selected using the A-D sweep pin select bit are used for repeat sweep A-
D conversion. Table 1.60 shows the specifications of repeat sweep mode 0.
Table 1.60. Repeat sweep 0 specifications
Item Specification
Functio n The pins sele cted b y the A-D swee p pin s elect bit are used f or repea t sweep A-D conversi on.
Start condition Writing "1" to A-D conversion start flag.
Stop condition Writing "0" to A-D conversion start flag.
Interrupt request
generati on tim ing None generated.
Input pin AN
0
and AN
1
(2 pins), AN
0
to AN
3
(4 pins), AN
0
to AN
5
(6 pins), or AN
0
to AN
7
(8 pins).
A-D converter results Read A-D register corresponding to selected pin (at any time).
A-D Converter
171
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Repeat sweep mode 1
In repeat sweep mode 1, all pins are used for A-D conversion with emphasis on the pin or pins selected
using the A-D sweep pin select bit. Table 1.61 shows the specifications of repeat sweep mode 1.
Table 1.61. Repeat sweep mode 1 specifications
Resolution select function
8 or 10-bit mode select bit of A-D control register 1 (bit 3 at address 03D716)
When set to 10-bit precision, the low 8-bits are stored in the even addresses and the high 2 bits in the odd
addresses. When set to 8-bit precision, the low 8 bits are stored in the even addresses.
Sample and hold
Sample and hold is selected by setting bit 0 of the A-D control register 2 (address 03D416) to “1”. When
sample and hold is selected, the rate of conversion of each pin increases. As a result, a 28 fAD cycle is
achieved with 8-bit resolution and 33 fAD with 10-bit resolution. Sample and hold can be selected in all
modes. However, in all modes, be sure to specify before starting A-D conversion whether sample and hold
is to be used.
Power consumption reduction function
The VREF connect bit (bit 5 at addresses 03D716) can be used to isolate the resistance ladder of the A-D
converter from the reference voltage pin (VREF) when the A-D converter is not used. This stops any current
from flowing into the resistance ladder from VREF, reducing the power dissipation. When using the A-D
converter, start A-D conversion only after connecting VREF. Do not write A-D conversion start flag and
VREF connect bit to “1” at the same time.
Precautions
Write to each bit (except bit 6) of A-D control register 0, A-D control register 1, and to bit 0 of A-D control
register 2 when A-D conversion is stopped (before a trigger occurs). When the VREF connection bit is
changed from “0” to “1”, wait 1 µs or longer before starting A-D conversion.
When changing A-D operation mode, select the analog input pin again.
Item Specification
Function All pin s perform re pea t s w ee p A-D c onv ers io n with emph as is on th e pin o r p ins s el ect ed by
the A-D sweep pin select bit.
Example: AN0 selected: AN0 AN1 AN0 AN2 AN0 AN3 etc.
Start condition Writing "1" to A-D conversion start flag.
Stop condition Writing "0" to A-D conversion start flag.
Interrupt request
generati on tim ing None generated.
Input pin AN0 to AN7.
Pin emphasis AN0 (1 pin) AN0 and AN1 (2 pins), AN0 to AN2 (3 pins), AN0 to AN3 (4 pins).
A-D converter results Read A-D register corresponding to selected pin (at any time).
A-D Converter
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
172
Vc is generally = {1 - e - }
t
C(R0+R)
And when t = T, Vc = VIN - X =(1 - X)
Y
Y
T
C(R0 + R) = X
Y
e -
T
C(R0 + R) = In X
Y
-
Therefore, R0 = -
C In X
Y
T- R
VINVIN
VIN
If T = 0.3µs, R = 7.8k, C = 3pF, X = 0.1, and Y = 1024
Then R0 = - 7.8 x 10
3
= approximately 3.0 x 10
3
0.3 x 10
-6
3.0 x 10
-12
In 0.1
1024
_
V
C
C (3.0pF)
V
IN
Internal circuit of microprocesso
r
Sensor-equivalent circuit
R (7.8k )
R
0
Using one-shot mode or single sweep mode:
Read the corresponding A-D register after confirming A-D conversion is finished. (Check the A-D conver-
sion interrupt request bit.)
Using repeat mode, repeat sweep mode 0 or repeat sweep mode 1:
Use the undivided main clock as the internal CPU clock.
When f(Xin) is faster than 10MHz, make the A-D frequency 10MHz or less by dividing.
Output impedance of sensor at A-D conversion (Reference value).
To carry out A-D conversion properly, charging the internal capacitor C shown in Figure 1.126 has to be
completed within a specified period of time T. Let the output impedance of sensor equivalent circuit be R0,
the microcomputer’s internal resistance be R, the precision (error) of the A-D converter be X, and the A-D
converter’s resolution be Y (Y is 1024 in the 10-bit mode, and 256 in the 8-bit mode).
With the model shown in Figure 1.126 as an example, when the difference between VIN and VC be-
comes 0.1LSB, we find impedance R0 when voltage between pins VC changes from 0 to VIN-(0.1/1024)
VIN in time T. (0.1/1024) means that A-D precision drop due to insufficient capacitor charge is held to
0.1LSB at time of A-D conversion in the 10-bit mode. Actual error however is the value of absolute
precision added to 0.1LSB. When f(Xin) = 10 MHz, T = 0.3 us in the A-D conversion mode with sample &
hold. Output impedance R0 for sufficiently charging capacitor C within time T is determined as follows.
Thus, the allowable output impedance of the sensor circuit capable of thoroughly driving the A-D
converter turns out to be approximately 3.0 k. Table 1.62 and Table 1.63 show output impedance
values based on the LSB values.
Figure 1.126. A circuit equivalent to the A-D conversion terminal
A-D Converter
173
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
f(X
IN
)
(MHz) Cycle (µs) T (Sampling
time) R (Kohm) C(pF) Resolution
(LSB) R0max
(Kohm)
10 0.1
0.3
(3 x cycle,
sample and
hold bit
enabled
7.8 3.0
0.1 3.0
0.3 4.5
0.5 5.3
0.7 5.9
0.9 6.4
1.1 6.8
1.3 7.2
1.5 7.5
1.7 7.8
1.9 8.1
10 0.1
0.2 (2 x cycle,
Sample and
hold bit is
enabled)
7.8 3.0
0.3 0.4
0.5 0.9
0.7 1.3
0.9 1.7
1.1 2.0
1.3 2.2
1.5 2.4
1.7 2.6
1.9 2.8
Table 1.62. Output impedance values based on the LSB values (10-bit mode)
Table 1.63. Output impedance values based on the LSB values (8-bit mode)
f(X
IN
)
(MHz) Cycle (µs) T (Sampling
time) R (Kohm) C(pF) Resolution
(LSB) R0max
(Kohm)
10 0.1
0.3
(3 x cycle,
sample and
hold bit
enabled
7.8 3.0
0.1 4.9
0.3 7.0
0.5 8.2
0.7 9.1
0.9 9.9
1.1 10.5
1.3 11.1
1.5 11.7
1.7 12.1
1.9 12.6
10 0.1
0.2 (2 x cycle,
Sample and
hold bit is
enabled)
7.8 3.0
0.1 0.7
0.3 2.1
0.5 2.9
0.7 3.5
0.9 4.0
1.1 4.4
1.3 4.8
1.5 5.2
1.7 5.5
1.9 5.8
CRC Calculation Circuit
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
174
CRC calculation circuit
The Cyclic Redundancy Check (CRC) calculation circuit detects any errors in data blocks. The microcomputer
uses a generator polynomial of CRC-CCITT (x16+ x12 + x5 + 1) or CRC-16 (x16+ x15 + x2 + 1) to generate CRC
code.
The CRC code is a 16-bit code generated for a block of a given data length in multiples of 8 bits. It is set in a CRC
data register every time one byte of data is transferred to a CRC input register after writing an initial value into the
CRC data register. Generation of CRC code for one byte of data is completed in two machine cycles.
Figure 1.127 shows the block diagram of the CRC circuit. Figure 1.128 shows the CRC-related registers. Figure
1.129 shows an example of the CRC using CRC-CCITT.
CRC Snoop
The CRC circuit includes the ability to snoop reads and writes to certain SFR addresses. This can be
used to accumulate the CRC value on a stream of data without using extra bandwidth to explicitly write
data into the CRCIN register. For example, it may be useful to snoop the writes to a UART TX buffer, or
the reads from a UART RX buffer. This can only be used on USB, UART and SSI registers.
To snoop an SFR address, the target address is written to the CRC Snoop Address Register (CRCSAR).
The two most significant bits of this register enable snooping on reads or writes to the target address. If the
target SFR is written to by the CPU or DMA, and the CRC snoop write bit is set (CRCSW=1), the CRC will
latch the data into the CRCIN register. The new CRC code will be set in the CRCD register.
Similarly, if the target SFR is read by the CPU or DMA, and the CRC snoop read bit is set (CRCSR=1), the
CRC will latch the data from the target into the CRCIN register and calculate the CRC.
The CRC circuit can only calculate CRC codes on data one byte at a time. Therefore, if a target SFR is
accessed in a word (16 bit) bus cycle, only the byte of data going to or from the target is snooped into
CRCIN. The other byte of the word access is ignored.
Note: CRC Snoop can only be used to snoop USB, UART and SSI related SFR registers.
Figure 1.127. CRC circuit block diagram
Eight low-order bits Eight high-order bits
Data bus high-order bits
Data bus low-order bits
CRC data register (16)
CRC input register (8)
CRC code generating circuit
x16 + x12 + x5 + 1
(Addresses 03BD16, 03BC
(Address 03BE
16)
16)
OR x16 + x15 + x2 + 1 Snoop Address
Equal?
Address Bus
Snoop
enable
Snoop
Block
Enable
CRC Calculation Circuit
175
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.128. CRC-related registers
Bit symbol R W
_ _
O O
When reset
0XXXXXX0
2
Symbol
CRCMR
Address
03B6
16
Function
0 : x
16
+ x
12
+ x
5
+ 1 (CRC-CCITT)
1 : x
16
+ x
15
+ x
2
+ 1 (CRC-16)
CRCPS
Nothing is assigned.
Write "0" when writing to this bit. The value is indeterminate if read.
CRCMS
CRC mode polynomial
selection bit
CRC mode selection bit 0 : LSB first mode
1 : MSB first mode O O
_ _
O O
When reset
00XXXX?? ????????
2
Symbol
CRCSAR
Address
03B5
16
, 03B4
16
CRC snoop address register
b7 b0
(b8)(b15)
b7 b0
0 : Disabled
1 : Enabled
0 : Disabled
1 : Enabled
Nothing is assigned.
Write "0" when writing to this bit. The value is indeterminate if read.
CRC Snoop on read enable bit
O O
CRC mode register
b7 b0
CRC Snoop on write enable bit
R W
CRCSAR9-0 O O
Bit name
Bit name
Function
(b15) (b8)
CRC data register
Symbol
CRCD
Address
03BD
16
to 03BC
16
When reset
Indeterminate
Function Values that can be set
CRC calculation result output 0000
16
to FFFF
16
R W
O O
b7 b0b7 b0
Symbol
CRCIN
Address
03BE
16
When reset
Indeterminate
Function
Data input 00
16
to FF
16
R W
O O
b7 b0
CRC input register
Values that can be set
CRC Snoop address bits
CRCSR
CRCSW
Bit symbol
Note: Only USB, UART and SSI related registers can be snooped
SFR address to snoop (Note)
CRC Calculation Circuit
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
176
b15 b0
(1) Setting 0000
16
CRC data register CRCD
[03BD
16
, 03BC
16
]
b0b7
b15 b0
(2) Setting 01
16
CRC input register CRCIN
[03BE
16
]
2 cycles
After CRC calculation is complete
CRC data register CRCD
[03BD
16
, 03BC
16
]
1189
16
Stores CRC code
b0b7
b15 b0
(3) Setting 23
16
CRC input register CRCIN
[03BE
16
]
After CRC calculation is complete
CRC data register CRCD
[03BD
16
, 03BC
16
]
0A41
16
Stores CRC code
The code resulting from sending 01
16
in LSB first mode is (1000 0000). Thus the CRC code in the generating polynomial,
(X
16
+ X
12
+ X
5
+ 1), becomes the remainder resulting from dividing (1000 0000) X
16
by (1 0001 0000 0010 0001) in
conformity with the modulo-2 operation.
Thus the CRC code becomes (1001 0001 1000 1000). Since the operation is in LSB first mode, the (1001 0001 1000 1000)
corresponds to 1189
16
in hexadecimal notation. If the CRC operation in MSB first mode is necessary in the CRC operation
circuit built in the M16C, switch between the LSB side and the MSB side of the input-holding bits, and carry out the CRC
operation. Also switch between the MSB and LSB of the result as stored in CRC data.
1 0001 0000 0010 0001 1000 0000 0000 0000 0000 0000
1000 1000 0001 0000 1
1000 0001 0000 1000 0
1000 1000 0001 0000 1
1001 0001 1000 1000
1000 1000
LSB MSB
LSB MSB
98 1 1
Modulo-2 operation is
operation that complies
with the law giv en below .
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 0
-1 = 1
Figure 1.129. CRC example using CRC-CCITT
Programmable Ports
177
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Programmable I/O ports
There are 83 programmable I/O ports: P0 to P10 (excluding P85). Each port can be set independently for input or
output using the direction register. A pull-up resistance for each block of 4 ports can be set. P85 is an input-only
port and has no built-in pull-up resistance.
Figure 1.130 to Figure 1.132 show the programmable I/O ports. Figure 1.133 shows the I/O pins.
Each pin functions as a programmable I/O port and as the I/O for the built-in peripheral devices.
To use the pins as the inputs for the built-in peripheral devices, set the direction register of each pin to input mode.
When the pins are used as the outputs for the built-in peripheral devices, they function as outputs regardless of
the contents of the direction registers. See the descriptions of the respective functions for how to set up the built-
in peripheral devices.
High drive capacity register
Figure 1.134 shows the Port P7 drive capacity register. Port P7 can be configured to drive an LED by
increasing the drive strength of the corresponding N-channel transistor bits.
Port control register
Figure 1.135 shows the port control register.
The bit 0 of port control resister is used to read Port P1:
0: When Port P1 is an input port, the port input level is read.
When Port P1 is an output port, the contents of Port P1 register are read.
1: The contents of Port P1 register are always read.
This register is valid for the external bus width which is 8 bits in microprocessor mode or memory expan-
sion mode.
Direction registers
Figure 1.136 shows the direction registers.
These registers are used to choose the direction of the programmable I/O ports. Each bit in these registers
corresponds one for one to each I/O pin.
Note: There is no direction register bit for P85.
Port registers
Figure 1.137 shows the port registers.
These registers are used to write and read data for input and output to and from an external device. A port
register consists of a port latch to hold output data and a circuit to read the status of a pin. Each bit in port
registers corresponds one for one to each I/O pin.
Pull-up control registers
Figure 1.138 shows the pull-up control registers.
The pull-up control register can be set to apply a pull-up resistance to each block of 4 ports. When ports
are set to have a pull-up resistance, the pull-up resistance is connected only when the direction register is
set for input.
However, in memory expansion mode and microprocessor mode, the pull-up control register of P0 to P3,
P40 to P43, and P5 is invalid.
Unused pins
Table 1.64 lists an example connection of unused pins in single chip mode. Table 1.65 lists an example of
unused pins in memory expansion mode. Figure 1.139 shows an example connection for unused pins.
Programmable Ports
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
178
Figure 1.130. Programmable I/O ports (1)
P00 to P07, P20 to P27,
P30 to P37, P40 to P47,
P50 to P54, P56
P10 to P17
P57, P60 to P67
P80, P81
Data bus
Direction register
Pull-up selection
Port latch
Data bus
Direction register
Pull-up selection
Port latch
Port P1 control register
Direction register
Port latch
Pull-up selection
Data bus
Input to respective peripheral functions
Note : symbolizes a parasitic diode.
Do not a
pp
l
y
a volta
g
e hi
g
her than Vcc to each
p
ort.
"1"
Output
(Note)
P8
2
to P8
4
Data bus
Direction register
Pull-up selection
Port latch
Input to respective peripheral functions
(Note)
(Note)
(Note)
Programmable Ports
179
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.131. Programmable I/O ports (2)
P7
0
, P7
1
P5
5
, P9
3
P9
2
Data bus
Direction register
Pull-up selection
Port latch
Input to respective peripheral functions
"1"
Output
Data bus
Direction register
Pull-up selection
Port latch
"1"
Output
Direction register
Port latch
Input to respective peripheral functions
Note :1 symbolizes a parasitic diode.
Do not apply a voltage higher than Vcc to each port.
Note :2 s
y
mbolizes a
p
arasitic diode.
(Note1)
(Note1)
(Note2)
Data bus
P7
2
to P7
7
Direction register
Port latch
Pull-up selection
Data bus
Input to respective peripheral functions
"1"
Output
(Note 1)
Drive capacity control register
Drive capacity control register
Programmable Ports
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
180
Figure 1.132. Programmable I/O ports (3)
P90Direction register
Pull-up selection
Port latch
Data bus
Note : symbolizes a parasitic diode.
Do not a
pp
l
y
a volta
g
e hi
g
her than Vcc to each
p
ort.
(Note)
UVcc
P9
0
-second
ATTACH
P8
7
P8
6
fc
Rf
Data bus
Direction register
Pull-up selection
Port latch
"1"
Output
Direction register
Pull-up selection
Port latch
Data bus (Note)
(Note)
Data bus
Direction register
Pull-up selection
Port latch
Analog input
Input to respective peripheral functions
P10
0
to P10
7

(Note)
P85 Data bus
NMI interrupt input (Note)
Programmable Ports
181
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.133. I/O pins
Figure 1.134. High drive capacity register
Bit Symbol Bit Name Function R W
P7DR0
P7DR1
P7DR2
P7DR3
P7DR4
P7DR5
P7DR6
P7DR7
P7
0
LED drive capacity
P7
1
LED drive capacity
P7
2
LED drive capacity
P7
3
LED drive capacity
P7
4
LED drive capacity
P7
5
LED drive capacity
P7
6
LED drive capacity
P7
7
LED drive capacity
The N-channel high drive
capacity is activated for the
corresponding bit.
0 : Normal drive
1 : N-channel high drive
O O
Symbol
P7DR Address
03FA
16
When reset
00
16
Port 7 drive capacity register
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
O O
O O
BYTE BYTE signal input
CNV
SS
CNV
SS
signal input
RESET RESET signal input
Note 1: symbolizes a parasitic diode.
 Do not apply a voltage higher than Vcc to each pin.
Note 2: A parasitic diode on the V
CC
side is added to the mask ROM version.
 Do not a
pp
l
y
a volta
g
e hi
g
her than Vcc to each
p
in.
(Note 2)
(Note 1)
(Note 2)
(Note 1)
(Note 1)
Must always be set to "0".
When reset
0016
Bit Symbol Bit Name Function R W
PCR0 Port P1 control register
Symbol
PCR Address
03FF16
Port control register
b7 b5b6 b4 b3 b2 b1 b0
O O
_ _
0 : When input port, read port
input level. When output port,
read the contents of Port P1
register.
1 : Read the contents of Port P1
register through input/output port.
Nothing is assigned.
Write "0" when writing to this bit. The value is"0" when read.
O O
Reserved.
000
Figure 1.135. Port control register
Programmable Ports
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
182
Bit Symbol Bit Name Function R W
PD8_0
PD8_1
PD8_2
PD8_3
PD8_4
Port P8
0
direction register
Port P8
1
direction register
Port P8
2
direction register
Port P8
3
direction register
Port P8
4
direction register
O O
Symbol
PD8 Address
03F2
16
When reset
00X00000
2
Port P8 direction register
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
O O
_ _
Bit Symbol Bit Name Function R W
PDi_0
PDi_1
PDi_2
PDi_3
PDi_4
PDi_5
PDi_6
PDi_7
Port Pi
0
direction register
Port Pi
1
direction register
Port Pi
2
direction register
Port Pi
3
direction register
Port Pi
4
direction register
Port Pi
5
direction register
Port Pi
6
direction register
Port Pi
7
direction register
0 : Input mode (Functions as an
input port)
1 : Output mode (Functions as
an output port)
O O
Symbol
PDi (i = 0 to 7, 10) Address
03E2
16
, 03E3
16
, 03E6
16
, 03E7
16
, 03EA
16
03EB
16
, 03EE
16
, 03EF
16
, 03F6
16
When reset
00
16
Port Pi direction register (Note)
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
O O
O O
0 : Input mode (Functions as an
input port)
1 : Output mode (Functions as an
output port)
Nothing is assigned.
Write "0" when writing to this bit. The value is indeterminate if read.
0 : Input mode (Functions as an
input port)
1 : Output mode (Functions as an
output port)
PD8_6
PD8_7
Port P8
6
direction register
Port P8
7
direction register
Bit Symbol Bit Name Function R W
PD9_0
PD9_2
PD9_3
Port P9
0
direction register
Port P9
2
direction register
Port P9
3
direction register
Symbol
PD9 Address
03F3
16
When reset
XXXX00XX0
2
Port P9 direction register
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
_ _
0 : Input mode (Functions as an
input port)
1 : Output mode (Functions as an
output port)
Nothing is assigned.
Write "0" when writing to this bit. The value is "0" if read.
0 : Input mode (Functions as an
input port)
1 : Output mode (Functions as an
output port)
Nothing is assigned.
Write "0" when writing to this bit. The value is "0" if read. _ _
Note: In memory expansion mode and microprocessor mode, the contents of corresponding Port Pi direction
register of pins A
0
to A
19
, D
0
to D
15
, CS
0
to CS
3
, RD, WRL/WR, WRH/BHE, ALE, RDY, HOLD HLDA and
BCLK cannot be modified.
Figure 1.136. Direction registers
Programmable Ports
183
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Bit Symbol Bit Name Function R W
Pi_0
Pi_1
Pi_2
Pi_3
Pi_4
Pi_5
Pi_6
Pi_7
Port Pi
0
register
Port Pi
1
register
Port Pi
2
register
Port Pi
3
register
Port Pi
4
register
Port Pi
5
register
Port Pi
6
register
Port Pi
7
register
Data is input and output to and
from each pin by reading the
writing to and from each
corresponding bit.
0 : "L" level data
1 : "H" level data (Note 1)
O O
Symbol
Pi (i = 0 to 7, 10) Address
03E0
16
, 03E1
16
, 03E4
16
, 03E5
16
, 03E8
16
03E9
16
, 03EC
16
, 03ED
16
, 03F4
16
When reset
00
16
Port Pi register (Note 2)
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
O O
O O
Note 1: Because P7
0
and P7
1
are N-channel open drain ports, the data are high-impedance.
Note 2: In memory expansion mode and microprocessor mode, the contents of corresponding port
Pi register of pins A
0
to A
19
, D
0
to D
15
, CS
0
to CS
3
, RD, WRL/WR,WRH/BHE, ALE, RDY,
HOLD HLDA and BCLK cannot be modified.
Bit Symbol Bit Name Function R W
P8_0
P8_1
P8_2
P8_3
P8_4
P8_5
P8_6
P8_7
Port P8
0
register
Port P8
1
register
Port P8
2
register
Port P8
3
register
Port P8
4
register
Port P8
5
register
Port P8
6
register
Port P8
7
register
Data is input and output to and
from each pin by reading the
writing to and from each
corresponding bit.
0 : "L" level data
1 : "H" level data
(except P8
5
)
O O
Symbol
P8 Address
03F0
16
When reset
00X00000
2
Port P8 register
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
O O
O X
Bit Symbol Bit Name Function R W
P9_0
VBDS
P9_2
P9_3
Port P9
0
register
Vbus detect state bit
Port P9
2
register
Port P9
3
register
_ _
Symbol
P9 Address
03F1
16
When reset
Indeterminate
Port P9 register
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O X
Nothing is assigned.
Write "0" when writing to these bits. The value is "0" if read.
0 : "L" level data
1 : "H" level data
0 : Not powered
1 : Powered (Note)
0 : "L" level data
1 : "H" level data
0 : "L" level data
1 : "H" level data
Note: This
p
in cannot be used for GPI/O. This bit reads "0" when Vbus detect is disabled.
Figure 1.137. Port registers
Programmable Ports
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
184
Bit Symbol Bit Name Function R W
PU00
PU01
PU02
PU03
PU04
PU05
PU06
PU07
P0
0
to P0
3
pull up
P0
4
to P0
7
pull up
P1
0
to P1
3
pull up
P1
4
to P1
7
pull up
P2
0
to P2
3
pull up
P2
4
to P2
7
pull up
P3
0
to P3
3
pull up
P3
4
to P3
7
pull up
The corresponding port is pulled
high with a pull-up resistor
0 : Not pulled high
1 : Pulled high
O O
Symbol
PUR0
Address
03FC
16
When reset
00
16
Pull-up control register 0 (Note)
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
O O
O O
Note: In memory expansion and microprocessor mode, the contents of this register can be
changed but the pull-up resistor is not connected.
Nothing is assigned.
Write "0" when writing to these bits. The value is "0" if read.
Bit Symbol Bit Name Function R W
PU10
PU11
PU12
PU13
PU14
PU15
PU16
PU17
P4
0
to P4
3
pull up (Note 3)
P4
4
to P4
7
pull up
P5
0
to P5
3
pull up (Note 3)
P5
4
to P5
7
pull up
P6
0
to P6
3
pull up
P6
4
to P6
7
pull up
P7
0
to P7
3
pull up (Note 1)
P7
4
to P7
7
pull up
The corresponding port is pulled
high with a pull-up resistor
0 : Not pulled high
1 : Pulled high
O O
Symbol
PUR1
Address
03FD
16
When reset (Note 2)
00
16
Pull-up control register 1
b7 b5b6 b4 b3 b2 b1 b0
O O
O O
O O
O O
O O
O O
O O
Note 1: Pull-up is not available for P7
0
and P7
1
because they are N-channel open drain ports.
Note 2: This register becomes 0216 when reset under the following conditions:
a) Hardware reset: when Vcc is applied to the CNVss pin.
b) Software reset: if bit 1 and bit 0 of processor mode register 0 (address 000416) are
102 or 112 before reset.
Note 3: In memory expansion and microprocessor mode, the contents of this register can be
changed but the pull-up resistor is not connected.
Bit Symbol Bit Name Function R W
PU20
PU21
PU22
P8
0
to P8
3
pull up
P8
4
to P8
7
pull up (except P8
5
)
P9
0
to P9
3
pull up (except P9
1
)
The corresponding port is pulled
high with a pull-up resistor
0 : Not pulled high
1 : Pulled high
O O
Symbol
PUR2
Address
03FE
16
When reset
00
16
Pull-up control register 2
b7 b5b6 b4 b3 b2 b1 b0
O O
_ _
O O
O O
O O
PU24
PU25
P10
0
to P10
3
pull up
P10
4
to P10
7
pull up
The corresponding port is pulled
high with a pull-up resistor
0 : Not pulled high
1 : Pulled high
_ _
Nothing is assigned.
Write "0" when writing to these bits. The value is "0" if read.
Figure 1.138. Pull-up control registers
Programmable Ports
185
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Note: With external clock input to XIN pin.
Pin name Connection
P0 to P10 (excluding P85)After setting to input mode, connect every pin to Vss or Vcc using a resistor.
OR
Leave these pins open after setting to output mode.
Xout (Note) Open
NMI Connect using resistor to Vcc (pull-up)
UVcc, AVcc Connect to Vcc
AVss, V
REF
, BYTE Connect to Vss
USB D+, USB D-
LPF
VbusDTCT
Open
Open
Open
Note: With external clock input to X
IN
pin.
Pin name Connection
P6 to P10 (excluding P8
5
)After setting to input mode, connect every pin to Vss or Vcc using a resistor.
OR
Leave these pins open after setting to output mode.
P4
5
/CS1 to P4
7
/CS3 Sets ports to input mode.
Sets bits CS1 through CS3 to 0
Connect to Vcc using resistors (pull-up)
BHE, ALE, HLDA, X
OUT
(Note), BCLK Open
HOLD, RDY, NMI Connect using resistor to Vcc (pull-up)
UVcc, AVcc Connect to Vcc
Port P0 to P10 (except for P8
5
)
(Input mode)
·
·
·
(Input mode)
(Output mode)
NMI
XOUT
UVcc, AVcc
BYTE
AVSS
VREF
Microcomputer
VSS
In single-chip mode
Port P6 to P10 (except for P8
5
)
(Input mode)
·
·
·
(Input mode)
(Output mode)
NMI
XOUT
UVcc, AVcc
AVSS
VREF
Open
Microcomputer
VCC
VS
S
In memory expansion mode or
in microprocessor mode
HOLD
RDY
ALE
BCLK (Note)
BHE
HLDA
Open
Open Open
·
·
· ·
·
·
Port P45 / CS1
to P47 / CS3
N
ote : When the BCLK output disable bit (bit 7 at address 000416) is set to “1”, connect to VCC using a pull-up resisto
r
LPF Open
USB D+, USB D-
Open Open
USB D+, USB D-
Open
LPF
VbusDTCT
Open
Vcc
Vcc
Vcc
Open
VbusDTCT Vcc
Table 1.64. Example connection of unused pins in single-chip mode
Table 1.65. Example connection of unused pins in memory expansion mode
Figure 1.139. Example connection of unused pins
Flash Memory
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
186
Flash memory
The M30245FC contains flash memory that can be rewritten with a single voltage of 3.3 V. Three flash
memory modes are available to read, program, and erase:
• CPU rewrite mode in which the flash memory can be manipulated by the Central Processing Unit (CPU).
• Parallel I/O and standard serial I/O modes can be manipulated using a programmer
The flash memory is divided into several blocks as shown in Figure 1.140.
Memory can be erased one block at a time. Each block has a lock bit to enable or disable execution of an
erase or program operation. This allows data in each block to be protected. Table 1.66 shows an overview
of the M30245 (flash memory version).
In addition to the ordinary user ROM area that stores the microcomputer operation program, the flash
memory has a boot ROM area that stores a program to control rewriting in CPU rewrite and standard serial
I/O modes. The boot ROM area has a standard serial I/O mode control program stored in it when it is
shipped from the factory. However, the user can write a CPU rewrite control program in this area specific
to the user’s application system. The boot ROM area can only be rewritten in parallel I/O mode.
Figure 1.140. Flash memory version user ROM memory map
User ROM area Boot ROM area
Note 1: The boot ROM area can be rewritten only in parallel input/
output mode. (Access to any other areas is inhibited.)
Note 2: To specify a block, use the maximum address in the block
that is an even address.
8K bytes
FE000
16
FFFFF
16
F0000
16
Block 3 : 32K bytes
F8000
16
Block 2 : 8K bytes
FA000
16
Block 1 : 8K bytes
Block 0 : 16K bytes
FC000
16
FFFFF
16
E0000
16
Block 4 : 64K bytes
Flash Memory
187
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.66. M30245 Flash Memory Overview
Note: The boot ROM contains a stored standard serial I/O control program when it is shipped from the factory. This
area can be erased and programmed in parallel I/O mode only.
Item Performance
Power supply voltage 3.0V to 3.6V
Program/erase voltage 3.0V to 3.6V
Flash memory operation mode 3 modes:
CPU
Parallel I/O
Standard serial I/O
Erase block division User ROM area See Figure 1.141
Boot ROM area One division (8 Kbytes) Note
Program method In page units (256 bytes)
Erase meth od Collective erase/block erase
Program/erase control method Program/erase control by software command
Protect method Protection for each block by lock bit
Number of commands 8
Program/erase count 100 times
Data holding 10 years
ROM code protect Parallel I/O and Standard serial I/O modes are supported
rewrite
CPU Rewrite Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
188
CPU Rewrite Mode
In CPU rewrite mode, the on-chip flash memory can be read, programmed, or erased under control of the
Central Processing Unit (CPU). Only the user ROM area, shown in Figure 1.140, can be rewritten. The
boot ROM area cannot be rewritten. Make sure the program and block erase commands are issued only
for each block of the user ROM area.
The control program for CPU rewrite mode can be stored in either the user ROM or the boot ROM area.
Because the flash memory cannot be read from the CPU, the rewrite control program must be trans-
ferred to an area other than the internal flash memory before it can be executed.
Overview
In the CPU rewrite mode, the CPU erases, programs and reads the internal flash memory as
instructed by software commands. Operations are executed from a memory other than the
internal flash memory, such as the internal RAM.
When the CPU rewrite mode select bit (bit 1 at address 02F716) is set to “1”, transition to CPU
rewrite mode occurs and software commands can be accepted. Read and write software com-
mands and data to even-numbered addresses (“0” for address A0) in 16-bit units. For 8-bit mode,
always write 8-bit software commands to even-numbered addresses. Commands are ignored
with odd-numbered addresses. Use software commands to control program and erase opera-
tions. The status register can verify if a program or erase operation has terminated normally or in
error.
Figure 1.141 shows the flash memory control register 0. Figure 1.142 shows a flowchart for
enabling/disabling the CPU rewrite mode. Always follow the operation as indicated in these
flowcharts.
Bit 0 is the RY/BY status flag used exclusively to read the operating status of the flash memory.
During programming and erase operations, it is “0”. Otherwise, it is “1”.
Bit 1 is the CPU rewrite mode select bit. The CPU rewrite mode is entered by setting this bit to “1”
to make software commands accepted. In CPU rewrite mode, the CPU becomes unable to
access the internal flash memory directly so, write bit 1 in an area other than the internal flash
memory. To set this bit to “1”, it is necessary to write “0” and then write “1” in succession when
the NMI pin is “H” level. The bit can be set to “0” by only writing “0”.
Bit 2 is the lock bit disable bit. By setting this bit to “1”, it is possible to disable erase and write
protect (block lock) effected by the lock bit data. The lock bit disable select bit only disables the
lock bit function; it does not change the lock data bit value. However, if an erase operation is
performed when this bit = “1”, the lock bit data that is “0” (locked) is set to “1” (unlocked) after
being erased. To set this bit to “1”, it is necessary to write “0” and then write “1” in succession.
This bit can be controlled only when the CPU rewrite mode select bit = “1”.
Bit 3 is the flash memory reset bit used to reset the control circuit of the internal flash memory.
This bit is used when exiting CPU rewrite mode and when flash memory access has failed. When
the CPU rewrite mode select bit is “1”, writing “1” to this bit resets the control circuit. To release
the reset, set this bit to “0”.
Bit 5 is the user ROM area select bit that is effective only in boot mode. If this bit is set to “1”, the
accessed area is switched from the boot ROM area to the user ROM area. When the CPU
rewrite mode is used in boot mode, set this bit to “1”. If the microcomputer is booted from the
user ROM area, the user ROM area is always accessed and this bit has no effect. When in boot
mode, the function of this bit is effective regardless of whether the CPU rewrite mode is on or off.
Use a control program that is not running in the internal flash memory to rewrite this bit.
CPU Rewrite Mode
189
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.141. Flash memory control register
Figure 1.142. CPU rewrite mode set/reset flowchart
Bit Symbol Bit Name Function R W
FMR00
FMR01
FMR02
FMR03
Reserved
FMR05
Nothing is assigned. Write "0" when writing to these bits.
The value is indeterminate if read.
RY/BY status bit
CPU rewrite mode select bit
(Note 1)
Lock bit disable bit
(Note 2)
Flash memory reset bit
(Note 3)
User ROM area select bit
(Note 4).
0 : Busy (overwrite or erase)
1 : Ready
0 : Normal mode
(invalid software commands)
1 : CPU rewrite mode
(software command accepted)
0 : Enabled
1 : Disabled
0 : Normal operation
1 : Reset
Must always be "0"
0 : Boot ROM area accessed
1 : User ROM area accessed
O O
Symbol
FMR0 Address
02F716 When reset
XX00000116
Flash memory control register 0
b7 b5b6 b4 b3 b2 b1 b0
O X
O O
O O
O O
_
_
O O
Note 1: To set this bit to "1", the user must write "0" and then "1" to it in succession. This bit
set to "1" unless this sequence has been performed. This is necessary to ensure th
interrupt or DMA transfer are executed during the interval. Use the control program
e
in the internal flash memory for writing to this bit. Also, write to this bit when the NM
is "H" level.
Note 2: To set this bit to "1", the user must write "0" and then "1" to it in succession when th
e
rewrite mode select bit = "1". This bit is not set to "1" unless this sequence has bee
n
performed. This is necessary to ensure that no interrupt or DMA transfer are execut
e
during the interval.
Note 3: Effective only when CPU rewrite mode select bit "1". Set this bit to "1" and then "0" i
succession.
Note 4: Effective only in boot mode. Use a control program that is not in the internal flash m
e
when writing to this bit.
0
End
Start
Execute read array command or reset flash
memory by setting flash memory reset bit (by
writing “1” and then “0” in succession) (Note 3)
Single-chip mode, memory expansion
mode, or boot mode
Set processor mode register (Note 1)
Using software command execute erase,
program, or other operation
(Set lock bit disable bit as required)
Jump to transferred control program in RAM
(Subsequent operations are executed by control
program in this RAM)
Transfer CPU rewrite mode control
program to internal RAM
Note 1: During CPU rewrite mode, set the main clock frequency as shown below using the main clock division
register (addresses 0006
16
and 0007
16
):
6.25 MHz or less when wait bit (bit 7 at address 0005
16
) = “0” (without internal access wait state)
12.5 MHz or less when wait bit (bit 7 at address 0005
16
) = “1” (with internal access wait state)
Note 2: For CPU rewrite mode select bit to be set to “1”, the user needs to write a “0” and then a “1” to it in
succession. When it is not this procedure, it is not enacted in “1”. This is necessary to ensure that no
interrupt or DMA transfer will be executed during the interval. Use the program except in the internal
flash memory for write to this bit. Also write to this bit when NMI pin is "H" level.
Note 3: Before exiting the CPU rewrite mode after completing erase or program operation, always be sure to
execute a read array command or reset the flash memory.
Note 4: “1” can be set. However, when this bit is “1”, user ROM area is accessed.
(Boot mode only)
Write “0” to user ROM area select bit (Note 4)
Write “0” to CPU rewrite mode select bit
(Boot mode only)
Set user ROM area select bit to “1”
Set CPU rewrite mode select bit to “1” (by
writing “0” and then “1” in succession)(Note 2)
*1
*1
Program in ROM Program in RAM
CPU Rewrite Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
190
Microcomputer Mode and Boot Mode
The control program for CPU rewrite mode must be written into the user ROM or boot ROM area in
parallel I/O mode. If the control program is written into the boot ROM area, the standard serial I/O
mode becomes unusable.
Normal microcomputer mode is entered when the microcomputer is reset when pulling CNVSS pin
low. In this case, the CPU starts operating using the control program in the user ROM area.
When the microcomputer is reset by pulling the P55 pin low, and the CNVSS pin and P50 pin high,
the CPU starts operating using the control program in the boot ROM area. This mode is called the
“boot” mode. The control program in the boot ROM area can also be used to rewrite the user ROM
area.
Block Address
Block addresses refer to the maximum even address of each block. These addresses are used in
the block erase command, lock bit program command, and read lock status command.
Software Commands
Table 1.67 lists the software commands available with the M30245 (flash memory version).
After setting the CPU rewrite mode select bit to 1, write a software command to specify an erase
or program operation. When entering a software command, the upper byte (D8 to D15) is ignored.
Table 1.67. List of software commands
Note 1: When a software command is input, the data high-order byte (D
8
to D
15
) is ignored.
Note 2: SRD= Status register data
Note 3: WA = Write address, WD = Write data.
WA and WD must be set sequentially from 00
16
to FE
16
(even byte address). The page size is 256 bytes.
Note 4: BA = Block address. Enter the maximum address of each block that is an even address.
Note 5: D
6
corresponds to the block lock status. When D
6
= "1", the unlocked blocks are "0".
Note 6: X denotes a given even address in the user ROM area.
Command
First bus cycle Second bus cycle Third bus cycle
Mode Address Data
(D
0
to D
7
)Mode Address Data
(D
0
to D
7
)Mode Address Data
(D
0
to D
7
)
1 Read array Write X (Note 6) FF
16
2 Read status register Write X 70
16
Read X SRD (Note 2)
3 Clear status register Write X 50
16
4 Page program (Note 3) Write X 41
16
Write WA0 (Note 3) WD0 (Note 3) Write WA1 WD1
5 Block erase Write X 20
16
Write BA (Note 4) D0
16
6 Erase all unlocked blocks Write X A7
16
Write X D0
16
7 Lock bit program Write X 77
16
Write BA D0
16
8 Read lock bit status Write X 71
16
Read BA D
6
(Note 5)
CPU Rewrite Mode
191
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.143. Page program flowchart
n = FE
16
Start
Write 41
16
n = 0
Write address n and
data n
RY/BY status flag
= 1?
Check full status
Page program
completed
n = n + 2
NO
YES
NO
YES
1. Read Array Command (FF16)
The read array mode is entered by writing the command code “FF16” in the first bus cycle.
When an even address that is to be read is input in one of the bus cycles that follow, the
content of the specified address is read out at the data bus (D0–D15), 16 bits at a time.
The read array mode is retained until another command is written.
2. Read Status Register Command (7016)
When the command code “7016” is written in the first bus cycle, the content of the status
register is read out at the data bus (D0–D7) by a read in the second bus cycle.
3. Clear Status Register Command (5016)
This command clears the bits SR3 to SR5 of the status register after being set. These bits
indicate that operation has ended in an error. To use this command, write the command
code “5016” in the first bus cycle.
4. Page Program Command (4116)
Page program allows for high-speed programming in units of 256 bytes. Page program
operation starts when the command code “4116” is written in the first bus cycle. In the
second bus cycle through the 129th bus cycle, the write data is sequentially written 16 bits at
a time. At this time, the addresses A0-A7 need to be incremented by 2 from “00 16” to “FE16.”
When the system finishes loading the data, it starts an auto write operation (data program
and verify operation). Figure 1.143 shows an example of a page program flowchart.
The completed auto write operation can be confirmed by reading the status register or the
flash memory control register 0. At the same time the auto write operation starts, the read
status register mode is automatically entered, so the content of the status register can be
read out. The status register bit 7 (SR7) is set to 0 at the same time the auto write operation
starts and is returned to 1 when the auto write operation has been completed. In this case,
the read status register mode remains active until the Read Array command (FF16) or Read
Lock Bit Status command (7116) is written or the flash memory is reset using its reset bit.
The RY/BY status flag of the flash memory control register 0 is “0” during auto write opera-
tion and “1” when the auto write operation and status register bit 7 have been completed.
After the auto write operation is completed, the status register can read out the results of the
auto write operation. Refer to the status register section for more details.
Each block of the flash memory can be write protected by using a lock bit. Refer to the data
protect function section for more details. Additional writes to the pages previously pro-
grammed are prohibited.
CPU Rewrite Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
192
5. Block Erase Command (2016/D016)
By writing the command code “2016” in the first bus cycle and the confirmation command code
“D016” in the second bus cycle to the block address of a flash memory block, the system initiates
an auto erase (erase and erase verify) operation. Figure 1.144 is an example of a block erase
flowchart.
Read the status register or the flash memory control register 0 to confirm the completion of the
auto erase operation. At the same time the auto erase operation starts, the read status register
mode is automatically entered, so the contents of the status register can be read out. The status
register bit 7 (SR7) is set to “0” at the same time the auto erase operation starts and is returned
to “1” when the auto erase operation is completed. The read status register mode remains active
until the Read Array command (FF16) or Read Lock Bit Status command (7116) is written or the
flash memory is reset using its reset bit.
The RY/BY status flag of the flash memory control register 0 is “0” during auto erase operation
and “1” when the auto erase operation and status register bit 7 is completed.
After the auto erase operation is completed, the status register can read for the results of the
auto erase operation. Refer to the status register for more details.
A lock bit protects each block of the flash memory against erasure. Refer to the data protect
function section for more details.
6. Erase All Unlock Blocks Command (A716/D016)
By writing the command code “A716” in the first bus cycle and the confirmation command code
“D016” in the second bus cycle that follows, the system starts erasing blocks successively.
Reading the status register or the flash memory control register 0 confirms whether the erase all
unlock blocks command was terminated in the same way as for block erase. Also, the status
register can read out the results of the auto erase operation.
When the lock bit disable bit of the flash memory control register 0 = “1”, all blocks are erased
regardless of how the lock bit is set. On the other hand, when the lock bit disable bit = “0”, the
function of the lock bit is effective and only unlocked blocks (where lock bit data = “1”) are erased.
Figure 1.144. Block erase flowchart
Write 20
16
Write D0
16
Block address
Check full status check
Block erase
completed
Start
RY/BY status flag
= 1?
NO
YES
CPU Rewrite Mode
193
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.145. Lock bit program flowchart
7. Lock Bit Program Command (7716/D016)
By writing the command code “7716” in the first bus cycle and the confirmation command code
“D016” in the second bus cycle to the block address of a flash memory block, the system sets the
lock bit for the specified block to “0” (locked).
Figure 1.145 is an example of a lock bit program flowchart. The lock bit status (lock bit data) can
be read out by a read lock bit status command.
Reading the status register or the flash memory control register 0 confirms whether the lock bit
program command has terminated the same way as in the page program.
Refer to the data protect function section for more details.
Write 77
16
Write D0
16
block address
SR4 = 0? NO
Lock bit program
completed
Lock bit program in
error
YES
Start
RY/BY status flag
= 1?
NO
YES
8. Read Lock Bit Status Command (7116)
By writing the command code “7116” in the first bus cycle and then the block address of a flash
memory block in the second bus cycle that follows, the system reads out the status of the lock bit
of the specified block to the data bit (D6). Figure 1.146 is an example of a read lock bit program
flowchart.
Figure 1.146. Read lock bit status flowchart
Write 7116
Enter block address
D6 = 0? NO
Blocks locked Blocks not locked
YES
Start
CPU Rewrite Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
194
Data Protect Function (Block Lock)
Each block in Figure 1.140 has a nonvolatile lock bit to specify that the block is protected (locked)
against erase/write. The lock bit program command is used to set the lock bit to 0 (locked). The
lock bit of each block can be read out using the read lock bit status command.
Whether block lock is enabled or disabled is determined by the status of the lock bit and the lock
bit disable bit in flash memory control register 0.
(1) When the lock bit disable bit = “0”, a specified block can be locked or unlocked by the lock bit
status (lock bit data). If lock bit data = “0” (locked), they are disabled against erase/write. On the
other hand, if lock bit data = “1” (unlocked) they are enabled for erase/write.
(2) When the lock bit disable bit = “1”, all blocks are unlocked regardless of the lock bit data, and
enabled for erase/write. In this case, the lock bit data is set to “1” (unlocked) after erasure, so that
the lock bit is disabled.
Status Register
The status register indicates the flash memory operating status and whether an erase or program
operation has terminated normally or in error. Table 1.68 details the status register. The contents
of this register can be read out only by writing the read status register command (7016). Writing
the Clear Status Register command (5016) clears the status register. After a reset, the status
register is set to “8016.”
Table 1.68. Status register bit definition
Write state machine (WSM) status (SR7)
After power-on, the write state machine (WSM) status is set to “1”.
The write state machine (WSM) status indicates the operating status of the RY/BY pin output. This
status bit is set to “0” during an auto write or auto erase operation and is set to “1” when the
operation is completed.
Each SRD bit Status name Definition
“1” “0”
SR7 (Bit 7) Write state machine (WSM) Ready Busy
SR6 (Bit 6) Reserved _ _
SR5 (Bit 5) Erase status Terminated in error Terminat ed norm ally
SR4 (Bit 4) Program status Terminated in error Terminated norm ally
SR4 (Bit 3) Block status after program Terminated in error Termin ated normally
SR2 (Bit 2) Reserved _ _
SR1 (Bit 1) Reserved _ _
SR0 (Bit 0) Reserved _ _
CPU Rewrite Mode
195
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Erase status (SR5)
The erase status indicates the operating status of an auto erase to the CPU. It is set to “1” when
an erase error occurs. The erase status is reset to “0” when cleared.
Program status (SR4)
The program status indicates the operating status of an auto write to the CPU. It is set to “1”
when a write error occurs. The program status is reset to “0” when cleared.
When an erase command is in error, which occurs if the command entered after the block erase
command (2016) is not the confirmation command (D016), both the program status and erase
status (SR5) are set to “1”.
If the program status or erase status = “1”, the following commands entered by command write
are not accepted and SR4 and SR5 are set to “1” (command sequence error):
(1) A valid command is not entered correctly
(2) The data entered in the second bus cycle of lock bit program (7716/D016), block erase (2016/
D016), or erase all unlocked blocks (A716/D016) is not the D016 or FF16. However, if FF16 is
entered, read array is assumed and the command that has been set up in the first bus cycle is
canceled.
Block status after program (SR3)
If data is overwritten (this occurs when a memory cell becomes overcharged and data incorrectly
read), “1” is set for the program status after the program at the end of the page write operation. In
other words:
• When writing ends successfully, “8016” is output;
• When writing fails, “9016” is output;
• When excessive data is written, “8816” is output.
Full-Status Check
A full-status check allows the user to review the erase and program operations. Figure 1.147
shows a full-status check flowchart and the action to take when an error occurs.
Figure 1.147. Full-status check flowchart
Read status register
SR4=1 and
SR5=1 ?
NO
Command
sequence error
YES
SR5=0?
YES
Block erase error
NO
SR4=0?
YES
Program error (page
or lock bit)
NO
End (block erase, program)
Execute the clear status register command (50
16
)
to clear the status register. Tr y performing the
operation one more time after confirming that the
command is entered correctly.
If a block erase error occurs, the block in error
cannot be used.
Execute the read lock bit status command (71
16
) to
see if the block is locked. After removing the lock, 
execute a write operation the same way. If the error still occurs,
the page in error cannot be used.
Note: When one of SR5 to SR3 is set to 1, none of the page program, block erase, erase all
YES
SR3=0? Program error
(block)
NO After erasing the block in error, exectue the operation again.
If the same error still occurs, the block in error cannot
be used.

unlocked blocks and lock bit program commands are accepted. Execute the clear 
status register command (50
16
) before executing these commands.
CPU Rewrite Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
196
Precautions
Operation speed
During CPU rewrite mode, set the main clock frequency as shown below using the main clock
division select bits (bit 6 at address 000616, and bits 6 and 7 at address 000716):
6.25 MHz or less when wait bit (bit 7 at address 000516) = 0 (without internal access wait state)
12.5 MHz or less when wait bit (bit 7 at address 000516) = 1 (with internal access wait state)
Prohibited Instructions
The UND, INTO, JMPS, JSRS, and BRK instructions cannot be used during CPU rewrite mode
because they refer to the internal data of the flash memory.
Prohibited Interrupts
The address match interrupt cannot be used during CPU rewrite mode because it refers to the
internal data of the flash memory. If the interrupt’s vector is in the variable vector table, it can be
used by transferring the vector into the RAM area.
The NMI and watchdog timer interrupts can be used to change the CPU rewrite mode select bit
forcibly to normal mode (FMR01=”0") when the interrupt occurs. If the rewrite operation is
stopped when the NMI or watchdog timer interrupts occurs, the CPU rewrite mode select bit
should be set to “1” and the erase/program operation should be repeated.
Reset
Reset input is always accepted.
Access
To set the CPU rewrite mode select bit, and the lock bit disable bit to “1”, the user must write a
“0” and then a “1”. This sequence must be followed to set this bit to “1”. This is necessary to
ensure that no interrupt or DMA transfer will be executed during the interval.
Write to the CPU rewrite mode select bit when NMI pin is a “H” level.
Access disable
Write the CPU rewrite mode select bit, and the user ROM area select bit in an area other than the
internal flash memory.
Writing in the user ROM area
If power is lost while rewriting blocks that contain the flash rewrite program with the CPU rewrite
mode, the blocks may not be correctly rewritten. Afterwards, it is possible that the flash memory
can not be rewritten. Therefore, use the standard serial I/O mode or parallel I/O mode to rewrite
these blocks.
Using the lock bit
In CPU rewrite mode, use a program that can set and clear the lock bit disable bit (FMR02).
Parallel I/O Mode
197
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Parallel I/O Mode
The parallel I/O mode can be used to input and output the software commands, addresses and data
needed to operate (read, program, erase, etc.) the internal flash memory. In this mode, the M30245
(flash memory version) operates in a manner similar to other flash memory from Mitsubishi. Because
there are some differences with some functions not available with the microcomputer and the memory
capacity, the M30245 cannot be programmed by a programmer for other Mitsubishi flash memory. Use
an exclusive programmer that supports the M30245 (flash memory version). Refer to the instruction
manual of each programmer manufacturer for usage details.
User ROM and Boot ROM Areas
In parallel I/O mode, the user ROM and boot ROM areas shown in Figure 1.140 can be rewritten.
Both areas of flash memory can be operated on in the same way.
Program and block erase operations can be performed in the user ROM area. The user ROM
area and it's blocks are shown in Figure 1.140.
The boot ROM area is 8 Kbytes in size. In parallel I/O mode, it is located at addresses 0FE00016
through 0FFFFF16. Ensure that the program and block erase operations are always performed
within this address range. Access to any location outside this address range is prohibited.
In the boot ROM area, an erase block operation is applied to only one 8 Kbyte block. The boot
ROM area has a standard serial I/O mode control program installed at the Mitsubishi factory,
therefore, it is unnecessary to write to the boot ROM area when using standard serial I/O mode.
Parallel I/O Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
198
Figure 1.148. ROM code protect control register
Bit Symbol Bit Name Function
Reserved
ROMCP2
ROMCR
ROMCP1
ROM code protect level 2
set bit (Note 1, 2)
ROM code protect reset bit
(Note 3)
ROM code protect level 1
set bit (Note 1)
Always set to "1"
b3 b2
0 0 : Protect enable
0 1 : Protect enable
1 0 : Protect enable
1 1 : Protect enable
b5 b4
0 0 : No protect set bit
0 1 : Protect set bit active
1 0 : Protect set bit active
1 1 : Protect set bit active
b7 b6
0 0 : Protect enable
0 1 : Protect enable
1 0 : Protect enable
1 1 : Protect enable
Symbol
ROMCP Address
0FFFFF
16
ROM code protect control register
b7 b5b6 b4 b3 b2 b1 b0
Note 1: When ROM code protect is turned on, the on-chip flash memory is
protected against readout or modification in parallel input/output mode.
Note 2: When ROM code protect level 2 is turned on, ROM code readout by a
shipment inspection LSI tester, etc, is inhibited.
Note 3: The ROM code protect reset bits can be used to turn off ROM code protect
levels 1 and 2. However, because these bits cannot be changed in parallel
input/output mode, they need to be rewritten in serial input/output or some
other mode.
11
When reset
FF
16
ROM code protect function
To prevent the contents of the flash memory from being read out or rewritten too easily, the
device incorporates a ROM code protect function for use in parallel I/O mode. The ROM code
protect function prevents reading out or modifying the contents of the flash memory by using the
ROM code protect control register (0FFFFF16) during parallel I/O mode. Figure 1.148 shows the
ROM code protect control address. (This address exists in the user ROM area.)
If one pair of ROM code protect bits is set to “0”, ROM code protect is turned on so that the
contents of the flash memory are protected against being read out or modified. The ROM code
protect function is implemented in two levels. If level 2 is selected, the flash memory is protected
even against readout by a shipment inspection LSI tester, etc. If both level 1 and level 2 are
selected, level 2 is selected by default.
If both of the two ROM code protect reset bits are set to “00,” the ROM code protect function is
turned off so that the contents of the flash memory can be read out or modified. Once ROM code
protect is turned on, the contents of the ROM code protect reset bits cannot be modified in
parallel I/O mode. Use the serial I/O mode or another mode to rewrite the contents of the ROM
code protect reset bits.
Serial I/O Mode
199
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Standard Serial I/O Mode
The standard serial I/O mode serially inputs and outputs the software commands, addresses and data
needed to operate (read, program, erase, etc.) the internal flash memory. It uses a specific serial pro-
grammer to accomplish this. It is different from the parallel I/O mode because the CPU controls opera-
tions like rewriting the flash memory (using the CPU rewrite mode) and serially inputting data.
The standard serial I/O mode is entered by clearing the reset with the P50 (CE) pin set to a “H” level, the
P55 (EPM) pin set to a “L” level and the CNVss pin set to a “H” level. (For normal microprocessor mode,
set the CNVss pin to “L” level.)
A control program is written in the boot ROM area when the product is shipped from Mitsubishi. The standard
serial I/O mode cannot be used if the boot ROM area is rewritten in the parallel I/O mode. Figure 1.149 shows the
pin connections for the standard serial I/O mode. Table 1.69 lists the pin functions for standard serial IO mode.
There are two standard serial I/O modes that both require a purpose-specific serial programmer: clock synchro-
nous and clock asynchronous. Standard serial I/O switches between mode 1 (clock synchronous) and mode 2
(clock asynchronous) according to the level of the CLK1 pin when the reset is released. Serial data I/O uses
UART1 and transfers the data serially in 8-bit units.
To use standard serial I/O mode 1 (clock synchronous):
• Set the CLK1 pin to “H” level and release the reset
• This mode uses the four UART1 pins CLK1, RxD1, TxD1 and RTS1 (BUSY).
• The CLK1 pin is the transfer clock input pin through which an external transfer clock is input.
• The TxD1 pin is for CMOS output.
• The RTS1 (BUSY) pin outputs an “L” level when ready for reception and an “H” level when reception starts.
To use standard serial I/O mode 2 (clock asynchronous):
• Set the CLK1 pin to “L” level and release the reset.
• This mode uses the two UART1 pins RxD1 and TxD1.
In standard serial I/O mode, only the user ROM area indicated in Figure 1.140 can be rewritten. The boot ROM
cannot.
The standard serial I/O mode uses a 7-byte ID code. When there is data in the flash memory, commands sent
from the programmer are not accepted unless the ID codes are identical.
ID Code Check Function
The ID code check function can be used in serial I/O mode to protect the contents of the flash
memory from being read out or rewritten. If the contents of the flash memory are not blank, the
ID code sent from the serial programmer is compared with the ID code written in the flash. If the
ID codes are not identical, the commands sent from the serial programmer are not accepted.
Figure 1.150 shows the ID code store addresses. The ID code consists of 8-bit data: (beginning
with the first byte) 0FFFDF16, 0FFFE316, 0FFFEB16, 0FFFEF16, 0FFFF316, 0FFFF716, and
0FFFFB16. Write a program that has the ID code preset at these addresses.
Serial I/O Mode
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
200
Figure 1.149. Pin descriptions for standard serial I/O mode
Figure 1.150. ID code storage addresses
Reset vector
Watchdog timer vector
Address match vector
BRK instruction vector
Overflow vector
Undefined instruction vector
ID7
ID6
ID5
ID4
ID3
ID2
ID1
NMI vector
0FFFFF
16
to 0FFFFC
16
0FFFFB
16
to 0FFFF8
16
0FFFF7
16
to 0FFFF4
16
0FFFF3
16
to 0FFFF0
16
0FFFEF
16
to 0FFFEC
16
0FFFEB
16
to 0FFFE8
16
0FFFE7
16
to 0FFFE4
16
0FFFE3
16
to 0FFFE0
16
0FFFDF
16
to 0FFFDC
16
4 bytes
Address
100
99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76
VbusDTCT
P9
0
/ATTACH
UVcc
USB D+
USB D-
BYTE
CNVss
P8
7
/XC
IN
P8
6
/XC
OUT
RESET
X
OUT
Vss
X
IN
Vcc
P8
5
/NMI
P8
4
/INT2
P8
3
/INT1
P8
2
/INT0
P8
1
/TA4
IN
P8
0
/TA4
OUT
P7
7
/CTS3/RTS3/SS3/TA3
IN
/LED7
P7
6
/CLK3/SCK3/TA3
OUT
/LED6
P7
5
/RxD3/SCL3/STxD3/TA2
IN
/LED5
P7
4
/TxD3/SDA3/SRxD3/TA2
OUT
/LED4
P7
3
/CTS2/RTS2/SS2/TA1
IN
/LED3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
P1
3
/D
11
P1
4
/D
12
P1
5
/D
13
P1
6
/D
14
P1
7
/D
15
P2
0
/A
0
P2
1
/A
1
P2
2
/A
2
P2
3
/A
3
P2
4
/A
4
P2
5
/A
5
P2
6
/A
6
P2
7
/A
7
Vss
P3
0
/A
8
Vcc
P3
1
/A
9
P32/A
10
P3
3
/A
11
P3
4
/A
12
P3
5
/A
13
P3
6
/A
14
P3
7
/A
15
P4
0
/A
16
P4
1
/A
17
75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51
50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26
P42/A18
P43/A19
P44/CS0
P45/CS1
P46/CS2
P47/CS3
P50/WRL/WR
P51/WRH/BHE
P52/RD
P53/BCLK
P54/HLDA
P55/HOLD
P56/ALE
P57/RDY
P60/CTS0/RST0/SS0/WS0
P61/CLK0/SCK0
P62/RxD0/SCL0/STxD0/SRxD0
P63/TxD0/SDA0/SRxD0/STxD0
P64/CTS1/RTS1/SS1/WS1
P65/CLK1/SCK1
P66/RxD1/SCL1/STxD1/SRxD1
P67/TxD1/SDA1/SRxD1/STxD1
P70/TxD2/SDA2/SRxD2/TA0OUT/LED0
P71/RxD2/SCL2/STxD2/TA0IN/LED1
P72/CLK2/TA1OUT/SCK2/LED2
P12/D10
P11/D9
P10/D8
P07/D7
P06/D6
P05/D5
P04/D4
P03/D3
P02/D2
P01/D1
P00/D0
P107/AN7/KI7
P106/AN6/KI6
P105/AN5/KI5
P104/AN4/KI4
P103/AN3/KI3
P102/AN2/KI2
P101/AN1/KI1
AVss
LPF
VREF
AVcc
P100/AN0/KI0
P93/ADTRG
P92/SOF
M30245 (100 Pin) Group
Flash Memory Version
(100P6Q)
CE
EPM
BUSY
SCLK
RxD
TxD
Vss
Vcc
RESET
CNVss
Connect
oscillation
circuit
Serial I/O Mode
201
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 1.69. Flash memory standard serial I/O mode pin functions
Pin Name IO Description
Vcc, Vss Power input Apply program/erase voltage to Vcc pin and 0V to Vss pin.
CNVss CNVss I Connect to Vcc pin.
RESET Reset input I Reset input pin. While reset is "L" level, a 20 cycle or longer clock must be input
to XIN pin.
XIN Clock input I Connect a ceramic resonator or crystal oscillator between XIN and XOUT pins. To
input an externally generated clock, input it to XIN pin and open XOUT pin.
XOUT Clock output O
BYTE BYTE I Connect this pin to Vcc or Vss.
AVcc, AVss Analog power supply input I Connect AVss to Vss and AVcc to Vcc respectively.
VREF Reference voltage input I Enter the reference voltage for A-D converter from this pin.
P00 to P07Input Port P0 I Input "H" or "L" level signal or open.
P10 to P17Input Port P1 I Input "H" or "L" level signal or open.
P20 to P27Input Port P2 I Input "H" or "L" level signal or open.
P30 to P37Input Port P3 I Input "H" or "L" level signal or open.
P40 to P47 Input Port P4 I Input "H" or "L" level signal or open.
P51 to P54, P56, P57Input Port P5 I Input "H" or "L" level signal or open.
P50CE input I Input "H" level signal.
P55 EPM input I Input "L" level signal.
P60 to P63Input Port P6 I Input "H" or "L" level signal or open.
P64BUSY output O Standard serial mode 1: BUSY signal output pin
Standard serial mode 2: Monitors the program operation check.
P65SCLK input I Standard serial mode 1: Serial clock input pin
Standard serial mode 2: Input "L" level signal
P66 RxD input I Serial data input pin
P67TxD output O Serial data output pin
P70 to P77Input Port P7 I Input "H" or "L" level signal or open.
P80 to P84, P86,P87Input Port P8 I Input "H" or "L" level signal or open.
P85NMI input I Connect this pin to Vcc
P90, P92Input Port P9 I Input "H" or "L" level signal or open.
P100 to P107Input Port P10 I Input "H" or "L" level signal or open.
, P93
Serial I/O Mode 1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
202
Figure 1.151. Example circuit application for the standard serial I/O mode 1
Standard serial I/O mode 1
In standard serial I/O mode 1, software commands, addresses, and data are input and output
between the MCU and a serial programmer using 4-wire clock-synchronized serial I/O (UART1).
Standard serial I/O mode 1 is initiated by releasing the reset with the P65 (CLK1) pin at a “H”
level.
In reception, the software commands, addresses, and program data are synchronized with the
rise of the transfer clock (input to the CLK1 pin) and input to the MCU on the RxD1 pin.
In transmission, the read data and status are synchronized with the fall of the transfer clock, and
output from the TxD1 pin. The TxD1 pin is a CMOS output. Transfer is in 8-bit units with LSB first.
When busy, such as during transmission, reception, erasing, or program execution, the RTS1
(BUSY) pin is at a “H” level. Accordingly, always start the next transfer after the RST1 (BUSY) pin
is at a “L” level.
Example Circuit Application
Figure 1.151 shows a circuit application for the standard serial I/O mode 1. Control pins will vary according
to peripheral unit (programmer), therefore check the peripheral unit (programmer) manual for more informa-
tion.
Clock input
BUSY output
Data input
Data output
(1) Control pins and external circuitry will vary according to peripheral unit (programmer). For more
information, see the peripheral unit (programmer) manual.
(2) In this example, the microprocessor mode and standard serial I/O mode are switched via a switch.
RTS1(BUSY)
CLK1
R
X
D1
T
X
D1
CNVss
P5
0
(CE)
P5
5
(EPM)
NMI
M30245 Flash
memory version
Serial I/O Mode 1
203
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Software Commands
In the standard serial I/O mode 1, erase , program and read operations are controlled by transferring
software commands using the RxD1 pin.
Data and status registers in memory can be read after inputting software commands. Reading the status
register can check the status of the flash memory operating state or successful completion of a program or
erase operation. Table 1.70 lists the software commands.
Table 1.70. Software commands
Note 1: The shaded areas indicate a transfer from flash memory MCU to peripheral unit. All other data is
transferred from the peripheral unit to the flash memory MCU.
Note 2: SRD refers to Status Register Data. SRD1 refers to S tatus Register Data 1.
Note 3: All commands are accepted if the flash memory is blank.
Control
command 2nd
byte 3rd
byte 4th
byte 5th
byte 6th
byte When ID is
no t ve r i fi e d
1Page read FF16 Address
(middle) Address
(high) Data
output Data
output Data
output Data output
to 259th byte Not
acceptable
2Page program 4116 Address
(middle) Address
(high) Data input Data input Data input Data input to
259th byte Not
acceptable
3Block erase 2016 Address
(middle) Address
(high) D016 Not
acceptable
4Erase all
unlocked blocks A716 D016 Not
acceptable
5Read status
register 7016 SRD
output SRD1
output Acceptable
6Clear status
register 5016 Not
acceptable
7Read lock bit
status 7116 Address
(middle) Address
(high) Lock bit
data output Not
acceptable
8Lock bit
program 7716 Address
(middle) Address
(high) D016 Not
acceptable
9Lock bit enable 7A16 Not
acceptable
10 Lock bit disable 7516 Not
acceptable
11 ID check
function F516 Address
(low) Address
(middle) Address
(high) ID size ID1 To ID7 Acceptable
12 Download
function FA16 Size
(low) Size
(high) Check sum Data
input As required Not
acceptable
13 Version data
output function FB16 Version
data
output
Version
data
output
Version
data output Version
data out-
put
Version data
output V ersion data
output to 9th
byte
Acceptable
14 Boot ROM area
output function FC16 Address
(middle) Address
(high) Data output Data
output Data output Data output
to 259th byte Not
acceptable
15 Read check
data FD16 Check
data
(low)
Check
data
(high)
Not
acceptable
Serial I/O Mode 1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
204
Figure 1.152. Timing for page read
1. Page Read Command
The page read command reads the specified page (256 bytes) in the flash memory sequentially one byte at
a time. Figure 1.152 shows the timing for the page read.
To execute the page read command:
(1) Transfer the “FF16” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) From the 4th byte on, data (D0–D7) for the page (256 bytes) specified by addresses A8 to A23, will be
output sequentially from the smallest address first in sync with the fall of the clock.
2. Page Program Command
This command writes the specified page (256 bytes) in the flash memory sequentially one byte at a time.
Figure 1.153 shows the page program timing.
To execute the page program command:
(1) Transfer the “4116” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) From the 4th byte on, write data (D0–D7) for the page (256 bytes) specified by addresses A8 to A23, will
be input sequentially from the smallest address first. The page is automatically written.
When reception of the page (256 bytes) ends, the RTS1 (BUSY) signal changes from the “H” to the “L”
level. The status register shows the results of the page program. Refer to the status register section for
more details.
Each block is write-protected with the lock bit. Refer to the data protection function section for more details.
Additional writing of previously programmed pages is not allowed.
Figure 1.153. Timing for the page program
data0 data255
CLK1
RxD1
TxD1
RTS1(BUSY)
A
8
to
A
15
A
16
to
A
23
FF
16
(M30245 reception data)
(M30245 transmit data)
CLK1
RxD1
TxD1
RTS1(BUSY)
A8 to
A15 A16 to
A23
4116 data0 data255
(M30245 reception data)
(M30245 transmit data)
Serial I/O Mode 1
205
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
3. Block Erase Command
This command erases the data in the specified block. Figure 1.154 shows the block erase timing.
To execute the block erase command:
(1) Transfer the “2016” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively. Write the highest
address of the specified block for addresses A16 to A23.
(3) Transfer the verify command code “D016” with the 4th byte. The verify command code allows the erase
operation to start for the specified block in the flash memory.
When the block erase is finished, the RTS1 (BUSY) signal changes from the “H” to the “L” level. The status
register shows the results of the block erase command. Refer to the status register section for more details.
Each block is erase-protected with the lock bit. Refer to the data protection section for more details.
Figure 1.154. Timing for block erasing
Figure 1.155. Timing for erasing all unlocked blocks
4. Erase All Unlocked Blocks Command
This command erases the contents of all blocks. Figure 1.155 shows the timing for erasing all unlocked
blocks. To execute the erase all unlocked blocks command:
(1) Transfer the “A716” command code with the 1st byte.
(2) Transfer the verify command code “D016” with the 2nd byte. The verify command code allows the erase
operation to continue for all of the flash memory.
When block erasing ends, the RTS1 (BUSY) signal changes from the “H” to the “L” level The status register
shows the results of the erase all unlocked blocks command. Refer to the status register section for more
details.
Each block is erase-protected with the lock bit. Refer to the data protection section for more details.
A
8
to
A
15
A
16
to
A
23
20
16
D0
16
CLK1
RxD1
TxD1
RTS1(BUSY)
(M30245 reception data)
(M30245 transmit data)
CLK1
RxD1
TxD1
RTS1(BUSY)
A716 D016
(M30245 reception data)
(M30245 transmit data)
Serial I/O Mode 1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
206
5. Read Status Register Command
This command reads the status information. Figure 1.156 shows the read status command timing.
When the “7016” command code is sent with the 1st byte, the contents of the status register (SRD) are
read with the 2nd byte and the contents of status register 1 (SRD1) are read with the 3rd byte.
SRD
output SRD1
output
CLK1
RxD1
TxD1
RTS1(BUSY)
7016
(M30245 reception data)
(M30245 transmit data)
Figure 1.156. Timing for reading the status register
6. Clear Status Register Command
This command clears the bits (SR3–SR5) that are set when an erase, program, or status operation ends
in error. Figure 1.157 shows the clear status register timing.
When the “5016” command code is sent with the 1st byte, bits SR3-SR5 are cleared. When the clear
status register operation has ended, the RTS1 (BUSY) signal changes from the “H” to the “L” level.
CLK1
RxD1
TxD1
RTS1(BUSY)
50
16
(M30245 reception data)
(M30245 transmit data)
Figure 1.157. Timing for clearing the status register
7. Read Lock Bit Status Command
This command reads the lock bit status of the specified block. Figure 1.158 shows the lock bit status
timing. To execute the read lock bit status command:
(1) Transfer the “7116” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) The lock bit data of the specified block is output with the 4th byte. The 6th bit (D6) of the output data is
the lock bit data. Write the highest address of the specified block for addresses A8 to A23.
Serial I/O Mode 1
207
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.158. Timing for reading lock bit status
CLK1
RxD1
TxD1
RTS1(BUSY)
A
8
to
A
15
A
16
to
A
23
71
16
DQ6
(M30245 reception data)
(M30245 transmit data)
8. Lock Bit Program Command
This command writes “0” (lock) for the lock bit of the specified block. Figure 1.159 shows the lock bit
program timing. To execute the lock bit program command:
(1) Transfer the “7716” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) Transfer the verify command code “D016” with the 4th byte. With the verify command code, “0” is written
to the lock bit of the specified block. Write the highest address of the specified block for addresses A8 to
A23.
When writing ends, the RTS1 (BUSY) signal changes from the “H” to the “L” level. Lock bit status can be
read with the read lock bit status command. Refer to the data protection function for more details.
Figure 1.159. Timing for the lock bit program
7A16
CLK1
RxD1
TxD1
RTS1(BUSY)
(M30245 reception data)
(M30245 transmit data)
9. Lock Bit Enable Command
This command enables the lock bit for all blocks. Figure 1.160 shows the lock bit enable timing. The
command code “7A16” is sent with the 1st byte of the serial transmission. This command only enables the
lock bit function; it does not set the lock bit itself.
Figure 1.160. Timing for enabling the lock bit
CLK1
RxD1
TxD1
RTS1(BUSY)
A8 to
A15 A16 to
A23
7716 D016
(M30245 reception data)
(M30245 transmit data)
Serial I/O Mode 1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
208
10. Lock Bit Disable Command
This command disables the lock bit for all blocks. Figure 1.161 shows the lock bit disable command
timing. The command code “7516” is sent with the 1st byte of the serial transmission. This command only
disables the lock bit function; it does not set the lock bit itself. However, if an erase command is executed
after executing the lock bit disable command, all “0” (locked) lock bit data is set to “1” (unlocked) after the
erase operation ends. After reset the lock bit is always enabled.
Figure 1.161. Timing for disabling the lock bit
11. ID Check Command
This command checks the ID code. Figure 1.162 shows the ID check command timing. To execute the
boot ID check command:
(1) Transfer the “F516” command code with the 1st byte.
(2) Transfer addresses A0 to A7, A8 to A15 and A16 to A23 of the 1st byte of the ID code with the 2nd, 3rd
and 4th bytes respectively.
(3) Transfer the number of data sets of the ID code with the 5th byte.
(4) The ID code is sent with the 6th byte on, starting with the 1st byte of the code.
See the ID code section for more information.
Figure 1.162. Timing for the ID check
75
16
CLK1
RxD1
TxD1
RTS1(BUSY)
(M30245 reception data)
(M30245 transmit data)
ID size ID1 ID7
CLK1
RxD1
TxD1
RTS1(BUSY)
F516 DF16 FF16 0F16
(M30245 reception
data)
(M30245 transmit
data)
Serial I/O Mode 1
209
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
12. Download Command
This command downloads a program to the RAM for execution. Figure 1.163 shows the download com-
mand timing. To execute the download command:
(1) Transfer the “FA16” command code with the 1st byte.
(2) Transfer the program size with the 2nd and 3rd bytes.
(3) Transfer the check sum with the 4th byte. The check sum is added to all data sent starting with the 5th
byte.
(4) The program to execute is sent starting with the 5th byte.
After all data has been transmitted, if the check sum matches, the downloaded program is executed. The
size of the program will vary according to the internal RAM.
FA16 Program
data
Data size (high)
Data size (low)
Check
sum
CLK1
RxD1
TxD1
RTS1(BUSY)
(M30245 reception data)
(M30245 transmit data)
Program
data
Figure 1.163. Timing for download
13. Version Information Output Command
This command outputs the version information of the control program stored in the boot area. Figure
1.164 shows the version information output timing. To execute the version information output command:
(1) Transfer the “FB16” command code with the 1st byte.
(2) The version information will be output from the 2nd byte on. The version data is composed of 8 ASCII
code characters.
FB
16
'X'
'V' 'E' 'R'
CLK1
RxD1
TxD1
RTS1(BUSY)
(M30245 reception data)
(M30245 transmit data)
Figure 1.164. Timing for version information output
Serial I/O Mode 1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
210
14. Boot ROM Area Output Command
This command outputs the control program stored in the boot ROM area in one page blocks (256 bytes).
Figure 1.165 shows the boot ROM area output timing. To execute the boot ROM area output command:
(1) Transfer the “FC16” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) Starting with the 4th byte, data (D0–D7) for the page (256 bytes) specified by addresses A8 to A23 will
be output sequentially from the smallest address first, in sync with the falling edge of the transfer clock.
Figure 1.165. Timing for boot ROM area output
data0 data255
CLK1
RxD1
TxD1
RTS1(BUSY)
A
8
to
A
15
A
16
to
A
23
FC
16
(M30245 reception data)
(M30245 transmit data)
15. Read Check Data command
This command reads the check data that confirms that the write data, sent with the page program
command, has been successfully received. Figure 1.166 shows the read check data timing. To execute
the read check data command:
(1) Transfer the “FD16” command code with the 1st byte.
(2) The check data (low) is received with the 2nd byte and the check data (high) with the 3rd byte.
To use this read check data command, first execute the command and then initialize the check data. Then
execute the page program command the required number of times. Afterwards, when the read check
command is executed again, the check data (for all of the read data that was sent with the page program
command during this time) is read. The check data is the result of a CRC operation of write data.
Figure 1.166. Timing for the read check data
Check data (low)
CLK1
RxD1
TxD1
RTS1(BUSY)
FD
16
(M30245 reception data)
(M30245 transmit data)
Check data (high)
Serial I/O Mode 1
211
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Data Protection (Block Lock)
Each block in Figure 1.167 has a nonvolatile lock bit that indicates protection (block lock) against erasing/
writing. A block is locked (writing “0” for the lock bit) with the lock bit program command. Any lock bit can
be read with the read lock bit status command.
Block lock disable/enable is determined by the status of the lock bit and execution status of the lock bit
disable and lock bit enable commands.
(1) After reset and the lock bit enable command is executed, the specified block can be locked/unlocked
using the lock bit (lock bit data). Blocks with a “0” lock bit data are locked and cannot be erased or written
to. Blocks with a “1” lock bit data are unlocked and can be erased or written to.
(2) After the lock bit disable command has been executed, all blocks are unlocked regardless of the lock bit
data status and can be erased or written to. In this case, any lock bit data that was “0” before the block was
erased is set to “1” (unlocked) after erasing.
User ROM area Boot ROM area
Note 1: The boot ROM area can be rewritten only in parallel input/
output mode. (Access to any other areas is inhibited.)
Note 2: To specify a block, use the maximum address in the block
that is an even address.
8K bytes
FE000
16
FFFFF
16
F0000
16
Block 3 : 32K bytes
F8000
16
Block 2 : 8K bytes
FA000
16
Block 1 : 8K bytes
Block 0 : 16K bytes
FC000
16
FFFFF
16
E0000
16
Block 4 : 64K bytes
Figure 1.167. Block diagram of the flash memory version
Status Register (SRD)
The status register indicates the flash memory operating status and whether an erase or program
operation has terminated normally or in error. It can be read by using the read status register command
(7016). Writing the clear status register command (5016) clears the status register. Table 1.71 defines
each status register bit. After reset, the status register outputs “8016”.
Each SRD bit Status name Definition
“1” “0”
SR7 (Bit 7) Write state machine (W SM) Ready
Busy
SR6 (Bit 6) Reserved _
_
SR5 (Bit 5) Erase status Terminated in error
Terminate d normally
SR4 (Bit 4) Program status Terminated in error
Terminate d normally
SR4 (Bit 3) Block status after program Terminated in error
Terminate d normally
SR2 (Bit 2) Reserved _
_
SR1 (Bit 1) Reserved _
_
SR0 (Bit 0) Reserved _
_
Table 1.71. Status register (SRD)
Serial I/O Mode 1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
212
Table 1.72. Status register 1 (SRD1)
Write State Machine (WSM) Status (SR7)
The write state machine (WSM) status indicates the operating status of the flash memory. When power is
turned on, “1” (ready) is set. The bit is set to “0” (busy) during an auto-write or auto-erase operation, but
returns to “1” when the operation ends.
Erase Status (SR5)
The erase status reports the operating status of the auto-erase operation. If an erase error occurs, it is set
to “1”. When the erase status is cleared, it is set to “0”.
Program Status (SR4)
The program status reports the operating status of the auto-write operation. If a write error occurs, it is set
to “1”. When the program status is cleared, it is set to “0”.
Block Status After Program (SR3)
If data is overwritten (this occurs when a memory cell becomes overcharged and data is incorrectly read), a
“1” is set for the block status after program at the end of the page write operation.
In other words:
• When writing ends successfully “8016” is output
• When writing fails, “9016” is output
• When excessive data is written, “8816” is output.
If “1” is written to any SR5, SR4 or SR3 bits, the page program, block erase, erase all unlocked blocks and
lock bit program commands are not accepted. Before executing these commands, execute the clear status
register command (5016).
Status Register 1 (SRD1)
Status register 1 indicates the status of serial communications, ID check results, and check sum compari-
sons. It can be read after the SRD by writing the read status register command (7016). Status register 1 can
be cleared by writing the clear status register command (5016).
Table 1.72 defines each status register 1 bit. “0016” is output when power is turned ON and the flag status
is maintained even after the reset.
SRD1 bits Status name Definition
"1" "0"
SR15 (Bit 7) Boot update complete bit Completed Not updated
SR14 (Bit 6) Reserved _ _
SR13 (Bit 5) Reserved _ _
SR12 (Bit 4) Checksum match bit Match No match
SR11 (Bit 3)
SR10 (Bit 2) ID check complet ed bits 0 0 Not verified
0 1 Verified no match
1 0 Reserved
1 1 Verified
SR9 (Bit 1) Data receive time out Time out Normal operation
SR8 (Bit 0) Reserved _ _
Serial I/O Mode 1
213
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Boot Update Completed Bit (SR15)
This flag indicates if the control program was properly downloaded (using the download function) to RAM.
Check Sum Consistency Bit (SR12)
This flag indicates if the check sum matches after a program is downloaded for execution (using the
download function).
ID Check Completed Bits (SR11 and SR10)
These flags indicate the result of ID checks. Some commands cannot be accepted without an ID check.
Data Reception Time Out (SR9)
This flag indicates when a time out error is generated during data reception. If this flag is set during data
reception, the received data is discarded and the microcomputer returns to the command wait state.
Full Status Check
A full-status check allows the user to review the erase and program operations. Figure 1.168 shows a full-
status check flowchart and the action to take when an error occurs.
Figure 1.168. Full status check flowchart
Read status register
SR4=1 and
SR5=1 ?
NO
Command
sequence error
YES
SR5=0?
YES
Block erase error
NO
SR4=0?
YES
Program error (page
or lock bit)
NO
End (block erase, program)
Execute the clear status register command (50
16
)
to clear the status register. Try performing the
operation one more time after confirming that the
command is entered correctly.
If a block erase error occurs, the block in error
cannot be used.
Execute the read lock bit status command (71
16
) to
see if the block is locked. After removing the lock, 
execute a write operation the same way. If the error still occurs,
the page in error cannot be used.
Note: When one of SR5 to SR3 is set to 1, none of the page program, block erase, erase all
YES
SR3=0? Program error
(block)
NO After erasing the block in error, exectue the operation again.
If the same error still occurs, the block in error cannot
be used.

unlocked blocks and lock bit program commands are accepted. Execute the clear 
status register command (50
16
) before executing these commands.
Serial I/O Mode 2
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
214
Standard serial I/O mode 2
In standard serial I/O mode 2 (clock asynchronous), software commands, addresses and data are
input and output between the MCU and peripheral units (serial programmer, etc.) using 2-wire
clock-asynchronous serial I/O (UART1).
Standard serial I/O mode is entered by releasing the reset with the P65 (CLK1) pin at a “L” level.
The TxD1 pin is set to CMOS output. Data transfer is in 8-bit units with LSB first, 1 stop bit and
parity OFF.
After reset, connections can be established at 9,600 bps when initial communications are made
with a peripheral unit. This requires a main clock with a minimum 2 MHz input oscillation fre-
quency. The baud rate can also be changed from 9,600 bps to 19,200, 38,400, or 57,600 bps by
executing software commands. Communication errors may occur because of the main clock
oscillation frequency. If errors occur, change the main clock’s oscillation frequency and the baud
rate.
After executing commands from a peripheral unit that require time to erase and write data, as
with the erase and program commands, allow a sufficient time interval or execute the read status
command and check how the processing ended before executing the next command.
Data and status registers can be read after transmitting software commands. Reading the status
register can check status of the flash memory operating state or successful completion of a
program or erase operation.
Initial communications with peripheral units
After reset, the bit rate generator is adjusted to 9,600 bps to match the main clock’s oscillation
frequency, by sending the code as prescribed by the protocol for initial communications with
peripheral units. Figure 1.169 shows the initial communication with peripheral units.
(1) Transmit “0016” from a peripheral unit 16 times. (The MCU with internal flash memory sets the
bit rate generator so that “0016” can be successfully received.)
(2) The MCU with internal flash memory outputs the “B016” check code and initial communica-
tions end successfully. Initial communications must be transmitted at a speed of 9,600 bps and a
transfer interval of a minimum 15 ms. Also, the baud rate at the end of initial communications is
9,600 bps.
Note. If the peripheral unit cannot receive “B016” successfully, change the oscillation frequency of
the main clock.
Figure 1.169. Peripheral unit and initial communication
MCU with internal
flash memory
Peripheral unit
(1) Transf er "00
16
" 16 times
At least 15ms
transfer interval
1st
2nd
15 th
16th (2) Transfer check code "B0
16
"
"00
16
"
"00
16
"
"00
16
"
"B0
16
"
"00
16
"
Reset
The bit rate generator setting completes (9600bps)
Serial I/O Mode 2
215
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Frequency identification
When “0016” data is received 16 times from a peripheral unit at a baud rate of 9,600 bps, the value of the
bit rate generator is set to match the operating frequency (2 - 16 MHz). The highest speed is taken from the
first 8 transmissions and the lowest from the last 8. These values are then used to calculate the bit rate
generator value for a baud rate of 9,600 bps. Baud rate cannot be attained with some operating frequen-
cies. Table 1.73 lists the operation frequency and the baud rate.
Table 1.73. Operation frequency and baud rate
Example Circuit Application
Figure 1.170 shows a circuit application for the standard serial I/O mode 2.
Figure 1.170. Example circuit application for the standard serial I/O mode 2
Monitor output
Data input
Data output
Note: In this example, the microprocessor mode and standard serial I/O mode are switched via a switch.
RTS1(BUSY)
CLK1
RXD1
TXD1
CNVss
P50(CE)
P55(EPM)
NMI
M30245 Flash
memory version
+ : Communications possible
_ : Communications not possible
Operation
Frequency
Baud rate
9,600
Baud rate
19,200
Baud rate
38,400
Baud rate
57,600
16 MHz
12 MHz
11 MHz
10 MHz
8 MHz
7.3728 MHz
6 MHz 
5 MHz 
4.5 MHz
4.194304 MHz 
4 MHz 
3.58 MHz
3 MHz 
2 MHz
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
_
+
+
+
+
+
+
+
+
+
+
+
+
_
+
+
+
+
+
+
+
+
_
_
_
_
_
_
_
Serial I/O Mode 2
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
216
Software Commands
In the standard serial I/O mode 2, erase, program, and read operations are controlled by transferring
software commands using the RxD1 pin. Standard serial I/O mode 2 adds four transmission speed com-
mands - 9,600, 19,200, 38,400, and 57,600 bps - to the software commands of standard serial I/O mode 1.
Table 1.74 lists the software commands for serial I/O mode 2.
Table 1.74. Software commands
Note 1: The shaded areas indicate a transfer from flash memory MCU to peripheral unit. All other data is
transferred from the peripheral unit to the flash memory MCU.
Note 2: SRD refers to Status Register Data. SRD1 refers to S tatus Register Data 1.
Note 3: All commands are accepted if the flash memory is blank.
Control command 2nd
byte 3rd
byte 4th
byte 5th
byte 6th
byte When ID is
not v e r i fi e d
1Page read FF
16
Address
(middle) Address
(high) Data
output Data
output Data
output Data output
to 259th byte Not
acceptable
2Page program 41
16
Address
(middle) Address
(high) Data input Data input Data input Data input to
259th byte Not
acceptable
3Block erase 20
16
Address
(middle) Address
(high) D0
16
Not
acceptable
4Erase all unlocked
blocks A7
16
D0
16
Not
acceptable
5Read status
register 70
16
SRD
output SRD1
output Acceptable
6Clear status
register 50
16
Not
acceptable
7Read lock bit
status 71
16
Address
(middle) Address
(high) Lock bit
data output Not
acceptable
8Lock bit
program 77
16
Address
(middle) Address
(high) D0
16
Not
acceptable
9Lock bit enable 7A
16
Not
acceptable
10 Lock bit disable 75
16
Not
acceptable
11 ID check
function F5
16
Address
(low) Address
(middle) Address
(high) ID size ID1 To ID7 Acceptable
12 Download
function FA
16
Size
(low) Size
(high) Check sum Data
input As required Not
acceptable
13 Version data
output function FB
16
Version
data
output
Version
data
output
Version
data output Version
data
output
Version data
output V ersion data
output to 9th
byte
Acceptable
14 Boot ROM area out-
put function FC
16
Address
(middle) Address
(high) Data output Data
output Data output Data output
to 259th byte Not
acceptable
15 Read check data FD
16
Check
data
(low)
Check
data
(high)
Not
acceptable
16 Baud rate 9600 B0
16
B0
16
Acceptable
17 Baud rate 19200 B1
16
B1
16
Acceptable
18 Baud rate 38400 B2
16
B2
16
Acceptable
19 Baud rate 57600 B3
16
B3
16
Acceptable
Serial I/O Mode 2
217
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
1. Page Read Command
The page read command reads the specified page (256 bytes) in the flash memory sequentially one byte
at a time. Figure 1.171 shows the page read timing. To execute the page read command:
(1) Transfer the “FF16” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) From the 4th byte on, data (D0–D7) for the page (256 bytes) specified by addresses A8 to A23, will be
output sequentially from the smallest address first, in sync with the rise of the clock.
Figure 1.171. Timing for page read
2. Page Program Command
This command writes the specified page (256 bytes) in the flash memory sequentially one byte at a time.
Figure 1.172 shows the page program timing. To execute the page program command:
(1) Transfer the “4116” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) From the 4th byte on, write data (D0–D7) for the page (256 bytes) specified by addresses A8 to A23, is
input sequentially from the smallest address first. The page is automatically written.
The page program results can be reviewed in the status register. Refer to the status register section for
more details.
Each block can be write-protected with the lock bit. Refer to the data protection function for more details.
Additional writing of previously programmed pages is not allowed.
Figure 1.172. Timing for the page program
data0 data255
RxD1
TxD1
A
8
to
A
15
A
16
to
A
23
FF
16
(M30245 reception data)
(M30245 transmit data)
RxD1
TxD1
A
8
to
A
15
A
16
to
A
23
41
16
data0 data255
(M30245 reception data)
(M30245 transmit data)
Serial I/O Mode 2
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
218
3. Block Erase Command
This command erases all the data in the specified block. Figure 1.173 shows the block erase timing. To
execute the block erase command:
(1) Transfer the “2016” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) Transfer the verify command code “D016” with the 4th byte. With the verify command code, the erase
operation will start for the specified block in the flash memory. Write the highest address of the specified
block for addresses A8 to A23.
After block erase ends, the results of the block erase operation can be reviewed in the status register.
Refer to the status register section for more details. Each block can be erase-protected with the lock bit.
Refer to the data protection function section for more details.
A8 to
A15 A16 to
A23
2016 D016
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data)
Figure 1.173. Timing for block erasing
4. Erase All Unlocked Blocks Command
This command erases the content of all blocks. Figure 1.174 shows the erase all unlocked blocks timing.
To execute the erase all unlocked blocks command:
(1) Transfer the “A716” command code with the 1st byte.
(2) Transfer the verify command code “D016” with the 2nd byte. With the verify command code, the erase
operation will start and continue for all blocks in the flash memory.
The results of the erase operation can be reviewed in the status register. Each block can be erase-pro-
tected with the lock bit. Refer to the data protection function and status register sections for more details.
Figure 1.174. Timing for erasing all unlocked blocks
RxD1
TxD1
A7
16
D0
16
(M30245 reception data)
(M30245 transmit data)
Serial I/O Mode 2
219
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
5. Read Status Register Command
This command reads the status information. When the “7016” command code is sent with the 1st byte,
the contents of the status register (SRD) are read with the 2nd byte and the contents of status register 1
(SRD1) are read with the 3rd byte. Figure 1.175 shows the read status register timing.
Figure 1.175. Timing for reading the status register
6. Clear Status Register Command
This command clears the bits (SR3–SR5) that are set when an erase, program or status operation ends
in error. When the “5016” command code is sent with the 1st byte, the SR3-SR5 bits are cleared. Figure
1.176 shows the clear status register timing.
Figure 1.176. Timing for clearing the status register
7. Read Lock Bit Status Command
This command reads the lock bit status of the specified block. Figure 1.177 shows the read lock bit
status timing. To execute the read lock bit status command:
(1) Transfer the “7116” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) The lock bit data of the specified block is output with the 4th byte. The 6th bit (D6) of the output data is
the lock bit data. Write the highest address of the specified block for addresses A8 to A23.
Figure 1.177. Timing for reading lock bit status
SRD
output SRD1
output
RxD1
TxD1
70
16
(M30245 reception data)
(M30245 transmit data)
RxD1
TxD1
50
16
(M30245 reception data)
(M30245 transmit data)
RxD1
TxD1
A8 to
A15 A16 to
A23
7116
D6
(M30245 reception data)
(M30245 transmit data)
Serial I/O Mode 2
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
220
8. Lock Bit Program Command
This command writes “0” (lock) for the lock bit of the specified block. Figure 1.178 shows the lock bit
program timing. To execute the lock bit program command:
(1) Transfer the “7716” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) Transfer the verify command code “D016” with the 4th byte. With the verify command code, “0” is written
for the lock bit of the specified block. Write the highest address of the specified block for addresses A8 to
A23.
The lock bit status can be read with the read lock bit status command. Refer to the data protection function
for more details about the lock bit function and reset procedure.
RxD1
TxD1
A
8
to
A
15
A
16
to
A
23
77
16
D0
16
(M30245 reception data)
(M30245 transmit data)
Figure 1.178. Timing for the lock bit program
9. Lock Bit Enable Command
This command enables the lock bits for all blocks. The command code “7A16” is sent with the 1st byte of
the serial transmission. This command only enables the lock bit function; it does not set the lock bit itself.
Figure 1.179 shows the lock bit enable timing.
Figure 1.179. Timing for enabling the lock bit
10. Lock Bit Disable Command
This command disables the lock bit for all blocks. The command code “7516” is sent with the 1st byte of
the serial transmission. This command only disables the lock bit function; it does not set the lock bit
itself. However, if an erase command is executed after executing the lock bit disable command, all “0”
(locked) lock bit data is set to “1” (unlocked) after the erase operation ends. Figure 1.180 shows the lock
bit disable timing. After reset the lock bit is always enabled.
Figure 1.180. Timing for disabling the lock bit
7A
16
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data)
7516
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data)
Serial I/O Mode 2
221
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
11. ID Check
This command checks the ID code. Figure 1.181 shows the ID check command timing. To execute the
boot ID check command:
(1) Transfer the “F516” command code with the 1st byte.
(2) Transfer addresses A0 to A7, A8 to A15 and A16 to A23 of the 1st byte of the ID code with the 2nd, 3rd
and 4th bytes respectively.
(3) Transfer the number of data sets of the ID code with the 5th byte.
(4) The ID code is sent with the 6th byte on, starting with the 1st byte of the code.
See the ID code section for more information.
Figure 1.181. Timing for the ID check
ID size ID1 ID7
RxD1
TxD1
F516 DF16 FF16 0F16
(M30245 reception
data)
(M30245 transmit
data)
12. Download Command
This command downloads a program to the RAM for execution. Figure 1.182 shows the download com-
mand timing. To execute the download command:
(1) Transfer the “FA16” command code with the 1st byte.
(2) Transfer the program size with the 2nd and 3rd bytes.
(3) Transfer the check sum with the 4th byte. The check sum is added to all data sent from the 5th byte on.
(4) The program to execute is sent starting with the 5th byte.
When all data has been transmitted, if the check sum matches, the downloaded program is executed. The
size of the program will vary according to the internal RAM.
FA
16 Program
data
Data size (high)
Data size (low)
Check
sum
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data)
Program
data
Figure 1.182. Timing for download
Serial I/O Mode 2
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
222
13. Version Information Output Command
This command outputs the version information of the control program stored in the boot area. Figure 1.183
shows the version information output timing. To execute the version information output command:
(1) Transfer the “FB16” command code with the 1st byte.
(2) The version information will be output from the 2nd byte on. This version data is composed of 8 ASCII
code characters.
Figure 1.183. Timing for version information output
14. Boot ROM Area Output Command
This command outputs the control program stored in the boot ROM area in one page blocks (256 bytes).
Figure 1.184 shows the boot ROM area output timing. To execute the boot ROM area output command:
(1) Transfer the “FC16” command code with the 1st byte.
(2) Transfer addresses A8 to A15 and A16 to A23 with the 2nd and 3rd bytes respectively.
(3) Starting with the 4th byte, data (D0–D7) for the page (256 bytes) specified by addresses A8 to A23, will
be output sequentially from the smallest address first.
FB
16
'X'
'V' 'E' 'R'
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data)
data0 data255
RxD1
TxD1
A
8
to
A
15
A
16
to
A
23
FC
16
(M30245 reception data)
(M30245 transmit data)
Figure 1.184. Timing for boot ROM area output
Serial I/O Mode 2
223
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
15. Read Check Data
This command reads the check data, that confirms that the write data, sent with the page program
command, was successfully received. Figure 1.185 shows the read check data timing. To execute the
read check data:
(1) Transfer the “FD16” command code with the 1st byte.
(2) The check data (low) is received with the 2nd byte and the check data (high) with the 3rd.
To use this read check data command, first execute the command and then initialize the check data. Next,
execute the page program command the required number of times. Afterwards, when the read check
command is executed again, the check data (for all of the read data sent with the page program command
during this time) is read. The check data is the result of a CRC operation of write data.
Check data (low)
RxD1
TxD1
FD16
(M30245 reception data)
(M30245 transmit data)
Check data (hig
Figure 1.185. Timing for the read check data
16. Baud Rate 9600
This command changes the baud rate to 9,600 bps. Figure 1.186 shows the baud rate 9600 command
timing. To execute the baud rate 9600 bps command:
(1) Transfer the “B016” command code with the 1st byte.
(2) After the “B016” check code is output with the 2nd byte, change the baud rate to 9,600 bps.
Figure 1.186. Timing of baud rate 9600
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data) B016
B016
17. Baud Rate 19200
This command changes the baud rate to 19,200 bps. Figure 1.187 shows the baud rate 19200 command
timing. To execute the baud rate 19200 bps command:
(1) Transfer the “B116” command code with the 1st byte.
(2) After the “B116” check code is output with the 2nd byte, change the baud rate to 19,200 bps.
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data) B1
16
B1
16
Figure 1.187. Timing of baud rate 19200
Serial I/O Mode 2
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
224
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data) B2
16
B2
16
RxD1
TxD1
(M30245 reception data)
(M30245 transmit data) B3
16
B3
16
18. Baud Rate 38400
This command changes the baud rate to 38,400 bps. Figure 1.188 shows the baud rate 38400 command
timing. To execute the baud rate 38400 bps command:
(1) Transfer the “B216” command code with the 1st byte.
(2) After the “B216” check code is output with the 2nd byte, change the baud rate to 38,400 bps.
Figure 1.188. Timing of baud rate 38400
19. Baud Rate 57600
This command changes the baud rate to 57,600 bps. Figure 1.189 shows the baud rate 57600 command
timing. To execute the baud rate 57600 bps command:
(1) Transfer the “B316” command code with the 1st byte.
(2) After the “B316” check code is output with the 2nd byte, change the baud rate to 57,600 bps.
Figure 1.189. Timing of baud rate 57600
225
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Electrical Specifications
Absolute Maximum Ratings
Table 1.75. Absolute maximum ratings
Symbol Parameter Condition Rated value Unit
Vcc Supply voltage
Vcc = AVcc = UVcc
-0.3 to 4.0 V
AVcc Analog supply voltage -0.3 to 4.0 V
VIInput voltage RESET, (mask ROM: CNVss,
BYTE) P00 to P07, P10 to P17,
P20 to P27, P30 to P37, P40 to
P47, P50 to P57, P60 to P67,
P72, P80 to P87
P93, P100 to P107,
VREF
, XIN, D+, D-
-0.3 to Vcc + 0.3 V
P70 to P71 -0.3 to 4.0 V
VOOutput voltage P00 to P07, P10 to P17, P20 to
P27, P30 to P37, P40 to P47,
P50 to P57, P60 to P67, P72 to
P77, P80 to P84, P86, P87,
P93, P100 to
-0.3 to Vcc + 0.3 V
P70 to P71-0.3 to 4.0 V
Pd Power dissipation =25 300 mW
Topr Operating ambient temperature -20 to 85
Tstg Storage temperature -65 to 150 C
C
C
P90, P92,
to P77
P90, P92,
P107, XOUT, D+, D-
VbusDTCT -0.3 to 5.50 V
Vcc = AVcc = UVcc
UVcc USB circuit supply voltage
Vcc = AVcc = UVcc
-0.3 to 4.0 V
Topr
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
226
Recommended operating conditions
Table 1.76. Recommended operating conditions (Note 1)
Note 1: Vcc = 3.0V to 3.6V at Topr = -20 to 85°C unless otherwise stated.
Note 2: The mean output current is the mean values within 100ms.
Note 3: The total IOL (peak) and IOH (peak) for Ports P0, P1, P2, P86, P87, P9 and P10 must be 80mA max. The total IOL (peak)
for Ports P3, P4, P5, P6, P7 and P80 to P84 must be 80mA max. The total IOH (peak) for ports P3, P4, P5, P6, P72 to P77
and P80 to P84 must be 80mA max.
Symbol Parameter
Standard
Unit
Min. Typ. Max.
Vcc Supply voltage 3.0 3.3 3.6 V
AVcc Analog supply voltage Vcc V
Vss Supply voltage 0V
AVss Analog supply voltage 0V
V
IH
HIGH
input voltage
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
, P4
0
to
P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
2
to P7
7
, P8
0
to P8
7
, P9
0
,
P9
2
, P9
3
, P10
0
to P10
7,
X
IN
, RESET, CNVss, BYTE
0.8 Vcc Vcc V
P7
0
to P7
1
4.0 V
V
IL
LOW
input voltage
I
OH
(peak) HIGH
peak output
current
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
, P4
0
to
P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
2
to P7
7
, P8
0
to P8
4
,
P8
6
, P8
7
, P9
0
, P9
2
, P9
3
, P10
0
to P10
7
-10.0 mA
I
OH
(avg) HIGH aver-
age output
current
-5.0 mA
I
OL
(peak) LOW
peak output
current
10.0 mA
I
OL
(avg) LOW aver-
age output
current
5.0 mA
f(X
IN
)Main clock input oscillation frequency 16
f(X
CIN
)Sub clock oscillation frequency 32.768 50 kHz
V
V
0.2 Vcc
0.2 Vcc
MHz
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
, P4
0
to
P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
2
to P7
7
, P8
0
to P8
7
, P9
0
,
P9
2
, P9
3
, P10
0
to P10
7,
X
IN
, RESET, CNVss, BYTE
VbusDTCT 5.25 V
0.8 Vcc
UVcc USB supply voltage 3.0 3.3 3.6 V
P7
0
to P7
1
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
, P4
0
to
P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
2
to P7
7
, P8
0
to P8
4
,
P8
6
, P8
7
, P9
0
, P9
2
, P9
3
, P10
0
to P10
7
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
, P4
0
to
P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
2
to P7
7
, P8
0
to P8
4
,
P8
6
, P8
7
, P9
0
, P9
2
, P9
3
, P10
0
to P10
7
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
, P4
0
to
P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
2
to P7
7
, P8
0
to P8
4
,
P8
6
, P8
7
, P9
0
, P9
2
, P9
3
, P10
0
to P10
7
V
0.8
D+, D-
V
2.0
D+, D-
4.0
VbusDTCT 1.0 V
227
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Electrical characteristics
Table 1.77. Electrical characteristics (Note 1)
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
,
P4
0
to P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
0
to P7
7
,
P8
0
to P8
7
, P9
0
, P9
2
, P9
3
, P10
0
to P10
7,
X
IN
, RESET, CNV
SS
, BYTE
Note 1 : Vcc = 3.0V to 3.6V, Vss = 0V at Topr = -20°C to 85°C, f(X
IN
) = 16MHz unless otherwise stated.
Note 2 : With one timer operated using fc32.
Symb o l P a rameter Measur in g co ndition Standard Unit
Min. Typ. Max.
V
OH
HIGH
output
voltage
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
,
P4
0
to P4
7
, P5
0
to P5
7
, P6
0
to P6
2
, P6
4
to P6
6
,
P7
0
to P7
7
, P8
0
to P8
4
, P8
6
, P8
7
,
P9
0
, P9
2
, P9
3
, P10
0
to P10
7
I
OH
= -1mA
2.5 V
V
OL
LOW
output
voltage
I
OL
= 1mA
0.5 V
V
T
+ - V
T
- Hysteresis HOLD, RDY, TA0
IN
to TA4
IN
, INT0 to INT2,
AD
TRG
, CTS0 to CTS3, CLK0, CLK1, TA2
OUT
to TA4
OUT
, NMI, KI
0
to KI
7
, RXD0 to RXD3,
SCL, SDA
0.2 1.0 V
VbusDTCT 1.0 V
I
IH
HIGH input
current V
I
= V
CC
4µA
I
IL
LOW input
current V
I
= 0V
-4 µA
R
PULLUP
Pull-up
resistance V
I
= 0V
30.0 50.0 167.0 k
R
fXIN
Feedback
resistance X
IN
1.0 M
R
fXCIN
X
CIN
10 M
V
RAM
RAM retention voltage When clock is stopped V
Icc Power supply
current In single-chip mode, the
output pins are open and
other pins are Vss
f(X
IN
) = 16MHz Square wave, no division, USB off mA
Topr = 25°C, when clock is stopped µA
2.0
µA
µA
µA
V
V
X
OUT
X
COUT
HIGHPOWER
HIGHPOWER
LOWPOWER
LOWPOWER
V
V
X
OUT
X
COUT
HIGHPOWER
HIGHPOWER
LOWPOWER
LOWPOWER
IOH = -0.1mA
IOH = -50µA
I
OH
= -1
µ
A
I
OH
= -0.5
µ
A
2.5
2.5
2.5
2.5
0.5
0.5
0.5
0.5
IOL = 50µA
I
OL
= 1
µ
A
I
OL
= 0.5
µ
A
30
12
P6
3
, P6
7
I
OH
= -10mA 2.5 V
P6
3
, P6
7
, P7
0
to P7
7
(P7 high drive mode)
I
OL
= 10mA 0.8 V
I
OL
= 0.1mA
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
,
P4
0
to P4
7
, P5
0
to P5
7
, P6
0
to P6
2
, P6
4
to P6
6
,
P7
0
to P7
7
, P8
0
to P8
4
, P8
6
, P8
7
,
P9
0
, P9
2
, P9
3
, P10
0
to P10
7
0.2 1.8 V
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
,
P4
0
to P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
0
to P7
7
,
P8
0
to P8
7
, P9
0
, P9
2
, P9
3
, P10
0
to P10
7,
X
IN
, RESET, CNV
SS
, BYTE, VbusDTCT
P0
0
to P0
7
, P1
0
to P1
7
, P2
0
to P2
7
, P3
0
to P3
7
,
P4
0
to P4
7
, P5
0
to P5
7
, P6
0
to P6
7
, P7
0
to P7
7
,
P8
0
to P8
4
, P8
6
, P8
7
, P9
0
, P9
2
, P9
3
,
P10
0
to P10
7
16
mA
25 43
Topr = 85°C, when clock is stopped
f(X
IN
) = 16MHz Square wave, no division, USB on
f(X
CIN
) = 32kHz Square wave
f(X
CIN
) = 32kHz When a WAIT instruction is
executed. Oscillation capacity High (Note 2)
f(X
CIN
) = 32kHz When a WAIT instruction is
executed. Oscillation capacity Low (Note 2)
µA
VbusDTCT 50 µA
µA
Topr = 50°C, when clock is stopped
RESET
TBD
TBD
TBD
TBD
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
228
Table 1.78. USB electrical characteristics (Note 1)
Note 1: V
CC
, AV
CC
, V
REF
= 3.3V, V
SS
, AV
SS
= 0V, Topr = 25°C, f(X
IN
) = 16MHz.
Note 2: Divide the frequency if f(X
IN
) exceeds 10MHz, and make ΦAD equal to or less than 10MHz.
Symbol Parameter
Measuring
condition Standard Unit
Min Typ Max
- Resolution V
REF = VCC 10 Bits
-Absolute
accuracy
Sample and hold function not used (10 bit) +4
Sample and hold function used (10 bit) +4
Sample and hold function not used (8 bit) +2
Sample and hold function used (8 bit) +2
RLADDER Ladder resistance k
tCONV Conversion time (10 bit) µs
tCONV Conversion time (8 bit) µs
tSAMP Sampling time 0.3 µs
VREF Reference voltage Vcc V
VIA Analog input voltage 0 Vcc V
3.3
2.8
10
VREF = VCC
VREF = VCC
VREF = VCC
VREF = VCC
VREF = VCC
VREF = VCC
VREF = VCC
40
LSB
LSB
LSB
LSB
Note1 : Vcc = 3.0V - 3.6V, Vss = 0V, Topr = -20°C to 85°C unless otherwise specified.
Symbol Parameter Measuring Condition Standard Unit
Min Typ Max
VOH D+, D- IOH/IOL = +/- 18.3mA, UVcc = 3.00V,
Rx = 332.2 V
VOL D+, D- IOH/IOL = +/- 18.3mA, UVcc = 3.00V,
Rx = 330.8 V
Isusp Suspend
current USB suspend mode, internal clock
stopped, with Vbus Detect µA
3.6
0
Isusp Suspend
current USB suspend mode, internal clock
stopped, without Vbus Detect µA
Table 1.79. A-D conversion characteristics (Note 1)
229
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Timing requirements (Vcc = 3.0V to 3.6V, Vss=0V, Topr =-20 °C to 85 °C unless otherwise stated)
Table 1.80. External clock input
Symbol Parameter Standard Unit
Min Max
tc External clock input cycle time ns
tw(H) External clock input HIGH pulse width ns
tw(L) External clock input LOW pulse width ns
tr External clock rise time ns
tf External clock fall time ns
62.5
25
25
10
10
Table 1.81. Memory expansion and microprocessor modes
Table 1.82. Timer A input (counter input in event counter mode)
Symbol Parameter Standard Unit
Min Max
tc(
TA
)TAi
IN
input cycle time 100 ns
tw(
TAH
)TAi
IN
input HIGH pulse width 50 ns
tw(
TAL
)TAi
IN
input LOW pulse width 40 ns
Symbol Parameter Standard Unit
Min Max
tac1 (RD-DB) Data input access time (no wait) ns
tac2 (RD-DB) Data input access time (with wait) ns
tsu (DB-RD) Data input setup time ns
tsu (RDY-BCLK) RDY input setup time ns
tsu (HOLD-BCLK) HOLD input setup time ns
th (RD-DB) Data input hold time ns
th (BCLK-RDY) RDY input hold time ns
th (BCLK-HOLD)HOLD input hold time ns
td (BCLK-HLDA) HLDA output delay time ns
50
40
105
0
40
0
0
(Note 1)
(Note 2)
Note 1:
t
ac1 =
t
cyc / 2 - 60nS
Note 2:
t
ac2 = (m+0.5)
x
t
cyc - 60nS
m = number of wait states (1 to 3)
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
230
Timing requirements (Vcc = 3.0V to 3.6V, Vss=0V, Topr =-20 °C to 85 °C unless otherwise stated)
Table 1.83. Timer A input (gating input in timer mode)
Table 1.84. Timer A input (external trigger input in one-shot timer mode)
Table 1.85. Timer A input (external trigger input in pulse width modulation mode)
Table 1.86. Timer input (up/down input in event counter mode)
Table 1.87. A-D trigger input
Symbol Parameter Standard Unit
Min Max
tw(TAH)TAiIN input HIGH pulse width 100 ns
tw(TAL)TAiIN input LOW pulse width 100 ns
Symbol Parameter Standard Unit
Min Max
tc(TA)TAiIN input cycle time 200 ns
tw(TAH)TAiIN input HIGH pulse width 100 ns
tw(TAL)TAiIN input LOW pulse width 100 ns
Symbol Parameter Standard Unit
Min Max
tc(TA)TAiIN input cycle time Note ns
tw(TAH)TAiIN input HIGH pulse width Note ns
tw(TAL)TAiIN input LOW pulse width Note ns
Note: When using the external gating mode feature, the width of TAi
IN
needs to be greater than the period of the clock source selected.
Symbol Parameter Standard Unit
Min Max
tc(UP)TAiOUT input cycle time 2000 ns
tw(UPH)TAiOUT input HIGH pulse width 1000 ns
tw(UPL)TAiOUT input LOW pulse width 1000 ns
tsu(UP-TIN)TAiOUT input setup time 400 ns
th(TIN-UP)TAiOUT input hold time 400 ns
Symbol Parameter Standard Unit
Min Max
tc(AD) ADTRG input cycle time (triggerable minimum) 1000 ns
tw(ADL) ADTRG input LOW pulse width 125 ns
231
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Timing requirements (Vcc = 3.0V to 3.6V, Vss=0V, Topr =-20 °C to 85 °C unless otherwise stated)
Table 1.88. Serial I/O
Symbol Parameter Standard Unit
Min Max
tc(
CK
) CLKi input cycle time 160 ns
tw(
CKH
) CLKi input HIGH pulse width 60 ns
tw(
CKL
) CLKi input LOW pulse width 60 ns
td(
C
-
Q
) TxDi output delay time 80 ns
th(
C
-
Q
) TxDi hold time 0 ns
tsu(
D
-
C
) RxDi input se tup time 60 ns
th(
C
-
D
) RxDi input hold time 20 ns
Table 1.89. External interrupt INTi inputs
Symbol Parameter Standard Unit
Min Max
tw(INH)INTI input HIGH pulse width 250 ns
tw(INL)INTI input LOW pulse width 250 ns
Symbol Parameter Measuring Condition Standard Unit
Min Typ Max
VbusDTCT Interrupt
tw
(INT)
Interrupt Pulse width 50 µS
Table 1.90. Vbus Detect interrupt
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
232
Note 1: Calculated according too the BCLK frequency as shown below:
Note 2: Calculated as follows: th (WR-DB) = tcyc / 2
Note 3: Calculated as follows: th (WR-CS) = tcyc / 2
Symbol Parameter Measuring
condition
Standard
Unit
Min. Max.
td (BCLK-AD) Address output delay time
See Figure 1.190
Measurements
taken with a
trigger value of
0.5Vcc.
ns
th (BCLK-AD) Address output hold time ns
th (RD-AD) Address output hold time ns
th (WR-AD) Address output hold time ns
td (BCLK-CS) Chip select output delay time ns
th (BCLK-CS) Chip select output hold time ns
td (BCLK-ALE) ALE signal output delay time ns
th (BCLK-ALE) ALE signal output hold time ns
td (BCLK-RD) RD signal output delay time ns
th (BCLK-RD) RD signal output hold time ns
td (BCLK-WR) WR signal output delay time ns
th (BCLK-WR) WR sginal output hold time ns
td (BCLK-DB) Data output delay time ns
th (BCLK-DB) Data output tristate time ns
td (DB-WR) Data output delay time ns
th (WR-DB) Data output hold time ns
30
30
30
30
30
40
0
0
0
0
0
0
0
0
(Note 1)
(When PM16 = 0) td (DB-WR) = (m-0.5) X tcyc - 40nS
(When PM16 = 1) td (DB-WR) = m X tcyc - 40nS
(Note 2)
ns
(Note 3)
th (WR-CS) Write high to Chip select high time
0 Wait selected: m = 1
1 Wait selected: m = 1
2 Wait selected: m = 2
3 Wait selected: m = 3
}
Switching characteristics (Vcc = 3.0V to 3.6V, Vss=0V, Topr =-20 °C to 85 °C unless otherwise stated)
Table 1.91. Memory expansion mode and microprocessor mode
P0
P1
P2
P3
P4
P5
P6
P7
P8
P9
P10
30pF
Figure 1.190. Port P0 to P10 measurement circuit
233
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
tsu(D–C)
TAi IN input
TAi OUT input
During event counter mode
CLKi
TxDi
RxDi
tc(TA)
tw(TAH)
tw(TAL)
tc(UP)
tw(UPH)
tw(UPL)
tc(AD)
tw(ADL)
tc(CK)
tw(CKH)
tw(CKL)
tw(INL)
tw(INH)
td(C–Q) th(C–D)
th(C–Q)
th(T
IN
–UP) tsu(UP–T
IN
)
TAi IN input
(When count on falling
edge is selected)
TAi IN input
(When count on rising
edge is selected)
TAi OUT input
(Up/down input)
INTi input
ADTRG input
Timing Diagrams
Figure 1.191. Timing diagram 1
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
234
Measuring conditions :
VCC=3.3V
Input timing voltage : Determined with VIL=1.0V, VIH=2.5V
Output timing voltage : Determined with VOL=1.0V, VOH=2.0V
Memory Expansion Mode and Microprocessor Mode
BCLK
HOLD input
HLDA output
P0, P1, P2,
P3, P4,
P50 to P52
(Valid with or without wait)
Note: The above pins are set to high-impedance regardless of the input level of the
BYTE pin and bit (PM06) of processor mode register 0 selects the function of
ports P40 to P43.
t
h(BCLK–HOLD)
t
su(HOLD–BCLK)
(Valid only with wait)
t
d(BCLK–HLDA)
t
d(BCLK–HLDA)
Hi–Z
RDY input
tsu(RDY–BCLK) th(BCLK–RDY)
BCLK
WR, WRL, WRH
RD
Figure 1.192. Timing diagram 2
235
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
BCLK
CSi
ALE
RD
Hi-Z
DB
ADi
BHE
Read timing
t
d(BCLK-AD)
t
d(BCLK-ALE)
t
h(BCLK-ALE)
t
SU(DB-RD)
t
d(BCLK-RD)
t
ac1(RD-DB)
Memory Expansion Mode and Microprocessor Mode
(With no wait)
t
d(BCLK-CS)
tcyc
t
h(BCLK-CS)
t
h(BCLK-AD)
t
h(RD-AD)
t
h(BCLK-RD)
t
h(RD-DB)
BCLK
CSi
ALE
t
h(WR-AD)
ADi
BHE
DBi
(PM16=0)
Write timing
WR,WRL,
WRH (PM16=0)
t
d(BCLK-CS)
tcyc
t
h(BCLK-CS)
t
h(WR-CS)
t
h(BCLK-AD)
t
d(BCLK-AD)
t
d(BCLK-ALE)
t
h(BCLK-ALE)
t
d(BCLK-WR)
t
h(BCLK-DB)
t
d(BCLK-DB)
t
d(DB-WR)
t
h(WR-DB)
t
h(BCLK-WR)
WR,WRL,
WRH (PM16=1)
t
d(BCLK-WR)
t
h(BCLK-WR)
t
h(BCLK-DB)
t
d(BCLK-DB)
t
d(DB-WR)
t
h(WR-DB)
DBi
(PM16=1)
Figure 1.193. Timing diagram 3
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
Electrical Characteristics SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
236
BCLK
CSi
ALE
RD
Hi-Z
DB
ADi
BHE
Read timing
t
d(BCLK-RD)
t
h(RD-AD)
Memory Expansion Mode and Microprocessor Mode
(When accessing external memory area with 1 wait)
t
d(BCLK-CS)
tcyc
t
h(BCLK-CS)
t
h(BCLK-AD)
t
d(BCLK-AD)
t
d(BCLK-ALE)
t
h(BCLK-ALE)
t
h(BCLK-RD)
t
ac2(RD-DB)
t
h(RD-DB)
t
SU(DB-RD)
BCLK
CSi
ALE
t
h(WR-AD)
ADi
BHE
DBi
(PM16=0)
Write timing
WR,WRL,
WRH (PM16=0)
t
d(BCLK-CS)
tcyc
t
h(BCLK-CS)
t
h(WR-CS)
t
h(BCLK-AD)
t
d(BCLK-AD)
t
d(BCLK-ALE)
t
h(BCLK-ALE)
t
d(BCLK-WR)
t
h(BCLK-DB)
t
d(BCLK-DB)
t
d(DB-WR)
t
h(WR-DB)
t
h(BCLK-WR)
WR,WRL,
WRH (PM16=1)
t
d(BCLK-WR)
t
h(BCLK-WR)
DBi
(PM16=1)
t
h(BCLK-DB)
t
d(BCLK–DB)
t
d(DB-WR)
t
h(WR-DB)
Figure 1.194. Timing diagram 4
Applications
237
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Applications
USB Transceiver
In order to meet the impedance matching requirements of the USB Specification, a 27-33 resistor must be
added to USB D+ (pin 4) and to USB D- (pin 5). In addition, capacitors connected between USB D+ and USB D-
and Vss may need to be added for rise/fall time matching and edge control. These capacitors can be placed
before or after the 27-33 resistors. A coupling capactior may also be placed between D+ and D-. Their con-
figuration and values will depend on the PCBs layout. Perform the approriate USB testing to determine the
correct component placement. An example placement of external components is illustrated in Figure 1.195.
Attach is connected to D+ through 1.5 K resistor.
A
TTACH
[
P90
]
D+ (pin 4 M30245)
UVcc D+ (pin 4 M30245)
1.5 K
1.5 K
A
ttach/Detach m ode disabled.
Figure 1.196 Attach/Detach function connections
Figure 1.195 Example configuration of External USB components
Attach/Detach Function
The Attach/Detach Function can be used to attach or detach a USB device from the host without physi-
cally disconnecting the USB cable. When attaching a USB device, the attach/detach register should be
set to 0316 at the same time or before the USB Enable bit is set. Similarly, when detaching the device
from the host , the attach/detach register should be set to 0116 when disabling the USB block.
If you do not set the Attach/Detach bit (bit 1 at address 001F16) to HIGH, the system will default to its
normal mode.
D+ is connected to P90/ATTACH through a 1.5 K resistor in compliance with the USB specification.
Note: If the D+ pin is connected to UVcc, this mode will not work.
Hardware connections are shown in Figure 1.196.
D+
D-
27-33
Note 1: Capacitor and resistor values and their configuration depend on PCB layout.
Note 2: Connecting any type of choke coil to D+ or D- is not recomended.
M30245
USB
Transceiver
27-33
68pF
UVcc
0.47uF
68pF
Applications
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
238
Programming Notes
USB
The following Programming Notes should be incorporated into user code, to ensure strict adherence to
the USB protocol for Control Transfers.
1. The interrupt service routine (ISR) associated with those USB Function interrupts that are caused by
errors must have execution priority over the ISR for EP0 interrupts. Upon receipt of a USB Function
interrupt, the following actions should be taken:
Step #1: From the USB Interrupt Status (USBIS) and the USB Endpoint 0 Control & Status (EP0CS)
registers, determine if the 'Error Interrupt Status Flag' & the SETUP_END flag (i.e., INTST8 &
EP0CSR5, respectively) are both set.
[YES] => Set CLR_SETUP_END (EP0CSR11). Go to Step #2.
[NO] => No special S/W action required. Go to Step #1 after the next USB Function interrupt.
Step #2: Is EP0 IN FIFO loading in progress - i.e., data has been written to EP0 IN FIFO, but
SET_IN_BUF_RDY (EP0CSR7) is not yet set?
[YES] => Set SET_IN_BUF_RDY (EP0CSR7). Go to Step #3 after the next EP0 interrupt.
[NO] => No special S/W action required. Go to Step #1 after the next USB Function interrupt.
Step #3: Are OUT_BUF_RDY & SETUP (i.e., EP0CSR0 & EP0CSR2, respectively) set?
[YES] => Go to Step #4.
[NO] => Go to Step #3 after the next EP0 interrupt.
Step #4: Does the current Control Transfer Setup stage DATA0 packet identify a Control Read Transfer?
[YES] => Complete loading EP0 IN FIFO. Set CLR_OUT_BUF_RDY, SET_IN_BUF_RDY, & CLR_SETUP
(i.e., EP0CSR6, EP0CSR7, & EP0CSR8, respectively). Go to Step #1 after the next USB Function interrupt.
[NO] => Go to Step #3 after the next EP0 interrupt.
Refer to the flowchart in Figure 1.197 for more information on this programming note.
Applications
239
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Figure 1.197 USB Programming Note 1 Flowchart
No
No
Yes
No
Yes
No
Yes
Yes
Wait for EP0 Interrupt.
Step #1
’Error Interrupt Status Flag’=1?
&
SETUP_END = 1?
CLR_SETUP_END = 1
SET_IN_BUF_RDY = 1
1) Complete loading EP0 IN FIFO.
2) Set: CLR_OUT_BUF_RDY = 1
Is EP0 IN FIFO loading in
progress => data written, but
SET_IN_BUF_RDY not yet set?
Step #2
Step #3
OUT_BUF_RDY = 1?
&
SETUP = 1?
Step #4
Does the current Setup DATA0
packet identify a Control Read
Transfer?
USB Function Interrupt
Applications
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
240
2. Additional actions to take upon receipt of an EP0 interrupt are as follows (Refer to the flowchart in
Figure 1.198):
Step #1: Is OUT_BUF_RDY (EP0CSR0) set?
[YES] => Go to Step #2.
[NO] => No special S/W action required. Go to Step #1 after the next EP0 interrupt.
Step #2: Is SETUP_END (EP0CSR5) set?
[YES] => Set CLR_OUT_BUF_RDY, CLR_SETUP_END, & SEND_STALL (i.e., EP0CSR6, EP0CSR11, &
EP0CSR12, respectively). [Also set CLR_SETUP, if SETUP flag == '1'.] Go to Step #1 after the next
EP0 interrupt.
[NO] => Go to Step #3.
Step #3: Read number of data bytes equal to the EP0 'Receive Byte Count', stored in EP0WC7-0, from
EP0 OUT FIFO. Is this the final DATA packet of a Control Write Transfer?
[YES] => Go to Step #4_0.
[NO] => Go to Step #5_0.
Step #4_0: Is SETUP_END (EP0CSR5) set?
[YES] => Set CLR_OUT_BUF_RDY, CLR_SETUP_END, & SEND_STALL (i.e., EP0CSR6, EP0CSR11, &
EP0CSR12, respectively). [Also set CLR_SETUP, if SETUP flag == '1'.] Go to Step #1 after the next
EP0 interrupt.
[NO] => Set CLR_OUT_BUF_RDY & SET_DATA_END (i.e., EP0CSR6 & EP0CSR9, respectively). [Also
set CLR_SETUP, if SETUP flag == '1'.] Go to Step #4_1.
Step #4_1: Is SETUP_END (EP0CSR5) set?
[YES] => Set SEND_STALL (EP0CSR12). Go to Step #6_0.
[NO] => Go to Step #1 after the next EP0 interrupt.
Step #5_0: Is SETUP_END (EP0CSR5) set?
[YES] => Set CLR_OUT_BUF_RDY, CLR_SETUP_END, & SEND_STALL (i.e., EP0CSR6, EP0CSR11, &
EP0CSR12, respectively). [Also set CLR_SETUP, if SETUP flag == '1'.] Go to Step #1 after the next
EP0 interrupt.
[NO] => Set CLR_OUT_BUF_RDY (i.e., EP0CSR6). [Also set CLR_SETUP, if SETUP flag == '1'.] Go to
Step #5_1.
Step #5_1: Is SETUP_END (EP0CSR5) set?
[YES] => Set SEND_STALL (EP0CSR12). Go to Step #6_0.
[NO] => Go to Step #1 after the next EP0 interrupt.
Step #6_0: Are OUT_BUF_RDY & SETUP (EP0CSR0 & EP0CSR2) set?
[YES] => Go to Step #6_1.
[NO] => Go to Step #6_0 after the next EP0 interrupt.
Applications
241
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Step #6_1: Is SETUP_END (EP0CSR5) set?
[YES] => Set CLR_OUT_BUF_RDY, CLR_SETUP, & CLR_SETUP_END (EP0CSR6, EP0CSR8 &
EP0CSR11). Go to Step #6_0 after the next EP0 interrupt.
[NO] => Set CLR_OUT_BUF_RDY & CLR_SETUP (EP0CSR6 & EP0CSR8), and clear SEND_STALL
(EP0CSR12). Go to Step #1 after the next EP0 interrupt.
Yes
No
No
Yes
Yes
No
SEND_STALL = 1
Read # of data bytes equal to EP0 Receive Byte
Count (i.e., EP0WC 7-0) from EP0 OUT FIFO .
Read packet data
EP0 Interrupt
Step #3
No
No
Yes
Yes
Yes
Step #2
SETUP_END = 1?
Step #1
OUT_BUF_RDY = 1?
CLR_OUT_BUF_RDY = 1
CLR_SETUP = 1 (if SETUP is set)
CLR_SETUP_END = 1
SEND_STALL = 1
No
No
No
CLR_OUT_BUF_RDY = 1
CLR_SETUP = 1 (if SETUP is set)
SET_DATA_END = 1
CLR_OUT_BUF_RDY = 1
CLR_SETUP = 1 (if SETUP is set)
Yes
Yes
Yes
CLR_OUT_BUF_RDY = 1
CLR_SETUP = 1
OUT_BUF_RDY = 1?
&
SETUP = 1?
Step #6_0
Wait for EP0 Interrupt.
SETUP_END = 1?
Step #
6_1
Final packet of Control
Write Transfer?
CLR_OUT_BUF_RDY = 1
CLR_SETUP = 1
Step #5_0
SETUP_END = 1?
Step #5_1
SETUP_END = 1?
Step #4_0
SETUP_END = 1?
Step #4_1
SETUP_END = 1?
No
Figure 1.198 USB Programming Note 2 Flowchart
Applications
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
242
3. Writing to the USB Function Interrupt Clear Register (USBIC).
Writing to the USB Function Interrupt Clear Register (USBIC) to clear USB Function Interrupt Status bits
requires special consideration. Before performing this operation, the USB Function Interrupt Enable
Register (USBIE) should be cleared (i.e., all bits disabled). Upon completion of the write to USBIC, the
value of USBIE just prior to its clearing should be restored.
Specifications in this manual are tentative and subject to change
Rev. E MITSUBISHI MICROCOMPUTERS
M30245 Group
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Keep safety first in your circuit designs!
Mitsubishi Electric Corporation puts the maximum effort into making semiconductor products better and more reliable, but there is always the possibility that trouble may occur
with them. Trouble with semiconductors may lead to personal injury, fire or property damage. Remember to give due consideration to safety when making your circuit designs,
with appropriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of non-flammable material or (iii) prevention against any malfunction or mishap.
These materials are intended as a reference to assist our customers in the selection of the Mitsubishi semiconductor product best suited to the customer's application; they do
not convey any license under any intellectual property rights, or any other rights, belonging to Mitsubishi Electric Corporation or a third party.
Mitsubishi Electric Corporation assumes no responsibility for any damage, or infringement of any third-party's rights, originating in the use of any product data, diagrams, charts,
programs, algorithms, or circuit application examples contained in these materials.
All information contained in these materials, including product data, diagrams, charts, programs and algorithms represents information on products at the time of publication of
these materials, and are subject to change by Mitsubishi Electric Corporation without notice due to product improvements or other reasons. It is therefore recommended that
customers contact Mitsubishi Electric Corporation or an authorized Mitsubishi Semiconductor product distributor for the latest product information before purchasing a product
listed herein.
The information described here may contain technical inaccuracies or typographical errors. Mitsubishi Electric Corporation assumes no responsibility for any damage, liability,
or other loss rising from these inaccuracies or errors.
Please also pay attention to information published by Mitsubishi Electric Corporation by various means, including the Mitsubishi Semiconductor home page (http://
www.mitsubishichips.com).
When using any or all of the information contained in these materials, including product data, diagrams, charts, programs, and algorithms, please be sure to evaluate all information
as a total system before making a final decision on the applicability of the information and products. Mitsubishi Electric Corporation assumes no responsibility for any damage,
liability or other loss resulting from the information contained herein.
Mitsubishi Electric Corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially
at stake. Please contact Mitsubishi Electric Corporation or an authorized Mitsubishi Semiconductor product distributor when considering the use of a product contained herein
for any specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use.
The prior written approval of Mitsubishi Electric Corporation is necessary to reprint or reproduce in whole or in part these materials.
If these products or technologies are subject to the Japanese export control restrictions, they must be exported under a license from the Japanese government and cannot be
imported into a country other than the approved destination.
Any diversion or reexport contrary to the export control laws and regulations of Japan and/or the country of destination is prohibited.
Please contact Mitsubishi Electric Corporation or an authorized Mitsubishi Semiconductor product distributor for further details on these materials or the products contained
therein.
Notes regarding these materials
2003 MITSUBISHI ELECTRIC CORP.
New publication, effective January 2003.
Specifications subject to change without notice.
MITSUBISHI ELECTRIC CORPORATION
HEAD OFFICE: 2-2-3, MARUNOUCHI, CHIYODA-KU, TOKYO 100-8310, JAPAN
REVISION HISTORY M30245 GROUP DATA SHEET
Rev. Date Description
Page Summary
(1/1)
E 02/04/03 First Edition