The M37736MHBXXXGP is a single-chip microcomputer using the
7700 Family core. This single-chip microcomputer has a CPU and a
bus interface unit. The CPU is a 16-bit parallel processor that can be
an 8-bit parallel processor, and the bus interface unit enhances the
memory access efficiency to execute instructions fast. This
microcomputer also includes a 32 kHz oscillation circuit, in addition
to the ROM, RAM, multiple-function timers, serial I/O, A-D converter,
and others.
In the M37736MHBXXXGP, as the multiplex method of the external
bus, either of 2 types can be selected.
FEATURES
●Number of basic instructions .................................................. 103
Control devices for general commercial equipment such as office
automation, office equipment, and others.
Control devices for general industrial equipment such as
communication equipment, and others.
3
3
/CS
3
/A
3
4
/CS
4
/A
4
16
/RSMP
/A
5
6
/A
/A
5
6
0
10
11
8
17
/A
/D
7
8
/A
/A
7
0
12
9
/D
/D
/D
/D
9
10
11
12
/A
/A
/A
/A
1
2
3
4
/D
13
14
15
0
/D
/D
/D
/A
13
14
15
16
/A
/A
/A
/A
5
6
7
0
4
1
2
/D
/D
/D
/D
3
4
1
2
/A
/A
/A
/A
19
20
17
18
/A
/A
/A
/A
3
4
1
2
P86/RXD1 ↔
P8
4
/CTS1/RTS1 ↔
P8
P8
P8
2/RXD0
/CLKS0 ↔
P8
P8
0
/CTS0/RTS0/CLKS1 ↔
AV
P7
7
/AN7/X
6
/AN6/X
P7
P7
5
/AN5/AD
P7
P7
P7
P7
P7
5
/CLK1 ↔
3/TXD0
1
/CLK0 ↔
V
CC
CC
V
REF
AV
SS
V
SS
CIN
COUT
TRG
4
/AN4 ↔
3
/AN3 ↔
2
/AN2 ↔
1
/AN1 ↔
0
/AN0 ↔
↔ P8
8079787776
81
82
83
84
↔
85
86
87
88
89
→
90
91
92
93
↔
94
↔
95
↔
96
97
98
99
100
123456789
↔
SUB
/f
IN
/TB2
7
P6
↔ P9
↔
IN
/TB1
6
P6
↔ P9
↔
IN
/TB0
5
P6
↔ P9
↔
2
/INT
4
P6
→ P9
↔
1
/INT
3
P6
→ P9
→ P95→ P96→ P97↔ P0
7574737271
↔
↔
↔
↔
0
IN
IN
OUT
/INT
2
/TA4
/TA3
1
7
/TA4
P6
0
P5
P6
P6
↔ P0
↔ P0
↔ P0
↔ P0
↔ P0
↔ P0
↔ P1
↔ P1
↔ P1
↔ P1
↔ P1
↔ P1
↔ P1
↔ P1
70696867666564636261605958575655545352
↔ P0
↔ P2
M37736MHBXXXGP
10
↔
OUT
/TA3
6
P5
11
↔
IN
/TA2
5
P5
1213141516
↔
↔
↔
↔
IN
IN
OUT
OUT
/TA1
/TA0
3
1
/TA2
/TA1
4
2
P5
P5
P5
P5
↔
OUT
/TA0
0
P5
171819
↔
↔
3
2
/KI
/KI
7
6
P10
P10
2021222324
↔
↔
↔
1
0
3
/KI
/KI
5
4
P10
P10
P10
↔
2
P10
↔
1
P10
↔
0
P10
25
↔
7
P4
26
↔
6
P4
↔ P2
↔ P2
272829
↔
↔
5
4
P4
P4
↔ P2
↔ P2
51
↔ P25/A21/A5/D
50
↔ P26/A22/A6/D
49
↔ P27/A23/A7/D
48
↔ P30/R/W/WEL
47
↔ P3
46
↔ P3
45
↔ P3
44
→ EVL0
43
42
→ EVL1 V
41
40
V
39
→ E/RDE
38
→ X
← X
37
← RESET
36
← BSEL
35
← CNV
34
33
← BYTE
32
↔ P4
31
↔ P4
30
↔
↔
3
f1
/
2
P4
P4
5
6
7
1
/BHE/WEH
2
/ALE
3
/HLDA
CC
SS
OUT
IN
SS
0
/HOLD
1
/RDY
Outline 100P6S-A
1
PRELIMINARY
Clock input
X
IN
Clock output
X
OUT
Clock Generating Circuit
Timer TA4(16)
RAM
3968 bytes
ROM
124 Kbytes
Timer TA3(16)
Timer TA2(16)
Timer TA1(16)
P8(8)
Input/Output
port P8
P7(8)
Input/Output
port P7
X
CIN
X
COUT
P6(8)
Input/Output
port P6
P5(8)
Input/Output
port P5
P4(8)
Input/Output
port P4
P3(4)
Input/Output
port P3
P2(8)
Input/Output
port P2
P1(8)
Input/Output
port P1
P0(8)
Input/Output
port P0
Timer TA0(16)
Watchdog Timer
Timer TB2(16)
Timer TB1(16)
Timer TB0(16)
UART2(9)
UART1(9)
UART0(9)A-D Converter(10)
Instruction Register(8)
Data Buffer DB
H
(8)
Data Buffer DB
L
(8)
Processor Status Register PS(11)
Direct Page Register DPR(16)
Stack Pointer S(16)
Index Register Y(16)
Index Register X(16)
Accumulator B(16)
Arithmetic Logic
Unit(16)
Accumulator A(16)
Instruction Queue Buffer Q
0
(8)
Instruction Queue Buffer Q
1
(8)
Incrementer(24)
Program Address Register PA(24)
Data Address Register DA(24)
Instruction Queue Buffer Q
2
(8)
Program Counter PC(16)
Incrementer/Decrementer(24)
Program Bank Register PG(8)
Data Bank Register DT((8)
Input Buffer Register IB(16)
Address Bus
Data Bus(Even)
Data Bus(Odd)
X
CINXCOUT
Enable output
E
Reset input
RESET
(0V)
V
SS
(0V)
AV
SS
CNV
SS
AV
CC
Reference
voltage input
V
REF
Bus method
selection input
BSEL
External data bus width
selection input
BYTE
V
CC
P9(8)
Output
port P9
P10(8)
Input/Output
port P10
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
M37736MHBXXXGP BLOCK DIAGRAM
2
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
FUNCTIONS OF M37736MHBXXXGP
ParameterFunctions
Number of basic instructions103
Instruction execution time160 ns (the fastest instruction at external clock 25 MHz frequency)
Memory size
Input/Output ports
Output portP98-bit ✕ 1
Multi-function timers
Serial I/O(UART or clock synchronous serial I/O) ✕ 3
3 external types, 16 internal types
Each interrupt can be set to the priority level (0 – 7.)
2 circuits built-in (externally connected to a ceramic resonator or a
quartz-crystal oscillator)
Input/Output voltage5 V
Output current5 mA
External bus mode A; maximum 16 Mbytes,
External bus mode B; maximum 1 Mbytes
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
3
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
PIN DESCRIPTION
PinNameInput/OutputFunctions
Vcc,Power sourceApply 5 V ± 10% to Vcc and 0 V to Vss.
Vss
CNVssCNVss inputInputThis pin controls the processor mode. Connect to Vss for the single-chip mode and the memory
_____
RESETReset inputInputWhen “L” level is applied to this pin, the microcomputer enters the reset state.
XINClock inputInput
X
OUTClock outputOutput
_
EEnable outputOutputThis pin functions as the enable signal output pin which indicates the access status in the internal
BYTE
External data
InputIn the memory expansion mode or the microprocessor mode, this pin determines whether the
bus width
selection input
BSELInputIn the memory expansion mode or the microprocessor mode, this pin determines the external bus
Bus method
select input
AVcc,Analog powerPower source input pin for the A-D converter. Externally connect AVcc to Vcc and AVss to Vss.
AVsssource input
V
REFReference InputThis is reference voltage input pin for the A-D converter.
voltage input
P0
0 – P07 I/O port P0I/OIn the single-chip mode, port P0 becomes an 8-bit I/O port. An I/O direction register is available so
P1
0 – P17 I/O port P1I/OIn the single-chip mode, these pins have the same functions as port P0. When the BYTE pin is set
P2
0 – P27 I/O port P2I/OIn the single-chip mode, these pins have the same functions as port P0. In the memory expansion
P3
0 – P33 I/O port P3I/OIn the single-chip mode, these pins have the same function as port P0. In the memory expansion
P4
0 – P47 I/O port P4I/OIn the single-chip mode, these pins have the same functions as port P0. In the memory expansion
P50 – P57 I/O port P5I/OIn addition to having the same functions as port P0 in the single-chip mode, these pins also
P6
0 – P67 I/O port P6I/OIn addition to having the same functions as port P0 in the single-chip mode, these pins also
P7
0 – P77 I/O port P7I/OIn addition to having the same functions as port P0 in the single-chip mode, these pins function as
P8
0 – P87 I/O port P8I/OIn addition to having the same functions as port P0 in the single-chip mode, these pins also
P9
0 – P97
P100 – P107I/O
EVL0, EVL1
Output port P9
port P10
––
OutputPort P9 is an 8-bit I/O port. These ports are floating when reset. When writting to the port latch,
I/OIn addition to having the same functions as port P0 in the single-chip mode, P104 – P107 also
OutputThese pins should be left open.
expansion mode, and to Vcc for the microprocessor mode.
These are pins of main-clock generating circuit. Connect a ceramic resonator or a quartzcrystal oscillator between X
IN and XOUT. When an external clock is used, the clock source should
be connected to the XIN pin, and the XOUT pin should be left open.
bus. In the external bus mode B and the memory expansion mode or the microprocessor mode,
___
this pin output signal RDE.
external data bus has an 8-bit width or a 16-bit width. The data bus has a 16-bit width when “L”
signal is input and an 8-bit width when “H” signal is input.
mode. The bus mode becomes the external bus mode A when “H” signal is input, and the external
bus mode B when “L” signal is input.
that each pin can be programmed for input or output. These ports are in the input mode when
reset.
In the memory expansion mode or the microprocessor mode, these pins output address (A0 – A7)
at the external bus mode A, and these pins output signals CS0 – CS4 and RSMP, and addresses
(A16, A17) at the external bus mode B.
to “L” in the memory expansion mode or the microprocessor mode and external data bus has a
16-bit width, high-order data (D8 – D15) is input/output or an address (A8 – A15) is output. When
the BYTE pin is “H” and an external data bus has an 8-bit width, only address (A8 – A15) is output.
mode or the microprocessor mode, low-order data (D0 – D7) is input/output or an address is
output. When using the external bus mode A, the address is A16 – A23. When using the external
bus mode B, the address is A0 – A7.
mode or the microprocessor mode, R/W, BHE, ALE, and HLDA signals are output at the external
___ _______
bus mode A, and WEL, WEH, ALE, and HLDA signals are output at the external bus mode B.
mode or the microprocessor mode, P40, P41 and P42 become HOLD and RDY input pins, and a
clock
1 output pin, respectively. Functions of the other pins are the same as in the single-chip
mode. However, in the memory expansion mode, P42 can be selected as anI/O port.
function as I/O pins for timers A0 to A3.
function as I/O pins for timer A4, input pins for external interrupt input (INT0 – INT2) and input pins
for timers B0 to B2. P67 also functions as sub-clock SUB output pin.
input pins for A-D converter. Additionally, P76 and P77 have the function as the output pin (XCOUT)
and the input pin (XCIN) of the sub-clock (32 kHz) oscillation circuit, respectively. When P76 and
P77 are used as the XCOUT and XCIN pins, connect a resonator or an oscillator between the both.
function as I/O pins for UART 0 and UART 1.
these ports become the output mode. P90 – P93 also function as I/O port for UART 2.
function as input pins for key input interrupt input (KI0 – KI3).
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
____
___ ___
__
_______
__ __
___ ___
____ ___
4
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
BASIC FUNCTION BLOCKS
The M37736MHBXXXGP contains the following peripheral devices
on a single chip: ROM, RAM, CPU, bus interface unit, timers, serial
I/O, A-D converter, I/O ports, clock generating circuit and others. Each
of these devices is described below.
MEMORY
The memory map is shown in Figure 1. The address space has a
capacity of 16 Mbytes and is allocated to addresses from 0
FFFFFF
16. The address space is divided by 64-Kbyte unit called bank.
The banks are numbered from 0
bus mode B, banks 10
16 to FF16 cannot be accessed.
16 to FF16. However, in the external
Built-in ROM, RAM and control registers for internal peripheral devices
are assigned to banks 0
The 124-Kbyte area from addresses 1000
ROM. Addresses FFD6
16 and 116.
16 to 1FFFF16 is the built-in
16 to FFFF16 are the RESET and interrupt
vector addresses and contain the interrupt vectors. Refer to the section
on interrupts for details.
00000016
Bank 016
00FFFF16
01000016
Bank 116
01FFFF16
• • • • • • • • • • • • • • • • • • •
FE000016
Bank FE16
FEFFFF16
FF000016
Bank FF16
FFFFFF16
16 to
00000016
00007F16
00008016
000FFF16
00100016
00FFD616
00FFFF16
01FFFF16
The 3968-byte area allocated to addresses from 80
16 to FFF16 is the
built-in RAM. In addition to storing data, the RAM is used as stack
during a subroutine call or interrupts.
Peripheral devices such as I/O ports, A-D converter, serial I/O, timer,
and interrupt control registers are allocated to addresses from 0
7F
16.
16 to
Additionally, the internal ROM and RAM area can be modified by
software. Refer to the section on ROM area modification function for
details.
A 256-byte direct page area can be allocated anywhere in bank 0
by using the direct page register (DPR). In the direct page addressing
mode, the memory in the direct page area can be accessed with two
words. Hence program steps can be reduced.
00000016
Internal peripheral
devices
control registers
Internal RAM
3968 bytes
refer to Fig. 2 for
detail information
00007F16
Interrupt vector table
00FFD616
Internal ROM
124 Kbytes
00FFFE16
A-D/UART2 trans./rece.
UART1 transmission
UART1 receive
UART0 transmission
UART0 receive
Timer B2
Timer B1
Timer B0
Timer A4
Timer A3
Timer A2
Timer A1
Timer A0
INT2
/Key input
INT1
INT0
Watchdog timer
DBC
BRK instruction
Zero divide
RESET
16
Notes 1. Internal ROM and RAM area can be modified. (Refer to the section on ROM area modification function.)
2. In the external bus mode B, banks 1016 to FF16 cannot be accessed.
Fig. 1 Memory map
5
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Address (Hexadecimal notation)
000000
000001
000002
000003
000004
000005
000006
000007
000008
000009
00000A
00000B
00000C
00000D
00000E
00000F
000010
000011
000012
000013
000014
Port P0 register
Port P1 register
Port P0 direction register
Port P1 direction register
Port P2 register
Port P3 register
Port P2 direction register
Port P3 direction register
Port P4 register
Port P5 register
Port P4 direction register
Port P5 direction register
Port P6 register
Port P7 register
Port P6 direction register
Port P7 direction register
Port P8 register
Port P9 register
Port P8 direction register
UART 2 transmit/receive control register 1
UART 2 receive buffer register
Oscillation circuit control register 0
Port function control register
Serial transmit control register
Oscillation circuit control register 1
A-D/UART 2 trans./rece. interrupt control register
UART 0 transmission interrupt control register
UART 0 receive interrupt control register
UART 1 transmission interrupt control register
UART 1 receive interrupt control register
Timer A0 interrupt control register
Timer A1 interrupt control register
Timer A2 interrupt control register
Timer A3 interrupt control register
Timer A4 interrupt control register
Timer B0 interrupt control register
Timer B1 interrupt control register
Timer B2 interrupt control register
INT
0 interrupt control register
INT
1 interrupt control register
INT
2/Key input interrupt control register
Note. Do not write to this address.
Fig. 2 Location of internal peripheral devices and interrupt control registers
6
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
CENTRAL PROCESSING UNIT (CPU)
The CPU has ten registers and is shown in Figure 3. Each of these
registers is described below.
ACCUMULATOR A (A)
Accumulator A is the main register of the microcomputer. It consists
of 16 bits and the low-order 8 bits can be used separately. The data
length flag (m) determines whether the register is used as a 16-bit
register or as an 8-bit register. It is used as a 16-bit register when flag
m is “0” and as an 8-bit register when flag m is “1”. Flag m is a part of
the processor status register (PS) which is described later.
Data operations such as arithmetic operation, data transfer, input/
output, etc., are executed mainly through the accumulator A.
ACCUMULATOR B (B)
Accumulator B has the same functions as accumulator A, but the
use of accumulator B requires more instruction bytes and execution
cycles than accumulator A.
INDEX REGISTER X (X)
Index register X consists of 16 bits and the low-order 8 bits can be
used separately. The index register length flag (x) determines whether
the register is used as a 16-bit register or as an 8-bit register. It is
used as a 16-bit register when flag x is “0” and as an 8-bit register
when flag x is “1”. Flag x is a part of the processor status register
(PS) which is described later.
In an index addressing mode where register X is used as the index
register, the contents of this address is added to obtain the real
address.
Also, when executing a block transfer instruction (MVP, MVN), the
contents of index register X indicates the low-order 16 bits of the
source data address. The third byte of the MVP or MVN is the highorder 8 bits of the source data address.
INDEX REGISTER Y (Y)
Index register Y consists of 16 bits and the low-order 8 bits can be
used separately. The index register length flag (x) determines whether
the register is used as a 16-bit register or as an 8-bit register. It is
used as a 16-bit register when flag x is “0” and as an 8-bit register
when flag x is “1”. Flag x is a part of the processor status register
(PS) which is described later.
In an index addressing mode where register Y is used as the index
register, the contents of this address is added to obtain the real
address.
Also, when executing a block transfer instruction (MVP, MVN), the
contents of index register Y indicates the low-order 16 bits of the
destination data address. The second byte of the MVP or MVN is the
high-order 8 bits of the destination data address.
70
PG
70
DT
Fig. 3 Register structure
Program bank register (PG)
Data bank register (DT)
1507
AHAL
1507
BHBL
1507
XHXL
1507
YHYL
150
S
150
PC
150
DPR
7150
NIPL2IPL0IPL1CZIDxmV0000
Accumulator A (A)
Accumulator B (B)
Index register X (X)
Index register Y (Y)
Stack pointer (S)
Program counter (PC)
Direct page register (DPR)
Processor status register (PS)0
Carry flag
Zero frag
Interrupt disable flag
Decimal mode flag
Index register length flag
Data length flag
Overflow flag
Negative flag
Processor interrupt priority level (IPL)
7
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
STACK POINTER (S)
Stack pointer (S) is a 16-bit register. It is used during a subroutine
call or interrupts. It is also used during stack, stack pointer relative,
or stack pointer relative indirect indexed Y addressing modes.
PROGRAM COUNTER (PC)
Program counter (PC) is a 16-bit counter that indicates the low-order
16 bits of the next program memory address to be executed. There
is a bus interface unit between the program memory and the CPU,
so that the program memory is accessed through the bus interface
unit. This is described later.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
1. Carry flag (C)
The carry flag contains the carry or borrow generated by the ALU
after an arithmetic operation. This flag is also affected by shift or
rotate instruction. This flag can be set or reset directly with the SEC,
CLC instructions or with the SEP, CLP instructions.
2. Zero flag (Z)
This zero flag is set when the result of an arithmetic operation or data
transfer is zero and reset when it is not. This flag can be set or reset
directly with the SEP or CLP instruction.
PROGRAM BANK REGISTER (PG)
Program bank register (PG) is an 8-bit register that indicates the highorder 8 bits of the next program memory address to be executed.
When a carry occurs by incrementing the contents of the program
counter, the contents of the program bank register (PG) is incremented
by 1. Also, when a carry or borrow occurs after adding or subtracting
the offset value to or from the contents of the program counter (PC)
by using a branch instruction, the contents of the program bank
register (PG) is incremented or decremented by 1 so that programs
can be written without worrying about bank boundaries.
DATA BANK REGISTER (DT)
Data bank register (DT) is an 8-bit register. With some addressing
modes, a part of the data bank register (DT) is used to specify a
memory address. The contents of data bank register (DT) is used as
the high-order 8 bits of a 24-bit address. Addressing modes that use
the data bank register (DT) to specify the address are direct indirect,
direct indexed X indirect, direct indirect indexed Y, absolute, absolute
bit, absolute indexed X, absolute indexed Y, absolute bit relative,
and stack pointer relative indirect indexed Y.
DIRECT PAGE REGISTER (DPR)
Direct page register (DPR) is a 16-bit register. Its contents is used as
the base address of a 256-byte direct page area. The direct page
area is allocated in bank 0
or more, the direct page area spans across bank 016 and bank 116.
All direct addressing modes use the contents of the direct page register
(DPR) to generate the data address. When the low-order 8 bits’
contents of the direct page register (DPR) is “00
cycles required to generate an address is minimized. Hence the loworder 8 bits’ contents of the direct page register (DPR) is usually set
to “00
16”.
16, but when the contents of DPR is FF0116
16”, the number of
3. Interrupt disable flag ( I )
When the interrupt disable flag is “1”, all interrupts except watchdog
____
timer, DBC, and software interrupt are disabled. This flag is
automatically set to “1” when an interrupt is accepted. It can be set or
reset directly with the SEI, CLI instructions or SEP and CLP
instructions.
4. Decimal mode flag (D)
The decimal mode flag determines whether addition and subtraction
are performed in the binary or the decimal system. Binary arithmetic
is performed when this flag is “0”. If it is “1”, decimal arithmetic is
performed with each word treated as the 2- or 4-digit number.
Arithmetic operation is performed with 4-digit number when the data
length flag (m) is “0” and with 2-digit number when it is “1”. Decimal
correction is automatically performed. (Decimal operation is possible
only with the ADC and SBC instructions.) This flag can be set or
reset with the SEP or CLP instruction.
5. Index register length flag (x)
The index register length flag determines whether index register X
and index register Y are used as 16-bit registers or as 8-bit registers.
The registers are used as 16-bit registers when flag x is “0” and as 8bit registers when it is “1”. This flag can be set or reset with the SEP
or CLP instruction.
6. Data length flag (m)
The data length flag determines whether the data has a length of 16
bits or that of 8 bits. The 16-bit length is selected when flag m is “0”
and the 8-bit length is selected when it is “1”. This flag can be set or
reset with the SEM, CLM instructions or with the SEP, CLP
instructions.
PROCESSOR STATUS REGISTER (PS)
Processor status register (PS) is an 11-bit register. It consists of flags
which indicate the result of operation and the processor interrupt
priority level (IPL).
Branch operations can be performed by testing flags C, Z , V, and N.
The details of each processor status register bit are described below.
8
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
7. Overflow flag (V)
The overflow flag is effective only when addition or subtraction is
performed with treating a word as a signed binary number. When the
data length flag (m) is “0”, the overflow flag is set if the result of
addition or subtraction is outside the range between – 32768 and
+32767. When the data length flag (m) is “1”, the overflow flag is set
if the result of addition or subtraction is outside the range between
–128 and +127. It is reset in the other cases. The overflow flag can
also be set or reset directly with the SEP or CLV, CLP instructions.
8. Negative flag (N)
The negative flag is set when the result of arithmetic operation or
data transfer is negative (If data length flag (m) is “0”, data bit 15 is
“1”. If data length flag (m) is “1”, data bit 7 is “1”.) It is reset in the
other cases. It can also be set or reset with the SEP or CLP
instructions.
9. Processor interrupt priority level (IPL)
The processor interrupt priority level (IPL) consists of 3 bits and
determines the processor interrupt priority level (0 to 7). Interrupt is
enabled when the interrupt priority level of the device requesting
interrupt (the priority can be set using the interrupt control register) is
higher than the processor interrupt priority level. When interrupt is
enabled, the current processor interrupt priority level is saved in a
stack and the processor interrupt priority level is replaced by the
interrupt priority level of the device requesting the interrupt. Refer to
the section on interrupts for more details.
BUS INTERFACE UNIT
The CPU operates on an internal clock ’s frequency. Internal clock
’s frequency is twice the bus cycle frequency. In order to speed up
processing, a bus interface unit is used to pre-fetch instructions when
the data bus is idle. The bus interface unit synchronizes the CPU
and the bus and pre-fetches instructions. Figure 4 shows the
relationship between the CPU and the bus interface unit. The bus
interface unit has a program address register, a 3-byte instruction
queue buffer, a data address register, and a 2-byte data buffer.
The bus interface unit obtains an instruction code from the memory
and stores it in the instruction queue buffer, obtains data from the
memory and stores it in the data buffer, or writes the data from the
data buffer to the memory.
D'15 – D'8
D'7 – D'0
A'23 – A'0
CPU
Control signal
Fig. 4 Relationship between the CPU and the bus interface unit
Bus interface
unit
D15 – D8
D7 – D0
A23 – A0
BHE
R/W
E
ALE
BYTE
HOLD
9
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
The bus interface unit operates using one of the waveforms (1) to
(10) shown in Figure 5. The standard waveforms are (1) and (2).
The ALE signal is used to latch only the address signal from the
multiplexed signal containing data and address.
_
Signal E becomes “L” when the bus interface unit reads an instruction
code or data from the memory or when it writes data to the memory.
Whether to perform read or write is controlled by signal R/W. When
signal R/W is “H”, read is performed; when “L”, write is performed.
In the external bus mode B, signals E and R/W are not directly output
to the outside of the chip. In the memory expansion mode or the
microprocessor mode, read signal RDE and write signals WEL, WEH
are output to the outside of the chip. While signal E is “L”, signal RDE
becomes “L” at reading. While signal E is “L”, signals WEL and WEH
become “L” at writing.
_
__
______
____
____ ___
Internal clock Internal clock
AD
(1)
Port P2
E
_
____
(7)
ALE
Access time
A + 1
D
(8)
(2)
Port P2
AD
E
ALE
Access time
Waveform (1) in Figure 5 is used to access a single byte or two bytes
simultaneously. To read or write two bytes simultaneously, the first
address accessed must be even. Furthermore, when accessing an
external memory area in the memory expansion mode or the
microprocessor mode, set the bus width selection input pin (BYTE)
to “L” (external data bus has a width of 16 bits). The data bus in the
internal memory area is always treated as the 16-bit bus independent
of BYTE.
Port P2
E
A
D
ALE
Access time
Port P2
ADA + 1
E
D
ALE
Access time
(3)
(4)
(5)
(6)
Port P2
ALE
Port P2
ALE
Port P2
ALE
Port P2
ALE
E
E
E
E
AD
Access time
A
DD
Access time
A
D
Access time
AD
A + 1
Access time
A + 1
A + 1
A + 1
(9)
Port P2
DA
E
D
ALE
Access time
(10)
Port P2
AD
E
A + 1
D
ALE
Access time
D
A : Address
D : Data
While signal E is “L” in the external bus mode B, signal RDE
becomes “L” (in the read cycle) or signals WEL and WEH
become “L” (in the write cycle).
D
____
___ ____
Fig. 5 Bus access timing
10
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
When performing 16-bit data read or write, waveform (2) is used to
access each byte one by one if the conditions for simultaneously
accessing two bytes are not satisfied. However, when prefetching
the instruction code, if the address of the instruction code is odd,
waveform (1) is used, and only one byte is read in the instruction
queue buffer.
Access to the even/odd address is controlled by signals BHE and A0.
In the external bus mode B, signal BHE is not directly output to the
___
___ ___
___
outside of the chip. Write signals (WEL, WEH) are generated
corresponding to the accessed address (even or odd).
Bit 2 of processor mode register 0 (address 5E
16) is the wait bit.
When the external memory area is accessed in the memory expansion
mode or the microprocessor mode with this bit set to “0”, the width of
_
signal E is extended and access time can be extended.
There are two ways to extend the access time and they are selected
with bit 0 of the processor mode register 1 (address 5F
16).
_
When this bit is set to “1”, the “L” width of signal E in (1) becomes
twice as long as in (3) and the access time becomes 1.5 times (wait
_
1). When this bit is set to “0”, signals ALE and E in (1) are extended
as in (7) and the access time is doubled (wait 0).
However, these signals are not extended when accessing the internal
memory area.
When the wait bit is set to “1”, these signals are not extended when
accessing any memory area regardless of the bit 0 of the processor
mode register 1.
Waveforms (4), (5), and (6) show the entire waveform, first half, and
last half respectively of waveform (2) for wait 1.
Waveforms (8), (9), and (10) show the entire waveform, first half,
and last half respectively of waveform (2) for wait 0.
Instruction code read, data read, and data write are described below.
Instruction code read will be described first.
The CPU obtains instruction codes from the instruction queue buffer
and executes them. The CPU notifies the bus interface unit that it is
requesting an instruction code during an instruction code request
cycle. If the requested instruction code is not yet stored in the
instruction queue buffer, the bus interface unit halts the CPU until
more instructions than requested is stored in the instruction queue
buffer. Even if there is no instruction code request from the CPU, the
bus interface unit reads instruction codes from the memory and stores
them in the instruction queue buffer when the instruction queue buffer
is empty or when only one instruction code is stored and the bus is
idle on the next cycle. This is referred to as instruction pre-fetching.
Normally , when reading an instruction code from the memory, if the
accessed address is even, the next odd address is read together
with the instruction code and stored in the instruction queue buffer.
However, in the memory expansion mode or the microprocessor
mode, only one byte is read and stored in the instruction queue buffer
if the following conditions are satisfied.
• The address to be read is in the external memory area when the
external data bus has an 8-bit width (BYTE = “H”).
• The address to be read is odd.
Therefore, waveform (1), (3) or (7) in Figure 5 is used for instruction
code read. Data read and write are described below.
The CPU notifies the bus interface unit when performing data read or
write. At this time, the bus interface unit halts the CPU if the bus
interface unit is already using the bus or if there is a request with
higher priority. When data read or write is enabled, the bus interface
unit uses one of the waveforms from (1) to (10) in Figure 5 to perform
the operation.
During data read, the CPU waits until the entire data is stored in the
data buffer. The bus interface unit sends the address received from
the CPU to the address bus. Then it reads the memory when signal
_
E is “L” and stores the result in the data buffer.
During data write, the CPU writes the data in the data buffer and the
bus interface unit writes it to the memory . Therefore, the CPU can
proceed to the next step without waiting for write completed. The bus
interface unit sends the address received from the CPU to the address
_
bus. Then when signal E is “L”, the bus interface unit sends the data
in the data buffer to the data bus and writes it to the memory.
11
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
INTERRUPTS
Table 1 shows the interrupt sources and the corresponding interrupt
vector addresses. Reset is also treated as a source of interrupt and
is described in this section.
___
DBC is an interrupt used only for debugging.
Interrupts other than reset, DBC, watchdog timer, zero divide, and
BRK instruction all have their respective interrupt control registers.
Table 2 shows the addresses of the interrupt control registers and
Figure 6 shows the bit configuration of the interrupt control register.
The interrupt request bit is automatically cleared by hardware during
reset or when processing an interrupt. Also, interrupt request bits
other than DBC and watchdog timer can be cleared by software.
___ ___
INT0 to INT2 are external interrupts, and whether to cause an interrupt
___
at the input level (level sense) or at the edge (edge sense) can be
selected with the level sense/edge sense selection bit. Furthermore,
the polarity of the interrupt input can be selected with a polarity
selection bit.
___
In the INT2 /Key input interrupt, whether to input an interrupt request
_____ __
from the INT2 pin or the KI0 – KI3 pins can be selected by bit 7 of the
port function control register (refer to Figure 11).
Timer and UART interrupts are described in the respective section.
The priority of interrupts when multiple interrupts are caused
simultaneously is partially fixed by hardware, but it can also be
adjusted by software as shown in Figure 7. The hardware priority is
fixed as follows:
___
reset > DBC > watchdog timer > other interrupts
___
Table 1. Interrupt sources and the interrupt vector addresses
BRK instruction00FFFA1600FFFB16
Zero divide00FFFC1600FFFD16
Reset00FFFE1600FFFF16
7
6543210
Interrupt control register configuration for timers A0 to A4, timers B0 to B2, UART0, UART1 and
A-D/UART2 trans./rece.
7
6543210
Interrupt control register configuration for
Fig. 6 Interrupt control register bit configuration
Interrupt priority level selection bits
Interrupt request bit
0 : No interrupt
1 : Interrupt
Interrupt priority level selection bits
Interrupt request bit
0 : No interrupt
1 : Interrupt
Polarity selection bit
0 : Interrupt request bit is set at “H” level for level sense or at the falling
edge for edge sence.
1 : Interrupt request bit is set at “L” level for level sense or at the rising
edge for edge sense.
Level sense/edge sense selection bit
0 : Edge sense
1 : Level sense
INT0 to INT2/Key input
12
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Table 2. Addresses of interrupt control registers
Interrupt control registersaddresses
A-D/UART2 trans./rece. interrput control register
00007016
UART0 transmit interrput control register00007116
UART0 receive interrput control register00007216
UART1 transmit interrput control register00007316
UART1 receive interrupt control register00007416
Timer A0 interrupt control register00007516
Timer A1 interrupt control register00007616
Timer A2 interrupt control register00007716
Timer A3 interrupt control register00007816
Timer A4 interrupt control register00007916
Timer B0 interrupt control register00007A16
Timer B1 interrupt control register00007B16
Timer B2 interrupt control register00007C16
___
INT0 interrupt control register00007D16
___
INT1 interrupt control register00007E16
___
INT2/Key input interrupt control register00007F16
Interrupts caused by a BRK instruction and when dividing by zero
are software interrupts and are not included in this list.
Other interrupts previously mentioned are A-D converter, UART,
Timer, INT interrupts. The priority of these interrupts can be changed
by changing the interrupt priority level selection bits of the
corresponding interrupt control register with software.
Figure 8 shows a diagram of the interrupt priority detection circuit.
When an interrupt is caused, the each interrupt device compares its
own priority with the priority from above and if its own priority is higher,
then it sends the priority below and requests the interrupt. If the
priorities are the same, the one above has priority.
This comparison is repeated to select the interrupt with the highest
priority among the interrupts that are being requested. Finally the
selected interrupt is compared with the processor interrupt priority
level (IPL) contained in the processor status register (PS), and the
request is accepted if it is higher than IPL and the interrupt disable
flag (I) is “0”. The request is not accepted if flag I is “1”. The reset,
___
DBC, and watchdog timer interrupts are not affected by the interrupt
disable flag (I).
When an interrupt is accepted, the contents of the processor status
register (PS) is saved to the stack and the interrupt disable flag (I) is
set to “1”.
Furthermore, the interrupt request bit of the accepted interrupt is
cleared to “0” and the processor interrupt priority level (IPL) in the
processor status register (PS) is replaced by the priority level of the
accepted interrupt.
Therefore, multiple interrupts are possible by resetting the interrupt
disable flag (I) to “0” and enable further interrupts.
___
For reset, DBC, watchdog timer, zero divide, and BRK instruction
interrupts, which do not have an interrupt control register, the
processor interrupt level (IPL) is set as shown in Table 3.
Priority detection is performed by latching the interrupt request bit
and interrupt priority level selection bits so that they do not change.
They are sampled at the first half and latched at the last half of the
operation code fetch cycle.
Because priority detection takes some time, no sampling pulse is
generated for a certain interval even if it is the next operation code
fetch cycle.
As shown in Figure 9, there are three different interrupt priority
detection time from which one is selected by software. After the
selected time has elapsed, the interrupt which has the highest priority
is determined and is processed after the current instruction execution
has been completed.
The time is selected with bits 4 and 5 of the processor mode register
0 (address 5E
between these bits and the number of cycles. After a reset, the
processor mode register 0 is initialized to “00
time is selected. However, the shortest time should be selected by
software.
16) shown in Figure 10. Table 4 shows the relationship
16”. Therefore, the longest
Internal clock
Operation code fetch cycle
Sampling pulse
Table 3. Value set in processor interrupt level (IPL) during an interrupt
Interrupt types Setting value
Reset0
___
DBC7
Watchdog timer7
Zero divideNot change value of IPL.
BRK instructionNot change value of IPL.
Table 4. Relationship between interrupt priority detection time selec-
Interrupt priority detection time selection bits
tion bits and number of cycles
Bit 5Bit 4
007 cycles of
014 cycles of
102 cycles of
: internal clock
Number of cycles
Priority detection time
Select one from 0 to 2 with
bits 4 and 5 of the
processor mode register 0
Software reset bit
The processor is reset when this bit is set to “1”.
Interrupt priority detection time selection bits
0 0 : Select 0 in Figure 9
0 1 : Select 1 in Figure 9
1 0 : Select 2 in Figure 9
Always “0”
Clock 1 output selection bit
0 : No 1 output
1 : 1 output
Fig. 10 Processor mode register 0 configuration
14
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
By setting the port function control register, the INT2/Key input interrupt
___
function can be switched to the key input interrupt function which
uses the KI0 to KI3 inputs. Figure 11 shows the bit configuration of the
__ __
___
port function control register, and Figure 12 shows the INT2/Key input
interrupt input circuit block diagram.
When the key input interrupt selection bit of the port function control
register is “0”, a signal is input from the INT2 pin to the INT2/Key input
______
___
interrupt control circuit and the INT2 interrupt is normally performed.
When the key input interrupt selection bit is “1”, signals input from
__ __
the KI0 to KI3 pins are inverted, and then the logical sum of these
signals is input to the INT2 interrupt control circuit. In this case, the
external interrupt which uses the KI0 to KI3 pins is performed. (Pins
__ __
KI0 to KI3correspond to ports P104 to P107, respectively.) Additionally,
___
__ __
___
by setting the port P6 pull-up selection bit 1 to “1”, the INT2 input is
added to that logical sum, so that the external interrupt which uses
__ __ ___
the inputs KI0 to KI3 and INT2 is performed. When using the key input
interrupt, it is necessary to select the edge sense which uses the
___
falling edge by setting the INT2/Key input interrupt control register.
Because of this selection, a key input interrupt request occurs when
“L” is input to one of the KI0 to KI3 and INT2 pins. The interrupt vector
__ __ ___
___
and the interrupt control register are common to the INT2 and key
input interrupts.
Port P6 pull-up
Pull–up
transistor
P64/
INT2
Pull–up
transistor
P107/
KI3
Pull–up
selection bit 1
Port P64 direction register
Port P6 pull-up
selection bit 1
Port P10 pull-up
selection bit
Port P107 direction
register
0
1
transistor
P106/
KI2
Pull–up
transistor
P105/
KI1
Pull-up resistors (transistors) can be added to the KI0 to KI3 pins by
__ __
setting “1” to the port P10 pull-up selection bit and “0” to the contents
of the port P10
i (i = 4 to 7) direction register. Similarly, a pull-up resistor
___
can be added to the INT2 pin by setting “1” to the port P6 pull-up
selection bit 1 and “0” to the content of the port P6
4 direction register.
With the key input interrupt and the pull-up function, the key input
circuit is easily composed.
INT2/Key input
interrupt control register
(Address 7F
16
)
When the key input interrupt is
selected, it is necessary to
Standby state selection bit
0: Pins P0 – P3 as external bus output
1: Pins P0 – P3 as port output
Sub-clock output selection bit/Timer B2 clock source selection bit
•
Port-Xc selection bit = “0” (sub-clock not used)
Timer B2 (event counter mode) clock source selection
0: TB2
IN input
1: Main clock divided by 32
•
Port-Xc selection bit = “1” (sub-clock used)
Sub-clock output selection
0: Function as port P6
1: Output sub-clock
7 pin
SUB from P67/TB2IN/ SUB pin
Timer B1 internal connect selection bit
0: No internal connect
1: Internal connect to timer B2
Port P6 pull-up selection bit 0
0: With no pull-up transistor for pins P6
2/INT0, P63/INT1
1: With pull-up transistor for pins P62/INT0, P63/INT1
0: Always “0”
Port P6 pull-up selection bit 1
•
Key input interrupt selection bit = “0”
0: With no pull-up transistor for P6
1: With pull-up transistor for P6
•
Key input interrupt selection bit = “1”
4/INT2 pin
4/INT2 pin
0: With port function, no pull-up transistor for P6
1: With key input interrupt, pull-up transistor for P6
4/INT2 pin
4/INT2 pin
Fig. 11 Bit configuration of port function control register
Port P10 pull-up selection bit
0: With no pull-up transistor for pins P10
4 – P107
1: With pull-up transistor for pins P104 – P107
Key input interrupt selection bit
0:
INT2 interrupt
1: Key input interrupt
16
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
TIMER
There are eight 16-bit timers. They are divided by type into timer A(5)
and timer B(3).
The timer I/O pins are also used as I/O pins for ports P5 and P6. To
use these pins as timer input pins, the port direction register bit
corresponding to the pin must be cleared to “0” to specify the input
mode.
TIMER A
Figure 13 shows a block diagram of timer A.
Timer A has four modes; timer mode, event counter mode, one-shot
pulse mode, and pulse width modulation mode. The mode is selected
with bits 0 and 1 of the timer Ai mode register (i = 0 to 4). Each of
these modes is described below.
Clock source selection
f
2
f
16
f
64
f
512
TAi
(i = 0 – 4)
IN
Polarity
selection
• Timer
• One-shot
• Pulse width modulation
Timer (gate function)
Event counter
External trigger
(1) Timer mode [00]
Figure 14 shows the bit configuration of the timer Ai mode register
during timer mode. Bits 0, 1, and 5 of timer Ai mode register must
always be “0” in the timer mode.
Bit 3 is ignored if bit 4 is “0”.
Bits 6 and 7 are used to select the timer counter source. The counting
of the selected clock starts when the count start flag is “1” and stops
when it is “0”.
Figure 15 shows the bit configuration of the count start flag. The
counter is decremented. An interrupt is caused and the interrupt
request bit of the timer Ai interrupt control register is set when the
contents becomes 0000
register are transferred to the counter, and count is continued.
When bit 2 of the timer Ai mode register is “1”, the output is generated
from TAiOUT pin. The output is toggled each time the contents of the
counter reaches to 0000
is “0”, “L” is output from TAi
When bit 2 is “0”, TAi
When bit 4 is “0”, TAi
16. When the contents of the count start flag
OUT pin.
OUT can be used as a normal port pin.
IN can be used as a normal port pin.
When bit 4 is “1”, counting is performed only while the input signal
from the TAi
can be used to measure the pulse width of the TAi
IN pin is “H” or “L” as shown in Figure 16. Therefore, this
IN input signal.
Whether to count while the input signal is “H” or while it is “L” is
determined by bit 3. When bit 3 is “1”, counting is performed while
the TAi
IN pin input signal is “H” and when bit 3 is “0”, counting is
more cycles of the timer count sourse.
When data is written to the timer Ai register with timer Ai halted, the
same data is also written to the reload register and the counter. When
data is written to timer Ai which is busy, the data is written to the
reload register, but not to the counter. The counter is reloaded with
new data from the reload register at the next reload time. The contents
of the counter can be read at any time.
When the value set in the timer Ai register is n, the timer frequency
dividing ratio is 1/(n + 1).
Addresses
0 ✕ : No gate function (TAi
1 0 : Count only while TAiIN input is “L”
Fig. 14 Timer Ai mode register bit configuration during timer mode
0 : No pulse output (TAiOUT is normal port pin)1 : Pulse output
IN is normal port pin)
0 : Select f2
18
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Fig. 15 Count start flag bit configuration
Selected clock source fi
TAiN
70654321
Count start flag
(Stop at “0”, Start at “1”)
Timer A0 count start flag
Timer A1 count start flag
Timer A2 count start flag
Timer A3 count start flag
Timer A4 count start flag
Timer B0 count start flag
Timer B1 count start flag
Timer B2 count start flag
Address
40
16
Timer mode register
Bit 4Bit 3
10
Timer mode register
Bit 4Bit 3
11
11
Fig. 16 Count waveform when gate function is available
19
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
(2) Event counter mode [01]
Figure 17 shows the bit configuration of the timer Ai mode register
during the event counter mode. In the event counter mode, the bit 0
of the timer Ai mode register must be “1” and bits 1 and 5 must be
“0”.
The input signal from the TAi
flag shown in Figure 15 is “1” and counting is stopped when it is “0”.
Count is performed at the fall of the input signal when bit 3 is “0” and
at the rise of the signal when it is “1”.
In the event counter mode, whether to increment or decrement the
count can be selected with the up-down flag or the input signal from
the TAi
OUT pin.
When bit 4 of the timer Ai mode register is “0”, the up-down flag is
used to determine whether to increment or decrement the count
(decrement when the flag is “0” and increment when it is “1”). Figure
18 shows the bit configuration of the up-down flag.
When bit 4 of the timer Ai mode register is “1”, the input signal from
the TAi
OUT pin is used to determine whether to increment or decrement
the count. However, note that bit 2 must be “0” if bit 4 is “1”. Because
TAi
OUT pin becomes an output pin with pulse output if bit 2 is “1”.
The count is decremented when the input signal from the TAi
is “L” and incremented when it is “H”. Determine the level of the input
signal from the TAi
TAi
IN pin.
OUT pin before an effective edge is input to the
An interrupt request signal is generated and the interrupt request bit
of the timer Ai interrupt control register is set when the counter reaches
0000
16 (decrement count) or FFFF16 (increment count). At the same
time, timers A0 and A1 transfer the contents of the reload register to
the counter and continue counting.
Timers A2, A3, and A4 transfer the contents of the reload register to
the counter and continue count when bit 6 of the corresponding timer
Ai mode register is “0”, but when bit 6 is “1”, they continue counting
without transferring the contents of the reload register to the counter.
When bit 2 is “1”, the waveform of which polarity is reversed each
time the counter reaches 0000
(increment count) is output from TAiOUT pin. If bit 2 is “0”, the TAiOUT
pin can be used as a normal port pin. However, if bit 4 is “1” and the
TAi
OUT pin is used as an output pin, the output from the TAiOUT pin
changes the count direction. Therefore, bit 4 must be “0” unless the
output from the TAi
OUT pin is used to select the count direction.
Data write and data read are performed in the same way as for the
timer mode. That is, when data is written to timer Ai which is halted,
it is also written to the reload register and the counter.
When data is written to timer Ai which is busy, the data is written to
the reload register, but not the counter. The counter is reloaded with
new data from the reload register at the next reload time and continues
counting. For timers A2, A3, and A4, the contents of the reload register
is not reloaded in the counter when bit 6 of the corresponding timer
Ai mode register is “1”. The contents of the counter can be read at
any time.
0 : Count at the falling edge of input
signal
1 : Count at the rising edge of input
signal
0 : Increment or decrement according
to up-down flag
1 : Increment or decrement according
to TAi
0 : Always “0” in event counter mode
This bit is available for times A2, A3,
and A4.
0 : Reload
1 : No reload
This bit is available for timer A3.
0 : Two-phase pulse signal processing
in the same manner as timer A2
1 : Two-phase pulse signal processing
in the same manner as timer A4
Up-down flag
Timer A0 up-down flag
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
selection bit
0 : Two-phase pulse signal processing disabled
1 : Two-phase pulse signal processing mode
Timer A3 two-phase pulse signal processing
selection bit
0 : Two-phase pulse signal processing disabled
1 : Two-phase pulse signal processing mode
Timer A4 two-phase pulse signal processing
selection bit
0 : Two-phase pulse signal processing disabled
1 : Two-phase pulse signal processing mode
OUT pin input signal level
Addresses
4416
20
Fig. 18 Up-down flag bit configuration
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
Furthermore, in the event counter mode, whether to increment or
decrement the counter can also be determined by supplying two kinds
of pulses of which phases differ by 90° to timer A2, A3, or A4. There
are two types of two-phase pulse signal processing operations. One
uses timer A2 and the other uses timer A4. Timer A3 can select one
of these two operations with bit 7 of the timer A3 mode register. In
both processing operations, two kinds of pulses of which phases differ
by 90° are input to the TAj
After the level of the TA2
A2 used, as shown in Figure 19, the count is incremented when a
rising edge is input to the TA2
when the falling edge is input.
For timer A4, as shown in Figure 20, when a phase related pulse
with a rising edge input to the TA4
TA4
OUT pin changes from “L” to “H”, the count is incremented at the
respective rising edge and falling edge of the TA4
pin. When a phase related pulse with a falling edge input to the TA4OUT
pin is input after the level of TA4IN pin changes from “H” to “L”, the
count is decremented at the respective rising edge and falling edge
of the TA4
IN pin and TA4OUT pin.
When performing this two-phase pulse signal processing, bits 0 and
4 of the timer Aj mode register must be set to “1” and bits 1, 2, 3, and
5 must be set to “0” as shown in Figure 21.
Bit 7 is used to select whether to perform two-phase pulse signal
processing for timer A3 in the same manner as timer A2 or as timer
A4. When this bit is “0”, two-phase pulse signal processing for timer
A3 is performed in the same manner as timer A2 and when it is “1”, it
is performed in the same manner as timer A4. This bit is ignored for
timers A2 and A4.
Note that bits 5, 6, and 7 of the up-down flag (address 44
two-phase pulse signal processing selection bits for timers A2, A3,
and A4, respectively.
Each timer operates in the normal event counter mode when the
corresponding bit is “0” and performs two-phase pulse signal
processing when it is “1”.
Count is started by setting the count start flag to “1”. Data write and
read are performed in the same way as for the normal event counter
mode. Note that the port direction register of the input port must be
set to the input mode because two-phase pulse signal is input. Also,
there can be no pulse output in this mode.
OUT (j = 2 to 4) pin and TAjIN pin respectively.
OUT pin changes from “L” to “H” with timer
IN pin and the count is decremented
IN pin is input after the level of
OUT pin and TA4IN
16) are the
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
TA2OUT
TA2IN
Increment
Increment
Increment
Decrement
Decrement
count
count
count
count
Fig. 19 Two-phase pulse signal processing operation of timer A2
TA4OUT
Increment count at each edgeDecrement count at each edge
TA4IN
Increment count at each edge Decrement count at each edge
Fig. 20 Two-phase pulse signal processing operation of timer A4
0 1 0 0 : Always “0100” when processing
two-phase pulse signal
0 : Reload
1 : No reload
This bit is avilable for timer A3
0 : Two-phase pulse signal processing
in the same manner as timer A2
1 : Two-phase pulse signal processing
in the same manner as timer A4
count
Decrement
count
Addresses
16
Fig. 21 Timer Aj mode register bit configuration when performing
two-phase pulse signal processing in event counter mode
21
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
(3) One-shot pulse mode [10]
Figure 22 shows the bit configuration of the timer Ai mode resister
during the one-shot pulse mode. In the one-shot pulse mode, bit 0
and bit 5 must be “0” and bit 1 and bit 2 must be “1”.
The trigger is enabled when the count start flag is “1”. The trigger
can be generated by software, or it can be input from the TAi
Software trigger is selected when bit 4 is “0”, and the input signal
from the TAi
Bit 3 is used to determine whether to trigger at the fall of the trigger
signal or at the rise. The trigger is at the fall of the trigger signal when
bit 3 is “0” and at the rise of the trigger signal when bit 3 is “1”.
Software trigger is generated by setting the bit of the one-shot start
flag corresponding to each timer.
Figure 23 shows the bit configuration of the one-shot start flag.
As shown in Figure 24, when a trigger signal is received, the counter
counts the clock selected by bits 6 and 7.
If the contents of the counter is not 0000
when a trigger signal is received. The count direction is decrement.
When the counter reaches 0001
is stopped. The contents of the reload register is transferred to the
counter. At the same time, an interrupt request signal is generated,
and the interrupt request bit of the timer Ai interrupt control register is
set. This is repeated each time a trigger signal is received. The output
pulse width is
If the count start flag is “0”, the level of the TAiOUT pin goes “L”.
Therefore, the counter’s value corresponding to the desired pulse
width must be written to timer Ai before setting “1” to the timer Ai
count start flag.
As shown in Figure 25, a trigger signal can be received before the
operation for the previous trigger signal is completed. In this case,
the contents of the reload register is transferred to the counter by the
trigger, and then that value is decremented.
Except when retriggering while operating, the contents of the reload
register is not transferred to the counter by triggering.
When retriggering, there must be at least two timer count source
cycles before a new trigger can be issued.
Fig. 22 Timer Ai mode register bit configuration during one-shot
pulse mode
22
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
Data write is performed in the same way as for the timer mode. When
data is written in timer Ai halted, it is also written to the reload register
and the counter.
When data is written to timer Ai which is busy, the data is written to
the reload register, but not to the counter. The counter is reloaded
with new data from the reload register at the next reload time and
continues counting.
Undefined data is read when timer Ai is read.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
70654321
70654321
One-shot start flag
One-shot start flag
Timer A0 one-shot start flag
Timer A0 one-shot start flag
Timer A1 one-shot start flag
Timer A1 one-shot start flag
Timer A2 one-shot start flag
Timer A2 one-shot start flag
Timer A3 one-shot start flag
Timer A3 one-shot start flag
Timer A4 one-shot start flag
Timer A4 one-shot start flag
Fig. 23 One-shot start flag bit configuration
Address
Address
16
16
42
42
Selected
Selected
clock source fi
clock source fi
TAiIN
TAiIN
(rising edge is
(rising edge is
selected)
selected)
TAi
TAi
OUT
OUT
In this case, the contents of the reload register is
Fig. 24 Pulse output example when external rising edge is selected
Selected
Selected
clock source fi
clock source fi
TAiIN
TAiIN
(rising edge is
(rising edge is
selected)
selected)
0003
16.
TAi
TAi
OUT
OUT
In this case, the contents of the reload register is
Fig. 25 Example when trigger is re-issued during pulse output
000416.
23
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
(4) Pulse width modulation mode [11]
Figure 26 shows the bit configuration of the timer Ai mode register
during the pulse width modulation mode. In the pulse width modulation
mode, bits 0, 1, and 2 must be set to “1”.
Bit 5 is used to determine whether to perform as the 16-bit length
pulse width modulator or the 8-bit length pulse width modulator. 16bit length pulse width modulator is selected when bit 5 is “0” and 8-bit
length pulse width modulator is selected when bit 5 is “1”. The 16-bit
length pulse width modulator is described first.
The pulse width modulator can be started with a software trigger or
with an input signal from a TAi
The software trigger mode is selected when bit 4 is “0”. Pulse width
modulator is started and pulse is output from the TAi
the timer Ai start flag is set to “1”.
The external trigger mode is selected when bit 4 is “1”. Pulse width
modulator starts when a trigger signal is input from the TAi
the timer Ai start flag is “1”. Whether to trigger at the fall or rise of the
trigger signal is determined by bit 3. The trigger is at the fall of the
trigger signal when bit 3 is “0” and at the rise when it is “1”.
When data is written to timer Ai with the pulse width modulator halted,
it is written to the reload register and the counter.
Then when the timer Ai start flag is set to “1” and a software trigger or
an external trigger is issued to start modulation, the waveform shown
in Figure 27 is output continuously. Once modulation is started,
triggers are not accepted. When the value in the reload register is m,
the duration “H” of pulse is
selected clock frequency
and the output pulse period is
selected clock frequency
IN pin (external trigger).
1
1
✕ m
✕ (216 – 1).
OUT pin when
IN pin when
The reload register and the counter are both divided into 8-bit halves.
The low-order 8 bits function as a prescaler and the high-order 8 bits
function as the 8-bit length pulse width modulator. The prescaler
counts the clock selected by bits 6 and 7. A pulse is generated when
the counter reaches 0000
the contents of the reload register is transferred to the counter, and
count is continued.
An interrupt request signal is generated and the interrupt request bit
of the timer Ai interrupt control register is set at each fall of the output
pulse.
The width of the output pulse is changed by updating timer data. The
update can be performed at any time. The output pulse width is
changed at the rise of the pulse after data is written to the timer.
The contents of the reload register is transferred to the counter just
before the rise of the next output pulse so that the pulse width is
changed from the next output pulse.
Undefined data is read when timer Ai is read.
The 8-bit length pulse width modulator is described next.
The 8-bit length pulse width modulator is selected when bit 5 of the
timer Ai mode register is “1”.
Fig. 26 Timer Ai mode register bit configuration during pulse width
modulation mode
24
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
Therefore, if the low-order 8 bits of the reload register is n, the period
of the generated pulse is
1
selected clock frequency
✕ (n + 1).
The high-order 8 bits function as an 8-bit length pulse width modulator
using this pulse as input. Its operation is the same as for 16-bit length
pulse width modulator except it has a length of 8 bits. When the highorder 8 bits’ contents of the reload register is m, the duration “H” of
pulse is
1 / fi✕ (216 – 1)
Selected clock
i
source f
TAiIN
(rising edge is
selected)
OUT
TAi
1 / f
i ✕ (m)
This trigger is not accepted
1
selected clock frequency
And the output pulse period is
1
selected clock frequency
✕ (n + 1) ✕ m.
✕ (n + 1) ✕ (28 – 1).
In this case, the contents of the reload register is 0003
Fig. 27 16-bit length pulse width modulator output pulse example
Selected clock
source f
i
IN
TAi
(falling edge is
selected)
1 / fi✕ (n + 1)
Prescaler output
(when n = 2)
i✕ (n + 1) ✕ (m)
1 / f
8-bit length pulse
width modulator
output
(when m = 2)
i✕ (n + 1) ✕ (2
1 / f
8
– 1)
16.
Fig. 28 8-bit length pulse width modulator output pulse example
25
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
TIMER B
Figure 29 shows a block diagram of timer B.
Timer B has three modes; timer mode, event counter mode, and
pulse period measurement/pulse width measurement mode. The
mode is selected with bits 0 and 1 of the timer Bi mode register (i = 0
to 2). Timer B2 can also be used as the clock timer of which clock
source is the main clock or the sub-clock divided by 32. Additionally,
timer B2 can be internally connected to timer B1 (cascade connection).
Each of these modes is described below.
(1) Timer mode [00]
Figure 30 shows the bit configuration of the timer Bi mode register
during the timer mode. Bits 0 and 1 of the timer Bi mode register
must always be “0” in the timer mode.
Bits 6 and 7 are used to select the clock source. The counting of the
selected clock starts when the count start flag is “1” and stops when
it is “0”.
Clock source selection
f2
f16
f64
f512
• Timer
• Pulse period measurement/pulse
width measurement
As shown in Figure 15, the timer Bi count start flag is at the same
address as the timer Ai count start flag. The count is decremented.
When the contents of the counter becomes 0000
16, an interrupt
request occurs and the interrupt request bit of the timer Bi interrupt
control register is set. At the same time, the contents of the reload
register is stored in the counter, and count is continued.
Timer Bi does not have a pulse output function or a gate function like
timer A.
When data is written to timer Bi halted, it is written to the reload register
and the counter. When data is written to timer Bi which is busy, the
data is written to the reload register, but not to the counter. The counter
is reloaded with new data from the reload register at the next reload
time and continues counting. The contents of the counter can be
read at any time.
Data bus (odd)
Data bus (even)
(Low-order 8 bits)
(High-order 8 bits)
Reload register (16)
TBiIN
(i = 0 – 2)
Polarity selection
and edge pulse
generator
Notes 1. Clock source of clock timer; Only timer B2 can select it (refer to Fig. 65)
2. Only timer B1 can select it (internal connect mode)
Figure 31 shows the bit configuration of the timer Bi mode register
during the event counter mode. In the event counter mode, the bit 0
of the timer Bi mode register must be “1” and bit 1 must be “0”.
The input signal from the TBi
IN pin is counted when the count start
flag is “1”, and counting is stopped when it is “0”. Counting is performed
at the fall of the input signal when bits 2 and 3 are “0” and at the rise
of the input signal when bit 3 is “0” and bit 2 is “1”.
When bit 3 is “1” and bit 2 is “0”, counting is performed at the rise and
fall of the input signal.
When the sub-clock (32 kHz) oscillation circuit is used and others,
and the event counter mode is selected, timer B2 functions as the
clock timer and the original functions as timer B2 in the event counter
mode are lost. For details, refer to “(4) Clock timer”.
When the internal connect mode which connects timer B1 to timer
B2 is selected, the original function as timer B1 in the event counter
mode is lost. For details, refer to “(5) Internal connect mode”.
Data write, data read, and interrupt generation are performed in the
same way as for the timer mode.
(3) Pulse period measurement/pulse width
measurement mode [10]
Figure 32 shows the bit configuration of the timer Bi mode register
during the pulse period measurement/pulse width measurement
mode.
In the pulse period measurement/pulse width measurement mode,
bit 0 must be “0” and bit 1 must be “1”. Bits 6 and 7 are used to select
the clock source. The selected clock is counted when the count start
flag is “1”, and counting stops when it is “0”.
The pulse period measurement mode is selected when bit 3 is “0”. In
the pulse period measurement mode, the selected clock is counted
during the interval starting at the fall of the input signal from the TBi
pin to the next fall or at the rise of the input signal to the next rise.
And then, the result is stored in the reload register. In this case, the
reload register acts as a buffer register.
When bit 2 is “0”, the clock is counted from the fall of the input signal
to the next fall. When bit 2 is “1”, the clock is counted from the rise of
the input signal to the next rise.
In the case of counting from the fall of the input signal to the next fall,
counting is performed as follows. As shown in Figure 33, when the
fall of the input signal from TBi
counter is transferred to the reload register. Next the counter is cleared
and count is started from the next clock. When the fall of the next
input signal is detected, the contents of the counter is transferred to
the reload register once more, the counter is cleared, and counting is
started. The period from the fall of the input signal to the next fall is
measured in this way.
After the contents of the counter is transferred to the reload register,
an interrupt request signal is generated and the interrupt request bit
of the timer Bi interrupt control register is set. However, no interrupt
request signal is generated when the contents of the counter is
transferred first time to the reload register after the count start flag is
set to “1”.
IN pin is detected, the contents of the
When bit 3 is “1”, the pulse width measurement mode is selected.
The pulse width measurement mode is similar to the pulse period
measurement mode except that the clock is counted from the fall of
the TBi
IN pin input signal to the next rise or from the rise of the input
0 : Always “0” in timer mode
(timer B0)
✕ : Not used in timer mode
(timers B1, B2)
✕ : Not used in timer mode
Clock source selection bit
0 0 : Select f
0 1 : Select f16
1 0 : Select f
1 1 : Select f
2
64
512
Fig. 30 Timer Bi mode register bit configuration during timer mode
Timer B0 mode register 5B
76543210
✕✕✕
IN
1
00
Timer B1 mode register 5C
Timer B2 mode register 5D
0 1 : Always “01” in event counter
mode
0 0 : Count at the falling edge of input
signal
0 1 : Count at the rising edge of input
signal
1 0 : Count at the both falling edge and
rising edge of input signal
0 : Always “0” in event counter mode
(timer B0)
✕ : Not used in event counter mode
(timers B1, B2)
✕ ✕ ✕ : Not used in event counter mode
Fig. 31 Timer Bi mode register bit configuration during event counter
mode
Addresses
16
16
16
Addresses
16
16
16
27
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
When timer Bi is read, the contents of the reload register is read.
Note that, in this mode, the interval from the fall of the TBiIN pin input
signal to the next rise or from the rise to the next fall must be at least
two cycles of the timer count source.
Timer Bi overflow flag which is bit 5 of the timer Bi mode register is
set to “1” when the timer Bi counter reaches 0000
16. This flag is cleared
by writing to the corresponding timer Bi mode register. By reading
this flag, the reason why the interrupt request signal is generated,
which is the completion of measurement or the counter overflow, can
be detected. An interrupt request signal may occur because the
counter value is particularly undefined just after counting starts.
Accordingly, make sure to detect the occurrence reason of an interrupt
request signal with the timer Bi overflow flag. This flag is “1” at reset.
When using timer B2 as the clock timer and using timer B1 in the
internal connect mode, functions in this mode are lost.
Fig. 32 Timer Bi mode register bit configuration during pulse period
measurement/pulse width measurement mode
Selected clock
source f
Reload register←Counter
Counter←0
Count start flag
Interrupt request signal
i
TBiIN
Fig. 33 Pulse period measurement mode operation (example of measuring the interval from the falling edge to next falling one)
28
PRELIMINARY
Notice: This is not a final specification.
Some parametric limits are subject to change.
Selected
clock source fi
Reload register←Counter
Counter←0
Count start
flag
TBi
MITSUBISHI MICROCOMPUTERS
M37736MHBXXXGP
SINGLE-CHIP 16-BIT CMOS MICROCOMPUTER
IN
Interrupt
request signal
Fig. 34 Pulse width measurement mode operation
(4) Clock timer
When the port-XC selection bit of the oscillation circuit control register
0 (refer to Figure 63) is set to “1” to make the sub-clock oscillation
circuit active, timer B2 can function as the clock timer, which uses
clock f
C32 as the clock source. Clock fC32 is the sub clock (32 kHz)
divided by 32.
Additionally, when the port-Xc selection bit is set to “0” not to use the
sub-clock and the timer B2 clock source selection bit of the port
function control register (refer to Figure 11) is set to “1”, timer B2 can
functions as the clock timer, which uses clock fc
Clock fc
32 is the main clock divided by 32.
Figure 35 shows the timer B2 mode register bit configuration when
timer B2 is used as the clock timer. As shown in Figure 35, the event
counter mode must be selected for timer B2.
For how to use the clock timer, refer to the section on clock generating
circuit.
32 as the clock source.
(5) Internal connect mode
When the timer B1 internal connect selection bit of the port function
control register (refer to Figure 11) is set to “1”, timer B1 uses the
timer B2’s overflow signal as the clock source and timer B1 is internally
connected to timer B2 (cascade connection).
The internal connect mode makes timers B1 and B2 function as 16 +
16 bit-timer with the timer B2’s clock source.
Figure 35 shows the timer B1 mode register bit configuration when
using timer B1 in the internal connect mode. Set timer B1 in the event
counter mode as shown in Figure 35.
02345671
✕✕✕✕
Fig. 35 Timer B1 mode register bit configuration when timer B1 is
used in the internal connect mode and timer B2 mode register
bit configuration when timer B2 is used as clock timer