F MC-16LX MB90385 Series Hardware Manual: 16-Bit Microcontroller
F MC-16LX MB90385 Series Hardware Manual: 16-Bit Microcontroller
CONTROLLER MANUAL
F2MC-16LX
16-BIT MICROCONTROLLER
MB90385 Series
HARDWARE MANUAL
F2MC-16LX
16-BIT MICROCONTROLLER
MB90385 Series
HARDWARE MANUAL
FUJITSU LIMITED
PREFACE
• The contents of this document are subject to change without notice. Customers are advised to consult with
FUJITSU sales representatives before ordering.
• The information and circuit diagrams in this document are presented as examples of semiconductor device
applications, and are not intended to be incorporated in devices for actual use. Also, FUJITSU is unable to assume
responsibility for infringement of any patent rights or other rights of third parties arising from the use of this
information or circuit diagrams.
• The products described in this document are designed, developed and manufactured as contemplated for general
use, including without limitation, ordinary industrial use, general office use, personal use, and household use, but
are not designed, developed and manufactured as contemplated (1) for use accompanying fatal risks or dangers
that, unless extremely high safety is secured, could have a serious effect to the public, and could lead directly to
death, personal injury, severe physical damage or other loss (i.e., nuclear reaction control in nuclear facility,
aircraft flight control, air traffic control, mass transport control, medical life support system, missile launch control
in weapon system), or (2) for use requiring extremely high reliability (i.e., submersible repeater and artificial
satellite).
Please note that Fujitsu will not be liable against you and/or any third party for any claims or damages arising in
connection with above-mentioned uses of the products.
• Any semiconductor devices have an inherent chance of failure. You must protect against injury, damage or loss
from such failures by incorporating safety design measures into your facility and equipment such as redundancy,
fire protection, and prevention of over-current levels and other abnormal operating conditions.
• If any products described in this document represent goods or technologies subject to certain restrictions on export
under the Foreign Exchange and Foreign Trade Law of Japan, the prior authorization by Japanese government will
be required for export of those products from Japan.
i
HOW TO READ THIS MANUAL
■ Page Structure
Each section content can be read easily because it is mentioned within one page or double spread.
A summary under the title in each section outlines the section contents.
The top-level title at the top of a double spread indicates where you are reading without returning to the table
of contents or the chapter title page.
■ How to Find Information
To find information in each section, use the following index in addition to general table of contents and
index.
● Register index
This index helps you find the page containing the explanation of the corresponding register from a register
name or related resource name. You can also check the mapped addresses on memory and reset values.
By writing 1 to the sleep bit of the standby control register (STBC: SLP), .......
Set data
Abbreviation of bit name
Abbreviation of register name
If an interrupt is enabled (CCR: I = 1), an interrupt can be accepted.
Current state
Abbreviation of bit name
Abbreviation of register name
ii
● Representation of dual-purpose pin
P41/SCK1 pin
Some pins are dual-purpose pins which functions can be switched by the setting of program. A slosh (/)
separates and represents the names corresponding to the functions of the dual-purpose pins.
■ Register Representation
The F2MC-16LX family is a CPU with a 16-bit bus width. The bit position of each control register and data
register is given in 16 bits.
In 16-bit registers, bits 15 to 8 are allocated to odd addresses and bits 7 to 0 even addresses.
Even in 8-bit registers, the position of bits allocated to odd addresses is given in bits 15 to 8.
The F2MC-16LX family enables access to 8-bit data in order to increase the efficiency of programs. So, if
odd-address registers are accessed in 8 bits, bits 7 to 0 in data correspond to bits 15 to 8 in the manual
representation.
iii
iv
CONTENTS
v
CHAPTER 6 WATCHDOG TIMER ................................................................................ 203
6.1 Overview of Watchdog Timer ........................................................................................................... 204
6.2 Configuration of Watchdog Timer ..................................................................................................... 205
6.3 Watchdog Timer Registers ............................................................................................................... 207
6.4 Explanation of Operation of Watchdog Timer ................................................................................... 210
6.5 Precautions when Using Watchdog Timer ........................................................................................ 213
6.6 Program Examples of Watchdog Timer ........................................................................................... 214
vi
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE .................................. 317
11.1 Overview of Delayed Interrupt Generation Module ........................................................................... 318
11.2 Block Diagram of Delayed Interrupt Generation Module .................................................................. 319
11.3 Configuration of Delayed Interrupt Generation Module .................................................................... 320
11.4 Explanation of Operation of Delayed Interrupt Generation Module .................................................. 322
11.5 Precautions when Using Delayed Interrupt Generation Module ....................................................... 323
11.6 Program Example of Delayed Interrupt Generation Module ............................................................. 324
vii
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION ................................. 503
16.1 Overview of Address Match Detection Function ............................................................................... 504
16.2 Block Diagram of Address Match Detection Function ...................................................................... 505
16.3 Configuration of Address Match Detection Function ........................................................................ 506
16.4 Explanation of Operation of Address Match Detection Function ...................................................... 511
16.5 Program Example of Address Match Detection Function ................................................................. 517
viii
CHAPTER 1
OVERVIEW
1
CHAPTER 1 OVERVIEW
● Clock
• Built-in PLL clock multiplying circuit
• Machine clock (PLL clock) selectable from 1/2 frequency of oscillation clock or 1 to 4-multiplied
oscillation clock (4 MHz to 16 MHz when oscillation clock is 4 MHz)
• Subclock operation (8.192 kHz) (MB90387, MB90F387)
• Minimum instruction execution time: 62.5 ns (4-MHz oscillation clock, 4-multiplied PLL clock)
2
CHAPTER 1 OVERVIEW
● Process
• CMOS Technology
● I/O ports
• General-purpose I/O ports (CMOS output): 34 ports (for M90387 or M90F387) (included 4 output ports
for high current)
note: 36 ports (for MB90387 or MB90F387S) on condition of unusing sub-clock.
● Timers
• Timebase timer, watch timer, watchdog timer: 1 channel
• 8/16-bit PPG timer: 8 bits × 4 channels or 16 bits × 2 channels
• 16-bit reload timer: 2 channels
• 16-bit I/O timer
- 16-bit free-run timer: 1 channel
- 16-bit input capture (ICU): 4 channels
By detecting the edge of the pin input, the count value of the 16-bit free-run timer is latched to generate an
interrupt request.
3
CHAPTER 1 OVERVIEW
4
CHAPTER 1 OVERVIEW
The MB90385 series is available in four types. This section provides the product lineup,
CPU, and resources.
ROM Size -- 64 KB
RAM Size 6 KB 2 KB
Clock dual system products MB90F387: dual system MB90387: dual system
products products
MB90F387S: single1 MB90387S: single1 system
system product product
Process CMOS
*: Setting of DIP Switch (S2) when using emulation pod (MB2145-507). For details, refer to the MB2145-507 Hardware
Manual (Section 2.7 Emulator-specific Power Supply).
5
CHAPTER 1 OVERVIEW
Minimum instruction execution time: 62.5 ns (at 16-MHz machine clock frequency)
Interrupt processing time: 1.5 µs (at 16-MHz machine clock frequency)
Low-power consumption Sleep mode, timer mode, timebase timer mode, stop mode, CPU intermittent operation
(standby) modes mode
I/O Ports General-purpose I/O ports (CMOS output): 34 ports (36 ports *)
included 4 output ports for high cyrrent (P14 to P17)
Module for generating delayed Interrupt generation module for switching task
interrupt generating module Used for Real-time OS
6
CHAPTER 1 OVERVIEW
*:MB90387S, MB90F387S
7
CHAPTER 1 OVERVIEW
X0,X1
CPU
RST Clock control circuit F2MC-16LX core
X0A,X1A
Watch timer
Input capture
(4 ch) IN0 to IN3
RAM
Internal data bus
RX
Prescaler CAN TX
SOT1
SCK1 UART1
SIN1 DTP/external interrupt INT4 to INT7
AVcc
AVss 16-bit reload timer TIN0, TIN1
8-/10-bit
A/D converter (2 ch) TOT0, TOT1
AN0 to AN7
(8 ch)
AVR
ADTG
8
CHAPTER 1 OVERVIEW
P42/ SOT1
P41/ SCK1
P40/ SIN1
X1A/ P36*
X0A/ P35*
P44/ RX
P43/ TX
AV SS
P33
P32
P31
P30
48
47
46
45
44
43
42
41
40
39
38
37
AV CC 1 36 P17/ PPG3
AVR 2 35 P16/ PPG2
P50/ AN 0 3 34 P15/ PPG1
P51/ AN 1 4 33 P14/ PPG0
P52/ AN 2 5 32 P13/ IN3
P53/ AN 3 6 TOP VIEW 31 P12/ IN2
P54/ AN 4 7 30 P11/ IN1
P55/ AN 5 8 29 P10/ IN0
P56/ AN 6 9 28 X1
P57/ AN 7 10 27 X0
P37/ ADTG 11 26 C
P20/ TINO 12 25 V SS
13
14
15
16
17
18
19
20
21
22
23
24
P24/ INT4
P25/ INT5
P26/ INT6
P27/ INT7
P21/ TOT0
P23/ TOT1
MD2
MD1
MD0
P22/ TIN1
V CC
RST
9
CHAPTER 1 OVERVIEW
10
CHAPTER 1 OVERVIEW
Package width ×
7 × 7 mm
package length
Weight 0.17 g
Code
(FPT-48P-M26) P-LFQFP48-7×7-0.50
(Reference)
48-pin plastic LQFP Note: Pins width and pins thickness include plating thickness.
(FPT-48P-M26)
9.00±0.20(.354±.008)SQ
7.00±0.10(.276±.004)SQ 0.145±0.055
(.006±.002)
36 25
37 24
48 13
"A" 0.10±0.10
0~8 û (.004±.004)
(Stand off)
LEAD No. 1 12
C
2001 FUJITSU LIMITED F48040S-c-1-1 Dimensions in mm (inches).
11
CHAPTER 1 OVERVIEW
This section describes the I/O pins and their functions of the MB90385 series.
■ Pin Description
Pin No.
Circuit
Pin Name Function
Type
M26
12
CHAPTER 1 OVERVIEW
Pin No.
Circuit
Pin Name Function
Type
M26
13
CHAPTER 1 OVERVIEW
Pin No.
Circuit
Pin Name Function
Type
M26
14
CHAPTER 1 OVERVIEW
■ I/O Circuit
X0A
Standby mode control signal
R
R
Hysteresis input
C • Hysteresis input
R
Hysteresis input
Digital output
N ch
R Vss
Hysteresis input
Digital output
N ch
R Vss
Hysteresis input
15
CHAPTER 1 OVERVIEW
Vss
16
CHAPTER 2
HANDLING DEVICES
17
CHAPTER 2 HANDLING DEVICES
This section describes the precautions against the power supply voltage of the device
and processing of pin.
X0
Open X1
MB90385 series
18
CHAPTER 2 HANDLING DEVICES
● Power pins
• When plural VCC pins and VSS pins are provided, pins designed to be at the same electric potential are
internally connected to the device to prevent malfunctions such as latch-up. However, always connect
all same electric potential pins to power supply and ground outside the device to prevent decrease of
unnecessary radiation, the malfunction of the strobe signal due to a rise of ground level, and follow the
standards of total output current.
• The power pins should be connected to VCC and VSS of the MB90385 series device at the lowest
possible impedance from the current supply source.
• It is best to connect approximately 0.1µF capacitor between VCC and VSS as a bypass capacitor near the
pins of the MB90385 series device.
● Precautions at power on
To prevent a malfunction of the internal step-down circuit, the voltage rise time at power-on should be
50 µs or more (between 0.2 V and 2.7 V).
19
CHAPTER 2 HANDLING DEVICES
20
CHAPTER 3
CPU
21
CHAPTER 3 CPU
The memory space of the F2MC-16LX is 16 MB and is allocated to I/O, programs, and
data. Part of the memory space is used for specific uses such as the expansion
intelligent I/O service (EI2OS) descriptors, the general-purpose registers, and the vector
tables.
■ Memory Space
I/O, programs and data are all allocated somewhere in the 16-MB memory space of the F2MC-16LX CPU.
The CPU can indicate their addresses in the 24-bit address bus to access each resource.
Figure 3.1-1 "Example of Relationships between F2MC-16LX System and Memory Map" shows an
example of the relationships between the F2MC-16LX and the memory map.
Figure 3.1-1 Example of Relationships between F2MC-16LX System and Memory Map
F2MC-16LX Device
FE0000 H
ROM area
(The same data as FF bank)
FF0000 H*2
Program Program area
FFFC00 H ROM area
Vector table area
FFFFFF H
22
CHAPTER 3 CPU
■ ROM Area
● Expanded intelligent I/O service (EI2OS) descriptor area (address: "000100H" to "00017FH")
• This area holds the transfer mode, I/O address, transfer count, and buffer address.
• This area is allocated to part of the RAM area, and can also be used as ordinary RAM.
■ I/O Area
23
CHAPTER 3 CPU
In the MB90385 series, the single-chip mode can be set as memory access modes.
When ROM mirror function is enabled When ROM mirror function is disabled
003900H
Extend I/O area Extend I/O area
004000H
ROM area
(image of FF bank)
010000H
FE0000H
ROM area * ROM area *
FF0000H
ROM area ROM area
FFFFFFH
Device Adress#1
MB90V495G 002000 H
MB90F387/S 000900 H
MB90387/S 000900 H
24
CHAPTER 3 CPU
25
CHAPTER 3 CPU
■ Memory Map
Figure 3.1-3 "Memory Map for MB90385 Series" shows the memory map for the MB90385 series.
FE0000H FE0000H
3 3
ROM ROM
FF0000 H FF0000 H
ROM ROM
FFFFFFH FFFFFFH
26
CHAPTER 3 CPU
3.1.3 Addressing
FD0000 H
FDFFFF H FD bank
FE0000 H
FE bank
FEFFFF H
FF0000 H FF bank
FFFFFF H FFFFFF H
123456H 123456 H
27
CHAPTER 3 CPU
JMPP 123456H
MOV A,@RL1+7
Upper 8 bits ignored
Old AL XXXX RL1 FFFF06F9H
+7
28
CHAPTER 3 CPU
The bank addressing is a type of addressing each of 254 64-KB banks into which the 16-
MB memory space is divided, using the bank register, and the lower 16 bits by an
instruction.
Bank register has the following five types depending on the use.
• Program bank register (PCB)
• Data bank register (DTB)
• User stack bank register (USB)
• System stack bank register (SSB)
• Additional bank register (ADB)
Table 3.1-1 Access Space for Each Bank Register and Major Use of Access Space
Data bank register Data (DT) Stores data that can be read/written
(DTB) space and can access resource control 00H
registers and data registers.
Figure 3.1-7 "Example of Bank Addressing" shows the relationships between the memory space divided
into banks and each register.
29
CHAPTER 3 CPU
000000H
070000H
System stack space 07H : SSB (System stack bank register)
07FFFF H
0B0000 H
Data space 0BH : DTB (Data bank register)
Physical address
0BFFFF H
0D0000 H
User stack space 0DH : USB (User stack bank register)
0DFFFF H
0F0000 H
Additional space 0FH : ADB (Additional bank register)
0FFFFF H
FF0000 H
Program space FFH : PCB (Program bank register)
FFFFFF H
Data space Addressing with @RW0, @RW1, @RW4, @RW5, @A, addr16, and dir
For details of the prefix codes, see Section 3.4 "Prefix Codes".
30
CHAPTER 3 CPU
Multi-byte data is written to memory in sequence starting from the low address. For 32-
bit length data, the lower 16 bits are written first, and then the higher 16 bits are written.
If a reset signal is output immediately after the lower 16 bits is written, the higher data
may not be written.
Low address
Address n 00010100B
n+1 11111111B
n+2 11001100B
n+3 01010101B
MSB LSB
High address 01010101B 11001100B 11111111B 00010100B
MSB: Most significant bit
LSB: Least significant bit
JMPP 123456H
Address n 63H
n+1 56H
n+2 34H
n+3 12H
High address
31
CHAPTER 3 CPU
PUSHW RW1,RW3
Low address PUSHW RW1, RW3
(35A4H) (6DF0H)
A4H
35H
F0H
6DH
SP
High address
RW1: 35A4H
RW3: 6DF0H
*: State of stack after execution of PUSHW instruction
Low address
AL before execution ?? ??
800000H 23H
: MOVW A, 080FFFFH
:
AL after execution 23H 01H
80FFFFH 01H
High address
32
CHAPTER 3 CPU
AH AL : Accumulator (A)
The accumulator is two 16-bit registers, and is used to store operation results.
It can also be used as one 32-bit register.
8 bits
16 bits
32 bits
33
CHAPTER 3 CPU
− : Unused
X : Undefined
Program counter (PC) Value of reset vector (data at "FFFFDCH" and "FFFFDH")
Note: The above reset values are the reset values for the device. The reset values for the ICE (such as emulator)
are different from those of the device.
34
CHAPTER 3 CPU
The F2MC-16LX family has two types of registers: dedicated registers in the CPU and
general-purpose register in the internal RAM.
Processor status
Program counter
Direct page register
Program bank register
Data bank register
User stack bank register
System stack bank register
Additional data bank register
35
CHAPTER 3 CPU
An accumulator (A) consists of two 16-bit length operation registers (AH and AL) used
for temporary storage of the operation result or data.
Accumulator can be used as a 32-, 16-, or 8-bit register. Various operations can be
performed between the register and memory or the other register, or between the AH
register and the AL register.
■ Accumulator (A)
32 bits
AH AL
32-bit data transfer
AH AL
16-bit data transfer Data saving
Data transfer
AH AL
8-bit data transfer Data saving
36
CHAPTER 3 CPU
Figure 3.2-4 Example of 8-bit Data Transfer to Accumulator (A) (Data Saving)
MOVW A,3000H (Instruction that stores the data at address "3000H" in the AL register.)
Memory space
MSB LSB
AH AL
Before execution XXXXH 2456H B53001 H 77H 88H B53000 H
DTB B5H
X : Undefined
After execution 2456H 7788H MSB : Most Significant Bit
LSB : Least Significant Bit
DTB : Data bank register
Figure 3.2-5 Example of 8-bit Data Transfer to Accumulator (A) (Data Saving, Zero-extended)
DTB B5H
X : Undefined
After
2456H 0088H MSB : Most significant bit
execution
LSB : Least significant bit
DTB : Data bank register
37
CHAPTER 3 CPU
Figure 3.2-6 Example of 16-bit Data Transfer to Accumulator (A) (Data Saving)
(Instruction that performs word length read using the result obtained
MOVW A,@RW1+6 by adding the 8-bit length offset to data of RW1 as an address, and then
stores the read value in the A register.)
Memory space
MSB LSB
AH AL
Before
execution XXXXH 1234H
RW1 15H 38H
DTB A6H +6
After A6153FH 2BH 52H A6153EH
execution 1234H 2B52H
A61541H 8FH 74H A61540H
X : Undefined
MSB : Most significant bit
LSB : Least significant bit
DTB : Data bank register
Figure 3.2-7 Example of 32-bit Data Transfer to Accumulator (A) (Register Indirect)
(Instruction that performs long-word length read using the result obtained
MOVL A,@RW1+6 by adding the 8-bit length offset to data of RW1 as an address, and then
stores the read value in the A register.)
MSB Memory space LSB
Before AH AL
execution XXXXH XXXXH
RW1 15H 38H
DTB A6H
+6
After A6153FH 2BH 52H A6153EH
execution 8F74H 2B52H
A61541H 8FH 74H A61540H
X : Undefined
MSB : Most significant bit
LSB : Least significant bit
DTB : Data bank register
38
CHAPTER 3 CPU
The stack pointers include a user stack pointer (USP) and a system stack pointer (SSP).
Both these pointers indicate the address where saved data and return data are stored
when the PUSH instruction, the POP instruction, and the subroutine is executed.
• The higher 8 bits of the stack address are set by the user stack bank register (USB) or
the system stack bank register (SSB).
• When the stack flag (PS: CCR: S) is 0, the USP and USB register are enabled. When
the stack flag is 1, the SSP and SSB register are enabled.
■ Stack Selection
For the F2MC-16LX family, two types of stack pointer can be used: system stack, and user stack.
The addresses of the stack pointers are set by the stack flag of the condition code register (CCR: S) as
shown in Table 3.2-2 "Stack Address Specification".
Stack Address
S Flag
Higher 8 Bits Lower 16 Bits
*: Reset value
Since the stack flag (CCR: S) is set to 1 by a reset, the system stack pointer is used after reset.
Ordinarily, the system stack pointer is used in processing the stack at the interrupt routine, and the user
stack pointer is used in processing the stack at other than interrupt routine. When it is necessary to divide
the stack space, use only the system stack pointer.
Note: When an interrupt is accepted, the stack flag (CCR: S) is set and the system stack pointer is always used.
Figure 3.2-8 "Stack Operation Instructions and Stack Pointers" shows an example of the stack operation
using the system stack.
39
CHAPTER 3 CPU
Before AL A624H USB C6H USP F328H 561233 H XXH XXH 561232 H
Execution
S flag 1 SSB 56H SSP 1234H
Notes: • Use even addresses for setting value to the stack pointer. Setting an odd address divides the word
access into two accesses, decreasing the efficiency.
• The reset values of the USP and SSP registers are undefined.
40
CHAPTER 3 CPU
■ Stack Area
000000 H
I/O area
0000C0 H
000100 H
000180 H General-
purpose
Stack area
register bank
000380 H
000900 H
~ ~
~ ~
*1
FF0000 H
ROM area
Vector table FFFC00H
(reset, interrupt vector
call instruction) FFFFFFH
Notes: • As a general rule, even addresses should be set in the stack pointers (SSP and USP).
• The system stack area, user stack area, and data area should not overlap.
41
CHAPTER 3 CPU
The processor status (PS) consists of the bits controlling CPU and various bits
indicating the CPU status. The PS consists of the following three registers.
• Interrupt level mask register (ILM)
• Register bank pointer (RP)
• Condition code register (CCR)
ILM RP CCR
bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0
PS ILM2 ILM1 ILM0 B4 B3 B2 B1 B0 I S T N Z V C
Reset value 0 0 0 0 0 0 0 0 0 1 X X X X X
: Unused
X : Undefined
42
CHAPTER 3 CPU
The condition code register (PS: CCR) is an 8-bit register consisting of bits indicating
the result of instruction execution, and the bits enabling or disabling the interrupt
request.
ILM RP CCR
43
CHAPTER 3 CPU
For the state of the condition code register (CCR) at instruction execution, refer to the Programming
Manual.
44
CHAPTER 3 CPU
The register bank pointer (RP) is a 5-bit register that indicates the starting address of
the currently used general-purpose register bank.
ILM RP CCR
• The register bank pointer (RP) can take the values from "00H" to "1FH" so that the starting address of
the register bank can be set within the range of "000180H" to "00037FH".
• The assembler instruction can use the 8-bit immediate value transfer instruction that is transferred to
The register bank pointer (RP), but only the lower 5 bits of that data is actually used.
• The reset value of the register bank pointer (RP) is set to "00H" after a reset.
45
CHAPTER 3 CPU
The interrupt level mask register (ILM) is a 3-bit register indicating the interrupt level
accepted by the CPU.
ILM RP CCR
The interrupt level mask register (ILM) indicates the level of an interrupt that the CPU is accepting for
comparison with the values of the interrupt level setting bits (ICR: IL2 to IL0) set according to interrupt
requests from each resource. The CPU performs interrupt processing only when an interrupt with a lower
value (interrupt level) than that indicated by the interrupt level mask register (ILM) is requested with an
interrupt enabled (CCR: I = 1).
• When an interrupt is accepted, its interrupt level value is set in the interrupt level mask register (ILM).
Thereafter, an interrupt with a level value lower than the set level value is not accepted.
• At a reset, the interrupt level mask register (ILM) is always set to 0s to enter the interrupt-disabled
(highest interrupt level) state.
• The assembler instruction can use the 8-bit immediate value transfer instruction that is transferred to the
interrupt level mask register (ILM), but only the lower 3 bits of that data is actually used.
Table 3.2-3 Interrupt Level Mask Register (ILM) and Interrupt Level (High/Low)
0 0 0 0
0 1 0 2
0 1 1 3
1 0 0 4
1 0 1 5
1 1 0 6
1 1 1 7 Low
46
CHAPTER 3 CPU
The program counter (PC) is a 16-bit counter indicating the lower 16 bits of the address
for the next instruction code to be executed by the CPU.
Next instruction to
FEABCDH be executed
Note: Neither the program counter (PC) nor The program bank register (PCB) can be rewritten directly by a
program (such as MOV PC and #FF).
47
CHAPTER 3 CPU
The direct page register (DPR) sets bit 8 to bit 15 (addr 15 to addr 8) for the 8 bits of the
low address directly specified using the operand when executing the instruction by the
abbreviated direct addressing.
Figure 3.2-17 "Setting of Direct Page Register (DPR) and Data Access Example" shows the setting of
direct page register (DPR) and an example of data access.
Figure 3.2-17 Setting of Direct Page Register (DPR) and Data Access Example
48
CHAPTER 3 CPU
The bank register sets the MSB 8 bit of the 24-bit address using bank addressing and
consists of the following five registers:
• Program bank register (PCB)
• Data bank register (DTB)
• User stack bank register (USB)
• System stack bank register (SSB)
• Additional bank register (ADB)
Each of the above registers indicate the memory bank to which the program, data, user
stack, system stack, or additional is allocated.
For the operation of each bank register, see Section 3.1 "Memory Space".
49
CHAPTER 3 CPU
Figure 3.3-1 Allocation and Configuration of General-Purpose Register Banks in Memory Space
Internal RAM
: Byte Byte
000180 H Register bank 0
address address
000190 H
Register bank 1 02C1H
0001A0H 02C0H RW0
Register bank 2 RL0
0001B0H 02C2H RW1 02C3H
:
0002B0H Register bank 19 02C4H RW2 02C5H
0002C0H RL1
Register bank 20 02C6H RW3 02C7H
0002D0H
0002E0H Register bank 21 02C8H R0 R1 02C9H RW4
RL2
: 02CAH R2 R3 02CBH RW5
: 02CCH R4 R5 02CDH RW6
RL3
: RP 14H 02CEH R6 R7 02CFH RW7
:
: LSB MSB
16bit
000360H
Register bank 30
000370H
Register bank 31
Conversion expression [000180H + RP × 10H]
000380H
R0 to R7 : Byte register
: RW0 to RW7 : Word register
RL0 to RL3 : Long-word register
MSB : Most significant bit
LSB : Least significant bit
50
CHAPTER 3 CPU
■ Register Bank
The register bank can be used as a general-purpose register (byte registers R0 to R7, word registers RW0 to
RW7, and long-word registers RL0 to RL3) to perform various operations or to serve as a pointer. The
long- word register can also be used as a linear addressing to directly access the entire memory space.
In the same way as ordinary RAM, the value in the general-purpose register is unchanged by a reset,
meaning that the state before the reset is held. However, at power-on, the value is undefined.
Table 3.3-1 "Typical Function of the General-purpose Register" shows the typical function of the general-
purpose register.
Used as addressing
Used as operands for various instructions
RW0 to RW7
Note:
RW0 can also be used as the string instruction counter.
51
CHAPTER 3 CPU
When prefix code is inserted by an instruction, the operation of the instruction can be
changed partially. The prefix code has the following three types:
• Bank select prefix (PCB, DTB, ADB, and SPB)
• Common register bank prefix (CMR)
• Flag change inhibit prefix (NCC)
■ Prefix Code
52
CHAPTER 3 CPU
When the bank select prefix (PCB, DTB, ADB, SPB) codes precede an instruction, any
memory space accessed by the instruction can be set, regardless of the addressing
modes.
The use of the bank select prefix (PCB, DTB, ADB, SPB) codes causes some instructions to perform
exceptional operations as explained below.
Table 3.4-2 "Instructions Unaffected by Bank Select Prefix" shows the instructions not affected by the bank
select prefix code, and Table 3.4-3 "Instructions Requiring Precaution When Using Bank Select Prefix"
shows the instructions requiring precaution when using the bank select prefix.
String instruction MOVS MOVSW The bank register specified for the operand
SCEQ SCWEQ is used irrespective of the presence or
FILS FILSW absence of the bank select prefix code.
Stack instruction PUSHW POPW Irrespective of the presence or absence of
the bank select prefix code, the user stack
bank (USB) is used when the S flag is 0; and
the system stack bank (SSB) is used when
the S flag is 1
53
CHAPTER 3 CPU
I/O Access MOV A,io MOVX A, io The I/O space ("000000H" to "0000FFH") is
instruction accessed irrespective of the presence or
MOVW A,io
absence of the bank select prefix code.
MOV io,A MOVW io,A
Table 3.4-3 Instructions Requiring Precaution When Using Bank Select Prefix
Flag change AND CCR,#imm8 The bank select prefix code affects up to the next
instruction OR CCR,#imm8 instruction.
ILM setting MOV ILM,#imm8 The bank select prefix code affects up to the next
instruction instruction.
PS Return instruction POPW PS Do not add the bank select prefix code to the PS
return instruction.
54
CHAPTER 3 CPU
When the common register bank prefix (CMR) code precedes an instruction for
accessing a general-purpose register, the general-purpose register to be accessed by
the instruction can be changed to a common bank (register bank selected when the
register bank pointer (RP) is 0) at "000180H" to "00018FH", regardless of the current
value of the register bank pointer (RP).
Table 3.4-4 Instructions Requiring Precaution When Using Bank Select Prefix (CMR)
String instruction MOVS MOVSW Do not add the CMR code to string instructions.
SCEQ SCWEQ
FILS FILSW
Flag change AND CCR,#imm8 The CMR code affects up to the next instruction.
instruction OR CCR,#imm8
PS return instruction POPW PS The CMR code affects up to the next instruction.
ILM setting MOV ILM,#imm8 The CMR code affects up to the next instruction.
instruction
55
CHAPTER 3 CPU
When the flag change inhibit prefix (NCC) code precedes an instruction for changing
various flags of the condition code register (CCR), a flag change caused by instruction
execution can be inhibited.
Table 3.4-5 Instructions Requiring Precaution When Using Flag Change Inhibit Prefix (NCC)
String instruction MOVS MOVSW Do not the add the NCC code to the string
SCEQ SCWEQ instruction.
FILS FILSW
Interrupt instruction INT #vct8 INT9 The CCR changes by execution of an instruction
Interrupt return INT addr16 INTP addr24 statement, regardless of the presence or absence of
instruction RETI the NCC code.
56
CHAPTER 3 CPU
● Interrupt Inhibition
Even if generated, an interrupt request is not accepted during execution of a prefix code and interrupt
inhibit instruction. When other instructions are executed after execution of a prefix code and interrupt
inhibit instruction, an interrupt is processed.
. . . . . . . . . . . . . . . (a) . . .
57
CHAPTER 3 CPU
Prefix codes
58
CHAPTER 3 CPU
3.5 Interrupt
The F2MC-16LX family has four interrupt functions for suspending the current
processing to transfer control to a program which is defined separately at generation of
event.
• Hardware interrupt
• Software interrupt
• Interrupts by extended intelligent I/O service (EI22OS)
• Exception processing
● Hardware interrupt
This transits control to the interrupt processing program defined by user in response to the interrupt request
from resources.
● Software interrupt
This transfers control to the interrupt processing program defined by user by executing an instruction (such
as INT instruction) dedicated to the software interrupt.
● Exception processing
If an exception (execution of an undefined instruction) is detected among instructions, ordinary processing
is suspended to perform exception processing. This is equivalent to the above software interrupt instruction
INT10.
59
CHAPTER 3 CPU
■ Interrupt Operation
Figure 3.5-1 "General Flow of Interrupt Operation" shows interrupt start and return processing.
YES
Interrupt request
enabled?
Executing of Interrupt start/return processing
string family*
instruction NO
YES
Fetch and decode Start EI2OS?
next instruction EI2OS
NO
YES
Software
interrupt/
EI2OS processing
INT instruction? exception
processing
YES Return to
RETI instruction? processing Read interrupt vector,
due to interrupt update PC and PCB,
and branch to
NO Dedicated registers from interrupt processing
system stack return, and return
to previous processing which
Executing of is the one before calling
ordinary instruction interrupt processing
NO Repetitive execution
of string family* instruction
completed?
YES
Move pointer to next
instruction by updating PC
*: Interrupt determination is performed by the step during execution of string family instruction
60
CHAPTER 3 CPU
The F2MC-16LX family has vector tables corresponding to 256 types of interrupt factor.
■ Interrupt Vector
The interrupt vector tables referenced at interrupt processing are allocated to the most significant addresses
("FFFC00H" to "FFFFFFH") of the memory area. The interrupt vectors share the same area with the EI2OS,
exception processing, and hardware and software interrupts.
• Interrupts (INT0 to INT255) are used as software interrupts.
• At hardware interrupts, the interrupt vectors and interrupt control register (ICR) are fixed for each
resource.
Table 3.5-1 "List of Interrupt Vectors" shows the interrupt number and allocation of interrupt vector.
: : : : : : :
: : : : : : :
Reference: It is recommended to set the unused interrupt vectors to the addresses for exception processing.
61
CHAPTER 3 CPU
Table 3.5-2 Interrupt Factor, Interrupt Vector, and Interrupt Control Register (1/2)
62
CHAPTER 3 CPU
Table 3.5-2 Interrupt Factor, Interrupt Vector, and Interrupt Control Register (2/2)
63
CHAPTER 3 CPU
The interrupt control registers (ICR00 to ICR15) are allocated in he interrupt controller,
and correspond to all resources with interrupt functions. The registers control the
interrupt and extended intelligent I/O service (EI2OS).
64
CHAPTER 3 CPU
The interrupt control register (ICR) has the following four functions.
Some functions of the interrupt control register (ICR) are different at write and read.
• Setting of interrupt level of corresponding resource
• Selection of whether to perform normal interrupt or EI2OS for corresponding resource
• Selection of channel of EI2OS
• Display of end state of EI2OS
Note: Do not access the interrupt control register (ICR) using the read modify write instruction because it
causes a malfunction.
65
CHAPTER 3 CPU
At write
7 6 5 4 3 2 1 0
Reset value
00000111 B
W W W W R/W R/W R/W R/W
66
CHAPTER 3 CPU
At read
7 6 5 4 3 2 1 0
Reset value
XX000111 B
bit 3
ISE EI2OS enable bit
0 Starts normal interrupt processing at an interrupt
1 Starts EI2OS at an interrupt
bit 5 bit 4
S1 S0 EI2OS status bits
R/W : Read/Write 0 0 2
When EI OS in operation or not started
W : Write only 0 1 Stop state by end of counting
: Unused 1 0 Reserved
X : Undefined 1 1 Stop state by request from resource
: Reset value
67
CHAPTER 3 CPU
The interrupt control registers (ICR00 to ICR15) consist of the following bits with four
functions.
• Interrupt level setting bits (IL2 to IL0)
• EI2OS enable bit (ISE)
• EI2OS channel select bits (ICS3 to ICS0)
• EI2OS status bits (S1 and S0)
References: • The setting of the channel select bits (ICR: ICS3 to ICS0) is enabled only when starting the EI2OS.
When starting the EI2OS, set the EI2OS enable bit (ICR: ISE) to 1. When not starting the EI2OS, set
the bit to 0.
• The channel select bits (ICR: ICS3 to ICS0) are enabled only at write, and the EI2OS status bits (ICR:
S1, S0) are enabled only at read.
68
CHAPTER 3 CPU
Table 3.5-4 Relationship between Interrupt Level Setting Bits and Interrupt Levels
0 0 0 0 (Highest)
0 0 1
0 1 0
0 1 1
1 0 0
1 0 1
1 1 0 6 (Lowest)
1 1 1 7 (No interrupt)
Table 3.5-5 "Correspondence between EI2OS Channel Select Bits and Descriptor Addresses" shows the
correspondence between the EI2OS channel select bits and descriptor addresses.
Table 3.5-5 Correspondence between EI2OS Channel Select Bits and Descriptor
Addresses (1/2)
0 0 0 0 0 000100H
0 0 0 1 1 000108H
0 0 1 0 2 000110H
69
CHAPTER 3 CPU
Table 3.5-5 Correspondence between EI2OS Channel Select Bits and Descriptor
Addresses (2/2)
0 0 1 1 3 000118H
0 1 0 0 4 000120H
0 1 0 1 5 000128H
0 1 1 0 6 000130H
0 1 1 1 7 000138H
1 0 0 0 8 000140H
1 0 0 1 9 000148H
1 0 1 0 10 000150H
1 0 1 1 11 000158H
1 1 0 0 12 000160H
1 1 0 1 13 000168H
1 1 1 0 14 000170H
1 1 1 1 15 000178H
Table 3.5-6 "Relationships Between EI2OS Status Bits and EI2OS Status" shows the relationship between
the EI2OS status bits (ICR: S1, S0) and the EI2OS status.
Table 3.5-6 Relationships Between EI2OS Status Bits and EI2OS Status
S1 S0 EI2OS Status
70
CHAPTER 3 CPU
The hardware interrupt responds to the interrupt request from a resource, suspends the
current-executing program and transfers control to the interrupt processing program
defined by user.
The hardware interrupt corresponds to the EI2OS.
■ Hardware Interrupt
● Multiple interrupts
Multiple hardware interrupts can be started.
● EI2OS
When the EI2OS function ends, normal interrupt processing is performed. No multiple EI2OSs are started.
Other interrupt requests and EI2OS requests are held during EI2OS processing.
● External interrupt
The external interrupt (wake-up interrupt included) is accepted as a hardware interrupt via the resource
(interrupt request detector).
● Interrupt vector
The interrupt vector tables referenced during interrupt processing are allocated to "FFFC00H" to
"FFFFFFH" in the memory and shared with software interrupts.
71
CHAPTER 3 CPU
Interrupt controller Interrupt control register (ICR) Sets interrupt level and controls EI2OS
● Hardware interrupt inhibition during write to resource control register in I/O area
No hardware interrupt requests are accepted during write to resource control register. This prevents the
CPU from malfunctioning with respect to interrupt requests generated during rewrite related to interrupt
control registers of each resource.
Figure 3.5-5 "Hardware Interrupt Request During Write to the Resource Control Register" shows the
hardware interrupt operation during write to the resource control register.
Figure 3.5-5 Hardware Interrupt Request During Write to the Resource Control Register
72
CHAPTER 3 CPU
73
CHAPTER 3 CPU
The operation from the generation of hardware interrupt request to the completion of
interrupt processing is explained below.
74
CHAPTER 3 CPU
Internal bus
PS,PC . . PS I ILM
(7) Microcode IR
Check Comparator
(6)
F2MC-16LX CPU (5) (4)
(3)
Other resources
RAM
75
CHAPTER 3 CPU
The settings of the system stack area, resources, interrupt control registers (ICR) are
required for using the hardware interrupt.
Start
(5) Set ILM and I in PS (10) Execute interrupt return instruction (RETI)
Main program
(6)
Interrupt request genarated
Main program
76
CHAPTER 3 CPU
Multiple hardware interrupts can be generated by setting different interrupt levels in the
interrupt level setting bits of the interrupt control register (ICR: ILO to IL2) in response
to plural interrupt requests from the resource. However, multiple EI2OS cannot be
started.
■ Multiple Interrupts
Note: Multiple EI2OS cannot be started. During EI2OS processing, other interrupt requests and other EI2OS
requests are all held.
77
CHAPTER 3 CPU
Main program
(ILM = "111B") A/D Interrupt processing (ILM = "010B")
Interrupt level 2
(IL = "010B") Timer interrupt processing (ILM = "001B")
Set interrupt (1)
Interrupt level 1
(IL = "001B")
(3) Timer interrupt
A/D interrupt (2)
genarated generated
Suspended (4) Timer interrupt
processing
Resumed
Resumption of (8)
main processing (6) A/D interrupt processing
(5) Return from timer
interrupt
(7) Return from A/D interrupt
• When processing of the A/D converter interrupt is started, the interrupt level mask register (ILM) is set
automatically to the value (2 in example) of the interrupt level (ICR: IL2 to IL0) of the A/D converter.
When an interrupt request with an interrupt level of 1 or 0 is generated under this condition, processing
the generated interrupt is preferred.
• When the interrupt return instruction (RETI) is executed after the completion of interrupt processing, the
values of the dedicated registers (A, DPR, ADB, DTB, PCB, PC, PS) saved in the system stack are
returned to each register and the interrupt level mask register (ILM) is returned to the value before
interrupt processing was suspended.
78
CHAPTER 3 CPU
The software interrupt is a function for transiting control from the current-executing
program to the interrupt processing program defined by user by execution of a software
interrupt instruction (INT instruction). The software interrupt is held during execution of
a software interrupt.
Note: When the program bank register (PCB) is "FFH", the vector area for the CALLV instruction overlaps the
table for the INT #vct8 instruction. A CALLV and INT #vct8 instructions can not use the same address in
creating a software.
79
CHAPTER 3 CPU
EI2OS is a function to automatically transfer data between the resources (I/O) and
memory. It generates the hardware interrupt at termination of data transfer.
■ EI2OS
The EI2OS provides automatic data transfer between the I/O area and memory. When data transfer is
terminated, the termination factor (end condition) is set, branching automatically to the interrupt processing
routine. Data can be transferred just by creating a setup program for starting the EI2OS and an end
program.
● Advantages of EI2OS
Compared to data transfer using the interrupt-processing routine, EI2OS has the following advantages.
• Since the creation of transfer program is not required, the program size can be reduced.
• The transfer count can be set to prevent transfer of unnecessary data.
• Whether to update the buffer address pointer can be specified.
• Whether to update the I/O address pointer can be specified.
80
CHAPTER 3 CPU
■ Operation of EI2OS
Figure 3.5-9 "Operation of EI2OS" shows the operation of the EI2OS.
Memory space
By IOA
00 bank area I/O area
(5)
CPU
Interrupt request (1)
(2)
(3)
By ICS
ISD
Interrupt control register (ICR)
(3)
Interrupt controller
By BAP
81
CHAPTER 3 CPU
The EI2OS descriptor (ISD) is allocated to the addresses "000100H" to "00017FH" in the
internal RAM, and consists of 8 bytes x 16 channels.
MSB LSB
Higher 8 bits of data counter (DCTH) H
Channel
Descriptor Starting Address
(ICR: ICS3 to ICS0)
0 000100H
1 000108H
2 000110H
3 000118H
4 000120H
5 000128H
6 000130H
82
CHAPTER 3 CPU
Channel
Descriptor Starting Address
(ICR: ICS3 to ICS0)
7 000138H
8 000140H
9 000148H
10 000150H
11 000158H
12 000160H
13 000168H
14 000170H
15 000178H
83
CHAPTER 3 CPU
DCTH DCTL
bit 15 14 13 12 11 10 9 bit 8 bit 7 6 5 4 3 2 1 bit 0
Reset value
DCT B15 B14 B13 B12 B11 B10 B09 B08 B07 B06 B05 B04 B03 B02 B01 B00
XXXXXXXX XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
R/W : Read/Write
X : Undefined
IOAH IOAL
bit 15 14 13 12 11 10 9 bit 8 bit 7 6 5 4 3 2 1 bit 0
Reset value
IOA A15 A14 A13 A12 A11 A10 A09 A08 A07 A06 A05 A04 A03 A02 A01 A00
XXXXXXXX XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W R/W
R/W : Read/Write
X : Undefined
84
CHAPTER 3 CPU
7 6 5 4 3 2 1 0
Reset value
XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
SE EI2OS termination control bit
0 Not terminated by a request from resource
1 Terminated by a request from resource
bit 1
DIR Data transfer direction specify bit
0 I/O address pointer → Buffer address pointer
1 Buffer address pointer → I/O address pointer
bit 2
BF BAP updating/fixing select bit
0 Buffer address pointer updated after data transfer
1 Buffer address pointer not updated after data transfer
bit 3
BW Transfer data length specify bit
0 Byte
1 Word
bit 4
IF IOA updating/fixing select bit
0 I/O address pointer updated after data transfer
1 I/O address pointer not updated after data transfer
85
CHAPTER 3 CPU
R/W : Read/Write
X : Undefined
References: • The area that can be set by the I/O address pointer (IOA) is "000000H" to "00FFFFH".
• The area that can be set by the buffer address pointer (BAP) is "000000H" to "FFFFFFH".
• The maximum transfer count that can be set by the data counter (DCT) is 65,536.
86
CHAPTER 3 CPU
The flowchart of operation of the EI2OS using the microcode in the CPU is shown
below:
■ Operation of EI2OS
YES
IF=0?
NO Updating value
IOA updated
depends on BW
YES
BF = 0?
NO Updating value BAP updated
depends on BW
Clear resource
interupt request Clear ISE to "0"
87
CHAPTER 3 CPU
Start
S1, S0 = "00B"
(Interrupt request) and (ISE = 1)
Execute user program
Data transfer
RETI
88
CHAPTER 3 CPU
The time required for EI2OS processing depends on the following factors:
• Setting of EI2OS status register (ISCS)
• Data length of transfer data
Some interrupt handling time is required at the transition to hardware interrupt
processing after completion of data transfer.
The EI2OS processing time at continuing data transfer is determined by the setting of the EI2OS status
register (ISCS) as shown in Table 3.5-10 "EI2OS Execution Time".
Unit: Machine cycle (one machine cycle is equal to one cycle of the machine clock (φ).)
In addition, compensation is required depending on the conditions at executing EI2OS as shown in Table
3.5-11 "Compensation Value for Data Transfer at EI2OS Processing Time".
Table 3.5-11 Compensation Value for Data Transfer at EI2OS Processing Time
Internal Access
II/O Register Address Pointer
B/even Odd
89
CHAPTER 3 CPU
At completion of data transfer by the EI2OS, since the hardware interrupt is started, the interrupt handling
time is added. The EI2OS processing time at the end of counting is calculated by the following expression.
El2OS processing time at end of counting = El2OS processing time at continuing data transfar + (21 + 6 x Z)
machine cycles
Interrupt handling time
(Z: Compensation value of interrupt handling time)
The interrupt handling time depends on the address set by the stack pointer. Table 3.5-12 "Compensation
Value (Z) of Interrupt Handling Time" shows the compensation value (Z) of the interrupt handling time.
If data transfer by the EI2OS is terminated during its processing by the termination request from a resource
(ICR: S1, S0 = "11B"), processing transits to interrupt processing. The EI2OS processing time at a
termination request from a resource is calculated as follows:
Reference: One machine cycle is equal to one clock cycle of the machine clock (φ).
90
CHAPTER 3 CPU
■ Exception Processing
91
CHAPTER 3 CPU
The time for terminating the currently executing instruction plus the interrupt handling
time is required from generation of the hardware interrupt request to execution of the
interrupt-processing.
Reference: The interrupt request sampling wait time is longest when the interrupt request is generated immediately
after starting execution of the POPW, RW0, …RW7 instructions with the longest execution cycle (45
machine cycles).
92
CHAPTER 3 CPU
The interrupt handling time depends on the address set by the stack pointer. Table 3.5-13 "Compensation
Value (Z) of Interrupt Handling Time" shows the compensation value (Z) of the interrupt handling time.
Reference: One machine cycle is equal to one clock cycle of the machine clock (φ).
93
CHAPTER 3 CPU
Immediately before interrupt Address Memory Immediately before interrupt Address Memory
SP after
updating
SSB 00 H 08F2H XX H Low SSB 00 H 08F2H E0 H
XX H 20H PS
SSP 08FEH XX H SSP 08F2H 3F H PC
XX H 80H
A 0000 H 08FEH XX H A 0000H 08FEH FF H PCB
AH AL XX H AH AL 00H DTB
XX H 00H ADB
DPR 01 H ADB 00 H XX H DPR 01 H ADB 00 H 01H DPR
XX H FEH AL
DTB 00 H PCB FF H XX H DTB 00 H PCB FF H 08H
XX H 00H
AH
PC 803FH XX H PC 803FH 00H
08FEH SP 08FEH SP
PS 20E0H 08FF H PS 20E0H 08FF H
Byte Byte
High
94
CHAPTER 3 CPU
● Processing specification
This is an example of interrupt program using external interrupt 4 (INT4).
● Coding example
95
CHAPTER 3 CPU
;-----Interrupt program----------------------------------------------------------
ED_INT1:
MOV I:EIRR,#00H ; New acceptance of INT4 disabled
NOP
NOP
NOP
NOP
NOP
NOP
RETI ; Return from interrupt
CODE ENDS
;-----Vector setting-------------------------------------------------------------
VECT CSEG ABS = OFFH
ORG OFFDOH ; Vector set to interrupt #11 (OBH)
DSL ED_INT1
ORG OFFDCH ; Reset vector set
DSL START
DB 00H ; Set to single-chip mode
VECT ENDS
END START
96
CHAPTER 3 CPU
● Processing specification
• The EI2OS is started by detecting the High level of the signal to be input to the INT4 pin.
• When the High level is input to the INT4 pin, EI2OS is started and the data of port 0 is transferred to
memory address "3000H".
• The transfer data is 100 bytes. After 100 bytes are transferred, an interrupt is generated at completion of
transfer by the EI2OS transfer.
● Coding example
97
CHAPTER 3 CPU
98
CHAPTER 3 CPU
3.6 Reset
When a reset factor occurs, the CPU immediately suspends the current processing and
starts the reset operation.
The reset factors are as follows:
• Power-on
• Overflow of watchdog timer
• Software reset request
• Generation of external reset request (RST pin)
■ Reset Factors
Oscillation
Machine Watchdog
Reset Factor Stabilization
Clock Timer
Waiting
● Power on reset
• The power on reset occurs at power on.
• The reset operation is executed after the oscillation stabilization wait time of 218/HCLK has elapsed.
For the details of the Watchdog timer, see CHAPTER 6 "WATCHDOG TIMER".
● Software reset
• The software reset occurs when 0 is written to the internal reset signal generate bit (LPMCR: RST) in
the low-power consumption mode control register.
• The oscillation stabilization wait time is not generated by a software reset.
99
CHAPTER 3 CPU
● External reset
• The external reset occurs when a Low level is input to the external reset pin (RST pin). The time for
inputting Low level from the RST pin requires at least 16 machine cycles (main clock).
• An external reset does not require the oscillation stabilization wait time.
Note: • If an external reset request is generated from the RST pin during writing by a transfer instruction (such
as MOV), the reset cancel wait state is set after completion of the transfer instruction, so writing is
terminated normally. For a string instruction (such as MOVS), the reset cancel wait state may be set
before completion of transfer by a specified counter value.
• When stop mode, sub-clock mode, sub-sleep mode and watch mode are returned to main clock mode
using an external reset pin (RST pin), input level "L" for at least "the oscillation time of the
oscillator(*) + 100µs + 16 machine cycles".
*: The oscillation time of the oscillator is the time required to reach 90% of amplitude. It takes several
to dozens of ms for crystal oscillators, hundreds of µs to several ms for FAR/ceramic oscillators, and
0 ms for external clocks.
100
CHAPTER 3 CPU
The oscillation stabilization wait state after reset varies depending on the reset factors.
Table 3.6-3 Oscillation Stabilization Wait Time by Clock Select Register (CKSCR)
101
CHAPTER 3 CPU
Note: Ceramic or crystal oscillators require the oscillation stabilization wait time of some tens of milliseconds
to stabilize oscillation.
102
CHAPTER 3 CPU
The external reset pin (RST pin) is a reset input pin. Input of an external Low level
generates a reset factor. The MB90385 series starts the reset operation in
synchronization between the CPU and clock.
RST Pch
Pin
Nch
Notes: • To prevent damage to memory due to a reset during writing to memory, a Low level is input to the
RST pin in a machine cycle in which memory is not damaged.
• The CPU operation clock is required to initialize internal circuits. In particular, at operation on an
external clock, the reset signal and CPU operation clock signal must be input.
103
CHAPTER 3 CPU
During reset operation, the mode for reading mode data and reset vectors is set
according to the settings of the mode pins (MD0 to MD2) and a mode fetch is executed.
When the oscillation clock is returned from stop states (power on, stop mode) by a
reset, a mode fetch is executed after the elapse of the main clock oscillation
stabilization wait time.
Software reset
Power-on reset External reset (RST pin)
Watchdog timer reset
Reset operation
Oscillation stabilization wait time
Reset cleared
Mode data fetched Changes pin state
related to bus mode
Reset sequence
Reset vector fetched
Reference: For standby mode operation, see Section 3.8 "Low-power Consumption Mode".
■ Mode Pin
The MD0 to MD2 mode pins are external pins. They are used to set the mode for reading data and reset
vectors.
For the details of the mode pins (MD0 to MD2), see Section 3.9.3 "Memory Access Mode".
104
CHAPTER 3 CPU
■ Mode Fetch
At transition to the reset operation, the CPU automatically transfers mode data and reset vectors by
hardware to the appropriate register in the CPU core. The mode data and reset vector are allocated to four
bytes of addresses "FFFFDCH" to "FFFFDFH". After a reset factor is generated (or after the elapse of the
oscillation stabilization wait time), the CPU immediately outputs the addresses of the mode data and reset
vectors to the bus to fetch the mode data and reset vectors. This operation is called "mode fetch." At
completion of mode fetch, the CPU starts processing from the address indicated by the reset vector.
PC
FFFFDCH Reset vector bits 7 to 0
FFFFDDH Reset vector bits 15 to 8 PCB
FFFFDE H Reset vector bits 23 to 16
Reset sequence
FFFFDFH CPU mode data
Micro ROM
Mode
register
Note: To read the mode data and reset vectors from internal ROM is set by the mode pins (MD0 to MD2).
For use in the single-chip mode, the mode pins should be set to the internal vector mode.
● Mode data
The mode data is used to set a memory access mode or a memory access area. It is allocated to address
"FFFFDFH". During the reset operation, this data is read automatically by a mode fetch and stored in the
mode register.
● Reset vectors
The reset vectors are the start addresses of execution after completion of the reset operation. They are
allocated to addresses "FFFFDCH" to "FFFFDEH". During the reset operation, these vectors are read
automatically by a mode fetch and transferred to the program counter.
105
CHAPTER 3 CPU
To check reset factors, read the value of the watchdog timer control register (WDTC).
LPMCR register
Power-on External reset Watchdog timer
RST bit write
detector request detector reset detector
detector
106
CHAPTER 3 CPU
Table 3.6-4 Correspondence of Reset Factor Bit Value and Reset Factor
Power on reset 1 X X X
● Power on reset
When a power on reset is executed, the PONR bit is set to 1 after completion of the reset operation. Any
reset factor bit other than the PONR bit is undefined. When the PONR bit is 1 after completion of the reset
operation, ignore the value of any bit other than the PONR bit.
107
CHAPTER 3 CPU
Note: Don’t let the device connected to pins that enter the high-impedance state, malfunction when the reset
factor is generated.
108
CHAPTER 3 CPU
3.7 Clocks
The clock generation section controls the internal clock that is an operating clock for
the CPU or resources. The clock generated by the clock generation section is called a
"machine clock" and one cycle of the machine clock is a machine cycle. The clock to be
supplied from a high-speed oscillator is called an "oscillation clock" and the 2-
frequency division of the oscillation clock is called a "main clock." The 4-frequency
division of a clock to be supplied from a low-speed oscillator is called a "subclock" and
the clock to be supplied from the PLL oscillator circuit is called a "PLL clock."
■ Clock
The clock generation section has oscillators and generates an oscillation clock by connecting an oscillator
to oscillation pins. External clocks that are input to the oscillation pins can be used as oscillation clocks.
The PLL clock multiplying circuit can be used to generate four clocks for multiplying the oscillation clock.
The clock generation section controls the oscillation stabilization wait time, PLL clock multiplying circuit,
and selects internal clock by the clock selector.
● Subclock (SCLK)
This clock is a clock with 4-frequency division of the clock generated by connecting an oscillator or
inputting an external clock to the low-speed oscillation pins (X0A and X1A). It can also be used as an
operating clock for the watch timer or as a low-speed machine clock.
109
CHAPTER 3 CPU
● Machine clock
This clock is an operating clock for the CPU and the resources. One cycle of the machine clock is a
machine cycle (1/φ). One clock can be selected from the main clock subclock, and four types of PLL clock.
Note: • When the operating voltage is 5 V, the oscillation clock can oscillate at 3 MHz to 16 MHz. The
maximum operating frequency of the CPU or resources is 16 MHz. If a multiplication rate that
exceeds the maximum operating frequency is set, the device does not operate normally. If the
oscillation clock is 16 MHz, the multiplication rate of PLL clock can only be set to x1. The PLL
oscillator oscillates in the range of 3 MHz to 16 MHz, which varies depending on the operating
voltage and multiplication rate.
• There is no sub-clock in MB90F387S and MB90387S.
110
CHAPTER 3 CPU
Resources
4
4 Watchdog timer
PPG0,1
Watch timer 8-/16- bit
Pin
PPG timer 0, 1
Timebase timer 8-/16- bit PPG2,3
Clock generation section PPG timer 2, 3 Pin
X0A TIN0
Pin Pin
Subclock
X1A generator 1 2 3 4 TOT0
Pin 16-bit reload Pin
PLL multiplying circuit timer 0
X0 4-devided
clock SCLK PCLK Communucation prescaler 1
Pin
Oscillation
2-devided
φ
X1 clock clock Clock selector SCK1
Pin generator HCLK Pin
MCLK
UART1 SOT1
Pin
SIN1
CPU intermittent Pin
operation
TIN1
Pin
CPU 16-bit reload TOT1
timer 1 Pin
ADTG
Pin
8-/10- bit
A/D converter IN0,1,2,3
Pin
Input capture unit
111
CHAPTER 3 CPU
Reset S Q S Q
Interrupt
R R
Operating 2 Oscillation
clock stabilization wait
selector time selector
2
PLL multiplying SCM MCM WS1 WS0 SCS MCS CS1 CS0
circuit
Clock select register (CKSCR)
X0 Pin 2-devided 1024-devided 2-devided 4-devided 2-devided 2-devided 2-devided 2-devided 2-devided
Oscillation clock clock clock clock clock clock clock clock clock
X1 Pin clock Main
clock
Timebase timer
Oscillation clock (HCLK) Subclock
generator To watchdog timer
112
CHAPTER 3 CPU
● Subclock generator
This generator generates a subclock (SCLK) by connecting an oscillator or inputting an external clock to
the low-speed oscillation pins (X0A, X1A).
● Clock selector
This selector selects the clock that is supplied to the CPU or resources from the main clock, subclock, and
four types of PLL clock.
113
CHAPTER 3 CPU
bit 15 14 13 12 11 10 9 8
114
CHAPTER 3 CPU
The clock select register (CKSCR) switches between the main clock, subclock, and PLL
clock, selects the oscillation stabilization wait time and the multiplication rate of PLL
clock.
15 14 13 12 11 10 9 8
Reset value
11111100 B
R R R/W R/W R/W R/W R/W R/W
bit 9 bit 8
CS1 CS0 Multiplication rate select bits
The parenthesized values are provided when the oscillation clock (HCLK) operates at 4 MHz
0 0 1 × HCLK (4 MHz)
0 1 2 × HCLK (8 MHz)
1 0 3 × HCLK (12 MHz)
1 1 4 × HCLK (16 MHz)
bit 10
MCS PLL clock select bit
0 The PLL clock selected
1 The main clock selected
bit 11
SCS Subclock select bit
0 The subclock selected
1 The main clock selected
bit 13 bit 12
WS1 WS0 Oscillation stabilization wait time select bits
The parenthesized values are provided when the oscillation clock (HCLK) operates at 4 MHz
115
CHAPTER 3 CPU
Table 3.7-1 Function of Each Bit of Clock Select Register (CKSCR) (1/2)
bit 9 CS1, CS0: These bits are used to select the multiplication rate of the PLL clock from four types.
bit 8 Multiplication rate select When reset, they all return to their reset value.
bits Note:
When the PLL clock is selected (CKSCR: MCS = 0), writing is inhibited. When
changing the multiplication rate, write 1 to the PLL clock select bit (CKSCR: MCS),
rewrite the multiplication rate select bits (CKSCR: CS1, CS0), and then return the
PLL clock select bit (CKSCR: MCS) to "0".
bit 10 MCS: This bit sets where to select the main clock or PLL clock as a machine clock.
PLL clock select bit If the machine clock is switched from the main clock to the PLL clock (CKSCR: MCS = 1
--> 0), the oscillation stabilization wait time of the PLL clock is generated and then the
mode transits to the PLL clock mode. The timebase timer is automatically cleared. When
the main clock mode is switched to PLL clock, the oscillation stabilization wait time is
fixed to 214/HCLK (approximately 4.1 ms when the oscillation clock operates at 4 MHz).
When subclock mode is switched to PLL clock, the oscillation stabilization wait time uses
the specified values in the oscillation stabilization wait time selection bits (CKSCR: WS1,
WS0).
When reset, this bit returns to its reset value.
Notes:
1. If both the MCS and SCS bits are 0, the SCS bit is preferred and the subclock mode is
set.
2. When switching the machine clock from the main clock to the PLL clock (CKSCR:
MCS = 1 --> 0), use the interrupt enable bit of the timebase timer (TBTC: TBIE) or
the interrupt level mask register (ILM: ILM2 to ILM0) to disable the timebase timer
interrupts.
bit 11 SCS: This bit sets whether to select main clock or subclock as machine clock.
Subclock select bit (sub) • When the machine clock is switched from the main clock to the subclock (CKSCR:
SCS = 1 --> 0), the main clock mode transits to the subclock mode in synchrony with
the subclock (approximately 130 µs).
• When the machine clock is switched from the subclock to the main clock (CKSCR:
SCS = 0 --> 1), the subclock mode transits to the main clock mode after the main
clock oscillation stabilization wait time is generated. The timebase timer is
automatically cleared.
When reset, this bit returns to its reset value.
Notes:
1. If both the MCS and SCS bits are 0, the SCS bit is preferred and the subclock mode is
set.
2. If both the subclock select bit (CKSCR: MCS) and PLL clock select bit (CKSCR:
SCS) are 0, the subclock is preferred.
3. When switching the machine clock from the main clock to the subclock (CKSCR:
SCS = 1 --> 0), use the interrupt enable bit of the timebase timer (TBTC: TBIE) or the
interrupt level mask register (ILM: ILM2 to ILM0) to disable the timebase timer.
4. At power on or when the stop mode is cancelled, the subclock oscillation stabilization
wait time (approximately 2 s) is generated. Therefore, if the mode is switched from the
main clock mode to the subclock mode, the oscillation stabilization wait time is
generated.
5. There is no sub-clock in MB90F387S and MB90387S. This bit should be set
to initial values.
116
CHAPTER 3 CPU
Table 3.7-1 Function of Each Bit of Clock Select Register (CKSCR) (2/2)
bit 13 WS1, WS0: These bits select an oscillation stabilization wait interval of the oscillation clock when
bit 12 Oscillation stabilization stop mode was released, when transition occurred from subclock mode to main clock
wait time select bits mode, or when transition occurred from subclock mode to PLL clock mode.
• These bits are used to select from four timebase timer outputs.
When reset, they all return to their reset value.
Note:
Set an oscillation stabilization wait time appropriate for an oscillator. For details, see
Section 3.6.1 "Reset Factors and Oscillation Stabilization Wait Time".
When the main clock mode is switched to PLL clock, the oscillation stabilization wait
time is fixed to 214/HCLK (approximately 4.1 ms when the oscillation clock operates
at 4 MHz). When subclock mode is switched to PLL clock or when PLL stop mode is
returned to PLL clock mode, the oscillation stabilization wait time uses the specified
values in the WS1 and WS0 bits. For PLL clock oscillation stabilization wait time, at
least 214 /HCLK is required. Accordingly, when subclock mode is switched to PLL
clock mode, or when PLL clock mode is switched to PLL stop mode, set WS1 and
WS0 bits to "10B" or "11B".
bit14 MCM: This bit indicates whether to select main clock or PLL clock as machine clock.
PLL clock flag bit • If the PLL clock flag bit (CKSCR: MCM) is 1 and the PLL clock select bit (CKSCR:
MCS) is 0, it indicates that the oscillation stabilization wait time of the PLL clock is
taken.
bit 15 SCM: This bit indicates whether to select main clock or the subclock as the machine clock.
Subclock flag bit • If the subclock flag bit (CKSCR: SCM) is 0 and the subclock select bit (CKSCR:
SCS) is 1, it indicates that the subclock switches to the main clock. If the subclock flag
bit (CKSCR: SCM) is 1 and the subclock select bit (CKSCR: SCS) is 0, it indicates
that the main clock switches to the subclock.
117
CHAPTER 3 CPU
Clock modes have a main clock mode, subclock mode, and PLL clock mode.
■ Clock Mode
● Subclock mode
In the subclock mode, a clock with 4-frequency division of the clock generated by connecting an oscillator
or inputting an external clock to the low-speed oscillation pins (X0A, X1A) is used as the operating clock
for the CPU or resources.
118
CHAPTER 3 CPU
Note: • When sub-clock mode are returned to main clock mode using an external reset pin (RST pin),
input level "L" for at least "the oscillation time of the oscillator(*) + 100µs + 16 machine cycles".
*: The oscillation time of the oscillator is the time required to reach 90% of amplitude. It takes
several to dozens of ms for crystal oscillators, hundreds of µs to several ms for FAR/ceramic
oscillators, and 0 ms for external clocks.
• There is no sub-clock in MB90F387S and MB90387S.
Notes: • The machine clock is not switched immediately even when the PLL clock select bit (CKSCR: MCS)
and the subclock select bit (CKSCR: SCS) are rewritten. When running resources that depend on the
machine clock, after switching the machine clock, reference the value of the PLL clock flag bit
(CKSCR: MCM) or the subclock flag bit to check that the machine clock has been switched.
• When the PLL clock select bit (CKSCR: MCS) is 0 (PLL clock mode) and the subclock select bit
(CKSCR: SCS) is 0 (subclock mode), the SCS bit the SCS bit is preferred, transiting to the subclock
mode.
• When transiting a clock mode, do not transit a clock mode to any other clock mode or a low-power
consumption mode until the completion of transition. Reference the MCM and SCM bits in the clock
select register (CKSCR) to check that the transition of a clock mode is completed.
• There is no sub-clock in MB90F387S and MB90387S.
Figure 3.7-5 "Clock Mode Transition" shows the transition of a clock mode.
119
CHAPTER 3 CPU
Main → Sub
MCS = 1
(8) MCM = 1 (9)
Main Sub
SCS = 0
MCS = 1 (10) MCS = 1
SCM = 1
MCM = 1 MCM = 1
CS1,CS0 = xx
SCS = 1 (1) (16) SCS = 0
SCM = 1 (10) SCM = 0
(11) Sub → Main
CS1,CS0 = xx CS1,CS0 = xx
MCS = 1 (8)
MCM = 1
SCS = 1
(6) (8)
SCM = 0
Main → PLLx (2) CS1,CS0 = xx (12) Sub → PLL
MCS = 0 (3) (13) MCS = 0
MCM = 1 MCM = 1
(4) (14)
SCS = 1 SCS = 1
SCM = 1 (5) (15) SCM = 0
CS1,CS0 = xx CS1,CS0 = xx
120
CHAPTER 3 CPU
Notes: • The reset value of the machine clock is in the main clock mode (MCS = 1, SCS = 1)
• When SCS and MCS are both 0, SCS is preferred, and the subclock is selected.
• When transiting from the subclock mode to the PLL clock mode, set the oscillation stabilization wait
time select bit of the CKSCR register (WS1, WS0) to 10B or 11B.
• There is no sub-clock in MB90F387S and MB90387S.
121
CHAPTER 3 CPU
At power on or return from the stop mode when the oscillation clock is stopped, a time
taken until the oscillation clock stabilizes (oscillation stabilization wait time) is required
after starting an oscillation. The oscillation stabilization wait time is also required for
switching the clock mode from main clock mode to PLL clock mode, from main clock
mode to subclock mode, from subclock mode to main clock mode, and from subclock
mode to PLL clock mode.
Starting of normal
Oscillation time Oscillation operation or transiting to
of oscillator stabilization wait time PLL clock/subclock
X1
122
CHAPTER 3 CPU
The MB90385 series has a system clock generator and generates an internal clock by
connecting an oscillator to the oscillation pins. External clocks input to the oscillation
pins can be used as oscillation clocks.
X0
X1
C1 C2 MB90385 series
X0A
X1A
C3 C4
X0
~ Open X1
MB90385 series
X0A
~ Open X1A
123
CHAPTER 3 CPU
The CPU operation modes are classified as follows according to the selection of the
operation clock and the oscillation control of a clock. All the operation modes except
the PLL clock mode are low-power consumption modes.
• Clock modes (main clock, PLL clock and subclock modes)
• CPU intermittent operation modes (main clock, PLL clock, and subclock modes)
• Standby modes (sleep, stop, watch, and timebase timer modes)
Current consumption
High CPU operation PLL clock mode 4-multiplied clock
mode
3-multiplied clock
2-multiplied clock
1-multiplied clock
3-multiplied clock
2-multiplied clock
1-multiplied clock
Watch mode
124
CHAPTER 3 CPU
■ Clock Mode
● Subclock mode
In subclock mode, the CPU and resources operate on a subclock (SCLK). In this mode, the main clock and
PLL multiplying circuit stop.
The subclock oscillation stabilization wait time (approximately 2 s) is generated at power on or at
cancellation of the stop mode. Therefore, if the clock mode transits from the main clock mode to the
subclock mode during that period, the oscillation stabilization wait time is generated.
● Sleep mode
The sleep mode stops supply of an operation clock to the CPU during operation in each clock mode. The
CPU stops and the resources operate in the clock mode before the transition to the sleep mode. The sleep
mode is divided into the main sleep mode, PLL sleep mode, and sub-sleep mode according to the clock
mode before the transition to the sleep mode.
● Watch mode
The watch mode operates only the subclock (SCLK) and watch timer. The main clock and PLL clock stop.
All resources except the watch timer stop.
125
CHAPTER 3 CPU
● Stop mode
The stop mode stops the oscillation clock (HCLK) and subclock (SCLK) during operation in each clock
mode. It enables data to be retained with the least power consumption.
Note: • When transiting a clock mode, do not transit a clock mode to any other clock mode or a low-power
consumption mode until the completion of transition. Reference the MCM and SCM bits in the clock
select register (CKSCR) to check that the transition of a clock mode is completed.
• There is no sub-clock in MB90F387S and MB90387S.
126
CHAPTER 3 CPU
PLL multiplying
circuit SCM MCM WS1 WS0 SCS MCS CS1 CS0
Clock select register (CKSCR)
Watch timer
X1A Pin
Subclock oscillator
127
CHAPTER 3 CPU
● Standby controller
This controller causes the CPU clock controller and resource clock controller to switch between the CPU
operating clock and the resource operating clock, and to transits a clock mode to, and cancel the standby
mode.
128
CHAPTER 3 CPU
This section explains the registers to be used to set lower-power consumption modes.
Figure 3.8-3 Low-power Consumption Mode Control Register and Reset Values
bit 7 6 5 4 3 2 1 0
129
CHAPTER 3 CPU
The low-power consumption mode control register (LPMCR) transits an operation mode
to, and cancels the low-power consumption modes, generates an internal reset signal,
and sets the halt cycle count in the CPU intermittent operation mode.
7 6 5 4 3 2 1 0
Reset value
00011000 B
W W R/W W W R/W R/W R/W
bit 0
Reserved Reserved bit
0 Always set to "0"
bit 2 bit 1
CG1 CG0 CPU halt cycle count select bits
0 0 0 cycle (CPU clock = resource clock)
0 1 8 cycles (CPU clock: resource clock = 1: approx. 3 to 4)
1 0 16 cycles (CPU clock: resource clock = 1: approx. 5 to 6)
1 1 32 cycles (CPU clock: resource clock = 1: approx. 9 to 10)
bit 3
TMD Timer mode bit
0 Transits to watch mode or timebase timer mode
1 No effect
bit 4
RST Internal reset signal generate bit
0 Generates internal reset signal of 3 machine cycles
1 No effect
bit 5
SPL Pin state specify bit
0 Holds input/output pin state
1 High impedance
Only in the timebase timer, watch, and stop modes
bit 6
SLP Sleep mode bit
0 No effect
1 Transits to sleep mode
bit 7
STP Stop mode bit
R/W : Read/Write 0 No effect
W : Write only 1 Transits to stop mode
: Reset value
130
CHAPTER 3 CPU
Table 3.8-1 Function of Each Bit of Low-power Consumption Mode Control Register (LPMCR)
bit 3 TMD: This bit is used to transit the operation mode to the watch mode or the timebase
Timer mode bit timer mode.
When set to 0: The mode transits to the watch mode.
When set to 1:Not effect
• This bit is set to 1 by a reset or interrupt.
Read: 1 is always read.
bit 5 SPL: This bit is used to set the state of input/output pins in transiting to the stop mode,
Pin state specify bit watch mode or timebase timer mode.
When set to 0: The current level of input/output pins is held.
When set to 1: The input/output pins are set to high impedance.
• This bit is initialized to 0 by a reset.
bit 6 SLP: This bit is used to transit the mode to the sleep mode.
Sleep mode bit When set to 0: No effect
When set to 1: The mode transits to the sleep mode.
• This bit is initialized to 0 by a reset or external interrupt.
• When both the STP and SLP bits are set to 1 simultaneously, the STP bit is
preferred and the mode transits to the stop mode.
bit 7 STP: This bit is used to transit the mode to the stop mode.
Stop mode bit When set to 0: No effect
When set to 1: The mode is transits to the stop mode.
When read: 1 is always read.
• This bit is initialized to 0 by a reset or external interrupt.
Notes: • When transiting to a low-power consumption mode using the low-power consumption mode control
register (LPMCR), use the instructions listed in Table 3.8-2 "Instructions at Transition to Low-power
Consumption Mode". If other instructions are used to transit to a low-power consumption mode,
operation is not assured.
• When writing in words in a low-power consumption mode, write data to even addresses. Writing to
odd addresses may cause a malfunction when the mode transits to a low-power consumption mode.
• To set a pin to high impedance when the pin is shared by a peripheral function and a port in stop mode,
watch mode or timebase timer mode, disable the output of peripheral functions, and set the STP bit to
1 or set the TMD bit to 0.
This applies to the following pins:
P14/PPGO, P15/PPG1, P16/PPG2, P17/PPG3, P21/TOT0, P23/TOT1
• There is no sub-clock in MB90F387S and MB90387S.
131
CHAPTER 3 CPU
132
CHAPTER 3 CPU
The CPU intermittent operation mode causes the CPU to operate intermittently with an
operating clock supplied to the CPU or resources to reduce power consumption.
Resource clock
CPU clock
A instruction
execution
Halt cycle cycle
133
CHAPTER 3 CPU
The standby mode causes the standby control circuit to either stop supplying an
operation clock to the CPU and resources, or to stop the oscillation clock (HCLK) to
reduce power consumption.
134
CHAPTER 3 CPU
135
CHAPTER 3 CPU
The sleep mode stops the operating clock to the CPU during an operation in each clock
mode. The CPU stops and the resources continue to operate.
Table 3.8-4 Settings of MCS and SCS Bits in Clock Select Register (CKSCR) and Sleep
Modes
1 0
Sub-sleep mode
0 0
Note: • If both the STP and SLP bits in the low-power consumption mode control register (LPMCR) are set to
1 simultaneously, the STP bit is preferred and the mode transits to the stop mode.
If the SLP bit is set to 1 and the TMD bit is set to 0 at the same time, the TMD bit is preferred and the
mode transits to the timebase timer mode or the watch mode.
• There is no sub-clock in MB90F387S and MB90387S.
● Pin state
In the sleep mode, pins other than those used for bus input/output or bus control are held in the state before
transiting to the sleep mode.
136
CHAPTER 3 CPU
Note: • When sub-sleep mode using an external reset pin (RST pin), input level "L" for at least "the
oscillation time of the oscillator(*) + 100µs + 16 machine cycles".
*: The oscillation time of the oscillator is the time required to reach 90% of amplitude. It takes
several to dozens of ms for crystal oscillators, hundreds of µs to several ms for FAR/ceramic
oscillators, and 0 ms for external clocks.
• There is no sub-clock in MB90F387S and MB90387S.
● Return by interrupt
When a higher interrupt request than the interrupt level (IL) of 7 is generated from the resources in the
sleep mode, the sleep mode is cancelled. After the sleep mode is cancelled, as with normal interrupt
processing, the generated interrupt request is identified according to the settings of the I flag in the
condition code register (CCR), the interrupt level mask register (ILM), and the interrupt control register
(ICR).
• When the CPU is not ready to accept any interrupt request, the instruction next to the currently
executing instruction is executed.
• When the CPU is ready to accept any interrupt request, it branches immediately to the interrupt
processing routine.
Figure 3.8-6 "Cancellation of Sleep Mode by Interrupt" shows the cancellation of sleep mode by an
interrupt.
INT generated NO
Sleep mode not cancelled
(IL<7)
YES Sleep mode not cancelled
Sleep mode cancelled
YES
I=0 Next instruction executed
NO
YES
ILM<IL
NO
Interrupt processing
executed
137
CHAPTER 3 CPU
Note: When an interrupt processing is executed, the CPU usually proceeds to the interrupt processing after
executing the instruction next to the one specifying the sleep mode.
138
CHAPTER 3 CPU
The watch mode operates only the subclock (SCLK) and the watch timer. The main
clock and PLL clock stop.
● Pin state
In the watch mode, the input/output pins can be set to the high-impedance state or held in the state before
transiting to the watch mode according to the setting of the SPL bit in the low-power consumption mode
control register (LPMCR).
Note: • To set a pin to high impedance when the pin is shared by a peripheral function and a port in watch
mode, disable the output of peripheral functions, and set the TMD bit to 0.
This applies to the following pins:
P14/PPGO, P15/PPG1, P16/PPG2, P17/PPG3, P21/TOT0, P23/TOT1
• There is no sub-clock in MB90F387S and MB90387S.
139
CHAPTER 3 CPU
Note: • When watch mode are returned to main clock mode using an external reset pin (RST pin), input level
"L" for at least "the oscillation time of the oscillator(*) + 100µs + 16 machine cycles".
*: The oscillation time of the oscillator is the time required to reach 90% of amplitude. It takes several
to dozens of ms for crystal oscillators, hundreds of µs to several ms for FAR/ceramic oscillators, and
0 ms for external clocks.
• There is no sub-clock in MB90F387S and MB90387S.
● Return by an interrupt
When an interrupt request higher than the interrupt level (IL) of 7 is generated from the watch timer and
external interrupt in the watch mode, the watch mode is cancelled. After the watch mode is cancelled, as
with normal interrupt processing, the generated interrupt request is identified according to the settings of
the I flag in the condition code register (CCR), the interrupt level mask register (ILM), and the interrupt
control register (ICR). In the sub-timer mode, no oscillation stabilization wait time is generated and the
interrupt request is identified immediately after return from the watch mode.
• When the CPU is not ready to accept any interrupt request, the instruction next to the currently
executing instruction is executed.
• When the CPU is ready to accept any interrupt request, it branches immediately to the interrupt
processing routine.
Note: • When an interrupt processing is executed, the CPU usually proceeds to the interrupt processing after
executing the instruction next to the one specifying the watch mode.
• There is no sub-clock in MB90F387S and MB90387S.
140
CHAPTER 3 CPU
The timebase timer mode operates only the oscillation clock (HCKL), subclock (SCLK),
timebase timer, and watch timer. Resources other than the timebase timer and watch
timer stop.
● Pin state
In the timebase timer mode, the input/output pins can be set to the high-impedance state or held in the state
before transiting to the timebase timer mode according to the setting of the SPL bit in the low-power
consumption mode control register (LPMCR).
Note: To set a pin to high impedance when the pin is shared by a peripheral function and a port in timebase
timer mode, disable the output of peripheral functions, and set the TMD bit to 0.
This applies to the following pins:
P14/PPGO, P15/PPG1, P16/PPG2, P17/PPG3, P21/TOT0, P23/TOT1
141
CHAPTER 3 CPU
Note: When the timebase timer mode is returned to main clock mode using an external reset pin (RST pin),
input level "L" for at least 100µs.
● Return by an interrupt
When an interrupt request higher than interrupt level (IL) 7 is generated from the watch timer, timebase
timer, and external interrupt in the timebase timer mode, the timebase timer mode is cancelled. After the
timebase timer mode is cancelled, as with normal interrupt processing, the generated interrupt request is
identified according to the settings of the I flag in the condition code register (CCR), the interrupt level
mask register (ILM), and the interrupt control register (ICR).
• When the CPU is not ready to accept any interrupt request, the instruction next to the currently
executing instruction is executed.
• When the CPU is ready to accept any interrupt request, it branches immediately to the interrupt
processing routine.
• The following two timebase timer modes are available:
- Main clock <-- --> timebase timer mode
- PLL clock <-- --> timebase timer mode
Note: • At interrupt processing, the CPU usually proceeds to the interrupt processing after executing the
instruction next to the one specifying the timebase timer mode.
• When the timebase timer mode is returned by an interrupt, the interrupt processing is performed after
the maximum 80 µs after the interrupt request is accepted.
142
CHAPTER 3 CPU
The stop mode stops the oscillation clock (HCLK) and subclock (SCLK) during
operation in each clock mode. Data can be held with the minimum power consumption.
■ Stop Mode
When 1 is written to the STP bit of the low-power consumption mode control register (LPMCR) during
operation in the PLL clock mode, the mode transits to the stop mode according to the settings of the MCS
bit and SCS bit in the clock select register (CKSCR).
Table 3.8-5 "Settings of MCS and SCS Bits in Clock Select Register (CKSCR) and Stop Modes" shows the
settings of the MCS and SCS bits in the clock select register (CKSCR) and the stop modes.
Table 3.8-5 Settings of MCS and SCS Bits in Clock Select Register (CKSCR) and Stop
Modes
Note: • If both the STP and SLP bits in the low-power consumption mode control register (LPMCR) are set to
1 simultaneously, the STP bit is preferred and the mode transits to the stop mode.
• There is no sub-clock in MB90F387S and MB90387S.
143
CHAPTER 3 CPU
● Pin state
In the stop mode, the input/output pins can be set to the high-impedance state or held in the state before
transiting to the stop mode according to the setting of the SPL bit in the low-power consumption mode
control register (LPMCR).
Note: To set a pin to high impedance when the pin is shared by a peripheral function and a port in stop mode,
disable the output of peripheral functions, and set the STP bit to 1.
This applies to the following pins:
P14/PPGO, P15/PPG1, P16/PPG2, P17/PPG3, P21/TOT0, P23/TOT1
RST pin
Stop mode
Note: • When stop mode are returned to main clock mode using an external reset pin (RST pin), input
level "L" for at least "the oscillation time of the oscillator(*) + 100µs + 16 machine cycles".
*: The oscillation time of the oscillator is the time required to reach 90% of amplitude. It takes
several to dozens of ms for crystal oscillators, hundreds of µs to several ms for FAR/ceramic
oscillators, and 0 ms for external clocks.
• There is no sub-clock in MB90F387S and MB90387S.
144
CHAPTER 3 CPU
● Return by an interrupt
When an interrupt request higher than the interrupt level (IL) of 7 is generated from external interrupt in the
stop mode, the stop mode is cancelled. In the stop mode, the main clock oscillation stabilization wait time
or the subclock oscillation stabilization wait time is generated after the stop mode is cancelled. After the
stop mode is cancelled, as with normal interrupt processing, the generated interrupt request is identified
according to the settings of the I flag in the condition code register (CCR), the interrupt level mask register
(ILM), and the interrupt control register (ICR).
• When the CPU is not ready to accept any interrupt request, the instruction next to the currently
executing instruction is executed.
• When the CPU is ready to accept any interrupt request, it branches immediately to the interrupt
processing routine.
Notes: • At interrupt processing, the CPU usually proceeds to the interrupt processing after executing the
instruction next to the one specifying the stop mode.
• In PLL stop mode, the main clock and PLL multiplication circuit stop. During recovery from PLL stop
mode, it is necessary to allot the main clock oscillation stabilization wait time and PLL clock
oscillation stabilization wait time. The oscillation stabilization wait times for the main clock and PLL
clock are counted simultaneously according to the value specified in the oscillation stabilization wait
time selection bits (CKSCR: WS1, WS0) in the clock selection register. The oscillation stabilization
wait time selection bits (CKSCR: WS1, WS0) in the clock selection register must be selected
accordingly to account for the longer of main clock and PLL clock oscillation stabilization wait time.
The PLL clock oscillation stabilization wait time, however, requires 214/HCLK or more. Set the
oscillation stabilization wait time selection bits (CKSCR: WS1, WS0) in the clock selection register to
"10B" or "11B".
145
CHAPTER 3 CPU
The operating state and state transition in the clock mode and standby mode in the
MB90385 series are shown in the diagram.
SCS=0
SCS=1
Oscillation stabilization
waiting terminated MCS=0 SCS=0
Main clock mode PLL clock mode Subclock mode
MCS=1 SCS=1
SLP=1 Interrupt SLP=1 Interrupt SLP=1 Interrupt
Note: • In attempting to switch the clock mode, do not attempt to switch to another clock mode or low-power
consumption mode until the first switching is completed. The MCM and SCM bits of the clock
selection register (CKSCR) indicate that switching is completed.
• There is no sub-clock in MB90F387S and MB90387S.
146
CHAPTER 3 CPU
The state of input/output pins in the standby mode and at reset is shown in each access
mode.
Stop/Watch/Timebase timer
Pin Name Sleep Reset
SPL = 0 SPL = 1
P07 to P10
P27 to P20
Input cut off/
Immediately-preceding Input cut off/ Input disabled/
P37 to P35, p33 to p30 immediately-preceding
state held *1 output Hi-z *2 output Hi-z
state held*1
P44 to P40
P57 to P50
*1: Indicates that state of pins output immediately before entering each standby mode is output as it is or "input disabled."
"State of pins output is output as it is" means that if the resource output is in operation, the state of pins is output
according to the state of the resource and if the state of output pins is output, it is held. "Input disabled" means that no
pin value can be accepted internally because the operation of the input gates of pins is enabled but the internal circuit
stops.
*2: "Input cut off" means that operation of the input gates of pins is disabled and "output Hi-z" means that the driving of
pin driving transistors is disabled to set pins to the high-impedance state.
Note: To set a pin to high impedance when the pin is shared by a peripheral function and a port in stop mode,
watch mode or timebase timer mode, disable the output of peripheral functions, and set the STP bit to 1 or
set the TMD bit to 0.
This applies to the following pins:
P14/PPGO, P15/PPG1, P16/PPG2, P17/PPG3, P21/TOT0, P23/TOT1
147
CHAPTER 3 CPU
This section explains the precautions when using the low-power consumption modes.
Note: • Take measures, such as disabling interrupts, not to branch to the interrupt processing immediately
after return from the standby mode.
• There is no sub-clock in MB90F387S and MB90387S.
148
CHAPTER 3 CPU
149
CHAPTER 3 CPU
The F2MC-16XL family enables the transition of operation modes and memory access
modes to set the CPU operation and access modes and areas.
■ Classification of Modes
Table 3.9-1 "Classification of Modes" shows the classification of operation modes and memory access
modes for the F2MC-16XL family. Each mode is set by mode pins (MD2 to MD0) in reset and mode-
fetched mode data.
Single-chip mode
RUN modes
(Internal-ROM internal-bus mode)
■ Operation Mode
The operation modes control the operating state of the device and are set by the mode pins (MD2 to MD0).
● RUN mode
The RUN mode is the normal CPU operation mode. It provides various low-power consumption modes,
such as the main clock mode, PLL clock mode, and subclock mode.
For details of the low-power consumption modes, see Section 3.8 "Low-power Consumption Mode".
150
CHAPTER 3 CPU
The mode pins are three external pins of MD2 to MD0, and enable a combination of
these pins to set, the following:
• Operation modes (RUN mode, flash serial programming mode, flash memory mode)
• Reading reset vectors and mode data
0 0 0
0 0 1 Setting disabled
0 1 0
1 0 0
Setting disabled
1 0 1
151
CHAPTER 3 CPU
Data programmed NO
to flash memory
YES
Flash
programming Internal vector
mode mode
MD2 MD1 MD0 MD2 MD1 MD0
"1" "1" "1" "0" "1" "1"
152
CHAPTER 3 CPU
Mode data is used to set the memory access mode. It is automatically read to the CPU
by mode fetch.
■ Mode Data
The values of the mode register can be changed only in the reset sequence. The changed mode register
values are enabled after the reset sequence.
15 14 13 12 11 10 9 8
153
CHAPTER 3 CPU
Signle-chip
mode
Signle-chip
mode
154
CHAPTER 3 CPU
■ Bus Mode
Figure 3.9-4 "Memory map in the mode" shows the memory map in the mode.
000000H Resource
0000C0H
000100H
RAM area
Register
Adress#1
003900H
Extend I/O area
004000H
ROM area
(image of FF bank)
010000H
FE0000H
ROM area *
FF0000H
ROM area
FFFFFFH
For details of the access area, see Section 3.1 "Memory Space".
155
CHAPTER 3 CPU
This section explains selection of the memory access mode in the reset sequence.
Reset factor
Reset factor
cancellation waiting
(External reset or YES
oscillation stabili- Reset operating?
zation wait time)
NO
156
CHAPTER 4
I/O PORT
157
CHAPTER 4 I/O PORT
I/O ports can be used as general-purpose I/O ports (parallel I/O ports). In the MB90385
series, there are five ports (34 pins).
Each port pin also serves as a resource I/O pins.
Port Output
Pin Name Input Type Function bit7 bit6 bit5 bit4 bit3 bit2 bit1 bit0
Name Type
General-
P10/IN0 to
CMOS purpose I/O P17 P16 P15 P14 P13 P12 P11 P10
P13/IN3
port
Port 1
CMOS
P14/PPG0 to
high Resource PPG3 PPG2 PPG1 PPG0 IN3 IN2 IN1 IN0
P17/PPG3
current
General-
P20/TIN0 to purpose I/O P27 P26 P25 P24 P23 P22 P21 P20
Port 2 port
P27/INT7
CMOS
(hysteresis) Resource INT7 INT6 INT5 INT4 TOT1 TIN1 TOT0 TIN0
General-
P30 to p33 P36* / P35* /
purpose I/O P37 P34 P33 P32 P31 P30
Port 3 P35/X0A to X1A X0A
port
P37/ADTG
Resource ADTG − − − − − − −
CMOS General-
P40/SIN1 to purpose I/O − − − P44 P43 P42 P41 P40
Port 4 port
P44/RX
Resource − − − RX TX SOT1 SCK1 SIN1
General-
Analog/ purpose I/O P57 P56 P55 P54 P53 P52 P51 P50
P50/AN0 to port
Port 5 CMOS
P57/AN7
(hysteresis) Analog
AN7 AN6 AN5 AN4 AN3 AN2 AN1 AN0
input pin
*: If the low-speed oscillation pin is selected (for MB90387 or MB90F387), P35 and P36 pins cannot be used.
158
CHAPTER 4 I/O PORT
Note: • Port 5 also serve as analog input pins. When using these ports as general-purpose ports, always set
each bit of the analog input enable register (ADER) corresponding to each pin of the ports to 0. ADER
bit is 1 at a reset.
159
CHAPTER 4 I/O PORT
R/W: Read/Write
X: Undefined value
160
CHAPTER 4 I/O PORT
4.3 Port 1
Port 1 is a general-purpose I/O port that serves as the resource I/O pin . When the
single-chip mode is set, use port 1 by switching between the resource pin and the
general-purpose I/O port.
The function as a general-purpose I/O port is mainly described here. The configuration,
pin assignment, block diagram of the pins, and registers for port 1 are shown below.
■ Configuration of Port 1
Port 1 consists of the following three elements:
• General-purpose I/O port, resource I/O pin (P10/IN0 to P17/PPG3)
• Port 1 data register (PDR1)
• Port 1 direction register (DDR1)
■ Pin Assignment of Port 1
• When the single-chip mode is set, use port 1 by switching between the resource pin and the general-
purpose I/O port.
• Since port 1 serves as a resource pin, it cannot be used as a general-purpose I/O port when used as
resources.
• When using port 1 as the input pin of the resource, set the pin corresponding to the resource in the
DDR1 as an input port.
• When using port 1 as the output of the resource, set the output of the corresponding resource to
"enabled". Port 1 functions as the output pin of the resource regardless of the settings of the DDR1
Table 4.3-1 "Pin Assignment of Port 1" shows the pin assignment of port 1.
I/O Type
Port Circuit
Pin Name Port Function Resource
Name Type
Input Output
161
CHAPTER 4 I/O PORT
PDR read
Internal data bus
Output latch P ch
PDR write
Pin
Port direction register (DDR)
Direction latch N ch
DDR write
Standby control: Control of stop mode (SPL = 1), timebase timer mode (SPL = 1), and timer mode (SPL = 1)
Port
Bits of Related Registers and Corresponding Pins
Name
PDR1, DDR1 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
Port 1
Corresponding pin P17 P16 P15 P14 P13 P12 P11 P10
162
CHAPTER 4 I/O PORT
Read/ Register
Register Name Data At Read At Write Reset Value
Write Address
The
The output buffer is set to OFF, and
0 direction
the pin becomes an input port pin.
Port 1 direction latch is 0.
R/W 000011H 00000000B
register (DDR1) The
The output buffer is set to ON, and
1 direction
the pin becomes an output port pin.
latch is 1.
R/W: Read/Write
X: Undefined value
References: • When using port 1 as the input pin of the resource, clear the bit in the DDR1 corresponding to the
input pin of the resource to 0 and set the input pin as an input port.
• When using port 1 as the output pin of the resource, set the output of the corresponding resource to
"enabled". Port 1 functions as the output pin of the resource regardless of the settings of the DDR1.
163
CHAPTER 4 I/O PORT
Note: If read modify write instructions (such as the bit set instruction) are used to read the PDR, the pin set as
an output port by the DDR outputs the desired data. However, the pin set as an input port outputs data
after the input state is written to the output latch. When switching from the input port to the output port,
write data to the PDR and set the pin as an output port in the DDR.
● Operation at reset
• When the CPU is reset, the value of the DDR1 is cleared to 0. Consequently, all output buffers are set to
OFF (the pin becomes an input port pin), and the pin enters the high-impedance state.
• The PDR1 is not initialized by reset. Therefore, when using port 1 as an output port, it is necessary to set
output data in the PDR1, and then set the bit in the DDR1 corresponding to the output pin to 1, and then,
to output.
164
CHAPTER 4 I/O PORT
SPL: Pin state specification bit of low power consumption mode control register (LPMCR: SPL)
Hi-Z: High impedance
Note: To set a pin to high impedance when the pin is shared by a peripheral function and a port in stop mode,
watch mode or timebase timer mode, disable the output of peripheral functions, and set the STP bit to 1 or
set the TMD bit to 0.
This applies to the following pins:
P14/PPGO, P15/PPG1, P16/PPG2, P17/PPG3
165
CHAPTER 4 I/O PORT
4.4 Port 2
Port 2 is a general-purpose I/O port that serves as the resource I/O pin. Use port 2 by
switching between the resource pin and the general-purpose I/O port.
The function as a general-purpose I/O port is mainly described here. The configuration,
pin assignment, block diagram of the pins, and registers for port 2 are shown below.
■ Configuration of Port 2
Port 2 consists of the following four elements:
• General-purpose I/O port, resource I/O pin (P20/TIN0 to P27/INT7)
• Port 2 data register (PDR2)
• Port 2 direction register (DDR2)
• High address control register (HACR)
■ Pin Assignment of Port 2
• If the single-chip mode is set, use port 2 by switching between the resource pin and the general-purpose
I/O port.
• Since port 2 serves as resource pin, when used as a resource pin port 2 cannot be used as general-
purpose I/O port.
• When using port 2 as the input pin of the resource, set the pin corresponding to the resource in the
DDR2 as an input port.
• When using port 2 as the output of the resource, set the output of the corresponding resource to
"enabled". Port 2 functions as the output pin of the resource regardless of the settings of the DDR2.
Table 4.4-1 "Pin Assignment of Port 2" shows the pin assignment for port 2.
I/O Type
Port Circuit
Pin Name Port Function Resource
Name Type
Input Output
166
CHAPTER 4 I/O PORT
PDR read
Internal data bus
Output latch P ch
PDR write
Pin
Port direction register (DDR)
Direction latch N ch
DDR write
Standby control: Control of stop mode (SPL = 1), timebase timer mode (SPL = 1), and timer mode (SPL = 1)
PDR2, DDR2 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
Port 2
Corresponding pin P27 P26 P25 P24 P23 P22 P21 P20
167
CHAPTER 4 I/O PORT
Table 4.4-3 "Function of Registers for Port 2" shows the functions of the registers for port 2.
Read/ Register
Register Name Data At Read At Write Reset Value
Write Address
The
The output buffer is set to OFF, and
0 direction
the pin becomes an input port pin.
Port 2 direction latch is 0."
R/W 000012H 00000000B
register (DDR2) The
The output buffer is set to ON, and
1 direction
the pin becomes an output port pin.
latch is 1.
R/W: Read/Write
X: Undefined value
References: • When using port 2 as the input pin of the resource, clear the bit in the DDR2 corresponding to the
input pin of the resource to 0 and set the input pin as an input port.
• When using port 2 as the output pin of the resource, set the output of the corresponding resource to
"enabled". Port 2 functions as the output pin of the resource regardless of the settings of the DDR2.
168
CHAPTER 4 I/O PORT
Note: If read modify write instructions (such as the bit set instruction) are used to read the PDR, the pin set as
an output port by the DDR outputs the desired data. However, the pin set as an input port outputs data
after the input state is written to the output latch. When switching from the input port to the output port,
write data to the PDR and set the pin as an output port in the DDR.
● Operation at reset
• When the CPU is reset, the value of the DDR2 is initialized to 0. Consequently, all output buffers are set
to OFF (the pin becomes an input port pin), and the pin enters the high-impedance state.
• The PDR2 is not initialized by reset. Therefore, when using port 2 as an output port, it is necessary to set
output data in the PDR2, and then set the bit in the DDR2 corresponding to the output pin to 1, and then,
to output.
169
CHAPTER 4 I/O PORT
P20/TIN0 to General-purpose I/O General-purpose I/O General-purpose I/O Input cut off, and
P27/INT7 port port port output becomes Hi-Z
SPL: Pin state specification bit of low power consumption mode control register (LPMCR: SPL)
Hi-Z: High impedance
Note: To set a pin to high impedance when the pin is shared by a peripheral function and a port in stop mode,
watch mode or timebase timer mode, disable the output of peripheral functions, and set the STP bit to 1 or
set the TMD bit to 0.
This applies to the following pins:
P21/TOT0, P23/TOT1
170
CHAPTER 4 I/O PORT
4.5 Port 3
Port 3 is a general-purpose I/O port that serves as the resource I/O pin. Use port 3 by
switching between the resource pin and the general-purpose I/O port.
The function as a general-purpose I/O port is mainly described here. The configuration,
pin assignment, block diagram of the pins, and registers for port 3 are shown below.
■ Configuration of Port 3
Port 3 consists of the following three elements:
• General-purpose I/O port, resource output pin (P30 to P33, P35*/X0A, P36*/X1A, P37/ADTG)
• Port 3 data register (PDR3)
• Port 3 direction register (DDR3)
■ Pin Assignment of Port 3
• Use port 3 by switching between the resource pin and the general-purpose I/O port.
• Since port 3 serves as a resource pin, when used as a resource pin, port 3 cannot be used as general-
purpose I/O port.
• When using port 3 as the resource I/O pin, set the pin corresponding to the resource in the DDR3 as an
input port.
Table 4.5-1 "Pin Assignment of Port 3" shows the pin assignment of port 3.
I/O Type
Port Circuit
Pin Name Port Function Resource
Name Type
Input Output
P30 P30 − −
P31 P31 − −
D
P32 P32 − −
P33 P33 General-purpose I/O − − CMOS
Port 3 CMOS
port (hysteresis)
P35/X0A P35* − − D/A
P36/X1A P36* − − D/A
External trigger input
P37/ADTG P37 ADTG D
for A/D converter
*: If the low-speed oscillation pin is selected (for MB90387 or MB90F387), P35 and P36 pins cannot be used.
171
CHAPTER 4 I/O PORT
PDR read
Internal data bus
Output latch P ch
PDR write
Pin
Port direction register (DDR)
Direction latch N ch
DDR write
Standby control: Control of stop mode (SPL = 1), timebase timer mode (SPL = 1), and timer mode (SPL = 1)
Port
Bits of Related Registers and Corresponding Pin
Name
PDR3, DDR3 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
Port 3
Corresponding pin P37 P36* P35* − P33 P32 P31 P30
172
CHAPTER 4 I/O PORT
Table 4.5-3 "Function of Registers for Port 3" shows the functions of the registers for port 3.
Read/ Register
Register Name Data At Read At Write Reset Value
Write Address
The
The output buffer is set to OFF, and
0 direction
the pin becomes an input port pin.
Port 3 direction latch is 0.
R/W 000013H 000X0000B
register (DDR3) The
The output buffer is set to ON, and
1 direction
the pin becomes an output port pin
latch is 1.
R/W: Read/Write
X: Undefined value
References: • When using port 3 as the input pin of the resource, clear the bit in the (DDR3) corresponding to the
input pin of the resource to 0 and set the input pin as an input port.
• When using port 3 as the output pin of the resource, set the output of the corresponding resource to
"enabled". Port 2 functions as the output pin of the resource regardless of the settings of the DDR3.
173
CHAPTER 4 I/O PORT
■ Operation of Port 3
Note: If read modify write instructions (such as the bit set instruction) are used to read the port data register
(PDR), the pin set as an output port by the port direction register (DDR) outputs the desired data.
However, the pin set as an input port outputs data after the input state is written to the output latch. When
switching from the input port to the output port, write data to the PDR and set the pin as an output port in
the DDR.
● Operation at reset
• When the CPU is reset, the value of the DDR3 is cleared to 0. Consequently, all output buffers are set to
OFF (the pin becomes an input port pin), and the pin enters the high-impedance state.
• The PDR3 is not initialized by reset. Therefore, when using port 3 as an output port, it is necessary to set
output data in the PDR3, and then set the bit in the DDR3 corresponding to the output pin to 1 and to
output.
174
CHAPTER 4 I/O PORT
Table 4.5-4 "State of Port 3 Pins" shows the state of the port 3 pins.
P30 to P33,
General-purpose I/O General-purpose I/O General-purpose I/O Input cut off, and
P35/X0A to P37/
port port port output becomes Hi-Z
ADTG
SPL: Pin state specification bit of low power consumption mode control register (LPMCR: SPL)
Hi-Z: High impedance
175
CHAPTER 4 I/O PORT
4.6 Port 4
Port 4 is a general-purpose I/O port that serves as the resource I/O. Use port 4 by
switching between the resource pin and the general-purpose I/O port.
The function as a general-purpose I/O port is mainly described here. The configuration,
pin assignment, block diagram of the pins, and registers for port 4 are shown below.
■ Configuration of Port 4
Port 4 consists of the following three elements:
• General-purpose I/O port, resource I/O pin (P40/SIN1 to P44/RX)
• Port 4 data register (PDR4)
• Port 4 direction register (DDR4)
■ Pin Assignment of Port 4
• Use port 4 by switching between the resource pin and the general-purpose I/O port.
• Since port 4 serves as a resource pin, it cannot be used as a general-purpose I/O port when used as a
resource.
• When using port 4 as the input pin of the resource, set the pin corresponding to the resource in the
DDR4 as an input port.
• When using port 4 as the output pin of the resource, set the output of the corresponding resource to
"enabled". Port 4 functions as the output pin of the resource regardless of the settings of the DDR4.
Table 4.6-1 "Pin Assignment of Port 4" shows the pin assignment of port 4.
I/O Type
Port Circuit
Pin Name Port Function Resource
Name Type
Input Output
UART1 serial
P40/SIN1 P40 SIN1
data input
UART1 serial
P41/SCK1 P41 SCK1
clock I/O
UART1 serial
P42/SOT1 P42 General- SOT1
data output CMOS
Port 4 purpose I/O CMOS D
(hysteresis)
port CAN
P43/TX P43 TX controller
send output
CAN
P44/RX P44 RX controller
receive input
176
CHAPTER 4 I/O PORT
PDR read
Internal data bus
Output latch P ch
PDR write
Pin
Port direction register (DDR)
Direction latch N ch
DDR write
Standby control: Control of stop mode (SPL = 1), timebase timer mode (SPL = 1), and timer mode (SPL = 1)
177
CHAPTER 4 I/O PORT
Read/ Register
Register Name Data At Read At Write Reset Value
Write Address
The
The output buffer is set to OFF, and
0 direction
the pin becomes an input port pin.
Port 4 direction latch is 0.
R/W 000014H XXX00000B
register (DDR4) The
The output buffer is set to ON, and
1 direction
the pin becomes an output port pin.
latch is 1.
R/W: Read/Write
X: Undefined value
References: • When using port 4 as the input pin of the resource, clear the bit in the DDR4 corresponding to the
input pin of the resource to 0 and set the input pin as an input port.
• When using port 4 as the output pin of the resource, set the output of the corresponding resource to
"enabled". Port 4 functions as the output pin of the resource regardless of the settings of the DDR4.
178
CHAPTER 4 I/O PORT
■ Operation of Port 4
Note: If read modify write instructions (such as the bit set instruction) are used to read the PDR, the pin set as
an output port by the DDR outputs the desired data. However, the pin set as an input port outputs data
after the input state is written to the output latch. When switching from the input port to the output port,
write data to the PDR and set the pin as an output port in the DDR.
179
CHAPTER 4 I/O PORT
● Operation at reset
• When the CPU is reset, the value of the DDR4 is initialized to 0. Consequently, all output buffers are set
to OFF (the pin becomes an input port pin), and the pin enters the high-impedance state.
• The PDR4 is not initialized by reset. Therefore, when using port 4 as an output port, it is necessary to set
output data in the PDR4, and then set the bit in the DDR4 corresponding to the output pin to 1 and to
output.
SPL: Pin state specification bit of low power consumption mode control register (LPMCR: SPL)
Hi-Z: High impedance
180
CHAPTER 4 I/O PORT
4.7 Port 5
Port 5 is a general-purpose I/O port that serves as the analog input pin. Use port 5 by
switching between the analog input pin and the general-purpose I/O port.
The function as a general-purpose I/O port is mainly described here. The configuration,
pin assignment, block diagram of the pins, and registers for port 5 are shown below.
■ Configuration of Port 5
Port 5 consists of the following four elements:
• General-purpose I/O port, analog input pins (P50/AN0 to P57AN7)
• Port 5 data register (PDR5)
• Port 5 direction register (DDR5)
• Analog input enable register (ADER)
■ Pin Assignment of Port 5
• Use port 5 by switching between the analog input pin and the general-purpose I/O port.
• Since port 5 serves as an analog input pin, it cannot be used as a general-purpose I/O port when used as
an analog input pin.
• When using port 5 as an analog input pin, set the pin corresponding to the analog input in the DDR5 as
an input port.
• When using port 5 as a general-purpose I/O port, do not input any analog signal.
Table 4.7-1 "Pins Assignment of Port 5" shows the pin assignment of port 5.
I/O Type
Port Circuit
Pin Name Port Function Resource
Name Type
Input Output
181
CHAPTER 4 I/O PORT
Analog input
ADER
PDR read
Output latch
P ch
PDR write
Pin
DDR (port direction register)
Direction latch N ch
DDR write
Standby control: Control of stop mode (SPL = 1), timebase timer mode (SPL = 1), and timer mode (SPL = 1)
Port
Bits of Related Registers and Corresponding Pins
Name
PDR5, DDR5 bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0
Port 5 ADER ADE7 ADE6 ADE5 ADE4 ADE3 ADE2 ADE1 ADE0
Corresponding pin P57 P56 P55 P54 P53 P52 P51 P50
182
CHAPTER 4 I/O PORT
Note: When a middle-level signal is input with port 5 set as an input port, input leakage current flows.
Therefore, when inputting an analog signal, set the corresponding ADE bit in the ADER to "analog input
enabled."
183
CHAPTER 4 I/O PORT
Read/ Register
Register Name Data At Read At Write Reset Value
Write Address
The
The output buffer is set to OFF, and
0 direction
the pin becomes an input port pin.
Port 5 direction latch is 0.
R/W 000015H 00000000B
register (DDR5) The
The output buffer is set to ON, and
1 direction
the pin becomes an input port pin.
latch is 1.
R/W: Read/Write
X: Undefined value
References: • When using port 5 as the analog input pin, clear the bit in the DDR5 corresponding to the analog input
pin to 0 and set the input pin as an input port.
• When using port 5 as the input pin of the resource, clear the bit in the DDR5 corresponding to the
input pin of the resource to 0 and set the input pin as an input port.
184
CHAPTER 4 I/O PORT
■ Operation of Port 5
Note: If read modify write instructions (such as the bit set instruction) are used to read the PDR, the pin set as
an output port by the DDR outputs the desired data. However, the pin set as an input port outputs data
after the input state is written to the output latch. When switching from the input port to the output port,
write data to the PDR and set the pin as an output port in the DDR
● Operation at reset
• When the CPU is reset, the value of the DDR5 is initialized to 0. Consequently, all output buffers are set
to OFF (the pin becomes an input port pin), and the pin enters the high-impedance state.
• The PDR5 is not initialized by reset. Therefore, when using port 5 as an output port, it is necessary to set
output data in the PDR5, and then set the bit in the DDR5 corresponding to the output pin to 1 and to
output.
185
CHAPTER 4 I/O PORT
P50/AN0 to General-purpose I/O General-purpose I/O General-purpose I/O Input cut off, and
P57/AN7 port port port output becomes Hi-Z
SPL: Pin state specification bit of low power consumption mode control register (LPMCR: SPL)
Hi-Z: High impedance
186
CHAPTER 5
TIMEBASE TIMER
187
CHAPTER 5 TIMEBASE TIMER
The timebase timer is an 18-bit free-run counter (timebase timer counter) that
increments in synchronization with the main clock (2-divided frequency of main
oscillation clock).
• Four interval times can be selected and an interrupt request can be generated for
each interval time.
• An operation clock is supplied to the oscillation stabilization wait time timer and
other resources.
188
CHAPTER 5 TIMEBASE TIMER
■ Clock Supply
• The timebase timer supplies an operation clock to the resources such as an oscillation stabilization wait
time timer, PPG timer, and watchdog timer. Table 5.1-2 "Clock Cycles Supplied from Timebase Timer"
shows the clock cycles supplied from the timebase timer.
189
CHAPTER 5 TIMEBASE TIMER
To watchdog
To PPG timer timer
Timebase timer counter
21/HCLK × 21 × 22 × 23 . . .. . . × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215 × 216 × 217 × 218
OF OF
OF
OF
To the oscillation
stabilization wait time
selector in the clock
Power-on reset control section
Stop mode Counter
Interval timer
CKSCR: MCS = 1 → 0*1 clesr circuit
selector
CKSCR: SCS = 0 → 1*2
TBOF set
TBOF clear
190
CHAPTER 5 TIMEBASE TIMER
191
CHAPTER 5 TIMEBASE TIMER
This section explains the registers and interrupt factors of the timebase timer.
bit 15 14 13 12 11 10 9 8
Timebase timer control register (TBTC)
1 × × 0 0 1 0 0
×: Undefined
192
CHAPTER 5 TIMEBASE TIMER
The timebase timer control register (TBTC) provides the following settings:
• Selecting the interval time of the timebase timer
• Clearing the count value of the timebase timer
• Enabling or disabling the interrupt request when an overflow occurs
• Checking and clearing the state of the interrupt request flag when an overflow occurs
15 14 13 12 11 10 9 8
Reset value
1XX00100B
R/W R/W R/W W R/W R/W
bit 9 bit 8
TBC1 TBC0 Interval time select bits
0 0 212/HCLK (Approx. 1.0ms)
0 1 214/HCLK (Approx. 4.1ms)
1 0 216/HCLK (Approx. 16.4ms)
1 1 219/HCLK (Approx. 131.1ms)
HCLK: Oscillation clock
The parenthesized values are provided at 4 MHz oscillation clock.
bit 10
Timebase timer counter clear bit
TBR
Read Write
0 Clears the timebase timer
counter and TBOF bit
bit 11
Overflow interrupt request flag bit
TBOF
Read Write
0 No overflow from the Cleared
selected count bit
1 Overflow from the No effect
selected count bit
bit 12
TBIE Overflow interrupt enable bit
0 Overflow interrupt request disabled
1 Overflow interrupt request enabled
bit 15
Reserved Reserved bit
1 Always write 1 to this bit
R/W : Read/Write
W : Write only
X : Undefined
: Reset value
: Unused
193
CHAPTER 5 TIMEBASE TIMER
bit 8 TBC1, TBC0: These bits set the cycle of the interval timer in the timebase timer counter.
bit 9 Interval time select bits • The interval time of the timebase timer is set according to the setting of the
TBC1 and TBC0 bits.
• Four interval times can be set.
bit 10 TBR: This bit clears all the bits in the timebase timer counter.
Timebase timer counter When set to 0: All the bits in the timebase timer counter are cleared to 0. The
clear bit TBOF bit is also cleared.
When set to 1: Disabled. The state remains unchanged.
Read: 1 is always read.
bit 11 TBOF: This bit indicates an overflow (carrying) in the time interval bit in the timebase
Overflow interrupt timer counter.
request flag bit When an overflow (carrying) occurs with interrupts enabled (TBIE = 1), an
interrupt request is generated.
When set to 0: The bit is cleared.
When set to 1: Disabled. The state remains unchanged.
Reading by read-modify-write type instructions always returns "1".
Notes:
1. To clear the TBOF bit, disable interrupts (TBIE = 0) or mask interrupts using
the interrupt mask register (ILM) in the processor status.
2. The TBOF bit is cleared when 0 is written to the bit, a transition to main stop
mode, a transition to PLL stop mode, a transition from subclock mode to
main clock mode, a transition from subclock mode to PLL clock mode, or a
transition from main clock mode to PLL clock mode occurs, 0 is written to
the timebase timer counter clear bit (TBR), or by a reset.
bit 12 TBIE: This bit enables or disables an interrupt when the interval time bit in the timebase
Overflow interrupt timer counter overflows.
enable bit When set to 0: No interrupt request is generated at an overflow (TBOF = 1).
When set to 1: An interrupt request is generated at an overflow (TBOF = 1).
bit 13 Unused bits Read: The value is undefined.
bit 14 Write: No effect
194
CHAPTER 5 TIMEBASE TIMER
The timebase timer generates an interrupt request when the interval time bit in the
timebase timer counter corresponding to the interval time set by the timebase timer
control register overflows (carries) (interval timer function).
Note: When an interrupt is enabled (TBTC: TBIE = 1) with the overflow interrupt request flag bit in the
timebase timer control register set (TBTC: TBOF = 1), an interrupt request is generated immediately.
195
CHAPTER 5 TIMEBASE TIMER
The timebase timer operates as an interval timer or an oscillation stabilization wait time
timer, and supplies a clock to resources.
bit 15 14 13 12 11 10 9 bit 8
Timebase timer control register Reserved TBIE TBOF TBR TBC1TBC0
(TBTC)
1 0 0
Ñ : Unused bit
: Used bit
0 : Set 0
1 : Set 1
Note: The interval time may become longer than the one set by clearing the timebase timer counter.
196
CHAPTER 5 TIMEBASE TIMER
Counter value
Cleared by transition
3FFFFH
to stop mode
Oscillation stabilization
wait overflow
00000 H
TBOF bit
TBIE bit
Sleep
SLP bit
(LPMCR register)
Releasing of sleep mode by interval
interrupt of timebase timer
Stop
STP bit
(LPMCR register)
When interval time selec bit (TBTC: TBC1, TBC0) is set to "11B" (219/HCLK)
: Oscillation stabilization wait time
HCLK : Oscillation clock
197
CHAPTER 5 TIMEBASE TIMER
Table 5.5-1 Clearing Conditions and Oscillation Stabilization Wait Time of Timebase Timer
Counter TBOF
Operation Oscillation Stabilization Wait Time
Clear Clear
198
CHAPTER 5 TIMEBASE TIMER
Note: Clearing the timebase timer counter may affect the operation of the resources such as the watchdog timer
and PPG timers using the output of the timebase timer.
For details of the PPG timers, see CHAPTER 10 "8-/16-BIT PPG TIMER".
For details of the watchdog timer, see CHAPTER 6 "WATCHDOG TIMER".
199
CHAPTER 5 TIMEBASE TIMER
This section explains the precautions when using the timebase timer.
For details of the oscillation stabilization wait time, see 3.7.5 "Oscillation Stabilization Wait Time".
200
CHAPTER 5 TIMEBASE TIMER
● Processing specification
The 212/HCLK (HCLK: oscillation clock) interval interrupt is generated repeatedly. In this case, the
interval time is approximately 1.0 ms (at 4-MHz operation).
● Coding example
201
CHAPTER 5 TIMEBASE TIMER
202
CHAPTER 6
WATCHDOG TIMER
203
CHAPTER 6 WATCHDOG TIMER
The watchdog timer is a 2-bit counter that uses the timebase timer or watch timer as a
count clock. If the counter is not cleared within a set interval time, the CPU is reset.
Approx. 3.58 ms Approx.4.61 ms 214 + 211/HCLK Approx. 0.457 s Approx. 0.576 s 212 + 29/SCLK
Approx. 14.33 ms Approx. 18.3 ms 216 + 213/HCLK Approx. 3.584 s Approx. 4.608 s 215 + 212/SCLK
Approx. 57.23 ms Approx. 73.73 ms 218 + 215/HCLK Approx. 7.168 s Approx. 9.216 s 216 + 213/SCLK
Approx. 458.75 ms Approx. 589.82 ms 221 + 218/HCLK Approx. 14.336 s Approx. 18.432 s 217 + 214/SCLK
HCLK: Oscillation clock (4 MHz), SLCK: Subclock (8.192 kHz)
Notes: • If the timebase timer output (carry signal) is used as a count clock to the watchdog timer, the timebase
timer is cleared and the time for the watchdog reset to occur may be long.
• If the subclock is used as a machine cock, always set the watchdog timer clock source select bit
(WDCS) in the watch timer control register (WTC) to 0 to select the watch timer output.
204
CHAPTER 6 WATCHDOG TIMER
Watchdog timer control register (WDTC) Watch timer control register (WTC)
PONR WRST ERST SRST WTE WT1 WT0 WDCS
Watchdog timer 2
Started
Reset generated
Transits to sleep mode Watchdog
Counter claer Count clock 2-bit To the internal
Transits to reset
timebase timer mode controller selector counter reset generator
generator
Transits to timer mode
Transits to stop mode Clear
4
4
(Watch counter)
Subclock
SCLK × 21 × 22 . . . × 25 × 26 × 27 × 28 × 29 × 210 × 211 × 212 × 213 × 214 × 215
205
CHAPTER 6 WATCHDOG TIMER
206
CHAPTER 6 WATCHDOG TIMER
This section explains the registers used for setting the watchdog timer.
bit 7 6 5 4 3 2 1 0
Watchdog timer control register
(WDTC)
× × × × × 1 1 1
×: Undefined
207
CHAPTER 6 WATCHDOG TIMER
The watchdog timer control register starts and clears the watchdog timer, sets the
interval time, and holds reset factors.
7 6 5 4 3 2 1 0
Reset value
XXXXX111 B
R R R R W W W
bit 1 bit 0
Interval time select bits (Timebase timer output selection)
WT1 WT0 Interval time
Clock cycle
Minimum Maximum
0 0 Approx. 3.58 ms Approx. 4.61 ms 214 ± 211/HCLK
0 1 Approx. 14.33 ms Approx. 18.3 ms 216 ± 213/HCLK
1 0 Approx. 57.23 ms Approx. 73.73 ms 218 ± 215/HCLK
1 1 Approx. 458.75 ms Approx. 589.82 ms 221 ± 218/HCLK
HCLK: Oscillation clock
bit 1 bit 0
Interval time select bits (Watch timer output selection)
WT1 WT0 Interval time
Clock cycle
Minimum Maximum
0 0 Approx. 0.457 s Approx. 0.576 s 212 ± 29/SCLK
0 1 Approx. 3.584 s Approx. 4.608 s 215 ± 212/SCLK
1 0 Approx. 7.168 s Approx. 9.216 s 216 ± 213/SCLK
1 1 Approx. 14.336 s Approx. 18.432 s 217 ± 214/SCLK
SCLK: Subclock
bit 2
WTE Watchdog timer control bit
0 First write after reset: starts the Second or subsequent write after
watchdog timer reset: clears of the watchdog timer
1 No effect
208
CHAPTER 6 WATCHDOG TIMER
bit 0, WT1, WT0: These bits set the interval time of the watchdog timer.
bit 1 Time interval select bits The time interval when the watch timer is used as the clock source to the
watchdog timer (watchdog clock select bit WDCS = 0) is different from when
the main clock mode or the PLL clock mode is selected as the clock mode and
the WDCS bit in the watch timer control register (WTC) is set to 1 as shown in
Figure 6.3-2 "Watchdog Timer Control Register (WDTC)" according to the
settings of the WTC register.
• Only data when the watchdog timer is started is enabled.
• Write data after the watchdog timer is started is ignored.
• These are write-only bits.
bit 2 WTE: This bit starts or clears the watchdog timer.
Watchdog timer control When set to 0 (first time after reset): The watchdog timer is started.
bit When set to 0 (second or subsequent): The watchdog timer is cleared.
209
CHAPTER 6 WATCHDOG TIMER
After starting, when the watchdog timer reaches the set interval time without the
counter being cleared, a watchdog reset occurs.
bit 7 6 5 4 3 2 1 bit 0
Watchdog timer control register PONR WRST ERST SRST WTE WT1 WT0
(WDTC)
0
bit 7 6 5 4 3 2 1 bit 0
Watch timer control register WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0
(WTC)
: Used bit
0 : Set "0"
210
CHAPTER 6 WATCHDOG TIMER
211
CHAPTER 6 WATCHDOG TIMER
Figure 6.4-2 Relationship between Clear Timing and Interval Time of Watchdog Timer
[Minimum interval time] When the WTE bit is cleared immediately before the count clock rises
Count starts
Counter cleared
Count clock a
Count enable
Reset signal d
Count clock a
Count enable
Reset signal d
212
CHAPTER 6 WATCHDOG TIMER
● Interval time
• The interval time uses the carry signal of the time-base timer or watch timer as a count clock. If the
time-base timer or watch timer is cleared, the interval time of the watchdog timer may become long.
The time-base timer is also cleared by writing zero to the timebase timer counter clear bit (TBR) in the
time-base timer control register (TBTC); transition from main clock mode to PLL clock mode;
transition from subclock mode to main clock mode; and transition from subclock mode to PLL clock
mode.
• Set the interval time concurrently with starting the watchdog timer. Setting the time interval except
starting the watchdog timer is ignored.
213
CHAPTER 6 WATCHDOG TIMER
● Processing specification
• The watchdog timer is cleared each time in loop of the main program.
• The main program must be executed once within the minimum interval time of the watchdog timer.
● Coding example
214
CHAPTER 7
16-BIT INPUT/OUTPUT
TIMER
215
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
The 16-bit input/output timer is a complex module that consists of a 16-bit free-run timer
(x 1 unit) and an input capture (x 2 units/4 input pins). The clock cycle of an input signal
and a pulse width can be measured based on the 16-bit input/output timer.
216
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
● Input capture
The input capture detects the rising edge, falling edge, or both edges of the external signal input to the input
pins to retain the count value of the 16-bit free-run timer. Detecting the edge of the input signal generates
an interrupt.
217
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
Free-run timer
φ : Machine clock interrupt request
OF : Overflow
● Prescaler
The prescaler divides the frequency of machine clock to supply a count clock to the 16-bit up counter. Any
of eight machine clock division ratios are selected by setting the timer counter control status register
(TCCS).
218
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
219
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
IN2
Pin Input capture data register 2 (IPCP2)
2
/
/
2
Input capture control
status register (ICS23) ICP1 ICP0 ICE1 ICE0 EG11 EG10 EG01 EG00
2
/
/
IN1 2
IN0
Pin Input capture data register 0 (IPCP0)
220
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
Table 7.2-1 Pins and Interrupt Request Numbers of 16-bit Input/Output Timer
IN2 P12/IN2
#30 (1EH)
IN3 P13/IN3
● Edge detector
The edge detection circuit detects the edge of the external signal input to the input pins. The detected edge
can be selected from the rising edge, falling edge, and both edges.
221
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
This section explains the pins, registers, and interrupt factors of the 16-bit input/output
timer.
IN0 General-purpose I/O port, capture input Set as input port in port direction register (DDR).
IN1 General-purpose I/O port, capture input Set as input port in port direction register (DDR).
IN2 General-purpose I/O port, capture input Set as input port in port direction register (DDR).
IN3 General-purpose I/O port, capture input Set as input port in port direction register (DDR).
222
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
Figure 7.3-1 List of Registers and Reset Values of 16-bit Input/Output Timer
bit 7 6 5 4 3 2 1 0
Timer counter control status register
(TCCS) 0 0 0 0 0 0 0 0
bit 15 14 13 12 11 10 9 8
Timer counter data register (High)
(TCDT: H) 0 0 0 0 0 0 0 0
bit 7 6 5 4 3 2 1 0
Timer counter data register (Low)
(TCDT: L) 0 0 0 0 0 0 0 0
bit 7 6 5 4 3 2 1 0
Input capture control status register
(ICS01) 0 0 0 0 0 0 0 0
bit 15 14 13 12 11 10 9 8
Input capture data register 0 (High)
(IPCP0: H) × × × × × × × ×
bit 7 6 5 4 3 2 1 0
Input capture data register 0 (Low)
(IPCP0: L) × × × × × × × ×
bit 15 14 13 12 11 10 9 8
Input capture data register 1 (High)
(IPCP1: H) × × × × × × × ×
bit 7 6 5 4 3 2 1 0
Input capture data register 1 (Low)
(IPCP1: L) × × × × × × × ×
bit 7 6 5 4 3 2 1 0
Input capture control status register
(ICS23) 0 0 0 0 0 0 0 0
bit 15 14 13 12 11 10 9 8
Input capture data register 2 (High)
(IPCP2: H) × × × × × × × ×
bit 7 6 5 4 3 2 1 0
Input capture data register 2 (Low)
(IPCP2: L) × × × × × × × ×
bit 15 14 13 12 11 10 9 8
Input capture data register 3 (High)
(IPCP3: H) × × × × × × × ×
bit 7 6 5 4 3 2 1 0
Input capture data register 3 (Low)
(IPCP3: L) × × × × × × × ×
×: Undefined
223
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
224
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
The timer counter control status register (TCCS) selects the count clock and conditions
for clearing the counter, clears the counter, enables or disables the count operation or
interrupt, and checks the interrupt request flag.
7 6 5 4 3 2 1 0
Reset value
00000000 B
bit 5
STOP Timer count bit
0 Counting enable
1 Counting disable
bit 6
IVFE Overflow interrupt enable bit
0 Overflow interrupt disable
1 Overflow interrupt enable
bit 7
Overflow generation flag bit
IVF
Read Write
0 No overflow Clear
R/W : Read/Write 1 Overflow No effect
: Reset value
225
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
bit 0 CLK2, CLK1, CLK0: These bits set the count clock to the 16-bit free-run time.
bit 1 Count clock select bits Note:
bit 2 1. Set the count clock after stopping the count operation (STOP = 1).
2. When rewriting the count clock, write 1 to the timer counter clear bit (CLR)
and clear the count value.
bit 3 CLR: This bit clears the count value of the 16-bit free-run timer.
Timer count clear bit When set to 1: Clears timer counter data register (TCDT) to "0000H"
When set to 0: No effect
Read: 0 is always read.
• When the count value changes, the CLR bit is cleared.
• When clearing the count value while stopping the count operation, write
"0000H" to the timer counter data register (TCDT).
bit 5 STOP: This bit enables or disables (stops) the count operation of the 16-bit free-run
Timer count bit timer.
When set to 0: Enables count operation
The 16-bit timer counter data register (TCDT) starts incrementing in
synchronization with the count clock selected by the count clock select bits
(CLK1 and CLK0).
When set to 1: Stops count operation
bit 6 IVFE: This bit enables or disables an interrupt request generated when the 16-bit free-
Overflow interrupt run timer overflows.
enable bit When set to 0: No interrupt request generated at overflow (IVF = 1)
When set to 1: Generates interrupt request at overflow (IVF = 1)
bit 7 IVF: This bit indicates that the 16-bit free-run timer has overflowed.
Overflow generation flag • If the 16-bit free-run timer overflows or mode setting causes a compare match
bit with the compare register 0 to clear the counter, this bit is set to 1.
• When an overflow occurs with an overflow interrupt enabled (IVFE = 1), an
interrupt request is generated.
When set to 0: Clears bit
When set to 1: No effect
When EI2OS started: Bit cleared
Read by read modify write instructions: 1 is always read.
226
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
The timer counter data register (TCDT) is a 16-bit up counter. At read the register value
being counted is read. At write while the counter is stopped, any count value can be set.
bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 Reset value
Timer counter data T15 T14 T13 T12 T11 T10 T9 T8 00000000B
register (TCDT): High
R/W R/W R/W R/W R/W R/W R/W R/W
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Reset value
Timer counter data T7 T6 T5 T4 T3 T2 T1 T0 00000000B
register (TCDT): Low
R/W R/W R/W R/W R/W R/W R/W R/W
R/W: Read/Write
Note: Always use a word instruction (MOVW) to set the timer counter data register (TCDT).
227
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
The input capture control status registers sets the operation of input captures. The
ICS01 register sets the operation of input captures 0 and 1 and the ICS23 sets the
operation of input captures 2 and 3.
The input capture control status registers provides the following settings:
• Selecting the edge to be detected
• Enabling or disabling an interrupt when the edge is detected
• Checking and clearing the valid edge detection flag when the edge is detected
Figure 7.3-4 Input Capture Control Status Registers (ICS01 and ICS23)
7 6 5 4 3 2 1 0
Reset value
0 0 0 0 0 0 0 0 B
bit 5
ICE1 Input capture 1 (3) Interrupt enable bit
0 Input capture 1 (3) Interrupt disable
1 Input capture 1 (3) Interrupt enable
bit 6
Input capture 0 (2) Valid edge detection flag bit
ICP0
Read Write
0 Input capture 0 (2) Clears ICP0 bit
No valid edge detected
1 Input capture 0 (2) No effect
Valid edge detected
bit 7
Input capture 1 (3) Valid edge detection flag bit
ICP1
Read Write
0 Input capture 1 (3) Clears ICP1 bit
No valid edge detected
1 Input capture 1 (3) No effect
R/W : Read/Write Valid edge detected
: Reset value
The numbers in parentheses indicate channel number of ICS 23.
228
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
bit0 EG01, CEG00: These bits enable or disable the operation of input capture 0.
bit1 Input capture 0 edge The edge detected by input capture 0 is selected when the operation of input
select bits capture 0 is enabled.
EG01, EG00 = "00B":
The operation of input capture 0 is disabled and no edge is detected.
EG01, EG00 "00B":
The operation of input capture 0 is enabled and the edge is detected.
bit 2 EG11, EG10: These bits enable or disable the operation of input capture 1.
bit 3 Input capture 1 edge The edge detected by input capture 1 is selected when the operation of input
select bits capture 1 is enabled.
EG01, EG00 = "00B":
The operation of input capture 1 is disabled and no edge is detected.
EG01, EG00 "00B":
The operation of input capture 1 is enabled and the edge is detected.
bit 4 ICE0: This bit enables or disables an interrupt when the edge is detected by input
Input capture 0 interrupt capture 0.
enable bit When set to 0:
No interrupt is generated even when the valid edge is detected by input
capture 0.
When set to 1:
An interrupt is generated when the valid edge is detected by input capture 0.
bit 5 ICE1: This bit enables or disables an interrupt when the edge is detected by input
Input capture 1 interrupt capture 1.
enable bit When set to 0:
No interrupt is generated even when the edge is detected by input capture 1.
When set to 1:
An interrupt is generated when the edge is detected by input capture 1.
bit 6 ICP0: This bit indicates the edge detection by input capture 0.
Input capture 0 valid • When the valid edge selected by the input capture 0 edge select bits (EG01,
edge detection flag bit EG00) is detected, the ICP0 bit is set to 1.
• When the valid edge is detected by input capture 0 (ICP0 = 1) when an
interrupt due to the edge detection by input capture 0 is enabled (ICE0 = 1),
an interrupt is generated.
When set to 0:
The bit is cleared.
When set to 1:
No effect
When EI2OS started:
The bit is cleared.
Read by read modify write instructions:
1 is always read.
229
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
bit 7 ICP1: This bit indicates the edge detection by input capture 1.
Input capture 1 valid • When the valid edge selected by the input capture 1 edge select bits (EG11,
edge detection flag bit EG10) is detected, the ICP1 bit is set to 1.
• When the valid edge is detected by input capture 1 (ICP1 = 1) when an
interrupt due to the edge detection by input capture 1 is enabled (ICE1 = 1),
an interrupt is generated.
When set to 0:
The bit is cleared.
When set to 1:
No effect
When EI2OS started:
The bit is cleared.
Read by read modify write instructions:
1 is always read.
230
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
The input capture data registers 0 to 3 (IPCP0 to IPCP3) store the counter value of the
16-bit free-run timer read in the timing with the edge detection by the input capture. The
counter value of the 16-bit free-run timer is stored in the input capture data registers
(IPCP0 to IPCP3) corresponding to the input pins (IN0 to IN3) to which an external signal
is input.
bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 Reset value
Input capture data CP15 CP14 CP13 CP12 CP11 CP10 CP9 CP8 XXXXXXXX B
register (IPCP): High
R R R R R R R R
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Reset value
Input capture data CP7 CP6 CP5 CP4 CP3 CP2 CP1 CP0 XXXXXXXX B
register (IPCP): Low
R R R R R R R R
R: Read only
X: Undefined
Note: Always use a word instruction (MOVW) to read the input capture data registers 0 to 3 (IPCP0 to IPCP3).
231
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
The interrupt factors of the 16-bit input/output timer include an overflow in the 16-bit
free-run timer and edge detection by the input capture. Interrupt generation starts
EI2OS.
Table 7.4-1 Interrupt Control Bits and Interrupt Factors of 16-bit Input/Output Timer
Overflow in counter value of Valid edge input to input pins (IN0 to IN3) of input capture
Interrupt factor
16-bit free-run timer IN0 IN1 IN2 IN3
Interrupt request flag bit TCCS: IVF ICS01: ICP0 ICS01: ICP1 ICS23: ICP0 ICS23: ICP1
Interrupt enable bit TCCS: IVFE ICS01: ICE0 ICS01: ICE1 ICS23: ICE0 ICS23: ICE1
232
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
After a reset, the 16-bit free-run timer starts incrementing from "0000H". When the
counter value is incremented from "FFFFH" to "0000H", an overflow occurs.
: Used bit
0 : Set 0
Reserved : Always set to "0"
233
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
Counter value
Overflow
FFFFH
BFFF H
7FFFH
3FFFH
0000H Time
Reset
Overflow interrupt
234
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
When the input capture detects the edge of the external signal input to the input pin, it
stores the counter value of the 16-bit free-run timer in the input capture data register.
DDR port
direction register
Set the bit corresponding to the pin
used as capture input pin to 0.
: Used bit
235
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
236
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
Valid edge
Capture signal
Input capture data
register (IPCP) N+1
Figure 7.6-3 shows the timing of the capture operation depending on the edge type.
Counter value
FFFFH
BFFFH
7FFFH
3FFFH
0000H Time
Reset
237
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
This section explains the precautions when using the 16-bit input/output timer.
● Precautions on interrupts
• When an overflow interrupt or an input capture interrupt is enabled, clear only the set bit of the overflow
generation flag bit or the input capture valid edge detection flag bit. For example, when clearing the flag
bit for the factor that accepted an interrupt, avoid unconditional clearing of the interrupt request flag bits
other than those for the factor accepting the interrupt, otherwise another input capture interrupt may be
generated.
• If the interrupt request flag bits in the 16-bit input/output timer (TCCS: IVF, ICS01, ICS23: ICP1, ICP0)
are set to 1 and interrupts corresponding to the set interrupt request flag bits are enabled (TCCS: IVFE =
1, ICS01, ICS23: ICE1 = 1, ICE0 = 1), it is impossible to return from interrupt processing. Always clear
the interrupt request flag bits. When using the EI2OS, the set interrupt request flag bits are cleared
automatically when the EI2OS, the set interrupt request flag bits are cleared automatically when the
EI2OS is started.
238
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
● Coding example
239
CHAPTER 7 16-BIT INPUT/OUTPUT TIMER
240
CHAPTER 8
16-BIT RELOAD TIMER
241
CHAPTER 8 16-BIT RELOAD TIMER
242
CHAPTER 8 16-BIT RELOAD TIMER
■ Operation at Underflow
When the start trigger is input, the value set in the 16-bit reload register (TMRLR) is reloaded to the 16-bit
timer register, starting decrementing in synchronization with the count clock. When the 16-bit timer
register (TMR) is decremented from "0000H" to "FFFFH", an underflow occurs.
• When an underflow occurs with an underflow interrupt enabled (TMCSR: INTE = 1), an underflow
interrupt is generated.
• The TMRLR operation when an underflow occurs is set by the reload select bit in the timer control
status register (TMCSR: RELD).
[One-shot mode (TMCSR: RELD = 0)]
When an underflow occurs, the TMR count operation is stopped. When the next start trigger is input, the
value set in the TMRLR is reloaded in the TMR, starting the TMR count operation.
• In the one-shot mode, during the TMR count operation, a High-level or Low-level rectangular wave is
output from the TOT pin.
• The pin output level select bit in the timer control status register (TMCSR: OUTL) can be set to select
the level (High or Low) of the rectangular wave.
[Reload mode (TMCSR: RELD = 1)]
When an underflow occurs, the value set in the TMRLR is reloaded to the TMR, continuing the TMR count
operation.
• In the reload mode, a toggle wave inverting the output level of the TOT pin is output each time an
underflow occurs during the TMR count operation.
• The pin output level select bit in the timer control status register (TMCSR: OUTL) can be set to select
the level (High or Low) of a toggle wave.
• The 16-bit reload timer can be used as an interval timer by using an underflow interrupt.
T: Machine cycle
The values in Interval time and the parenthesized values are provided when the machine clock operates at
16 MHz.
References: The 16-bit reload timer 1 can be used as the clock input source of the UART1 and the start trigger of the
A/D converter.
243
CHAPTER 8 16-BIT RELOAD TIMER
The 16-bit reload timers 0 and 1 composed of the following seven blocks:
• Count clock generator
• Reload controller
• Output controller
• Operation controller
• 16-bit timer register (TMR)
• 16-bit reload register (TMRLR)
• Timer control status register (TMCSR)
TMRLR
16-bit reload register
Reload signal Reload
controller
TMR
16-bit timer register UF
CLK
Count clock generator
Gate
Machine input Valid
3 Wait signal
Prescaler clock
clock
detector
φ Output to
Clear internal resource
Internal CLK Output controller
clock
Output signal
Input Clock Pin
Pin generator
controller selector
TIN EN TOT
External clock Select
3 2 signal
Operation
Function selected controller
CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE UF CNTE TRG
244
CHAPTER 8 16-BIT RELOAD TIMER
● Reload controller
When the 16-bit reload timer starts operation or the TMR underflows, the reload controller reloads the
value set in the 16-bit reload register (TMRLR) to the TMR.
● Output controller
The output controller inverts and enables or disables the output of the TOT pin at underflow.
● Operation controller
The operation controller starts or stops the 16-bit reload timer.
245
CHAPTER 8 16-BIT RELOAD TIMER
This section explains the pins, registers, and interrupt factors of the 16-bit reload timer.
TIN0 General-purpose I/O port, Set as input port in port direction register (DDR).
16-bit reload timer input
TOT0 General-purpose I/O port, Set timer output enable (TMCSR0: OUTE = 1).
16-bit reload timer output
TIN1 General-purpose I/O port, Set as input port in port direction register (DDR).
16-bit reload timer input
TOT1 General-purpose I/O port, Set timer output enable (TMCSR1: OUTE = 1).
16-bit reload timer output
246
CHAPTER 8 16-BIT RELOAD TIMER
Figure 8.3-1 List of Registers and Reset Values of 16-bit Reload Timer 0
bit 15 14 13 12 11 10 9 8
Figure 8.3-2 List of Registers and Reset Values of 16-bit Reload Timer
bit 15 14 13 12 11 10 9 8
247
CHAPTER 8 16-BIT RELOAD TIMER
248
CHAPTER 8 16-BIT RELOAD TIMER
The timer control status registers (High) (TMCSR0: H, TMCSR1: H) set the operation
mode and count clock.
This section also explains the bit 7 in the timer control status registers (Low) (TMCSR0:
L, TMCSR1: L).
15 14 13 12 11 10 9 8 7
Reset value
XXXX00000B
R/W R/W R/W R/W R/W
bit 9 bit 8 bit 7
Operation mode select bits (internal clock mode)
MOD2 MOD1 MOD0 (CSL1, 0 = "00B", "01B", "10B")
Function of input pin Valid edge, level
0 0 0 Trigger diasble
0 0 1 Rising edge
0 1 0 Trigger input Falling edge
0 1 1 Both edges
1 × 0 Gate input Low level
1 × 1 High level
bit 9 bit 8 bit 7
Operation mode select bits (event count mode)
MOD2 MOD1 MOD0 (CSL1, 0="11B")
Function of input pin Valid edge
× 0 0
× 0 1 Rising edge
× 1 0 Trigger input Falling edge
× 1 1 Both edges
bit 11 bit 10
Count clock select bits
CSL1 CSL0
Count clock Count clock cycle
0 0 2 1T
0 1 Internal clock mode 23T
R/W : Read/Write 25T
1 0
× : Undefined
Event count mode External event clock
1 1
: Unused
T: Machine cycle
: Reset value
249
CHAPTER 8 16-BIT RELOAD TIMER
Table 8.3-2 Functions of Timer Control Status Registers (High) (TMCSR0: H, TMCSR1: H)
bit 7 to bit 9 MOD2, MOD1, MOD0: These bits set the operation conditions of the 16-bit reload timer.
Operation mode select [Internal clock mode]
bits The MOD2 bit is used to select the function of the input pin.
When MOD2 bit set to 0:
The input pin functions as a trigger input.
The MOD1 and MOD0 bits are used to select the edge to be detected.
When the edge is detected, the value set in the 16-bit reload register
(TMRLR) is reloaded in the 16-bit timer register (TMR), starting the count
operation of the TMR.
When MOD2 set to 1:
The input pin functions as a gate input.
The MOD1 bit is not used. The MOD0 bit is used to select the signal level
(High or Low) to be detected. The count operation of the 16-bit timer register
(TMR) is performed only when the signal level is input.
[Event count mode]
The MOD2 bit is not used. An external event clock is input from the input
pin. The MOD1 and MOD0 bits are used to select the edge to be detected.
bit 10 CSL1, CSL0: These bits select the count clock of the 16-bit reload timer.
bit 11 Count clock select bits When set to anything other than "11B": The edge of the external event
clock is counted (event count mode)
When set to "11B": The edge of the external event clock is counted (event
count mode)
250
CHAPTER 8 16-BIT RELOAD TIMER
The timer control status registers (Low) (TMCSR0: L, TMCSR1: L) enables or disables
the timer operation, checks the generation of a software trigger or an underflow,
enables or disables an underflow interrupt, selects the reload mode, and sets the output
of the TOT pin.
bit 1
CNTE Timer operation enable bit
0 Timer operation disable
1 Timer operation enable (start trigger wait)
bit 2
Underflow generaiton flag bit
UF
Read Write
0 No underflow Clears UF bit
1 Underflow No effect
bit 3
INTE Underflow interrupt enable bit
0 Underflow interrupt disable
1 Underflow interrupt enable
bit 4
RELD Reload select bit
0 One-shot mode
1 Reload mode
bit 5
TOT pin output level select bit
OUTL One-shot mode Reload mode
(RELD=0) (RELD=1)
0 High rectangular wave output during counting Low toggle output at starting reload timer
1 Low rectangular wave output during counting High toggle output at starting reload timer
bit 6
TOT pin output enable bit
OUTE Register and pin corresponding to each channel
Pin function
TMCSR0 TMCSR1
0 General-purpose I/O port General-purpose I/O port General-purpose I/O port
R/W : Read/Write
: Reset value 1 TOT output TOT0 TOT1
251
CHAPTER 8 16-BIT RELOAD TIMER
bit 0 TRG: This bit starts the 16-bit reload timer by software.
Software trigger bit The software trigger function works only when the timer operation is enabled
(CNTE = 1).
When set to 0: Disabled. The state remains unchanged.
When set to 1: Reloads value set in 16-bit reload register (TMRLR) to 16-bit
timer register (TMR), starting TMR count operation
Read: 1 is always read.
bit 1 CNTE: This bit enables or disables the operation of the 16-bit reload timer.
Timer operation enable When set to1: 16-bit reload timer enters start trigger wait state.
bit When set to 0: Stops count operation
bit 5 OUTL: This bit sets the output level of the output pin of the 16-bit reload timer.
TOT Pin output level <One-shot mode (RELD = 0)>
select bit When set to 0: Outputs High-level rectangular wave during TMR count
operation
When set to 1: Outputs Low-level rectangular wave during TMR count
operation
<Reload mode (RELD = 1)>
When set to 0: Outputs Low-level toggle wave when 16-bit reload timer started
When set to 1: Outputs High-level toggle wave when 16-bit reload timer started
bit 6 OUTE: This bit sets the function of the TOT pin of the 16-bit reload timer.
TOT Output enable bit When set to 0: Functions as general-purpose I/O port
When set to 1: Functions TOT as pin of 16-bit reload timer
252
CHAPTER 8 16-BIT RELOAD TIMER
The 16-bit timer registers (TMR0, TMR1) are 16-bit down counters. At read, the value
being counted is read.
15 14 13 12 11 10 9 8 Reset value
TMR0
D15 D14 D13 D12 D11 D10 D9 D8 XXXXXXXX B
TMR1
R R R R R R R R
7 6 5 4 3 2 1 0 Reset value
TMR0
TMR1 D7 D6 D5 D4 D3 D2 D1 D0 XXXXXXXX B
R R R R R R R R
R : Read only
X : Undefined
When the timer operation is enabled (TMCSR: CNTE = 1) and the start trigger is input, the value set in the
16-bit reload register (TMRLR) is reloaded to the 16-bit timer register (TMR), starting the TMR count
operation.
When the timer operation is disabled (TMCSR: CNTE = 0), the TMR value is retained.
When the TMR value is counted down from "0000H" to "FFFFH" during the TMR count operation, an
underflow occurs.
[Reload mode]
When the TMR underflows, the value set in the TMRLR is reloaded to the TMR, starting the TMR count
operation.
[One-shot mode]
When the TMR underflows, the TMR count operation is stopped, entering the start trigger input wait state.
The TMR value is retained to "FFFFH".
Notes: • The TMR can be read during the TMR count operation. However, always use the word instruction
(MOVW).
• The TMR and the TMRLR are assigned to the same address. At write, the set value can be written to
the TMRLR without affecting the TMR. At read, the TMR value being counted can be read.
253
CHAPTER 8 16-BIT RELOAD TIMER
The 16-bit reload registers (TMRLR0, TMRLR1) set the value to be reloaded to the 16-bit
timer register (TMR). When the start trigger is input, the value set in the 16-bit reload
registers (TMRLR0, TMRLR1) is reloaded to the TMR, starting the TMR count operation.
15 14 13 12 11 10 9 8 Reset value
TMRLR0
D15 D14 D13 D12 D11 D10 D9 D8 XXXXXXXX B
TMRLR1
W W W W W W W W
7 6 5 4 3 2 1 0 Reset value
TMRLR0
TMRLR1 D7 D6 D5 D4 D3 D2 D1 D0 XXXXXXXX B
W W W W W W W W
W : Write only
X : Undefined
Set the 16-bit reload registers (TMRLR0, TMRLR1) after disabling the timer operation (TMCSR: CNTE =
0). After completing setting of the 16-bit reload registers (TMRLR0, TMRLR1), enable the timer operation
(TMCSR: CNTE = 1).
When the start trigger is input, the value set in the TMRLR is reloaded to the TMR, starting the TMR count
operation.
Notes: • Perform a write to the TMRLR after disabling the operation of the 16-bit reload timer (TMCSR:
CNTE = 0). Always use the word instruction (MOVW).
• The TMRLR and the TMR are assigned to the same address. At write, the set value can be written to
the TMRLR without affecting the TMR. At read, the TMR value being counted is read.
• Instructions, such as the INC/DEC instruction, which provide the read modify write (RMW) operation
cannot be used.
254
CHAPTER 8 16-BIT RELOAD TIMER
The 16-bit reload timer generates an interrupt request when the 16-bit timer register
(TMR) underflows.
Table 8.4-1 Interrupt Control Bits and Interrupt Factors of 16-bit Reload Timer
255
CHAPTER 8 16-BIT RELOAD TIMER
This section explains the setting of the 16-bit reload timer and the operation state of the
counter.
bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0
TMCSR CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE UF CNTE TRG
1
Except "11B"
: Used bit
1 : Set 1
bit 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 bit 0
TMCSR CSL1 CSL0 MOD2 MOD1 MOD0 OUTE OUTL RELD INTE UF CNTE TRG
1 1 1
Set the bit of DDR (port direction register) corresponding to the pin to be used as TIN pin to "0".
: Used bit
1 : Set 1
256
CHAPTER 8 16-BIT RELOAD TIMER
CNTE = 0 CNTE = 0
CNTE = 1 CNTE = 1
TRG = 0 TRG = 1
257
CHAPTER 8 16-BIT RELOAD TIMER
In the internal clock mode, three operation modes can be selected by setting the
operation mode select bits in the timer control status register (TMCSR: MOD2 to MOD0).
When the operation mode and reload mode are set, a rectangular wave or a toggle wave
is output from the TOT pin.
Note: It takes 1 machine cycle (time) to load the value set in the TMRLR to the TMR after the start trigger is
input.
258
CHAPTER 8 16-BIT RELOAD TIMER
Note: When both the timer operation enable bit in the timer control status register (TMCSR: CNTE) and the
software trigger bit in the timer control status register (TMCSR: TRG) are set to 1, the 16-bit reload timer
and the count operation of the TMR are started simultaneously.
259
CHAPTER 8 16-BIT RELOAD TIMER
Count clock
UF bit
CNTE bit
TRG bit
T*
TOT pin
Count clock
Counter Reload data -1 0000H Reload data -1 0000H Reload data -1 0000H Reload data -1
CNTE bit
TRG bit
T*
TOT pin
T : Machine cycle
* : It takes 1 machine cycle (time) to load data of reload register from trigger input.
260
CHAPTER 8 16-BIT RELOAD TIMER
Note: The trigger pulse width of the edge to be input to the TIN pin should be 2 machine cycles (time) or more.
Count clock
CNTE bit
TIN pin
2T to 2.5T*
TOT pin
Count clock
Counter Reload data -1 0000H Reload data -1 0000H Reload data -1 0000H Reload data -1
CNTE bit
TIN pin
2T to 2.5T*
TOT pin
T : Machine cycle
* : It takes 2 to 2.5 machine cycles (time) to load data of reload register from external trigger input.
261
CHAPTER 8 16-BIT RELOAD TIMER
Figure 8.5-8 Count Operation in External Gate Input Mode (One-shot Mode)
Count clock
Figure 8.5-9 Count Operation in External Gate Input Mode (Reload Mode)
Count clock
Counter Reload data -1 -1 -1 0000H Reload data -1 -1
UF bit
CNTE bit
TRG bit
T*
TIN pin
TOT pin
T : Machine cycle
* : It takes 1 machine cycle (time) to load data of reload register from trigger input.
262
CHAPTER 8 16-BIT RELOAD TIMER
In the event count mode, after the 16-bit reload timer is started, the edge of the signal
input to the TIN pin is detected to perform the count operation of the 16-bit timer
register (TMR). When the operation mode and the reload mode are set, a rectangular
wave or a toggle wave is output from the TOT pin.
Note: It takes 1 machine cycle (time) to load the value set in the TMRLR to the TMR after the start trigger is
input.
263
CHAPTER 8 16-BIT RELOAD TIMER
264
CHAPTER 8 16-BIT RELOAD TIMER
Note: The trigger pulse width of the edge to be input to the TIN pin should be 4 machine cycles (time) or more.
TIN pin
UF bit
CNTE bit
TRG bit
T*
TOT pin
TIN pin
Counter Reload data -1 0000H Reload data -1 0000H Reload data -1 0000H Reload data -1
UF bit
CNTE bit
TRG bit
T*
TOT pin
T : Machine cycle
* : It takes 1 machine cycle (time) to load data of reload register from trigger input.
265
CHAPTER 8 16-BIT RELOAD TIMER
This section explains the precautions when using the 16-bit reload timer.
● Precautions on interrupt
• When the UF bit in the TMCSR is set to 1 and the underflow interrupt output is enabled (TMCSR:
INTE = 1), it is impossible to return from interrupt processing. Always clear the UF bit. However, when
the EI2OS is used, the UF bit is cleared automatically.
• When using the EI2OS in the 16-bit reload timer, it is necessary to disable generation of interrupt
requests by resources that share the interrupt control register (ICR) with the 16-bit reload timer.
266
CHAPTER 8 16-BIT RELOAD TIMER
This section gives a program example of the 16-bit reload timer operated in the internal
clock mode and the event count mode are given below:
● Processing specification
• The 25-ms interval timer interrupt is generated by the 16-bit reload timer 0.
• The repeated interrupts are generated in the reload mode.
• The timer is started using the software trigger instead of the external trigger input.
• EI2OS is not used.
• The machine clock is 16 MHz; the count clock is 2 µs.
267
CHAPTER 8 16-BIT RELOAD TIMER
● Coding example
ICR03 EQU 0000B3H ; Interrupt control register for 16-bit reload timer
TMCSR0 EQU 000066H ; Timer control status register
TMR0 EQU 003900H ; 16-bit timer register
TMRLR0 EQU 003900H ; 16-bit reload register
UF0 EQU TMCSR0:2 ; Interrupt request flag bit
CNTE0 EQU TMCSR0:1 ; Counter operation enable bit
TRG0 EQU TMCSR0:0 ; Software trigger bit
;-----Main program---------------------------------------------------------------
CODE CSEG
; : ; Stack pointer (SP), already initialized
AND CCR,#0BFH ; Interrupts disabled
MOV I:ICR03,#00H ; Interrupt level 0 (highest)
CLRB I:CNTE0 ; Counter suspended
MOVW I:TMRLR0,#30D4H ; Data set for 25-ms interval timer interrupt
MOVW I:TMCSR0,#0000100000011011B
; Operation of interval timer, clock = 2 ms.
; External trigger disabled, external output disabled
; Reload mode selected, interrupt enabled
; Interrupt flag cleared, count started
MOV ILM,#07H ; ILM in PS set to level 7
OR CCR,#40H ; Interrupts enabled
LOOP:
:
Processing by user
:
BRA LOOP
;-----Interrupt program----------------------------------------------------------
WARI:
CLR I:UF0 ; Interrupt request flag cleared
:
Processing by user
:
RETI ; Return from interrupt
CODE ENDS
;-----Vector setting-------------------------------------------------------------
VECT CSEG ABS=0FFH
ORG 00FFB8H ; Vector set to interrupt #17 (11H)
DSL WARI
ORG 00FFDCH ; Reset vector set
DSL START
DB 00H ; Set to single-chip mode
VECT ENDS
END START
268
CHAPTER 8 16-BIT RELOAD TIMER
● Processing specification
• An interrupt is generated when rising edges of the pulse input to the external event input pin are counted
10000 times by the 16-bit reload timer/counter.
• Operation is performed in the one-shot mode.
• The rising edge is selected for the external trigger input.
• EI2OS is not used.
269
CHAPTER 8 16-BIT RELOAD TIMER
● Coding example
ICR03 EQU 0000B3H ; Interrupt control register for 16-bit reload timer
TMCSR0 EQU 000066H ; Timer control status register
TMR0 EQU 003900H ; 16-bit timer register
TMRLR0 EQU 003900H ; 16-bit reload register
DDR2 EQU 000012H ; Port data register
UF0 EQU TMCSR0:2 ; Interrupt request flag bit
CNTE0 EQU TMCSR0:1 ; Counter operation enable bit
TRG0 EQU TMCSR0:0 ; Software trigger bit
;-----Main program---------------------------------------------------------------
CODE CSEG
; : ; Stack pointer (SP), already initialized
AND CCR,#0BFH ; Interrupts disabled
MOV I:ICR03,#00H ; Interrupt level 0 (highest)
MOV I:DDR2,00H ; Sets P20/TIN0 pin to input
CLRB I:CNTE0 ; Counter suspended
MOVW I:TMRLR0,#2710H; Reload value set to 10000 times
MOVW I:TMCSR0,#0000110000001011B
; Counter operation, external trigger,
; rising edge, and external output disabled
; One-shot mode selected, interrupt enabled
; Interrupt flag cleared, count started
MOV ILM,#07H ; ILM in PS set to level 7
OR CCR,#40H ; Interrupts enabled
LOOP:
:
Processing by user
:
BRA LOOP
;-----Interrupt program----------------------------------------------------------
WARI:
CLR I:UF0 ; Interrupt request flag cleared
:
Processing by user
:
RETI ; Return from interrupt
CODE ENDS
;-----Vector setting-------------------------------------------------------------
VECT CSEG ABS=0FFH
ORG 00FFB8H ; Vector set to interrupt #17 (11H)
DSL WARI
ORG 00FFDCH ; Reset vector set
DSL START
DB 00H ; Set to single-chip mode
VECT ENDS
END START
270
CHAPTER 9
WATCH TIMER
271
CHAPTER 9 WATCH TIMER
The watch timer is a 15-bit free-run counter that increments in synchronization with the
subclock.
• Eight interval times can be selected and an interrupt request can be generated for
each interval time.
• An operation clock can be supplied to the oscillation stabilization wait time timer of
the subclock and the watchdog timer.
• The subclock is always used as a count clock regardless of the settings of the clock
select register (CKSCR).
213/SCLK (1.0 s)
214/SCLK (2.0 s)
215/SCLK (4.0 s)
SCLK: Subclock
The parenthesized values are provided when the subclock operates at 8.192 kHz.
272
CHAPTER 9 WATCH TIMER
213/SCLK (1.000 s)
Watchdog timer
214/SCLK (2.000 s)
215/SCLK (4.000 s)
273
CHAPTER 9 WATCH TIMER
To watchdog
timer
Watch timer counter
OF OF OF
OF
OF
OF
OF
OF
Power on reset
Counter To stabilization wait time
Transits to hardware standby subclock oscillation
clear circuit
Transits to stop mode
Interval timer
selector
OF: Overflow WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0
SCLK: Subclock
Watch timer control register (WTC)
274
CHAPTER 9 WATCH TIMER
275
CHAPTER 9 WATCH TIMER
This section explains the registers and interrupt factors of the watch timer.
bit 7 6 5 4 3 2 1 0
×: Undefined
276
CHAPTER 9 WATCH TIMER
This section explains the functions of the watch timer control register (WTC).
7 6 5 4 3 2 1 0
Reset value
1X001000B
R/W R R/W R/W R/W R/W R/W R/W
bit 2 bit 1 bit 0
WTC2 WTC1 WTC0 Interval time select bits
0 0 0 28/SCLK (31.25ms)
0 0 1 29/SCLK (62.5ms)
0 1 0 210/SCLK (125ms)
0 1 1 211/SCLK (250ms)
1 0 0 212/SCLK (500ms)
1 0 1 213/SCLK (1.0s)
1 1 0 214/SCLK (2.0s)
1 1 1 215/SCLK (4.0s)
bit 3
Watch timer clear bit
WTR
Read Write
0 Clears watch timer counter
1 "1" always read No effect
bit 4
Overflow flag bit
WTOF
Read Write
0 No overflow of the bit Clears WTOF bit
corresponding to set interval time
1 Overflow of the bit corresponding No effect
to set interval time
bit 5
WTIE Overflow interrupt enable bit
0 Interrupt request disable
1 Interrupt request enable
bit 6
SCE Oscillation stabilization wait time end bit
0 Oscillstion stabilization wait state
1 Oscillstion stabilization wait time end
bit 7
Watchdog clock select bit
WDCS (input clock of watchdog timer)
R/W : Read/Write Main or PLL clock mode Subclock mode
R : Read only 0 Watch timer Set "0"
X : Undefined 1 Timebase timer
SCLK : Subclock
: Reset value
The parenthesized values are provided when subclock operates at 8.192 kHz.
277
CHAPTER 9 WATCH TIMER
bit 2 to WTC2, WTC1, WTC0: These bits set the interval time of the watch timer.
bit 0 Interval time select bits • When the interval time set by the WTC2 to WTC0 bits is reached, the
corresponding bit of the watch timer counter overflows (carries) and the
overflow flag bit is set (WTC: WTOF = 1).
• To set the WTC2 to WTC0 bits, set the WTOF bit to 0.
bit 4 WTOF: This bit is set to 1 when the counter value of the watch timer reaches the value
Overflow flag bit set by the interval time select bit.
When an overflow occurs (WTOF = 1) with interrupt request enabled (WTIE =
1), an interrupt request is generated.
When set to 0: Clears watch timer counter
When set to 1: No effect
• The overflow flag bit is set to 1 when the bit of the watch timer counter
corresponding to the interval time set by the interval time select bits (WTC2
to WTC0) overflows.
bit 5 WTIE: This bit enables or disables generation of an interrupt request when the watch
Overflow interrupt timer counter overflows (carries).
enable bit When set to 0: Interrupt request not generated even at overflow (WTOF = 1)
When set to 1: Interrupt request generated at overflow (WTOF = 1)
bit 6 SCE: This bit indicates that the oscillation stabilization wait time of the subclock ends.
Oscillation stabilization When cleared to 0: Subclock in oscillation stabilization wait state
wait time end bit When set to 1: Subclock oscillation stabilization wait time ends
• The oscillation stabilization wait time of the subclock is fixed at 215/SCLK
(SCLK: subclock frequency).
bit 7 WDCS: This bit selects the operation clock of the watchdog timer.
Watchdog clock select <Main clock mode or PLL clock mode>
bit When set to 0: Selects output of watch timer as operation clock of watchdog
timer.
When set to 1: Selects output of timebase timer as operation clock of watchdog
timer.
<Subclock mode>
Always set this bit to 0 to select the output of the watch timer.
Note:
The watch timer and the timebase timer operate asynchronously. When the
WDCS bit is changed from 0 to 1, the watchdog timer may run fast. The
watchdog timer must be cleared before and after changing the WDCS bit.
278
CHAPTER 9 WATCH TIMER
When the interval time is reached with the watch timer interrupt enabled, the overflow
flag bit is set to 1 and an interrupt request is generated.
Watch Timer
• When the value set by the interval time select bits (WTC2 to WTC0) in the watch timer control register
(WTC) is reached, the overflow flag bit in the WTC register is set to 1 (WTC: WTOF = 1).
• When the overflow flag bit is set (WTC: WTOF = 1) with the watch timer interrupt enabled (WTC:
WTIE = 1), an interrupt request is generated.
• At interrupt processing, set the WTOF bit to 0 and cancel the interrupt request.
279
CHAPTER 9 WATCH TIMER
The watch timer operates as an interval timer or an oscillation stabilization wait time
timer of subclock. It also supplies an operation clock to the watchdog timer.
Note: When the watch timer counter is cleared, the interrupts of the watchdog timer and interval timer that use
the output of the watch timer counter are affected.
To clear the watch timer by writing zero to the watch timer clear bit (WTR) in the watch timer control
register (WTC), set the overflow interrupt enable bit (WTIE) to "0" and set the watch timer to interrupt
inhibited state. Before permitting an interrupt, clear the interrupt request issued by writing zero to the
overflow flag bit (WTOF) .
bit 7 6 5 4 3 2 1 bit0
WTC WDCS SCE WTIE WTOF WTR WTC2 WTC1 WTC0
: Used bit
: Unused bit
• When the value set by the interval time select bits (WTC1, WTC0) in the watch timer control register
(WTC) is reached, the overflow flag bit in the WTC register is set to 1 (WTC: WTOF = 1).
• When the overflow flag bit is set (WTC: WTOF = 1) with the overflow interrupt of the watch timer
counter enabled (WTC: WTIE = 1), an interrupt request is generated.
• The overflow flag bit (WTC: WTOF) is set when the interval time is reached at the starting point of the
timing at which the watch timer is finally cleared.
280
CHAPTER 9 WATCH TIMER
281
CHAPTER 9 WATCH TIMER
● Processing specifications
An interval interrupt at 213/SCLK (SCLK: subclock) is generated repeatedly. The internal time is
approximately 1.0s (when subclock operates at 8.192 kHz).
● Coding example
282
CHAPTER 10
8-/16-BIT PPG TIMER
283
CHAPTER 10 8-/16-BIT PPG TIMER
The 8-/16-bit PPG timer is a reload timer module with two channels (PPG0 and PPG1)
that outputs a pulse in any cycle and at any duty ratio. A combination of two channels
provides:
• 8-bit PPG output 2-channel independent operation mode
• 16-bit PPG output mode
• 8 + 8-bit PPG output mode
The MB90385 series has two 8-/16-bit PPG timers. This section explains the functions of
PPG0/1. PPG2/3 has the same functions as PPG0/1.
284
CHAPTER 10 8-/16-BIT PPG TIMER
Table 10.1-1 Interval Times in 8-bit PPG Output 2-channel Independent Operation Mode
PPG0, PPG1
Count Clock Cycle
Interval Time Output Pulse Time
285
CHAPTER 10 8-/16-BIT PPG TIMER
PPG0 PPG1
Count
Clock Cycle Interval Output Pulse Interval Output Pulse
Time Time Time Time
1/φ (62.5 ns) 1/φ to 28/φ 2/φ to 29/φ 1/φ to 216/φ 2/φ to 217/φ
2/φ (125 ns) 2/φ to 29/φ 22/φ to 210/φ 2/φ to 217/φ 22/φ to 218/φ
22/φ (250 ns) 22/φ to 210/φ 23/φ to 211/φ 22/φ to 218/φ 23/φ to 219/φ
23/φ (500 ns) 23/φ to 211/φ 24/φ to 212/φ 23/φ to 219/φ 24/φ to 220/φ
24/φ (1 µs) 24/φ to 212/φ 25/φ to 213/φ 24/φ to 220/φ 25/φ to 221/φ
286
CHAPTER 10 8-/16-BIT PPG TIMER
One 8-/16-bit PPG timer consists of 8-bit PPG timers with two channels.
This section shows the block diagrams for the 8-/16-bit PPG timer 0 and 8-/16-bit PPG
timer 1.
The PPG2 has the same function as the PPG0, and PPG3 has the same function as
PPG1.
PPG0/1 Pin
PPG0 output pin
Pin
PPG1 output pin
PPG2/3 Pin
PPG2 output pin
Pin
PPG3 output pin
287
CHAPTER 10 8-/16-BIT PPG TIMER
Interrupt
PPG0 temporary R
request output*
buffer 0 (PRLBH0)
S Q
2
Operation mode
Reload register Select signal control signal
L/H selector
PPG1 underflow
Count start value PPG0 underflow
Reload Clear (to PPG1)
Pulse selector
PPG0 down counter Underflow
(PCNT0)
CLK
PPG0
Pin
Invert output latch
PPG0
Timebase timer output PPG output control circuit
(512/HCLK)
Resource clock (1/φ)
Resource clock (2/φ)
Resource clock (4/φ)
Count clock
Resource clock (8/φ)
Resource clock (16/φ) selector
3
Select signal
288
CHAPTER 10 8-/16-BIT PPG TIMER
PPG0 P14/PPG0
#22 (16H)
PPG1 P15/PPG1
PPG2 P16/PPG2
#26 (1AH)
PPG3 P17/PPG3
289
CHAPTER 10 8-/16-BIT PPG TIMER
290
CHAPTER 10 8-/16-BIT PPG TIMER
PPG0 underflow
(from PPG0) Timebase timer output
(512/HCLK)
Resource clock (1/φ)
Resource clock (2/φ)
Resource clock (4/φ)
Resource clock (8/φ)
Resource clock (16/φ)
Count clock 3
selector Select signal
291
CHAPTER 10 8-/16-BIT PPG TIMER
PPG0 P14/PPG0
#22 (16H)
PPG1 P15/PPG1
PPG2 P16/PPG2
#26 (1AH)
PPG3 P17/PPG3
292
CHAPTER 10 8-/16-BIT PPG TIMER
293
CHAPTER 10 8-/16-BIT PPG TIMER
This section explains the pins, registers and interrupt factors of the 8-/16-bit PPG timer.
294
CHAPTER 10 8-/16-BIT PPG TIMER
Figure 10.3-1 List of Registers and Reset Values of 8-/16-bit PPG Timer
bit 15 14 13 12 11 10 9 8
295
CHAPTER 10 8-/16-BIT PPG TIMER
The PPG0 operation mode control register (PPGC0) provides the following settings:
• Enabling or disabling operation of 8-/16-bit PPG timer
• Switching between pin functions (enabling or disabling pulse output)
• Enabling or disabling underflow interrupt
• Setting underflow interrupt request flag
7 6 5 4 3 2 1 0
Reset value
0X000XX1B
R/W R/W R/W R/W W
bit 0
Reserved Reserved bit
1 Always set to "1"
bit 3
Underflow generation flag bit
PUF0
Read Write
0 No underflow Clears PUF0 bit
1 Underflow No effect
bit 4
PIE0 Underflow interrupt enable bit
0 Interrupt request disable
1 Interrupt request enable
bit 5
PE0 PPG0 pin output enable bit
0 General-purpose I/O port (pulse output disable)
1 PPG0 output (pulse output enable)
bit 7
PEN0 PPG0 operation enable bit
0 Couting disable (holds "L" level output)
R/W : Read/Write 1 Counting enable
X : Undefined
: Unused
: Reset value
296
CHAPTER 10 8-/16-BIT PPG TIMER
bit 3 PUF0: 8-bit PPG output 2-channel independent operation mode, 8+8-bit PPG
Underflow generation output operation mode: When the value of the PPG0 down counter is
flag bit decremented from "00H" to "FFH", an underflow occurs (PUF0 = 1).
16-bit PPG output operation mode: When the values of the PPG0 and PPG1
down counters are decremented from "0000H" to" FFFFH", an underflow occurs
(PUF0 = 1).
• When an underflow occurs (PUF0 = 1) with an underflow interrupt enabled
(PIE0 = 1), an interrupt request is generated.
When set to 0: Clears counter
When set to 1: No effect
Read by read modify write instructions: 1 read
bit 5 PE0: This bit switches between PPG0 pin functions and enables or disables the pulse
PPG0 pin output enable output.
bit When set to 0: PPG0 pin functions as general-purpose I/O port.
The pulse output is disabled.
When set to 1: PPG0 pin functions as PPG0 output pin.
The pulse output is enabled.
bit 7 PEN0: This bit enables or disables the count operation of the 8-/16-bit PPG timer 0.
PPG0 operation enable When set to 0: Count operation disabled
bit When set to 1: Count operation enabled
• When the count operation is disabled (PEN0 = 0), the output is held at a Low
level.
297
CHAPTER 10 8-/16-BIT PPG TIMER
The PPG1 operation mode control register (PPGC1) provides the following settings:
• Enabling or disabling operation of 8-/16-bit PPG timer
• Switching between pin functions (enabling or disabling pulse output)
• Enabling or disabling underflow interrupt
• Setting underflow interrupt request flag
• Setting the operation mode of the 8-/16-bit PPG timer
15 14 13 12 11 10 9 8
Reset value
0X000001 B
298
CHAPTER 10 8-/16-BIT PPG TIMER
bit 11 PUF1: 8-bit PPG output 2-channel independent operation mode, 8+8-bit PPG
Underflow generation output operation mode: When the value of the PPG1 down counter is
flag bit decremented from "00Hto "FFH", an underflow occurs (PUF1 = 1).
16-bit PPG output operation mode: When the values of the PPG0 and PPG1
down counters are decremented from "0000H" to "FFFF H", an underflow occurs
(PUF1 = 1).
• When an underflow occurs (PUF1 = 1) with an underflow interrupt enabled
(PIE1 = 1), an interrupt request is generated.
When set to 0: Clears counter
When set to 1: No effect
Read by read modify write instructions: 1 is read.
bit 15 PEN1: This bit enables or disables the count operation of the 8-/16-bit PPG timer 1.
PPG1 operation enable When set to 0: Count operation disabled
bit When set to 1: Count operation enabled
• When the count operation is disabled (PEN1 = 0), the output is held at a Low
level.
299
CHAPTER 10 8-/16-BIT PPG TIMER
The PPG0/1 count clock select register (PPG01) selects the count clock of the 8-/16-bit
PPG timer.
7 6 5 4 3 2 1 0
Reset value
000000XX B
300
CHAPTER 10 8-/16-BIT PPG TIMER
bit 5 to bit 7 PCS2 to PCS0: These bits set the count clock of the 8-/16-bit PPG timer 1.
PPG1 count clock select • The count clock can be selected from five frequency-divided clocks of the
bits machine clock and the frequency-divided clocks of the timebase timer.
• The settings of the PPG1 count clock select bits (PCS2 to PCS0) are
enabled only in the 8-bit PPG output 2-channel independent mode
(PPGC1: MD1, MD0 = "00B").
301
CHAPTER 10 8-/16-BIT PPG TIMER
The value (reload value) from which the PPG down counter starts counting is set in the
PPG reload registers, which are an 8-bit register at Low level and an 8-bit register at
High level.
bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 Reset value
PRLH0/PRLH1 D15 D14 D13 D12 D11 D10 D9 D8 XXXXXXXX B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Reset value
PRLL0/PRLL1 D7 D6 D5 D4 D3 D2 D1 D0 XXXXXXXX B
R/W : Read/Write
X : Undefined
Table 10.3-5 "Functions of PPG Reload Registers" indicates the functions of the PPG reload registers.
Notes: • In the 16-bit PPG output operation mode (PPGC1: MD1, MD0 = "11B"), use a long-word instruction
to set the PPG reload registers or the word instruction to set the PPG0 and PPG1 in this order.
• In the 8 + 8-bit PPG output operation mode (PPGC1: MD1, MD0 = "01B"), set the same value in both
the Low-level and High-level PPG reload registers (PRTLL0/PRLH0) of the 8-/16-bit PPG timer 0.
Setting a different value in the Low-level and High-level PPG reload registers may cause the 8-/16-bit
PPG timer 1 to have different PPG output waveforms at each clock cycle.
302
CHAPTER 10 8-/16-BIT PPG TIMER
The 8-/16-bit PPG timer can generate an interrupt request when the PPG down counter
underflows. It corresponds to the EI2OS.
PPG0 PPG1
Interrupt factor Underflow in PPG0 down counter Underflow in PPG1 down counter
[8-bit PPG output 2-channel independent operation mode or 8 + 8-bit PPG output operation mode]
• In the 8-bit PPG output 2-channel independent operation mode or the 8 + 8-bit PPG output operation
mode, the PPG0 and PPG1 timers can generate an interrupt independently.
• When the value of the PPG0 or PPG1 down counter is decremented from "00H" to "FFH", an underflow
occurs. When an underflow occurs, the underflow generation flag bit in the channel causing an
underflow is set (PPGC0: PUF0 = 1 or PPGC1: PUF1 = 1).
• If an interrupt request from the channel that causes an underflow is enabled (PPGC0: PIE0 = 1 or
PPGC1: PIE1 = 1), an interrupt request is generated.
[16-bit PPG output operation mode]
• In the 16-bit PPG output operation mode, when the values of the PPG0 and PPG1 down counters are
decremented from "0000H" to "FFFFH", an underflow occurs. When an underflow occurs, the underflow
generation flag bits in the two channels are set at one time (PPGC0: PUF0 = 1 and PPGC1: PUF1 = 1).
• When an underflow occurs with either of the two channel of the interrupt requests enabled (PPGC0:
PIE1 = 0, PPGC1: PIE1 = 1 or PPGC0: PIE1 = 1, PPGC1: PIE1 = 0), an interrupt request is generated.
• To prevent duplication of interrupt requests, disable either of the two channel of the underflow interrupt
enable bits (PPGC0: PIE1 = 0, PPGC1: PIE1 = 1 or PPGC0: PIE1 = 1, PPGC1: PIE1 = 0).
• When the two channels of the underflow generation flag bits are set (PPGC0: PUF0 = 1 and PPGC1:
PUF1 = 1), clear the two channels at the same time.
303
CHAPTER 10 8-/16-BIT PPG TIMER
304
CHAPTER 10 8-/16-BIT PPG TIMER
The 8-/16-bit PPG timer outputs a pulse width at any cycle and at any duty ratio
continuously.
T × (L + 1) T × (H + 1)
305
CHAPTER 10 8-/16-BIT PPG TIMER
In the 8-bit PPG output 2-channel independent operation mode, the 8-/16-bit PPG timer
is set as an 8-bit PPG timer with two independent channels. PPG output operation and
interrupt request generation can be performed independently for each channel.
Figure 10.5-2 Setting for 8-bit PPG Output 2-channel Independent Operation Mode
1 0 0 1 1 1
PRLH0/PRLL0 PPG0 Set High level side reload values. PPG0 Set Low level side reload values.
PRLH1/PRLL1 PPG1 Set High level side reload values. PPG1 Set Low level side reload values.
: Used bit
: Unused bit
1 : Set 1
0 : Set 0
Note: Use the word instruction to set both High-level and Low-level PPG reload registers (PRLL0/PRLH0 and
PRLL1/PRLH1) at the same time.
306
CHAPTER 10 8-/16-BIT PPG TIMER
Figure 10.5-3 Output Waveform in 8-bit PPG Output 2-channel Independent Operation Mode
T × (L + 1) T × (H + 1)
307
CHAPTER 10 8-/16-BIT PPG TIMER
In the 16-bit PPG output operation mode, the 8-/16-bit PPG timer is set as a 16-bit PPG
timer with one channel.
1 1 1 1 1 1
PRLH1/PRLL1 PPG1 Set high level side reload values of upper 8 bits. PPG1 Set low level side reload values of upper 8 bits.
: Used bit
× : Undefined bit
: Unused bit
1 : Set 1
0 : Set 0
Note: Use a long-word instruction to set the values in the PPG reload registers or a word instruction to set the
PPG0 and PPG1 (PRLL0 --> PRLL1 or PRLH0 --> PRLH1) in this order.
308
CHAPTER 10 8-/16-BIT PPG TIMER
Notes: • In the 16-bit PPG output operation mode, the underflow generation flag bits in the two channels are
set simultaneously when an underflow occurs (PPGC0: PUF0 = 1 and PPGC1: PUF1 = 1). To prevent
duplication of interrupt requests, disable either of the underflow interrupt enable bits in the two
channels (PPGC0: PIE0 = 0, PPGC1: PIE1 = 1 or PPGC0: PIE0 = 1, PPGC1: PIE1 = 0).
• If the underflow generation flag bits in the two channels are set (PPGC0: PUF0 = 0 and PPGC1: PUF1
= 0), clear the two channels at the same time.
309
CHAPTER 10 8-/16-BIT PPG TIMER
T × (L + 1) T × (H + 1)
310
CHAPTER 10 8-/16-BIT PPG TIMER
In the 8+8-bit PPG output operation mode, the 8-/16-bit PPG timer is set as an 8-bit PPG
timer. The PPG0 operates as an 8-bit prescaler and the PPG1 operates using the PPG
output of the PPG0 as a clock source.
1 0 1 1 1 1
PRLH1/PRLL1 PPG1 Set High level side reload values. PPG1 Set Low level side reload values.
: Used bit
× : Udefined bit
: Unused bit
1 : Set 1
0 : Set 0
Note: Use the word instruction to set both High-level and Low-level PPG reload registers (PRLL0/PRLH0 and
PRLL1/PRLH1) at the same time.
311
CHAPTER 10 8-/16-BIT PPG TIMER
Notes: • Do not operate PPG1 (PPGC1: PEN1 = 1) when PPG0 is stopped (PPGC0: PEN0 = 0).
• It is recommended to set the same value in both Low-level and High-level PPG reload registers
(PRLL0/PRLH0, PRLL1/PRLH1).
312
CHAPTER 10 8-/16-BIT PPG TIMER
T × (L0 + 1) T × (H0 + 1)
313
CHAPTER 10 8-/16-BIT PPG TIMER
This section explains the precautions when using the 8-/16-bit PPG timer.
Figure 10.6-1 Waveform when Values in PPG Reload Registers Rewritten Using Byte Instruction
PRLL A C
PRLH B D
A+B A+B B+C C+D C+D C + D Timing of updating
reload value
PPG pin
A B A B C B C D C D
<1> <2>
<1>: Change the value (A → C) of PPG reload register (PRLL)
<2>: Change the value (B → D) of PPG reload register (PRLH)
314
CHAPTER 10 8-/16-BIT PPG TIMER
315
CHAPTER 10 8-/16-BIT PPG TIMER
316
CHAPTER 11
DELAYED INTERRUPT
GENERATION MODULE
317
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE
The delayed interrupt generation module generates the interrupt for task switching.
The hardware interrupt request can be generated/cancelled by software.
Interrupt factor An interrupt request is generated by setting the R0 bit in the delayed interrupt
request generate/cancel register to 1 (DIRR: R0 = 1).
An interrupt request is cancelled by setting the R0 bit in the delayed interrupt
request generate/cancel register to 0 (DIRR: R0 = 0).
Interrupt flag The interrupt flag is held in the R0 bit in the DIRR register.
318
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE
R0 Interrupt
S Interrupt request
Delayed interrupt request generate/cancel register (DIRR) request
R latch
signal
: Unused
319
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE
This section lists registers and reset values in the delayed interrupt generation module.
Figure 11.3-1 List of Registers and Reset Values in Delayed Interrupt Generation Module
bit 15 14 13 12 11 10 9 8
×: Undefined
320
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE
15 14 13 12 11 10 9 8
Reset value
XXXXXXX0B
R/W
bit 8
R0 Delayed interrupt request generate bit
: Unused
0 Cancels delayed interruput request
R/W : Read/Write
1 Generates delayed interrupt request
: Reset value
321
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE
The delayed interrupt generation module has a function for generating or canceling an
interrupt request by software.
bit 15 14 13 12 11 10 9 bit 8
DIRR R0
: Unused bit
: Used bit
When the R0 bit in the delayed interrupt request generate/cancel register (DIRR) is set to 1 (DIRR: R0 = 1),
an interrupt request is generated. There is no interrupt request enable bit.
322
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE
This section explains the precautions when using the delayed interrupt generation
module.
323
CHAPTER 11 DELAYED INTERRUPT GENERATION MODULE
This section gives a program example of the delayed interrupt generation module.
● Processing specifications
The main program writes 1 to the R0 bit in the delayed interrupt request generate/cancel register (DIRR),
generates a delayed interrupt request, and changes the task.
● Coding example
324
CHAPTER 12
DTP/EXTERNAL INTERRUPT
325
CHAPTER 12 DTP/EXTERNAL INTERRUPT
The DTP/external interrupt sends interrupt requests from external peripheral devices or
data transfer requests to the CPU to generate an external interrupt request, or starts the
(EI2OS). RX input of CAN controller can be used as external interrupt input.
The interrupt factor is set in unit of pins using the detection level setting registers.
Interrupt factor Input of High level, Low level, Input of High level or Low level
rising edge, or falling edge
Interrupt control The interrupt request output is enabled/disabled using the DTP/external interrupt enable register
(ENIR).
Interrupt flag The interrupt factor is held using the DTP/external interrupt factor register (EIRR)
Processing contents A branch is caused to the external interrupt EI2OS performs auto data transfer and
processing routine. completes the specified number of timer for
data transfers, causing a branch to the interrupt
processing.
326
CHAPTER 12 DTP/EXTERNAL INTERRUPT
Level edge
Pin
selector
INT7
Level edge
Pin
selector
INT6
Internal data bus
Level edge
Pin
selector
INT5
Interrupt Interrupt
request signal request signal
327
CHAPTER 12 DTP/EXTERNAL INTERRUPT
P24/INT4 4
#24 (18H)
P25/INT5 5
P26/INT6 6
#27 (1BH)
P27/INT7 7
328
CHAPTER 12 DTP/EXTERNAL INTERRUPT
This section lists and details the pins, interrupt factors, and registers in the DTP/
external interrupt.
P24/INT4
Set as input ports in port direction register (DDR)
P25/INT5 General-purpose I/O ports,
P26/INT6 DTP external interrupt inputs
P27/INT7
bit 15 14 13 12 11 10 9 8
bit 15 14 13 12 11 10 9 8
bit 7 6 5 4 3 2 1 0
×: Undefined
329
CHAPTER 12 DTP/EXTERNAL INTERRUPT
The DTP/external interrupt factor register (EIRR) holds DTP/external interrupt factors.
When a valid signal is input to the DTP/external interrupt pin and the RX pin, the
corresponding interrupt request flag bit is set to 1.
15 14 13 12 11 10 9 8
Reset value
XXXXXXXX B
R/W R/W R/W R/W - - - R/W
bit 15 to bit 12, bit 8
DTP/external interrupt request flag bits
ER7 to ER4, ER0
Read Write
R/W : Read/Write 0 No DTP/external interrupt input Clears ER bit
X : Undefined 1 DTP/ external interrupt input No effect
- : Unused
bit 8, ER7 to ER4, ER0: These bits are set to 1 when the edges or level signals set by the detection
bit 12 to bit 15 DTP/External interrupt condition select bits in the detection level setting register (ELVR: LB, LA)
request flag bits are to the DTP/external interrupt pins and RX pin.
When set to 1: When the DTP/external interrupt request enable bit (ENIR:
EN) is set to 1, an interrupt request is generated to the corresponding DTP/
external interrupt channel.
When set to 0: Cleared
When set to 1: No effect
Note:
Reading by read-modify-write type instructions always returns "1".
If more than one DTP/external interrupt request is enabled (ENIR: EN =
1), clear only the bit in the channel that accepts an interrupt (EIRR: ER =
0). No other bits must be cleared unconditionally.
Reference:
When the (EI2OS) is started, the interrupt request flag bit is automatically
cleared after the completion of data transfer (EIRR: ER = 0)
330
CHAPTER 12 DTP/EXTERNAL INTERRUPT
7 6 5 4 3 2 1 0
Reset value
Re- Re- Re-
served served served 00000000B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 3 to bit 1
Reserved Reserved bits
0 Always set these bits to 0
bit 0, EN7 to EN4, EN0: The DTP/external interrupt enable register (ENIR) enables/disables the DTP/
bit 4 to bit 7 DTP/external external interrupt request for external interrupt pins (INT7 to INT4) and the RX pin.
interrupt request If the DTP/external interrupt request enable bit (ENIR: EN) and the DTP/external
enable bits interrupt request flag bit (EIRR: ER) are set to 1, the interrupt request is generated to
the corresponding DTP/external interrupt pins or the RX pin.
Reference:
The state of the DTP/external interrupt pin and the RX pin can be read directly
using the port data register irrespective of the setting of the DTP/external
interrupt request enable bit.
331
CHAPTER 12 DTP/EXTERNAL INTERRUPT
The detection level setting register (High) sets the levels or edges of input signals that
cause interrupt factors in INT7 to INT4 of the DTP/external interrupt pins.
15 14 13 12 11 10 9 8
Reset value
00000000 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 15 to bit 8
LB7, LA7
LB6, LA6
Detection condition select bits
LB5, LA5
LB4, LA4
0 0 Detects Low level
0 1 Detects High level
R/W : Read/Write 1 0 Detects rising edge
: Reset value 1 1 Detects falling edge
bit 8 to bit 15 LB7, LA7 to LB4, LA4: These bits set the levels or edges of input signals from external peripheral
Detection condition devices that cause interrupt factors in the DTP/external interrupt pins.
select bits • Two levels or two edges are selectable for external interrupts, and two
levels are selectable for the EI2OS.
Reference:
When the set detection signal is input to the DTP/external interrupt pins,
the DTP/external interrupt request flag bits are set to 1 even if DTP/
external interrupt requests are disabled (ENIR: EN = 0).
Table 12.3-6 Correspondence between Detection Level Setting Register (ELVR) (High) and
Channels
332
CHAPTER 12 DTP/EXTERNAL INTERRUPT
The detection level setting register (ELVR) (Low) sets the levels or edges of input
signals that cause interrupt factors in the RX pin.
7 6 5 4 3 2 1 0
Reset value
Re- Re- Re- Re- Re- Re-
served served served served served served 00000000 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit1 bit0
bit 7 to bit 2
bit 0 to bit 1 LB3, LA0: These bits set the levels or edges of input signals from external peripheral
Detection condition devices that cause interrupt factors in the RX pin.
select bits • Two levels or two edges are selectable for external interrupts, and two
levels are selectable for the EI2OS.
Reference:
When the set detection signal is input to the RX pin, the DTP/external
interrupt request flag bits are set to 1 even if DTP/external interrupt
requests are disabled (ENIR: EN = 0).
Table 12.3-8 Correspondence between Detection Level Setting Register (ELVR) (Low) and
Channels
RX LB0, LA0
333
CHAPTER 12 DTP/EXTERNAL INTERRUPT
The DTP/external interrupt circuit has an external interrupt function and a DTP function.
The setting and operation of each function are explained.
EIRR/ENIR ER7 ER6 ER5 ER4 ER0 EN7 EN6 EN5 EN4 Re- Re- Re-
served served served EN0
0 0 0
● Setting procedure
To use the DTP/external interrupt, set each register by using the following procedure:
1. Set the interrupt request enable bit corresponding to the DTP/external interrupt channel to be used to 0
(ENIR: EN).
2. Use the detection condition select bit corresponding to the DTP/external interrupt pin and the RX pin to
be used to set the edge or level to be detected (ELVR: LA, LB).
3. Set the interrupt request flag bit corresponding to the DTP/external interrupt channel to be used to 0
(EIRR: ER).
4. Set the interrupt request enable bit corresponding to the DTP/external interrupt channel to be used to 1
(ENIR: EN).
• When setting the registers for the DTP/external interrupt, the external interrupt request must be disabled
in advance (ENIR: EN0 = 0).
• When enabling the DTP/external interrupt request (ENIR: EN = 1), the corresponding DTP/external
interrupt request flag bit must be cleared in advance (EIRR: ER = 0). These actions prevent the mistaken
interrupt request from occurring when setting the register.
334
CHAPTER 12 DTP/EXTERNAL INTERRUPT
Notes: • All interrupt requests assigned to one interrupt control register have the same interrupt levels (IL2 to
IL0).
• If two or more interrupt requests are assigned to one interrupt control register and the EI2OS is used in
one of them, other interrupt requests cannot be used.
Table 12.4-1 Control Bits and Interrupt Factors for DTP/External Interrupt
If the interrupt request signal from the DTP/external interrupt is output to the interrupt controller and the
EI2OS enable bit in the interrupt control register (ICR: ISE) is set to 0, the interrupt processing is executed.
This bit is set to 1, the EI2OS is executed.
Figure 12.4-2 "Operation of DTP/External Interrupt" shows the operation of the DTP/external interrupt.
335
CHAPTER 12 DTP/EXTERNAL INTERRUPT
DTP/external
interrupt circuit
Other request Interrupt controller CPU
ELVR
ICR YY IL Interrupt
EIRR CMP CMP
processing
ENIR ICR XX ILM
Factor
EI2OS starts
DTP/external interrupt
request generated Transfer data between
memory and resource
Descriptor =0
data counter Interrupt processing
Interrupt acceptance
determined by CPU ≠0
Reset or stop
1
ICR : ISE
336
CHAPTER 12 DTP/EXTERNAL INTERRUPT
The DTP/external interrupt has an external interrupt function for generating an interrupt
request by detecting the signal (edge or level) in the DTP/external interrupt pin and the
RX pin.
Notes: • When the DTP/external interrupt start factor is generated, the DTP/external interrupt request flag bit
(EIRR: ER) is set to 1, regardless of the setting of the DTP/external interrupt request enable bit
(ENIR: EN).
• When the interrupt processing is started, clear the DTP/external interrupt request flag bit that caused
the start factor. Control cannot be returned from the interrupt while the DTP/external interrupt request
flag bit is set to 1. When clearing, do not clear any flag bit other than the accepted DTP/external
interrupt factor.
337
CHAPTER 12 DTP/EXTERNAL INTERRUPT
The DTP/external interrupt has the DTP function that detects the signal of the external
peripheral device from the DTP/external interrupt pin and the RX pin to start the EI2OS.
■ DTP Function
The DTP function detects the signal level set by the detection level setting register of the DTP/external
interrupt function to start the EI2OS.
• When the EI2OS operation is already enabled (ICR: ISE = 1) at the point when the interrupt request is
accepted by the CPU, the DTP function starts the EI2OS and starts data transfer.
• When transfer of one data item is completed, the descriptor is updated and the DTP/external interrupt
request flag bit is cleared to prepare for the next request from the DTP/external interrupt pin and the RX
pin.
• When the EI2OS completes transfer of all the data, control branches to the interrupt processing.
Peripheral
device Internal data bus
external- Read/Write
connected operation*2
Interrupt
DTP factor*1 INT DTP/external request Internal
Data transfer CPU
request interrupt circuit (EI2OS) memory
*1: This must be cancelled within three machine clocks after the start of data transfer.
*2: When EI2OS is "peripheral function → internal memory transfer".
338
CHAPTER 12 DTP/EXTERNAL INTERRUPT
This section explains the precautions when using the DTP/external interrupt.
Figure 12.5-2 DTP/External Interrupt Factor and Interrupt Request Generated when Interrupt Request
Enabled
339
CHAPTER 12 DTP/EXTERNAL INTERRUPT
● Precautions on interrupts
• When the DTP/external interrupt is used as the external interrupt function, no return from interrupt
processing can be made with the DTP/external interrupt request flag bit set to 1 (EIRR: ER) and the
DTP/external interrupt request set to "enabled" (ENIR: EN = 1). Always set the DTP/external interrupt
request flag bit to 0 (EIRR: ER) at interrupt processing.
• When the level detection is set in the detection level setting register and the level that becomes the
interrupt factor remains input, the external interrupt request flag bit is reset immediately even when
cleared (EIRR: ER = 0). Disable the DTP/external interrupt request output as needed (ENIR: EN = 0), or
cancel the interrupt factor itself.
340
CHAPTER 12 DTP/EXTERNAL INTERRUPT
● Processing specifications
An external interrupt is generated by detecting the rising edge of the pulse input to the INT4 pin.
● Coding example
341
CHAPTER 12 DTP/EXTERNAL INTERRUPT
● Processing specification
• Channel 0 of the EI2OS is started by detecting the High level of the signal input to the INT4 pin.
• RAM data is output to port 1 by performing DTP processing (EI2OS).
● Coding example
342
CHAPTER 12 DTP/EXTERNAL INTERRUPT
LOOP:
:
Processing by user
:
BRA LOOP
;-----Interrupt program----------------------------------------------------------
WARI:
CLRB I:ER4 ; INT4 interrupt request flag cleared
:
Processing by user
:
RETI ; Return from interrupt
CODE ENDS
;-----Vector setting-------------------------------------------------------------
VECT CSEG ABS = 0FFH
ORG 00FF9CH ; Vector set to interrupt number #24 (18H)
DSL WARI
ORG 00FFDCH ; Reset vector set
DSL START
DB 00H ; Set to single-chip mode set
VECT ENDS
END START
343
CHAPTER 12 DTP/EXTERNAL INTERRUPT
344
CHAPTER 13
8-/10-BIT A/D CONVERTER
345
CHAPTER 13 8-/10-BIT A/D CONVERTER
The 8-/10-bit A/D converter converts the analog input voltage to a 8- or 10-bit digital
value by using the RC sequential-comparison converter system.
• An input signal can be selected from the input signals of the analog input pins for 8
channels.
• The start trigger can be selected from a software trigger, internal timer output, and an
external trigger.
Conversion Description
Mode
Single-shot A/D conversion is performed sequentially from the start channel to the end
conversion mode channel. When A/D conversion for the end channel is terminated, it stops.
Continuous A/D conversion is performed sequentially from the start channel to the end
conversion mode channel. When A/D conversion for the end channel is terminated, it is continued
after returning to the start channel.
Pause-conversion A/D conversion is performed sequentially from the start channel to the end
mode channel. When A/D conversion for the end channel is terminated, A/D conversion
and pause are repeated after returning to the start channel.
346
CHAPTER 13 8-/10-BIT A/D CONVERTER
2 6
ADTG 2
TO Start selector Decoder
Comparator
AN7 Sample & hold
AN6 circuit Controller
AN5
AN4 Analog
AN3 channel
AN2 selector
AN1 AVR
AN0 AVcc D/A converter
AVss
2
2
A/D data
register
(ADCR) S10 ST1 ST0 CT1 CT0 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0
347
CHAPTER 13 8-/10-BIT A/D CONVERTER
● Start selector
This selector selects the trigger to start A/D conversion. An internal timer output or external pin input can
be set as the start trigger.
348
CHAPTER 13 8-/10-BIT A/D CONVERTER
● Decoder
This decoder sets the A/D conversion start channel select bits and the A/D conversion end channel select
bits in the A/D control status register (ADCS: ANS2 to ANS0 and ANE2 to ANE0) to select the analog
input pin to be used for A/D conversion.
● D/A converter
This converter generates the reference voltage which is compared with the input voltage held in the sample
& hold circuit.
● Comparator
This comparator compares the D/A converter output voltage with input voltage held in the sample & hold
circuit to determine the mount of voltage.
● Controller
This circuit determines the A/D conversion value by receiving the signal indicating the amount of voltage
determined by the comparator. When the A/D conversion results are determined, the result data is stored in
the A/D data register. If an interrupt request is enabled, an interrupt is generated.
349
CHAPTER 13 8-/10-BIT A/D CONVERTER
This section explains the pins, registers, and interrupt factors of the A/D converter.
Trigger input ADTG General-purpose I/O port, Set as input port in port direction register
external trigger input (DDR).
Channel 0 AN0
Channel 1 AN1
Channel 2 AN2
Set as input ports in port direction
Channel 3 AN3 General-purpose I/O ports, register (DDR).
Channel 4 AN4 analog inputs Input of analog signal enabled (ADER:
ADE7 to ADE0 = 11111111B)
Channel 5 AN5
Channel 6 AN6
Channel 7 AN7
350
CHAPTER 13 8-/10-BIT A/D CONVERTER
bit 15 14 13 12 11 10 9 8
×: Undefined
351
CHAPTER 13 8-/10-BIT A/D CONVERTER
The A/D control status register (High) (ADCS: H) provides the following settings:
• Starting A/D conversion function by software
• Selecting start trigger for A/D conversion
• Storing A/D conversion results in A/D data register to enable or disable interrupt
request
• Storing A/D conversion results in A/D data register to check and clear interrupt
request flag
• Pausing A/D conversion and checking state during conversion
352
CHAPTER 13 8-/10-BIT A/D CONVERTER
Table 13.3-2 Function of Each Bit of A/D Control Status Register (High) (ADCS: H)
353
CHAPTER 13 8-/10-BIT A/D CONVERTER
The A/D control status register (Low) (ADCS: L) provides the following settings:
• Selecting A/D conversion mode
• Selecting start channel and end channel of A/D conversion
7 6 5 4 3 2 1 0
Reset value
00000000 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 2 bit 1 bit 0
ANE2 ANE1 ANE0 A/D conversion end channel select bits
0 0 0 AN0 pin
0 0 1 AN1 pin
0 1 0 AN2 pin
0 1 1 AN3 pin
1 0 0 AN4 pin
1 0 1 AN5 pin
1 1 0 AN6 pin
1 1 1 AN7 pin
bit 5 bit 4 bit 3
A/D conversion start channel select bits
0 0 0 AN0 pin
0 0 1 AN1 pin
0 1 0 AN2 pin
Channel number Channel number
0 1 1 AN3 pin
currently being just previously
1 0 0 AN4 pin converted converted
1 0 1 AN5 pin
1 1 0 AN6 pin
1 1 1 AN7 pin
bit 7 bit 6
MD1 MD0 A/D conversion mode select bits
0 0 Single-shot conversion mode 1 (restartable during conversion)
0 1 Single-shot conversion mode 2 (not-restartable during conversion)
1 0 Continuous conversion mode (not-restartable during conversion)
R/W : Read/Write
1 1 Pause-conversion mode (not-restartable during conversion)
: Reset value
354
CHAPTER 13 8-/10-BIT A/D CONVERTER
Table 13.3-3 Function of Each Bit of A/D Control Status Register (Low) (ADCS: L) (1/2)
bit 0 to bit 2 ANE2 to ANE0: These bits set the channel at which A/D conversion terminated.
A/D conversion end Start channel < end channel: A/D conversion starts at channel set by A/D
channel select bits conversion start channel select bits (ANS2 to ANS0) and terminates channel set
by A/D conversion end channel select bits (ANE2 to ANE0)
Start channel = end channel: A/D conversion is performed only for one
channel set by A/D converter end (= start) channel select bits (ANE2 to ANE0 =
ANS2 to ANS0).
Start channel > end channel: A/D conversion is performed from channel set by
A/D conversion start channel select bits (ANS2 to ANS0) to AN7, and from
AN0 to channel set by A/D conversion end channel select bits (ANE2 to ANE0).
Continuous conversion mode and pause-conversion mode: When A/D
conversion terminated at the channel set by the A/D conversion end channel
select bits (ANE2 to ANE0), it returns to the channel set by the A/D conversion
start channel select bits (ANS2 to ANS0).
Note:
Do not set the A/D conversion end channel select bits (ANE2 to ANE0)
during A/D conversion.
bit 3 to bit 5 ANS2 to ANS0: These bits set the channel at which A/D conversion start. At read, the channel
A/D conversion start number under A/D conversion or A/D-converted immediately before A/D
channel select bits conversion pauses can be checked.
Start channel < end channel: A/D conversion starts at channel set by A/D
conversion start channel select bits (ANS2 to ANS0) and terminates at channel
set by A/D conversion end channel select bits (ANE2 to ANE0)
Start channel = end channel: A/D conversion is performed only for one
channel set by A/D conversion (= end) channel select bits (ANS2 to ANS0 =
ANE2 to ANE0)
Start channel > end channel: A/D conversion performed from channel set by
A/D conversion start channel select bits (ANS2 to ANS0) to AN7, and from
AN0 to channel set by A/D conversion end channel select bits (ANE2 to ANE0)
Continuous conversion mode and pause-conversion mode: When A/D
conversion terminates at the channel set by the A/D conversion end channel
select bits (ANE2 to ANE0), it returns to the channel set by the A/D conversion
start channel select bits (ANS2 to ANS0).
Read (Except pause-conversion mode): The channel numbers (7 to 0) under A/
D conversion are read.
Read (Pause-conversion mode): At read during a pause, the channel number A/
D-converted immediately before a pause is read.
Note:
Do not set the A/D conversion start channel bits (ANS2 to ANS0) during A/
D conversion.
355
CHAPTER 13 8-/10-BIT A/D CONVERTER
Table 13.3-3 Function of Each Bit of A/D Control Status Register (Low) (ADCS: L) (2/2)
bit 6 MD1, MD0: These bits set the A/D conversion mode.
bit 7 A/D conversion Single-shot conversion mode 1:
mode select bits • The analog inputs from the start channel (ADCS: ANS2 to ANS0) to the end
channel (ADCS: ANE2 to ANE0) are A/D-converted continuously.
• The A/D conversion pauses after A/D conversion for the end channel.
• This mode can be restarted during A/D conversion.
Single-shot conversion mode 2:
• The analog inputs from the start channel (ADCS: ANS2 to ANS0) to the end
channel (ADCS: ANE2 to ANE0) are A/D-converted continuously.
• The A/D conversion after A/D conversion for the end channel.
• This mode cannot be restarted during A/D conversion.
Continuous conversion mode:
• The analog inputs from the start channel (ADCS: ANS2 to ANS0) to the end
channel (ADCS: ANE2 to ANE0) are A/D-converted continuously.
• When A/D conversion for the end channel is terminated, it is continued after
returning to the analog input for the start channel.
• To terminate A/D conversion forcibly, write 0 to the A/D conversion-on flag
bit in the A/D control status register (ADCS: BUSY).
• This mode cannot be restarted during A/D conversion.
Pause conversion mode:
• A/D conversion for the start channel (ADCS: ANS2 to ANS0) starts. The A/
D conversion pauses at termination of A/D conversion for a channel. When
the start trigger is input while A/D conversion pauses, A/D conversion for the
next channel is started.
• The A/D conversion pauses at the termination of A/D conversion for the end
channel. When the start trigger is input while A/D conversion pauses, A/D
conversion is continued after returning to the analog input for the start
channel.
• To terminate A/D conversion forcibly, write 0 to the A/D conversion-on flag
bit in the A/D control status register (ADCS: BUSY).
• This mode cannot be restarted during A/D conversion.
Note:
When the conversion mode is set to "not restartable" (MD1, MD0 "00B"),
it cannot be restarted with any start triggers (software trigger, internal timer,
and external trigger) during A/D conversion.
356
CHAPTER 13 8-/10-BIT A/D CONVERTER
The higher five bits in the A/D data register (ADCR: H) select the compare time,
sampling time and resolution of A/D conversion.
Bits 9 and 8 in the A/D data register (ADCR) are explained in Section 13.3.4 "A/D Data
Register (Low) (ADCR: L)".
15 14 13 12 11 10 9 8
Reset value
* * 00101XXX B
W W W W W R R
bit 12 bit 11
CT1 CT0 Compare time select bits
0 0 44/φ (5.5 µs)*1
0 1 66/φ (4.12 µs)*2
1 0 88/φ (5.5 µs)*2
1 1 176/φ (11.0 µs)*2
bit 14 bit 13
ST1 ST0 Sampling time select bits
0 0 20/φ (2.5 µs)*1
0 1 32/φ (2.0 µs)*2
1 0 48/φ (3.0 µs)*2
1 1 128/φ (8.0 µs)*2
bit 15
S10 Resolution select bits
0 10 bits (D9 to D0)
R : Read only
1 8 bits (D7 to D0)
W : Write only
X : Undefined
*1 : The parenthesized values are provided when the machine clock operates at 8-MHz.
: Unused
*2 : The parenthesized values are provided when the machine clock operates at 16-MHz.
φ : Machine clock
: Reset value
357
CHAPTER 13 8-/10-BIT A/D CONVERTER
bit 11 CT1, CT0: These bits set the A/D conversion compare time.
bit 12 Compare time select bits • These bits set the time required from when analog input is A/D-converted
until it is stored in the data bits (D9 to D0).
Note:
The setting of CT1 and CT0 = "00B" is based on operation at 8 MHz. Setting
based on operation at 16 MHz does not assure normal operation. When these
bits are read, "00B" is read.
bit 13 ST1, ST0: These bits set the A/D conversion sampling time.
bit 14 Sampling time select bits • These bits set the time required from when A/D conversion starts until the
input analog voltage is sampled and held by the sample & hold circuit.
Note:
The setting of ST1 and ST0 = "00B" is based on operation at 8 MHz. Setting
based on operation at 16 MHz does not assure normal operation. When these
bits are read, "00B" is read.
358
CHAPTER 13 8-/10-BIT A/D CONVERTER
The A/D data register (Low) (ADCR: L) stores the A/D conversion results.
Bits 8 and 9 in the A/D data register (ADCR) in this section.
R: Read only
X: Undefined
bit 0 to bit 9 D9 to D0: These bits store the A/D conversion results.
A/D conversion data bits When resolution set in 10 bits (S10 = 0): Conversion data is stored in the 10
bits from D9 to D0.
When resolution set in 8 bits: Conversion data is stored in the 8 bits from
D7 to D0.
Note:
Use a word instruction (MOVW) to read the A/D conversion results
stored in the A/D conversion data bits (D9 to D0).
359
CHAPTER 13 8-/10-BIT A/D CONVERTER
The analog input enable register (ADER) enables or disables the analog input pins to be
used in the 8-/10-bit A/D converter.
7 6 5 4 3 2 1 0
Reset value
11111111 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
ANE0 Analog input enable bit 0 (AN0)
0 Analog input disable
1 Analog input enable
bit 1
ANE1 Analog input enable bit 1 (AN1)
0 Analog input disable
1 Analog input enable
bit 2
ANE2 Analog input enable bit 2 (AN2)
0 Analog input disable
1 Analog input enable
bit 3
ANE3 Analog input enable bit 3 (AN3)
0 Analog input disable
1 Analog input enable
bit 4
ANE4 Analog input enable bit 4 (AN4)
0 Analog input disable
1 Analog input enable
bit 5
ANE5 Analog input enable bit 5 (AN5)
0 Analog input disable
1 Analog input enable
bit 6
ANE6 Analog input enable bit 6 (AN6)
0 Analog input disable
1 Analog input enable
bit 7
ANE7 Analog input enable bit 7 (AN7)
0 Analog input disable
1 Analog input enable
R/W : Read/Write
: Reset value
360
CHAPTER 13 8-/10-BIT A/D CONVERTER
bit 0 to bit 7 ADE7 to ADE0: These bits enable or disable the analog input of the pin to be used for A/D
Analog input enable bits conversion.
When set to 0: Disables analog input
When set to 1: Enables analog input
Notes: • The analog input pins serve as a general-purpose I/O port of the port 5. When using the pin as an
analog input pin, switch the pin to analog input pin according to the setting of the port 5 direction
register (DDR5) and the analog input enable register (ADER).
• When using the pin as an analog input pin, write 0 to the bit in the port 5 direction register (DDR5)
corresponding to the pin to be used and turn off the output transistor. Also write 1 to the bit in the
analog input enable register (ADER) corresponding to the pin to be used and set the pin to analog
input.
361
CHAPTER 13 8-/10-BIT A/D CONVERTER
When A/D conversion is terminated and its results are stored in the A/D data register
(ADCR), the 8-/10-bit A/D converter generates an interrupt request. The EI2OS function
can be used.
362
CHAPTER 13 8-/10-BIT A/D CONVERTER
The 8-/10-bit A/D converter has the following A/D conversion modes. Set each mode
according to the setting of the A/D conversion mode select bits in the A/D control status
register (ADCS: MD1, MD0).
• Single conversion mode (restartable/not-restartable during A/D conversion)
• Continuous conversion mode (not-restartable during A/D conversion)
• Pause conversion mode (not-restartable during A/D conversion)
363
CHAPTER 13 8-/10-BIT A/D CONVERTER
In the single conversion mode, A/D conversion is performed sequentially from the start
channel to the end channel. The A/D conversion stops at the termination of A/D
conversion for the end channel.
ADER
: Unused
: Used bit
: Set the bit corresponding to pin to be used as analog input pin to 1.
0 : Set 0
364
CHAPTER 13 8-/10-BIT A/D CONVERTER
AN0 pin AN3 pin AN0 --> AN1 --> AN2 --> AN3 --> End
(ADCS: ANS = "000B") (ADCS: ANE = "011B")
AN6 pin AN2 pin AN6 --> AN7 --> AN0 --> AN1 --> AN2 --> End
(ADCS: ANS = "110B") (ADCS: ANE = "010B")
365
CHAPTER 13 8-/10-BIT A/D CONVERTER
In the continuous conversion mode, A/D conversion is performed sequentially from the
start channel to the end channel.
When A/D conversion for the end channel is terminated, it is continued after returning
to the start channel.
ADER
: Unused
: Used bit
: Set the bit corresponding to pin to be used as analog input pin to 1.
1 : Set 1
0 : Set 1
366
CHAPTER 13 8-/10-BIT A/D CONVERTER
AN0 pin AN3 pin AN0 --> AN1 --> AN2 --> AN3 --> AN0 -->
(ADCS: ANS = "000B") (ADCS: ANE = "011B") Repeat
AN6 pin AN2 pin AN6 --> AN7 --> AN0 --> AN1 --> AN2 -->
(ADCS: ANS = "110B") (ADCS: ANE = "010B") AN6 --> Repeat
367
CHAPTER 13 8-/10-BIT A/D CONVERTER
In the pause-conversion mode, A/D conversion starts and pauses repeatedly for each
channel. When the start trigger is input after the A/D conversion pauses at the
termination of the A/D conversion for the end channel, A/D conversion is continued
after returning to the start channel.
ADER
: Unused
: Used bit
: Set the bit corresponding to pin to be used as analog input pin to 1.
1 : Set 1
0 : Set 1
368
CHAPTER 13 8-/10-BIT A/D CONVERTER
AN0 pin AN3 pin AN0 --> Stop, Start --> AN1 --> Stop, Start -->
(ADCS: ANS = "000B") (ADCS: ANE="011B") AN2 --> Stop, Start --> AN3 --> Stop, Start -->
AN0 --> Repeat
AN6 pin AN2 pin AN6 --> Stop, Start --> AN7 --> Stop, Start -->
(ADCS: ANS = "110B") (ADCS: ANE="010B") AN0 --> Stop, Start --> AN1 --> Stop, Start -->
AN2 --> Stop, Start --> AN6 --> Repeat
AN3 pin AN3 pin AN3 --> Stop, Start --> AN3 --> Stop, Start -->
(ADCS: ANS = "011B") (ADCS: ANE="011B") Repeat
369
CHAPTER 13 8-/10-BIT A/D CONVERTER
The 8-/10-bit A/D converter can transfer the A/D conversion result to memory by using
the EI2OS function.
Interrupt generated
EI2OS starts
Specified count NO
completed?*1
Interrupt cleared
YES
Interrupt processing
370
CHAPTER 13 8-/10-BIT A/D CONVERTER
A/D conversion with the output an interrupt request enabled activates the A/D
conversion data protection function.
● Processing flow of A/D conversion data protection function when EI2OS used
Figure 13.5-5 "Processing Flow of A/D Conversion Data Protection Function when Using EI2OS" shows
the processing flow of the A/D conversion data protection function when the EI2OS is used.
371
CHAPTER 13 8-/10-BIT A/D CONVERTER
Figure 13.5-5 Processing Flow of A/D Conversion Data Protection Function when Using EI2OS
EI2OS set
NO
EI2OS terminates A/D pauses
YES
Continued
Interrupt processing
End
Note: The operation flow of when the A/D converter is stopped is omitted.
Notes: • The A/D conversion data protection function is activated only when an interrupt request is enabled.
Set the interrupt request enable bit in the A/D control status register (ADCS: INTE) to 1.
• When the EI2OS function is used to transfer the A/D conversion results to memory, do not disable
output of an interrupt request. If output of an interrupt request is disabled during a pause of A/D
conversion (ADCS: INTE = 0), A/D conversion may be restarted to rewrite data being transferred.
• When the EI2OS function is used to transfer the A/D conversion results to memory, do not restart.
Restarting during a pause of A/D conversion may cause loss of the A/D conversion results.
372
CHAPTER 13 8-/10-BIT A/D CONVERTER
Precautions when using the 8-/10-bit A/D converter are given below:
373
CHAPTER 13 8-/10-BIT A/D CONVERTER
374
CHAPTER 14
UART1
375
CHAPTER 14 UART1
■ Function of UART1
● Function of UART1
The UART1 is a general-purpose serial-data communication interface, which transmits/receives serial data
with external devices. UART1 has functions listed in Table 14.1-1 "Function of UART1".
Function
Note: At the clock synchronous transfer, the UART only transfers data, not affixing the start and stop bits.
376
CHAPTER 14 UART1
Data Length
Synchronous/ Length of
Operation Mode
Asynchronous Stop Bit
With Parity No Parity
Asynchronous mode
0 7 or 8 bits Asynchronous
(Normal mode)
1 bit or 2 bits *2
1 Multiprocessor mode 8 + 1 *1 − Asynchronous
−: Setting disabled
*1: +1 is the address/data select bit (SCR1 register bit 11: A/D) used for controlling communications.
*2: During reception, only one bit can be detected as the stop bit.
377
CHAPTER 14 UART1
Control bus
Receive interrupt
request output
Dedicated baud
Transmit interrupt
rate generator Transmit clock
request output
16-bit reload Clock
timer selector
Receive clock
Receive Transmit
Pin controller controller
SCK1 Start bit Transmit
detector start circuit
Receive Transmit
Pin
shift register shift register
SIN1
Start of reception
Serial input End of Serial output
reception
data register 1 data register 1
Reception state
determine circuit Receive-error-
generate signal
for EI2OS (to CPU)
378
CHAPTER 14 UART1
● Clock selector
The clock selector selects the transmit/receive clock from the dedicated baud rate generator, external input
clock, and internal clock (clock supplied from 16-bit reload timer).
● Receive controller
The receive controller is composed of receive bit counter, start bit detector and receive parity counter. The
receive bit counter counts the receive data, and outputs a receive interrupt request when reception of one
piece of data is completed.
The start bit detector detects the start bit from the serial input signal and writes the received data to the
serial input data register, on a bit-by-bit shift basis in accordance with the transfer rate.
● Transmit controller
The transmit controller is composed of the transmit bit counter, transmit start circuit, and transmit parity
counter. The transmit bit counter counts the transmit data, and outputs a transmit interrupt request when
transmission of one piece of data is completed according to the set data length. The transmit start circuit
starts transmission when serial output data register (SODR1) is written. The transmit parity counter
generates the parity bit of the data transferred when parity is provided.
379
CHAPTER 14 UART1
380
CHAPTER 14 UART1
The UART1 pins, interrupt factors, register list and details are shown.
■ UART1 Pin
The pins used in the UART1 serve as general-purpose I/O port.
Table 14.3-1 "UART1 Pin" indicates the pin functions and the setting necessary for use in the UART1.
General-purpose I/O port, Set to output enable. (SMR1 register bit 0: SOE=1)
SOT1
serial data output
bit 15 14 13 12 11 10 9 8
bit 7 6 5 4 3 2 1 0
bit 15 14 13 12 11 10 9 8
bit 7 6 5 4 3 2 1 0
Serial input data register 1 (SIDR1)
/Serial output data register 1 (SODR1)
× × × × × × × ×
381
CHAPTER 14 UART1
● Receive interrupt
• When receive data is loaded to the serial input data register (SIDR1), the receive data load flag bit (bit
12: RDRF) in the serial status register (SSR1) is set to 1. When a receive interrupt is enabled (bit 9: RIE
= 1), a receive interrupt request is generated to the interrupt controller.
• When either a framing error, overrun error, or parity error occurs, the framing error flag bit (bit 13:
FRE), the overrun error flag bit (bit 14: ORE), or parity error flag bit (bit 15: PE) in the serial status
register (SSR1) are set to 1 according to the error occurred. When a receive interrupt is enabled (bit 9:
RIE = 1), a receive interrupt is requested to the interrupt controller.
● Transmit interrupt
When transmit data is transferred from the serial output data register (SODR1) to the transmit shift register,
the transmit data empty flag bit (bit 11: TDRE) in the serial status register (SSR1) is set to 1. If a transmit
interrupt is enabled (bit 8: TIE = 1), a transmit interrupt is requested.
382
CHAPTER 14 UART1
The serial control register 1 (SCR1) performs the following: setting parity bit, selecting
stop bit length and data length, selecting frame data format in operation mode 1,
clearing receive error flag, and enabling/disabling of transmitting/receiving.
15 14 13 12 11 10 9 8
Reset value
00000100 B
R/W R/W R/W R/W R/W W R/W R/W
bit 8
TXE Transmit enable bit
0 Transmit disable
1 Transmit enable
bit 9
RXE Receive enable bit
0 Receive disable
1 Receive enable
bit 10
REC Receive error flag clear bit
0 Clear PE and ORE, FRE, bits
1 No effect
bit 11
A/D Address/data select bit
0 Data frame
1 Address frame
bit 12
CL Data-length select bit
0 7 bits
1 8 bits
bit 13
SBL Stop-bit length select bit
0 1-bit length
1 2-bit length
bit 14
Parity select bit
P
Enable only when parity provided (PEN = 1)
0 Even parity
1 Odd parity
bit 15
PEN Parity addition enable bit
0 No parity
R/W : Read/Write
1 With parity
W : Write only
: Reset value
383
CHAPTER 14 UART1
bit 10 REC: Clear the receive error flags (bit 15 to 13: PE, ORE and FRE) of the serial status
Receive error flag clear register (SSR1) to 0.
bit When set to 0: Clears PE, ORE and FRE flags
When set to 1: No effect
When read: 1 always read
Note:
When a receive interrupt is enabled (bit 9: RIE = 1), set the bit10: REC bit to
0 only when any one of the PE, ORE and FRE flags is set to 1.
bit 11 A/D: In operation mode 1 (asynchronous multiprocessor mode), set the data format of
Address/data select bit the frame to be transmitted/received.
When bit set to 0: Data frame set
When bit set to 1: Address data frame set
bit 13 SBL: Set the length of the stop bit (frame end mark of send data) in operation modes 0
Stop-bit length select bit and 1 (multiprocessor mode, synchronous mode).
Note:
At receiving, only the first bit of the stop bit is always detected.
bit 14 P: Select either odd or even parity when with parity (PEN = 1) is set.
Parity select bit
bit 15 PEN: Specify whether to add (at sending) and detect (at receiving) a parity bit.
Parity addition enable bit Note:
A parity bit is not added in operation modes 1 and 2 (Multiprocessor mode,
Synchronous mode). Be sure to set this bit to 0.
384
CHAPTER 14 UART1
The serial mode register 1 (SMR1) performs selecting operation mode, selecting baud
rate clock, and disabling/enabling of output of serial data and clock to pin.
7 6 5 4 3 2 1 0
Reset value
00000000 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
SOE Serial data output enable bit (SOT1 pin)
0 Serves as general-purpose I/O port
1 Serves as serial data output of UART1
bit 1
SCKE Serial clock I/O enable bit (SCK1 pin)
0 Serves as general-purpose I/O port or clock input pin of UART 1
1 Serves as serial clock output pin of UART1
bit 2
Reserved Reserved bit
0 No effect
1 Initialize all registers of UART1
385
CHAPTER 14 UART1
bit 1 SCKE: Switch between input and output of the serial clock.
Serial clock I/O enable When set to 0: General-purpose I/O port or serial clock input pin set
bit When set to 1: Serial clock output pin set
Notes:
1. When using the SCK1 pin as the serial clock input, set the pin to the input
port using the port direction register (DDR). Also select the external clock
(bit 5 to 3: CS2 to CS0 = "111B") using the clock input source select bit.
2. When using the SCK pin as the serial clock output, set the clock input
source select bit to anything other than the external clock (bit 5 to 3: CS2
to CS0 = anything other than "111B").
bit 2 RST: UART Reset bit This bit resets all registers in the UART1.
When set to 0: No effect on operation
When set to 1: Resets all registers in UART1
bit 3 to bit 5 CS0 to CS2: Set the clock input source for the baud rate.
Clock input source select • Select the external clock (SCK1 pin), internal timer (16-bit reload timer),
bits or dedicated baud rate generator as the clock input source.
• Set the baud rate when selecting the dedicated baud rate generator.
bit 6 and bit 7 MD0, MD1: Select the UART1 operation mode.
Operation mode select Notes:
bits 1. In operation mode 1 (asynchronous multiprocessor mode), only the
master can be used for master/slave communication. In operation mode 1,
the address/data bit on bit 9 cannot be received, so the slave cannot be
used.
2. In operation mode 1 (asynchronous multiprocessor mode), the parity
check function cannot be used, set the parity addition enable bit to no
parity (SCR1 register bit 15: PEN = 0).
Note: When 0 is written to the RST bit of Serial Mode Register, the interruption UART should be prohibited.
To prohibit the interruption, take one of the following procedures:
1. Before writing 0 to the RST bit, clear I flag to prohibit all interrupt factors.
2. Before writing 0 to the RST bit, prohibit the UART interruption with the ILM register.
3. When 0 is written to the RST bit, writing should be performed at the UART interruption level or
the level with higher priority than the UART interruption.
386
CHAPTER 14 UART1
The serial status register 1 (SSR1) checks the transmission/reception status and error
status and enables/disables interrupts.
15 14 13 12 11 10 9 8
Reset value
00001000 B
R R R R R R/W R/W R/W
bit 8
TIE Transmit interrupt enable bit
0 Disables transmit interrupt
1 Enables transmit interrupt
bit 9
RIE Receive interrupt enable bit
0 Disables receive interrupt
1 Enables receive interrupt
bit 10
BDS Transfer direction select bit
0 LSB first (transfer from least significant bit)
1 MSB first (transfer from most significant bit)
bit 11
TDRE Transmit data writing flag bit
0 With transmit data (write of transmit data disabled)
1 No transmit data (write of transmit data enabled)
bit 12
RDRF Receive data load flag bit
0 No receive data
1 With receive data
bit 13
FRE Framing error flag bit
0 No framing error
1 With framing error
bit 14
ORE Overrun error flag bit
0 No overrun error
1 With overrun error
bit 15
PE Parity error flag bit
0 No parity error
1 With parity error
R/W : Read/Write
R : Read only
: Reset value
387
CHAPTER 14 UART1
388
CHAPTER 14 UART1
The serial input data register (SIDR1) and serial output data register (SODR1) are
allocated to the same address. At read, the register functions as SIDR1. At write, the
register functions as SODR1.
R: Read only
X: Undefined
389
CHAPTER 14 UART1
W: Write only
X: Undefined
The serial output data register 1 (SODR1) is a data buffer register for transmitting serial data.
• When data to be transmitted is written to SODR1 when transmission is enabled (SCR1 register bit 8:
TXE = 1), it is transferred to the transmit shift register, converted to serial data, and transmit from the
serial data output pin (SOT1).
• When the data length is 7 bits, the upper one bit (SODR1 register bit 7: D7) becomes invalid.
• The transmit data write flag (SSR1 register bit 11: TDRE) is cleared to 0 when send data is written to
SODR1.
• The transmit data write flag is set to 1 at completion of data transfer to the transmit shift register.
• When the transmit data write flag (SSR1 register bit 11: TDRE) is 1, the transmit data can be written.
When a transmit interrupt is enabled (SSR1 register bit 8: TIE=1), a transmit interrupt occurs. The
transmit bit data should be written with the transmit data write flag (SCR1 register bit 11: TDRE) at 1.
Note: Serial output data register is a write-only register and serial input data register is a read-only register.
However, since they are allocated to the same address, the write and read values are different. Therefore,
do not use instructions that perform read-modify-write (RMW) operation such as INC and DEC
instructions.
390
CHAPTER 14 UART1
The communication prescaler control register 1 (CDCR1) is used to set the baud rate of
the dedicated baud rate generator for the UART1.
• Starts/stop the communication prescaler
• Sets the division ratio for machine clock
15 14 13 12 11 10 9 8
Reset value
0XXX0000 B
R/W R/W R/W R/W R/W
bit 10 bit 9 bit 8
DIV2 DIV1 DIV0 Communication prescaler division ratio (div) bits
0 0 0 1-divided clock
0 0 1 2-divided clock
0 1 0 3-divided clock
0 1 1 4-divided clock
1 0 0 5-divided clock
1 0 1 6-divided clock
1 1 0 7-divided clock
1 1 1 8-divided clock
bit 11
Reserved Reserved bit
0 Always set 0
bit 15
MD Communication prescaler control bit
R/W : Read/Write 0 Communication prescaler stopped
X : Undefined 1 Communication prescaler enabled
: Unused
: Reset value
391
CHAPTER 14 UART1
bit 8 to bit 10 DIV0 to DIV2: • These bits set the machine clock division ratio.
Communication Note:
prescaler division ratio When changing the division ratio, the time of at least one 1/2-frequency
bits division of the division clock should be allowed before the next
communication is started in order to stabilize the clock frequency.
392
CHAPTER 14 UART1
The UART1 has a receive and a transmit interrupts, and the following factors can issue
interrupt requests.
• Receive data is loaded to the serial input data register 1 (SIDR1).
• A receive error (parity error, overrun error, framing error) occurs.
• When send data transferred from the output data register 1 (SODR1) to transmit shift
register
Also, each of these interrupt factors supports the expansion intelligent I/O service
(EI2OS).
■ Interrupt of UART1
The UART1 interrupt control bits and interrupt factors are shown in Table 14.4-1 "UART1 Interrupt
Control Bit and Interrupt Factor".
Operation
Interrupt- Interrupt
Trans-mission/ Mode Clear of the Interrupt-
request Interrupt Factor Factor
Reception request Flag
Flag Bit Enable Bit
0 1 2
Ο: Used bit
X: Unused bit
393
CHAPTER 14 UART1
● Receive interrupt
When a receive interrupt is enabled (SSR1 register bit 9: RIE = 1), a receive interrupt request is issued at
completion of data receiving (SSR1 register bit 12: RDRF = 1) or when any one of the overrun error (SSR1
register bit 14: ORE = 1), framing error (SSR 1 register bit 13: FRE = 1), and parity error (SSR 1 register
bit 15: PE = 1) occurs.
The receive data load flag (SSR1 register bit 12: RDRF) is cleared to 0 automatically when the serial input
data register 1 (SIDR1) is read. Each receive error flag (SSR1 register bit 15, 14, 13: PE, ORE, FRE) is
cleared to 0 when 0 is written to the receive error flag clear bit (SCR1 register bit 10: REC).
Note: If a receive error (parity error, overrun error, framing error) occurs, correct the error as necessary, and
then write 0 to the receive error flag clear bit (SCR0: REC) to clear each receive error flag.
● Transmit interrupt
When send data is transmitted from the serial output data register 1 (SODR1) to the transmit shift register,
the transmit data write flag bit (SSR1 register bit 11: TDRE) is set to 1.
When a transmit interrupt is enabled (SSR1 register bit 8: TIE = 1), a send interrupt request is issued.
● At reception:
The EI2OS can be used regardless of the state of other resources.
● At transmission:
Since the interrupt control registers (ICR13, 14) are shared with receive interrupts of UART1, EI2OS can
be started only when UART1 transmit interrupts are not used.
394
CHAPTER 14 UART1
Interrupts at receiving include the receive completion (SSR1 register bit 12: RDRF), and
the receive error (SSR1 register bit 15, 14, 13: PE, ORE, FRE).
● Receive data load flag and each receive error flag sets
When data is received, it is stored in the serial input data register (SIDR) when the stop bit is detected (in
operation modes 0 and 1: Asynchronous normal mode, Asynchronous multiprocessor mode) or when the
last bit of receive data (SIDR1 register bit 7: D7) is detected (in operation mode 2: Clock synchronous
normal mode). When a receive error occurs, the error flags (SSR1 register bit 15, 14, 13: PE, ORE, FRE)
and receive data load flag (SSR1 register bit 12: RDRF) are set. In each operation mode, the received data
in the serial input data register 0 (SIDR1) is invalid if either error flag is set.
Operation mode 0 (Asynchronous normal mode)
The receive data load flag bit (SSR1 register bit 12: RDRF) is set when the stop bit is detected. The error
flags (SSR1 register bit 15, 14, 13: PE, ORE, FRE) are set when a receive error occurs.
Operation mode 1 (Asynchronous multiprocessor mode)
The receive data load flag bit (SSR1 register bit 12: RDRF) is set to 1 when the stop bit is detected. The
error flags (SSR1 register bit 14, 13: ORE, FRE) are set when a receive error occurs. A parity error (SSR1
register bit 15: PE) cannot be detected.
Operation mode 2 (Clock synchronous mode)
The receive data load flag bit (SSR1 register bit 12: RDRF) is set to 1 when the last bit of receive data
(SIDR1 register bit 7: D7) is detected. The error flags (SSR1 register bit 14: ORE) are set when a receive
error occurs. A parity error (SSR1 register bit 15: PE) and framing error (SSR1 register bit 13: FRE) cannot
be detected.
Reception and timing of flag set are shown in Figure 14.4-1 "Reception and Timing of Flag Set".
395
CHAPTER 14 UART1
Receive data ST D0 D1 D5 D6
(operation mode 0) D7 SP
Receive data D0 D1 D4 D5 D6 D7
(operation mode 2)
SSR1: RDRF
396
CHAPTER 14 UART1
At transmission, the interrupt is generated in the state which the succeeding data can
be written to the serial output data register 1 (SODR1).
SSR1: TDRE
SP SP ST D0 D1 D2 D3
ST D0 D1 D2 D3 D4 D5 D6 D7 A/D
Output to SOT1
SSR1: TDRE
Output to SOT1 D0 D1 D2 D3 D4 D5 D6 D7 D0 D1 D2 D3 D4 D5 D6 D7
ST : Start bit
D0 to D7 : Data bits
SP : Stop bit
A/D : Address/data select bit
Note: When sending is disabled during sending (SCR1 register bit 8: TXE=0: and also in operation mode 1
(asynchronous multiprocessor mode), receiving disabled (also including bit 9: RXE)), the send data write
flag bit is set (SSR1 register bit 11: TDRF=1) and UART 1 communications are disabled after the shift
operation of the send shift register stops. The send data written to the serial output data register 1 before
the transmission stops (SODR1) is sent.
397
CHAPTER 14 UART1
398
CHAPTER 14 UART1
Clock selector
[Internal timer]
TMCSR1: CSL1, CSL0 CS2 to CS0 = "110B"
[External clock]
SCK1
1/1 [Clock synchronous]
Pin 1/16 [Asynchronous]
399
CHAPTER 14 UART1
The baud rate that can be set when the output clock of the dedicated baud rate
generator is selected as the transfer clock of the UART1 is shown.
Figure 14.5-2 Baud Rate Selector Based on Dedicated Baud Rate Generator
400
CHAPTER 14 UART1
● Division ratio based on communication prescaler (common between asynchronous and clock
synchronous modes)
The division ratio of the machine clock is set by the division ratio select bits in the communication
prescaler control register (CDCR1 register bit 10 to 8: DIV2 to DIV0).
0 − − − − Stop
1 0 0 0 0 1
1 0 0 0 1 2
1 0 0 1 0 3
1 0 0 1 1 4
1 0 1 0 0 5
1 0 1 0 1 6
1 0 1 1 0 7
1 0 1 1 1 8
401
CHAPTER 14 UART1
0 0 0 2 Mbps (φ/div) / 1
0 0 1 1 Mbps (φ/div) / 2
0 1 0 500 kbps (φ/div) / 4
0 1 1 250 kbps (φ/div) / 8
1 0 0 125 kbps (φ/div) / 16
1 0 1 62.5 kbps (φ/div) / 32
φ: Machine clock frequency
div: Division ratio based on communication prescaler
402
CHAPTER 14 UART1
The setting when selecting the internal clock supplied from the 16-bit reload timer 1 as
the clock input source of the UART1 and the baud rate calculation are shown below.
Figure 14.5-3 Baud Rate Selector by Internal Timer (16-bit Reload Timer Output)
Clock selector
● Baud Rate
φ/N
Asynchronous baud rate = bps
16 × 2 × (n+1)
φ/N
Clock synchronouse = bps
2 × (n+1)
403
CHAPTER 14 UART1
● Example of setting baud rates and reload register setting values (machine clock frequency: 7.3728
MHz)
Reload Value
38,400 2 − 47 11
19,200 5 − 95 23
9,600 11 2 191 47
4,800 23 5 383 95
404
CHAPTER 14 UART1
This section explains the setting when selecting the external clock as the transmit/
receive clock of the UART1.
Clock selector
SCK1
1/1 [Clock synchronous]
Pin Baud rate
1/16 [Asynchronous]
405
CHAPTER 14 UART1
The UART1 has master/slave type connection communication function (operation mode
1: asynchronous multiprocessor mode) in addition to bidirectional serial
communication function (operation modes 0 and 2: asynchronous normal mode and
clock synchronous mode).
■ Operation of UART1
● Operation mode
The UART1 has three types of operation modes, they can set the inter-CPU connection mode or data
communication mode.
Table 14.6-1 "Operation Mode of UART" shows operation mode of UART1.
Data Length
Synchronous/
Operation Mode Length of Stop Bit
Asynchronous
No Parity With Parity
−: Setting disabled
*1: +1 is the address/data select bit (SCR1 register bit 11: A/D) used for controlling communications.
*2: During reception, only one bit can be detected as the stop bit.
Note: The UART1 operation mode 1 (asynchronous multiprocessor mode) is only used as the master in the
master/slave type connection.
406
CHAPTER 14 UART1
● Synchronous/asynchronous
For the operation modes, either the asynchronous mode (start-stop synchronization) or the clock-
synchronous mode can be selected.
● Signal mode
The UART1 can only handle the NRZ (Non Return to Zero) data format.
● Start of transmission/reception
• Transmission starts when the transmission enable bit of the serial control register (SCR1 register bit 8:
TXE) is set to 1.
• Reception starts when the reception enable bit of the serial control register (SCR1 register bit 9: RXE) is
set to 1.
● Stop of transmission/reception
• Transmission stops when the transmission enable bit of the serial control register (SCR1 register bit 8:
TXE) is set to 0.
• Reception stops when the reception enable bit of the serial control register (SCR1 register bit 9: RXE) is
set to 0.
407
CHAPTER 14 UART1
When the UART is used in operation mode 0 (asynchronous normal mode) or operation
mode 1 (asynchronous multiprocessor mode), the asynchronous transfer mode is
selected.
408
CHAPTER 14 UART1
[Operation mode 0]
ST D0 D1 D2 D3 D4 D5 D7 D8 SP SP
P not
provided
ST D0 D1 D2 D3 D4 D5 D7 D8 SP
Data 8 bits
ST D0 D1 D2 D3 D4 D5 D7 D8 P SP SP
P
provided
ST D0 D1 D2 D3 D4 D5 D7 D8 P SP
ST D0 D1 D2 D3 D4 D5 D7 SP SP
P not
provided
ST D0 D1 D2 D3 D4 D5 D7 SP
Data 7 bits
ST D0 D1 D2 D3 D4 D5 D7 P SP SP
P
provided
ST D0 D1 D2 D3 D4 D5 D7 P SP
[Operation mode 1]
ST D0 D1 D2 D3 D4 D5 D7 D8 A/D SP SP
Data 8 bits
ST D0 D1 D2 D3 D4 D5 D7 D8 A/D SP
ST : Start bit
SP : Stop bit
P : Parity bit
A/D : Address/data bit
● Transmission
• Transmit data is written to the serial output data register 1 (SODR1) with the transmit data write flag bit
(SSR1 register bit 11: TDRE) set to 1.
• Transmission starts when transmit data is written and the transmit enable bit of the serial control register
(SCR1 register bit 8: TXE) is set to 1.
• The transmit data write flag bit (SSR1 register bit 11: TDRE) is cleared to 0 temporarily when transmit
data is written to SODR1.
• The transmit data write flag bit (SSR1 register bit 11: TDRE) is set to 1 again once the transmit data is
written to the send shift register from the serial output data register 0 (SODR1).
• When the transmit interrupt enable bit (SSR1 register bit 8: TIE) is set to 1, a send interrupt request is
issued once the send data write flag bit (SSR1 register bit 11: TDRE) is set to 1. The succeeding send
data can be written to the serial output data register 1 (SODR1) at interrupt processing.
409
CHAPTER 14 UART1
● Reception
• When reception is enabled (SCR1 register bit 9: RXE = 1), receiving is always performed.
• When the start bit of receive data is detected, the serial input data register 1 (SIDR1) receives one frame
of data and stores data to the serial input data register 1 (SIDR1) according to the data format specified
in the serial control register 1 (SCR1).
• At completion of receiving one frame of data, the receive data load flag bit (SSR1 register bit 12:
RDRF) is set to 1.
• When the status of the error flag of the serial status register 1 (SSR1) is checked to find normal
reception at the completion of one frame of data, read the receive data. When a receive error occurs,
perform error processing.
• The receive data load flag bit (SSR1 register bit 12: RDRF) is cleared to 0 when receive data is read.
410
CHAPTER 14 UART1
SIN ST D0 D1 D2 D3 D4 D5 D6 D7 SP
(Sending 01010101b)
RXE
Receive clock
Sampling clock
Receive clock (8 pulse) Generating sampling clocks by dividing the receive clock by 16
Recognition by the microcontroller ST D0 D1 D2 D3 D4 D5 D6 D7 SP
(Receiving 01010101b)
Note that specifying reception permission at the timing shown below obstructs the correct recognition of
the input data (SIN) by the microcontroller.
• Example of operation if reception permission (RXE = H) is specified while the communication line
level is L.
SIN ST D0 D1 D2 D3 D4 D5 D6 D7 SP
(Sending 01010101b)
RXE
Receive clock
Sampling clock
PE,ORE,FRE
● Stop bit
During transmission, one bit or two bits can be selected. However, the receive side always detects only the
first bit.
411
CHAPTER 14 UART1
● Error detection
• In operation mode 0 (asynchronous normal mode), parity, overrun, and frame errors can be detected.
• In operation mode 1 (asynchronous multiprocessor mode), overrun and frame errors can be detected, but
parity errors cannot be detected.
● Parity bit
A parity bit can be set only in operation mode 0 (asynchronous normal mode). The parity addition enable
bit (SCR1 register bit 15: PEN) is used to specify whether there is parity or not, and the parity select bit
(SCR1 register bit 14: P) is used to select odd or even parity.
There is no parity bit in operation modes 1 (asynchronous multiprocessor mode).
The transmit/receive data when the parity bit enabled are shown in Figure 14.6-4 "Transmit/Receive Data
when Parity Bit Enabled".
1 0 1 1 0 0 1 0 0
1 0 1 1 0 0 1 0 1
Data Parity
ST : Start bit
SP : Stop bit
Note : Parity bit cannot be set in operation mode 1.
412
CHAPTER 14 UART1
When the UART1 is used in operation mode 2, the transfer mode is clock synchronous.
SOT1
(LSB) 1 0 1 1 0 0 1 0 (MSB)
Transmit data
Write transmit data
TXE
SIN1
(LSB) 1 0 1 1 0 0 1 0 (MSB)
Receive data
RXE
Read receive data
413
CHAPTER 14 UART1
● Clock supply
In the clock synchronous mode, count of clocks equal to the transmit and receive bits count must be
supplied.
• When the internal clock (dedicated baud rate generator or internal timer) has already selected (SMR1
register bit 5 to 3: CS2 to CS0 = "000B" to "101B" or "110B") and data is transmitted, the synchronous
clock for data reception is generated automatically.
• When the external clock has already selected (SMR1 register bit 5 to 3: CS2 to CS0 = "11B"), the clock
for exact one byte must be supplied from outside after ensuring that data is present (SSR1 register bit
11: TDRE = 0) in the serial output data register (SODR1). Also, before and after transmitting, always
return to the mark level (High level).
● Error detection
Only overrun errors can be detected; parity and framing errors cannot be detected.
● Setting of register
Table 14.6-2 "Setting of Control Register" shows the setting of the control register in transmitting serial
data from the transmitting end to the receiving end using the clock synchronous mode (operation mode 2).
Setting
Register Name Bit Name
Transmit End Receive End
(output serial clock) (input serial clock)
Serial mode MD1, Set clock synchronous mode (MD1, MD0 = "10B").
register 1 (SMR1) MD0
CS2, CS1, Set clock input source. Set clock input source.
CS0 • Dedicated baud rate generator • External clock
(CS2 to CS0 = "000B" to "100B") (CS2 to CS0 = "111B")
• Internal timer (CS2 to CS0 = "110B")
SOE Set serial data output pin Set general-purpose I/O port (SOE = 0).
(SOE = 1).
414
CHAPTER 14 UART1
● Starting communications
When send data is written to the serial output data register 1 (SODR1), communication is starts. When
starting communication only in receiving, it is always necessary to write dummy send data to the serial
output data register 1 (SODR1).
● Terminating communications
After transmitting and receiving of one frame of data, the receive data load flag bit (SSR1 register bit 12:
RDRF) is set to 1. When data is received, check the overrun error flag bit (SSR1 register bit 14: ORE) to
ensure that the communication has performed normally.
415
CHAPTER 14 UART1
Figure 14.6-6 Setting of Operation Modes 0, 2 (Asynchronous Normal Mode and Clock Synchronous
Mode) for UART1
● Inter-CPU connect
Connect the two CPUs as shown in Figure 14.6-7 "Example of Bidirectional Communication Connect for
UART1".
SOT1 SOT1
SIN1 SIN1
Output Input
SCK1 SCK1
CPU-1 CPU-2
416
CHAPTER 14 UART1
● Communication procedure
Communications start at any timing from the transmitting end when transmit data is provided. At the
transmitting end, set transmit data in the serial output data register (SODR1) and set the transmitting enable
bit in the serial control register (SCR1 register bit 8: TXE) to 1 to start transmitting.
Figure 14.6-8 "Flowchart for Bidirectional Communication" gives an example of transferring receive data
to the transmitting end to inform the transmitting end of normal reception.
YES
Receive data
NO presence Read and process
receive data
YES
Data transmission
Read and process
Transmit 1-byte data
receive data
417
CHAPTER 14 UART1
Figure 14.6-9 Setting of Operation Mode 1 (Asynchronous Multiprocessor Mode) for UART1
● Inter-CPU connect
One master CPU and more than one slave CPU are connected to two common communication lines to
compose the communication system. The UART1 can be used only as the master CPU.
SOT1
SIN1
Master CPU
SOT SIN SOT SIN
418
CHAPTER 14 UART1
● Function select
At master/slave type communication, select the operation mode and data transfer type.
Since the parity check function cannot be used in operation mode 1 (asynchronous multiprocessor mode),
set the parity add enable bit (SCR1 register bit 15: PEN) to 0.
Operation Mode
Synchronous
Data Parity Stop Bit
Master Slave System
CPU CPU
Address A/D = 1
transmit/ +
receive Operation 8-bit address Not
− Asynchronous 1 bit or 2 bits
Data mode 1 A/D = 0 provided
transmit/ +
receive 8-bit data
● Communication procedure
Communications start when the master CPU transmits address data.
The address data is data with the A/D bit set to 1. The address/data select bit (SCR1 register bit 11: A/D) is
added to select the slave CPU that the master CPU communicates with. When the program identifies
address data and finds a match with the allocated address, each slave CPU starts communications with the
master CPU.
Figure 14.6-11 "Flowchart for Master/Slave Communications" shows the flowchart for master/slave
communications.
419
CHAPTER 14 UART1
(Master CPU)
Start
Set 0 to A/D
Reception enabled
Communicate
with slave CPU
Communication NO
ended?
YES
Communicate NO
with other slave
CPU
YES
Reception disabled
End
420
CHAPTER 14 UART1
421
CHAPTER 14 UART1
● Processing
The bidirectional communication function (normal mode) of the UART1 is used to perform serial
transmission/reception.
• Set operation mode 0, asynchrononus mode (normal), 8-bit data length, and no parity.
• Set operation mode 0, asynchronous mode (normal), 8-bit data length, 2-bit stop bit length, and no
parity.
• Use the P40/SIN1 and PS/SOT1 pins for communications.
• Use the dedicated baud rate generator to set the baud rate to approximately 9600 bps.
• Transmit the character 13Hfrom the SOT1 pin and receive it at an interrupt.
• Assume the machine clock (φ) 16 MHz.
422
CHAPTER 14 UART1
● Coding example
423
CHAPTER 14 UART1
424
CHAPTER 15
CAN CONTROLLER
425
CHAPTER 15 CAN CONTROLLER
16 MHz 1 Mbps
12 MHz 1 Mbps
8 MHz 1 Mbps
4 MHz 500 Kbps
426
CHAPTER 15 CAN CONTROLLER
The CAN controller consists of two types of registers; one controls the CAN controller
and the other controls each message buffer.
LEIR
427
CHAPTER 15 CAN CONTROLLER
428
CHAPTER 15 CAN CONTROLLER
● Prescaler
The prescaler generates a bit timing clock at a frequency of 1/1 to 1/64 of the system clock.
It sets the operation clock (TQ).
429
CHAPTER 15 CAN CONTROLLER
● Acceptance filter
This filter compares the receive message ID with the acceptance code to select the message to be received.
430
CHAPTER 15 CAN CONTROLLER
This section explains the pins and, related registers, interrupt factors of the CAN
controller.
431
CHAPTER 15 CAN CONTROLLER
Reserved area*
AMR0 (Acceptance mask register 0) XXXXXXXX B XXXXXXXX B
XXXXXXXX B XXXXXXXX B
432
CHAPTER 15 CAN CONTROLLER
Figure 15.3-2 Registers of CAN Controller (ID Register and DLC Register)
Message buffer (ID register)
bit 15 bit 8 bit 7 bit 0 Reset value
RAM (General-purpose RAM) (16 bytes) XXXXXXXX B ~
~ XXXXXXXX B
433
CHAPTER 15 CAN CONTROLLER
434
CHAPTER 15 CAN CONTROLLER
The control status register (CSR) controls operation of the CAN controller. The control
status register (High) (CSR: H) transmits and receives the message and indicates the
node status.
15 14 13 12 11 10 9 8
Reset value
00XXX000B
R R R/W R R
bit 9 bit 8
NS1 NS0 Node status bits
0 0 Error active
0 1 Warning (error active)
1 0 Error passive
1 1 Bus off
bit 10
NT Node status transition flag
0 No node status transition
1 Node status transition
bit 14
RS Receive status bit
0 Message is not received
1 Message is being received
bit 15
TS Transmit status bit
R/W : Read/Write 0 Message is not transmittes
R : Read only 1 Message is being transmitted
X : Undefined
: Unused
: Reset value
Note: It is prohibited to execute a bit operation (read-modify-write) instruction on the control status register
(CSR).
435
CHAPTER 15 CAN CONTROLLER
bit 8 NS1, NS0: The combination of the NS1 and NS0 bits indicates the current node status.
bit 9 Node status bits 00B: Error active
01B: Warning (error active)
10B: Error passive
11B: Bus off
Note:
Warning is included in error active in the CAN specifications as a node
status.
bit 10 NT: This bit indicates that the node status transits.
Node status transition When node status transits: Bit set to 1
flag bit 1. Error active (00B) --> Warning (01B)
2. Warning (01B) --> Error Passive (10B)
3. Error Passive (10B) --> Bus off (11B)
4. Bus off (11B) --> Error active (00B)
(The parenthesized values are those for the NS1 and NS0 bits.)
When set to 0: Clears this bit.
When set to 1: Disables bit setting
Read using read modify write instructions: 1 always read
bit 14 RS: This bit indicates whether the message is being received.
Receive status bit Message being received: Bit set to 1
• For example, if the message is on the bus, even during message
transmitting, this bit is set to 1 regardless of whether the receive message
passes the acceptance filter.
Error frame or overload frame on bus: Bit set to 0
• When the RS bit is 0, the bus halt state (HALT = 1), bus intermission state
and bus idle state are also included.
bit 15 TS: This bit indicates whether the message is being transmitted.
Transmit status bit Message being transmitted: Bit set to 1
Error frame or overload frame being transmitted: Bit set to 0
436
CHAPTER 15 CAN CONTROLLER
The control status register (CSR) controls operation of the CAN controller. The control
status register (Low) (CSR: L) enables and disables transmit interrupt and node status
transition interrupt and, controls bus halt and indicates the node status.
7 6 5 4 3 2 1 0
Reset value
0XXXX001B
R/W R/W W R/W
bit 0
HALT Bus operation stop bit
0 Cancels bus operation stop
(bus operation not in stop mode)
1 Stops bus operation
(bus operation in stop state)
bit 1
Reserved Reserved bit
0 Always set "0"
bit 2
NIE Node status transition interrupt output enable bit
0 Interrupt output disable by node status transition
1 Interrupt output enable by node status transition
bit 7
TOE Transmit output enable bit
0 Used as general-purpose I/O port
R/W : Read/Write
W : Write only 1 Used as transmit pin TX
X : Undefined
: Unused
: Reset value
Note: It is prohibited to execute a bit operation (read-modify-write) instruction on the control status register
(CSR).
437
CHAPTER 15 CAN CONTROLLER
bit 0 HALT: This bit controls the bus halt. The halt state of the bus can be checked by
Bus halt bit reading the HALT bit.
When set to 0: Cancels bus halt
When set to 1: Halt bus
[Conditions for halting bus]
• Hardware reset
• Node status transition to bus off
• Writing 1 to HALT bit
[Operation when bus halted]
Message being transmitted: Bus halted after completion of transmitting
Message being receiving: Bus halted immediately
Storing in message buffer: Bus halted after completion of storing
Notes:
• To check whether the bus is halted, read the value of the HALT bit.
• To switch to the low-power consumption, write 1 to the HALT bit, and
then read the HALT bit to check that the bus is completely halted (CSR:
HALT = 1).
[Conditions for canceling bus halt]
• The state in which the bus is halted by a hardware reset or by writing 1 to
the HALT bit is cancelled after 0 is written to the HALT bit and an 11-bit
High level (receive) is input continuously to the receive input pin (RX).
• The state in the bus off is cancelled after 0 is written to the HALT bit and
an 11-bit High level (receive) is input continuously 128 times to the
receive input pin (RX).
• The values of the transmit and receive error counters are both returned to
0 and the node status transits to error active.
[State in which bus halted]
• Transmitting and receiving are not performed.
• A High level (receive) is output to the transmit output pin (TX).
• Values of other register and error counter remain unchanged.
Note:
• Set the bit timing register (BTR) after halting the bus.
bit 2 NIE: This bit controls generation of a node status transition interrupt when the
Node status transition node status transits (CSR: NT = 1).
interrupt output enable When set to 0: Disables interrupt generation
bit When set to 1: Enables interrupt generation
bit 7 TOE: This bit switches between the general-purpose I/O port and the transmit pin
Transmit output enable (TX).
bit When set to 0: Functions as general-purpose I/O port
When set to 1: Functions as transmit pin (TX)
438
CHAPTER 15 CAN CONTROLLER
bit 7 6 5 4 3 2 1 0
Reset value
000XX000 B
Note: When any of the node status transition bit (NTE), transmission complete bit (TCE), and reception
complete bit (RCE) corresponding to the last event is set to 1, other bits are set to 0.
439
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 2 MBP2 to MBP0: These bits indicate the number (x) of the message buffer where the last event
Message buffer pointer occurs which is corresponding to each message buffer pointer bit.
bits Receiving completed: Indicates number (x) of message buffer that completes
receiving message
Transmitting completed: Indicates number (x) of message buffer that
completes transmitting message
Node status transition: The values of the MBP2 to MBP0 bits are invalid.
When set to 0: Cleared
When set to 1: No effect
Read by read modify write instruction: 1 always read
bit 3 Unused bits Read: Value not fixed
bit 4 Write: No effect on operation
bit 5 RCE: This bit indicates that receiving the last event is completed.
Last event reception Receiving of last event completed: Sets bit to 1 when RCx bit in reception
complete bit complete register set (RCR: RCx = 1)
• Nothing is related to the setting of the reception complete interrupt enable
register (RIER).
• The number (x) of the message buffer that completes receiving the
message is indicated as the last event in the MBP2 to MBP0 bits.
When set to 0: Cleared
When set to 1: No effect
Read using read modify write instructions: 1 always read
bit 6 TCE: This bit indicates that the transmitting the last event is completed.
Last event transmission Transmitting of last event completed: Sets bit to 1 when TCx bit in
complete bit transmission complete register set (TCR: TCx = 1)
• Nothing is related to the setting of the transmission complete interrupt
enable register (TIER).
• The number (x) of the message buffer that completes receiving the
message is indicated as the last event in the MBP2 to MBP0 bits.
When set to 0: Cleared
When set to 1: No effect
Read using read modify write instruction: 1 always read
bit 7 NTE: This bit indicates that the last event refers to the node status transition.
Last event node status Last event referring to node status transition: Sets bit to 1 when NTx bit in
transition bit control status register set (CSR: NTx = 1)
• The NTE bit is set to 1 at the same time that the TCx in the transmission
complete register (TCR) is set.
• Nothing is related to the setting of the NIE bit in the control status register
(CSR).
When set to 0: Cleared
When set to 1: No effect
Read by read modify write instruction: 1 always read
Note: When the last event indicate register (LEIR) is accessed in interrupt processing of the CAN controller, the
event causing the interrupt does not always match the event indicated by the last event indicate register
(LEIR). Other event may occur before the last event indicate register (LEIR) is accessed in interrupt
processing after an interrupt request is generated.
440
CHAPTER 15 CAN CONTROLLER
The receive/transmit error counter (RTEC) indicates the number of times an error
occurs at transmitting and receiving the message. It counts up when transmit or receive
errors occurs and counts down when transmitting and receiving are performed
normally.
7 6 5 4 3 2 1 0 Reset value
REC7 REC6 REC5 REC4 REC3 REC2 REC1 REC0 00000000B
R R R R R R R R
R: Read only
bit 0 to bit 7 REC7 to REC0: Receive error counter value = 96 or more: Node status transits to warning
Receive error counter (CSR: NS1, NS0 = 01B)
bits Receive error counter value = 128 or more: Node status transits to error
passive (CSR: NS1, NS0 = 10B)
Receive error counter value = 256 or more: Stops counting up. The node
status remains with error passive (CSR: NS1, NS0="10B").
bit 8 to bit 15 TEC7 to TEC0: Transmit error counter value = 96: Node status transits to warning (CSR:
Transmit error counter NS1, NS0 = 01B)
bits Transmit error counter value = 128: Node status transits to error passive
(CSR: NS1, NS0 = 10B)
Transmit error counter value = 256: Stops counting up. The node status
transits to bus off (CSR: NS1, NS0 = 11B).
441
CHAPTER 15 CAN CONTROLLER
Hardware reset
Cancellation of bus operation halt is necessary
REC ≥ 96
or TEC ≥ 96
REC ≥ 128
or TEC ≥ 128
Warning
A bus fault occurs
Error passive
Bus off Communications are disabled. The CAN controller is completely isolated
from the CAN bus.
(To return to the normal state, perform the steps in the above figure.)
442
CHAPTER 15 CAN CONTROLLER
The bit timing register (BTR) sets the prescaler and bit timing. After halting the bus
(CSR: HALT = 1).
7 6 5 4 3 2 1 0 Reset value
RSJ1 RSJ0 PSC5 PSC4 PSC3 PSC2 PSC1 PSC0 11111111B
R/W R/W R/W R/W R/W R/W R/W R/W
R/W : Read/Write
X : Undefined
: Unused
bit 0 to bit 5 PSC5 to PSC0: • These bits divide the frequency of the system clock to determine the
Prescaler setting bits 5 to 0 time quantum (TQ) of the CAN controller.
bit 6 to bit 7 RSJ1, RSJ0: • These bits set the resynchronous jump width (RSJW).
Resynchronous jump
width setting bits 1, 0
bit 8 TS1.3 to TS1.0: • These bits set the time of time segment 1 (TSEG1). Time segment 1 is
to Time segment 1 setting equivalent to propagation segment (PROP_EG) and phase buffer
bit 11 bits 3 to 0 segment 1 (PHASE_SEG1) based on CAN specifications.
bit 12 TS2.2 to TS2.0: • These bits set the time of time segment 2 (TSEG2). Time segment 2 is
to Time segment 2 setting equivalent to phase buffer segment 2 (PHASE_SEG2) based on CAN
bit 14 bits 2 to 0 specifications.
Note:
Set the bit timing register (BTR) after halting the bus (CSR: HALT = 1). After setting the bit timing register (BTR),
write 0 to the HALT bit in the control status register to cancel the bus halt.
443
CHAPTER 15 CAN CONTROLLER
Sampling point
• SYNC_SEG (sync segment): Synchronization is performed to shorten or prolong the bit time.
• PROP_SEG (propagation segment): The physical delay among networks is adjusted.
• PHASE_SEG (phase segment): The phase shift due to oscillation errors is adjusted.
Sampling point
444
CHAPTER 15 CAN CONTROLLER
. TQ = (PSC + 1) × CLK
. BT = SYNC_SEG + TSEG1 + TSEG2
= (1 + (TS1 + 1) + (TS2 + 1) ) × TQ
= (3 + TS1 + TS2) × TQ
. RSJW = (RSJ + 1) × TQ
445
CHAPTER 15 CAN CONTROLLER
Examle: When 1TQ is 1/20 bit timing at 100 kbps (1/100 kbps/20)
Condition: (resynchronous jump width is 4TQ, delay time is 50 µs)
(3) Setting of resynchronous jump width (when resynchronous jump width is 4TQ)
RSJ+1 (frequency division of TQ) 1 2 3 4 (unit: TQ)
RSJW = (RSJ + 1) × TQ 0.5 1 1.5 2 (unit: µs)
(2) Calculation of bit time (BT) based on the above setting and conditions
(unit: kbps)
BT = SYNC_SEG + TSEG1 + TSEG2
TSEG2 + 1
= (1 + (TS1 + 1) + (TS2+1)) × TQ
= (3 + TS1 + TS2) × TQ 1 2 3 4 5 6 7 8
1 667 500 400 333 286 250 222 200
2 500 400 333 286 250 222 200 182
3 400 333 286 250 222 200 182 167
Calculation of sampling point 4 333 286 250 222 200 182 167 154
5 286 250 222 200 182 167 154 143
Sampling 6 250 222 200 182 167 154 143 133
SYNC_SEG + (TSEG1 + 1) TSEG2 + 1
point 7 222 200 182 167 154 143 133 125
(1) 16 4 80% TSEG1 + 1 8 200 182 167 154 143 133 125 118
(2) 15 5 75% 9 182 167 154 143 133 125 118 111
(3) 14 6 70% 10 167 154 143 133 125 118 111 105
(4) 13 7 65% 11 154 143 133 125 118 111 105 100
(5) 12 8 60% 12 143 133 125 118 111 105 100 95.2
13 133 125 118 111 105 100 95.2 90.9
SYNC_SEG TSEG 1 + 1 TSEG2 + 1 14 125 118 111 105 100 95.2 90.9 87
15 118 111 105 100 95.2 90.9 87 83.3
Sampling point 16 111 105 100 95.2 90.9 87 83.3 80
(1) (2) (3) (4) (5)
446
CHAPTER 15 CAN CONTROLLER
The message buffer valid register (BVALR) enables or disables the message buffers
and indicates their status.
7 6 5 4 3 2 1 0
Reset value
00000000 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
BVAL0 Message buffer enable bit 0
0 Disables message buffer 0
1 Enables message buffer 0
bit 1
BVAL1 Message buffer enable bit 1
0 Disables message buffer 1
1 Enables message buffer 1
bit 2
BVAL2 Message buffer enable bit 2
0 Disables message buffer 2
1 Enables message buffer 2
bit 3
BVAL3 Message buffer enable bit 3
0 Disables message buffer 3
1 Enables message buffer 3
bit 4
BVAL4 Message buffer enable bit 4
0 Disables message buffer 4
1 Enables message buffer 4
bit 5
BVAL5 Message buffer enable bit 5
0 Disables message buffer 5
1 Enables message buffer 5
bit 6
BVAL6 Message buffer enable bit 6
0 Disables message buffer 6
1 Enables message buffer 6
bit 7
BVAL7 Message buffer enable bit 7
0 Disables message buffer 7
1 Enables message buffer 7
R/W : Read/Write
: Reset value
447
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 BVAL7 to BVAL0: These bits enable or disable transmitting and receiving of the message to and
Message buffer enable from the message buffer (x).
bits 7 to 0 When set to 0: No message can be transmitted and received to and from the
message buffer (x).
When set to 1: A message can be transmitted and received to and from the
message buffer (x).
[Message buffer disabled (BVALx = 0)]
During transmitting: Transmitting and receiving are disabled after message
transmitting is completed or a transmit error is terminated.
During receiving: Transmitting and receiving are disabled immediately.
When the received message is stored in the message buffer, transmitting and
receiving are disabled after the message is stored.
Note:
The read modify write instructions are disabled until the BVALx bit is
actually set to 0 after 0 is written to the bit.
Note: To invalidate the message buffer (by setting the BVALR: BVAL bit to 0) while CAN Controller is
participating in CAN communication (the read value of the CSR: HALT bit is 0 and CAN Controller is
ready to receive or transmit messages), follow the cautions in Section 15.6 "Precautions when Using
CAN Controller".
448
CHAPTER 15 CAN CONTROLLER
The IDE register (IDER) sets the frame format of the message buffer used during
transmitting and receiving. Transmitting and receiving are enabled in the standard
frame format (ID11 bits) and the extended frame format (ID29 bits).
7 6 5 4 3 2 1 0
Reset value
XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
IDE0 ID format select bit 0 (message buffer 0)
0 Used in standard fomat (ID 11 bits)
1 Used in extended format (ID 29 bits)
bit 1
IDE1 ID format select bit 1 (message buffer 1)
0 Used in standard fomat (ID 11 bits)
1 Used in extended format (ID 29 bits)
bit 2
IDE2 ID format select bit 2 (message buffer 2)
0 Used in standard fomat (ID 11 bits)
1 Used in extended format (ID 29 bits)
bit 3
IDE3 ID format select bit 3 (message buffer 3)
0 Used in standard fomat (ID 11 bits)
1 Used in extended format (ID 29 bits)
bit 4
IDE4 ID format select bit 4 (message buffer 4)
0 Used in standard fomat (ID 11 bits)
1 Used in extended format (ID 29 bits)
bit 5
IDE5 ID format select bit 5 (message buffer 5)
0 Used in standard fomat (ID 11 bits)
1 Used in extended format (ID 29 bits)
bit 6
IDE6 ID format select bit 6 (message buffer 6)
0 Used in standard fomat (ID 11 bits)
1 Used in extended format (ID 29 bits)
bit 7
IDE7 ID format select bit 7 (message buffer 7)
X : Undefined 0 Used in standard fomat (ID 11 bits)
R/W : Read/Write 1 Used in extended format (ID 29 bits)
449
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 IDE7 to IDE0: These bits set the ID format of the message buffer (x).
ID Format select bits 7 to 0 When set to 0: Uses message buffer (x) in standard format (ID11 bits)
When set to 1: Uses message buffer (x) in extended format (ID29 bits)
Note:
The IDE register (IDER) should be set after having the message buffer
(x) disabled (BVALR: BVALx = 0). Setting the IDE register (IDER)
with the message buffer (x) being enabled may store message
unnecessary received.
Note: To invalidate the message buffer (by setting the BVALR: BVAL bit to 0) while CAN Controller is
participating in CAN communication (the read value of the CSR: HALT bit is 0 and CAN Controller is
ready to receive or transmit messages), follow the cautions in Section 15.6 "Precautions when Using
CAN Controller".
450
CHAPTER 15 CAN CONTROLLER
The transmission request register (TREQR) sets a transmit request for each message
buffer and indicates its status.
451
CHAPTER 15 CAN CONTROLLER
bit 0 to bit7 TREQ7 to TREQ0: These bits starts transmitting for the message buffer (x).
Transmission request When set to 0: No effect
bits 7 to 0 When set to 1: Starts transmitting for message buffer (x)
• If more than one transmit complete bit is set (TREQx = 1), transmitting is
started with the lower number of the message buffer (x) that accepts the
transmit request.
• These bits remain 1s during the transmit being requested and are cleared to 0
when transmitting is completed or the transfer request is cancelled.
• Clearing a transmit request when transmitting is completed (TREQx = 0)
overrides setting of the transmit request bit when 0 is written (TREQx = 1) if
both occur at the same time.
Read by read modify write instruction: 1 always read
[Setting of remote frame receive wait bit (RFWTR: RFWTx)]
RFWTx bit = 0: Starts transmitting immediately even if RRTRx bit in receive
RTR register = 1
RFWTx bit = 1: Starts transmitting after remote frame received.
• See 15.3.10 "Remote Frame Receiving Wait Register (RFWTR)" for details of the remote frame receive
wait register (RFWTR).
• See 15.3.15 "Reception RTR Register (RRTRR)" for details of the receive RTR register (RRTRR).
• See 15.3.11 "Transmission Cancel Register (TCANR)" and 15.5.1 "Transmission" for details about the
transmit cancellation.
452
CHAPTER 15 CAN CONTROLLER
This register sets the frame format of transmit message for the message buffers.
453
CHAPTER 15 CAN CONTROLLER
• When 0 is written to each bit in the transmit RTR register (TRTRR), the data frame format is set. When
1 is written to each bit, the remote frame format is set.
bit 0 to bit 7 TRTR7 to TRTR0: These bits set the transfer format of the message buffer (x) for transmitting or
Remote frame setting receiving.
bits 7 to 0 When set to 0: Sets data frame format
When set to 1: Sets remote frame format
454
CHAPTER 15 CAN CONTROLLER
Remote frame receiving wait register (RFWTR) sets whether this register waits remote
frame receiving when transmission request of data frame is set.
455
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 RFWT7 to RFWT0: These bits set whether to wait for reception of a remote frame for the
Remote frame receiving message buffer (x) for which a request to transmit a data frame is set.
wait bits 7 to 0 When set to 0: Starts transmitting immediately for message buffer (x) for
which a request to transmit data frame set
• Transmitting is started immediately even if the receive RTR register is
already set in the message buffer (x) (RRTRR: RRTRx = 1).
When set to 1: Starts transmitting after remote frame is received in message
buffer (x) in which a request to transmit a data frame
Note:
When transmitting a remote frame, do not write 1 to the RFWTx bit.
• See 15.3.8 "Transmission Request Register (TREQR)" for details of the transmission request register
(TREQR).
• See 15.3.9 "Transmission RTR Register (TRTRR)" for details of the transmission RTR register
(TRTRR).
• See 15.3.15 "Reception RTR Register (RRTRR)" for details of the receive RTR register (RRTRR).
456
CHAPTER 15 CAN CONTROLLER
7 6 5 4 3 2 1 0
Reset value
00000000 B
W W W W W W W W
bit 0
TCAN0 Transmission cancel bit 0
0 No effect
1 Cancels transmission request of message buffer 0
bit 1
TCAN1 Transmission cancel bit 1
0 No effect
1 Cancels transmission request of message buffer 1
bit 2
TCAN2 Transmission cancel bit 2
0 No effect
1 Cancels transmission request of message buffer 2
bit 3
TCAN3 Transmission cancel bit 3
0 No effect
1 Cancels transmission request of message buffer 3
bit 4
TCAN4 Transmission cancel bit 4
0 No effect
1 Cancels transmission request of message buffer 4
bit 5
TCAN5 Transmission cancel bit 5
0 No effect
1 Cancels transmission request of message buffer 5
bit 6
TCAN6 Transmission cancel bit 6
0 No effect
1 Cancels transmission request of message buffer 6
bit 7
TCAN7 Transmission cancel bit 7
0 No effect
1 Cancels transmission request of message buffer 7
W : Write only
: Reset value
457
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 TCAN7 to TCAN0: These bits cancel a transmission request for the message buffer (x) in the
Transmission on cancel transmit wait state.
bits 7 to 0 When set to 0: No effect
When set to 1: Cancels transmission request for message buffer (x)
• When a transmission request is cancelled by setting 1 to the TCANx bit,
the TREQx bit corresponding to the message buffer (x) is cleared
(TREQx = 0) for which transmission request is cancelled.
Read: 0 always read
Note:
The transmission cancel register (TCANR) is a write-only register.
458
CHAPTER 15 CAN CONTROLLER
The transmission complete register (TCR) indicates whether transmitting a data from
the message buffer completes. When an output of interrupt is enabled at completing
transmitting, an interrupt request is output when transmitting is completed.
7 6 5 4 3 2 1 0
Reset value
00000000 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
TC0 Transmission complete bit 0 (message buffer 0)
0 Transmission is not completed/no transmission
1 Transmission is completed
bit 1
TC1 Transmission complete bit 1 (message buffer 1)
0 Transmission is not completed/no transmission
1 Transmission is completed
bit 2
TC2 Transmission complete bit 2 (message buffer 2)
0 Transmission is not completed/no transmission
1 Transmission is completed
bit 3
TC3 Transmission complete bit 3 (message buffer 3)
0 Transmission is not completed/no transmission
1 Transmission is completed
bit 4
TC4 Transmission complete bit 4 (message buffer 4)
0 Transmission is not completed/no transmission
1 Transmission is completed
bit 5
TC5 Transmission complete bit 5 (message buffer 5)
0 Transmission is not completed/no transmission
1 Transmission is completed
bit 6
TC6 Transmission complete bit 6 (message buffer 6)
0 Transmission is not completed/no transmission
1 Transmission is completed
bit 7
TC7 Transmission complete bit 7 (message buffer 7)
0 Transmission is not completed/no transmission
1 Transmission is completed
R/W : Read/Write
: Reset value
459
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 TC7 to TC0: These bits indicate whether the message buffer (x) completes transmitting
Transmission complete message.
bits 7 to 0 When message transmitting completed: 1 is set to the TCx bit
corresponding to the message buffer (x) that completes transmitting.
When set to 0: Clears bits if transmitting already completed
When set to 1: No effect
Read by read modify write instruction: 1 always read
• Setting the TCx bit when transmitting is completed (TCx = 1) overrides
clearing of the TCx bit when 0 is written (TCx = 0) if both occur at the
same time.
• When the TREQx bit in the transmit request register (TREQR) is set
(TREQR: TREQx = 1), the TCx bit is cleared (TCx = 0).
[Generation of transmission complete interrupt]
• If the transmit complete interrupt enable register (TIER) is set (TIER:
TIEx = 1), a transmit complete interrupt is generated when transmitting is
completed (TCR: TCx = 1).
460
CHAPTER 15 CAN CONTROLLER
7 6 5 4 3 2 1 0
Reset value
00000000B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
Transmission interrupt enable bit 0
TIE0 (message buffer 0)
0 Disables transmission complete interrupt
1 Enables transmission complete interrupt
bit 1
Transmission interrupt enable bit 1
TIE1 (message buffer 1)
0 Disables transmission complete interrupt
1 Enables transmission complete interrupt
bit 2
Transmission interrupt enable bit 2
TIE2 (message buffer 2)
0 Disables transmission complete interrupt
1 Enables transmission complete interrupt
bit 3
Transmission interrupt enable bit 3
TIE3 (message buffer 3)
0 Disables transmission complete interrupt
1 Enables transmission complete interrupt
bit 4
Transmission interrupt enable bit 4
TIE4 (message buffer 4)
0 Disables transmission complete interrupt
1 Enables transmission complete interrupt
bit 5
Transmission interrupt enable bit 5
TIE5 (message buffer 5)
0 Disables transmission complete interrupt
1 Enables transmission complete interrupt
bit 6
Transmission interrupt enable bit 6
TIE6 (message buffer 6)
0 Disables transmission complete interrupt
1 Enables transmission complete interrupt
bit 7
Transmission interrupt enable bit 7
TIE7 (message buffer 7)
R/W : Read/Write 0 Disables transmission complete interrupt
: Reset value 1 Enables transmission complete interrupt
461
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 TIE7 to TIE0: These bits enable or disable a transmission complete interrupt for the
Transmission complete message buffer (x).
interrupt enable bits 7 to 0 When set to 0: Disables transmit complete interrupt for message buffer (x)
When set to 1: Enables transmit complete interrupt for message buffer (x)
462
CHAPTER 15 CAN CONTROLLER
The reception complete register (RCR) indicates whether the reception a data to the
message buffer (x) completes receiving. When an interrupt is enabled at completion of
receiving, an interrupt request is generated.
7 6 5 4 3 2 1 0
Reset value
00000000 B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
RC0 Reception complete bit 0 (message buffer 0)
0 Reception is not completed/no reception
1 Reception is completed
bit 1
RC1 Reception complete bit 1 (message buffer 1)
0 Reception is not completed/no reception
1 Reception is completed
bit 2
RC2 Reception complete bit 2 (message buffer 2)
0 Reception is not completed/no reception
1 Reception is completed
bit 3
RC3 Reception complete bit 3 (message buffer 3)
0 Reception is not completed/no reception
1 Reception is completed
bit 4
RC4 Reception complete bit 4 (message buffer 4)
0 Reception is not completed/no reception
1 Reception is completed
bit 5
RC5 Reception complete bit 5 (message buffer 5)
0 Reception is not completed/no reception
1 Reception is completed
bit 6
RC6 Reception complete bit 6 (message buffer 6)
0 Reception is not completed/no reception
1 Reception is completed
bit 7
RC7 Reception complete bit 7 (message buffer 7)
0 Reception is not completed/no reception
1 Reception is completed
R/W : Read/Write
: Reset value
463
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 RC7 to RC0: These bits indicate whether the message buffer (x) completes message
Reception complete bits transmitting.
7 to 0 When message receiving completed: 1 is set to the RCx bit corresponding
to the message buffer (x) that completes receiving.
When set to 0: Clears bits when receiving already completed
When set to 1: No effect
Read by read modify write instruction: 1 always read
• Setting the RCx bit when receiving is completed (TCx = 1) overrides
clearing of the RCx bit when 0 is written (RCx = 0) if both occur at the
same time.
[Generation of reception complete interrupt]
• If the transmit complete enable register is set (RIER: RIEx = 1), a
reception complete interrupt is generated when receiving is completed.
Note:
To clear the reception complete register (RCR), read the received
message after the completion of receiving and write 0.
464
CHAPTER 15 CAN CONTROLLER
The reception RTR register (RRTRR) indicates that the remote frame is stored in the
message buffer.
465
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 RRTR7 to RRTR0: These bits indicate that the message buffer (x) receives a remote frame.
Remote frame receive When remote frame is received: 1 is set to the RRTRx bit corresponding to
bits 7 to 0 the message buffer (x) that receives a remote frame.
When set to 0: Cleared when receiving completed
When set to 1: No effect
• Setting the RRTRx bit when a remote frame is received (RRTRx = 1)
overrides clearing of the RRTRx bit when 0 is written (RRTRx = 0) if
both occur at the same time.
• The RRTRx bit corresponding to the message buffer (x) that receives a
data frame is cleared (RRTRx = 0).
• If message transmitting is completed (TCR: TCx = 1), the RRTRx bit
corresponding to the message buffer (x) that transmits the message is
cleared (RRTRx = 0).
Read by read modify write instruction: 1 always read
466
CHAPTER 15 CAN CONTROLLER
The reception overrun register (ROVRR) indicates that an overrun occurs (the
corresponding message buffer is in the receive complete state.) at storing the received
message in the message buffer.
467
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 ROVR7 to ROVR0: These bits indicate that an overrun occurs at storing the received message in
Reception overrun bits 7 the message buffer that had completed receiving.
to 0 At overrun: 1 is set to the ROVRx bit corresponding to the message buffer
(x) where an overrun occurs.
When set to 0: Cleared when 0 is set to after reception overrun occurred
When set to 1: No effect
Read by read modify write instruction: 1 always read
• Setting the ROVRx bit when an overrun occurs (ROVRx = 1) overrides
clearing of the ROVRx bit when 0 is written (ROVRx = 0) if both occur at
the same time.
468
CHAPTER 15 CAN CONTROLLER
The reception complete interrupt enable register (RIER) enables or disables a reception
complete interrupt for each message buffer.
7 6 5 4 3 2 1 0
Reset value
00000000B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 0
RIE0 Reception complete interrupt enable bit 0 (message buffer 0)
0 Disables reception complete interrupt
1 Enables reception complete interrupt
bit 1
RIE1 Reception complete interrupt enable bit 1 (message buffer 1)
0 Disables reception complete interrupt
1 Enables reception complete interrupt
bit 2
RIE2 Reception complete interrupt enable bit 2 (message buffer 2)
0 Disables reception complete interrupt
1 Enables reception complete interrupt
bit 3
RIE3 Reception complete interrupt enable bit 3 (message buffer 3)
0 Disables reception complete interrupt
1 Enables reception complete interrupt
bit 4
RIE4 Reception complete interrupt enable bit 4 (message buffer 4)
0 Disables reception complete interrupt
1 Enables reception complete interrupt
bit 5
RIE5 Reception complete interrupt enable bit 5 (message buffer 5)
0 Disables reception complete interrupt
1 Enables reception complete interrupt
bit 6
RIE6 Reception complete interrupt enable bit 6 (message buffer 6)
0 Disables reception complete interrupt
1 Enables reception complete interrupt
bit 7
RIE7 Reception complete interrupt enable bit 7 (message buffer 7)
R/W : Read/Write 0 Disables reception complete interrupt
: Reset value 1 Enables reception complete interrupt
469
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 RIE7 to RIE0: These bits enable or disable a reception complete interrupt for the message
Reception complete buffer (x).
interrupt enable bits 7 to 0 When set to 0: Disables reception complete interrupt for message buffer (x)
When set to 1: Enables reception complete interrupt for message buffer (x)
470
CHAPTER 15 CAN CONTROLLER
The acceptance mask select register (AMSR) selects the mask (acceptance mask)
format for comparison between the identifier (ID) of the received message and the
message buffer.
7 6 5 4 3 2 1 0 Reset value
AMS3.1 AMS3.0 AMS2.1 AMS2.0 AMS1.1 AMS1.0 AMS0.1 AMS0.0 XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W
X : Undefined
R/W : Read/Write
471
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 15 AMS7.0 to AMS0.0, These bits select the mask (acceptance mask) format for comparison between
AMS7.1 to AMS0.1: the received message ID and message buffer ID (IDR) for the message buffer
Acceptance mask select (x).
bits 7.0 to 0.0, 7.1 to 0.0 No comparison with masked bits is made.
Full-bit comparison: All bits are compared in collating the setting values of
the ID register (IDR) with the received message ID.
Full-bit masking: All bits for the setting values of the ID register (IDR) and
the received message ID are masked.
Using acceptance mask register 0 (or 1): The acceptance mask register 0 or
1 (AMR0 or AMR1) is used as an acceptance mask filter. At collating the
setting values of the ID register (IDR) with the received message ID, only the
bits set to 0 and corresponding to the AMx bit in the acceptance mask register
are compared and the bits set to 1 and corresponding to the AMx bit are
masked.
• If the AMSx.1 and AMSx.0 bits are set to 10B or 11B, always set the
acceptance mask register (AMR0 or AMR1) to be used, too.
Note:
• The acceptance mask select register (AMSR) should be set after disabling
the message buffer (x) to be set (BVALR: BVALx = 0). Setting the
acceptance mask select register (AMSR) with the message buffer (x)
enabled may store a message unnecessary received.
Note: To invalidate the message buffer (by setting the BVALR: BVAL bit to 0) while CAN Controller is
participating in CAN communication (the read value of the CSR: HALT bit is 0 and CAN Controller is
ready to receive or transmit messages), follow the cautions in Section 15.6 "Precautions when Using
CAN Controller".
472
CHAPTER 15 CAN CONTROLLER
The CAN controller has two acceptance mask registers (AMR0 and AMR1). Both of them
can be used in the standard frame format (ID11 bits, AM28 to AM18) and the extended
frame format (ID29 bits, AM28 to AM0).
15 14 13 12 11 10 9 8 Reset value
BYTE3 AM4 AM3 AM2 AM1 AM0 XXXXXXXXB
R/W R/W R/W R/W R/W
R/W : Read/Write
X : Undefined
: Unused
: Used bits in the standard frame format
473
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 AM21 to AM 28: These bits set whether to compare or mask each bit at collating the
Acceptance mask bits 28 acceptance code set in the ID register (IDR: IDx) with the received message
to 21 (BYTE0) ID.
• If the AMSx.1 or AMSx.0 bits of acceptance mask select registers are set
bit 8 to bit 15 AM20 to AM 13: to 10B or 11 B, always set the acceptance mask register (AMR0 or AMR1)
Acceptance mask bits 20 to be used, too.
to 13 (BYTE1) Standard frame format (IDER: IDEx = 0): 11 bits from AM28 to AM18
bit 0 to bit 7 AM12 to AM 5: are used.
Extended frame format (IDER: IDEx = 1): 29 bits from AM28 to AM0 are
Acceptance mask bits 12
used.
to 5 (BYTE2)
When AMx bit set to 0 (compare): The bits corresponding to the AMx bit
bit 11 to bit 15 AM4 to AM 0: set to 0 are compared at collating the acceptance code set in the ID register
Acceptance mask bits 4 (IDR: IDx) with the received message ID.
to 0 (BYTE3) When AMx bit set to 1 (mask): The bits corresponding to the AMx bit set to
1 are masked at collating the acceptance code set in the ID register (IDR:
IDx) with the received message ID.
Note:
• The acceptance mask select register (AMSR) should be set after disabling
the message buffer (x) to be set (BVALR: BVALx = 0). Setting the
acceptance mask select register (AMSR) with the message buffer (x)
enabled may store a message unnecessary received.
Note: To invalidate the message buffer (by setting the BVALR: BVAL bit to 0) while CAN Controller is
participating in CAN communication (the read value of the CSR: HALT bit is 0 and CAN Controller is
ready to receive or transmit messages), follow the cautions in Section 15.6 "Precautions when Using
CAN Controller".
474
CHAPTER 15 CAN CONTROLLER
The message buffers consist of ID register, DLC register, and data register are used for
transmission/reception of the message.
■ Message Buffers
• There are 8 message buffers.
• One message register (x) (x = 0 to 7) consists of an ID register (IDRx), DLC register (DLCRx), and data
register (DTRx).
• The message buffer (x) is used to transmit and receive messages.
• Higher priority is given to smaller number message buffer.
- At transmitting, if a transmit request is generated to more than one message buffer, transmitting is
started with the message buffer with the smallest number.
- At receiving, if the received message ID passes the acceptance filter (which compares received
message ID with message buffer ID after acceptance masking) set in more than one message buffer, a
received message is stored in the message buffer with the smallest number.
• If the same acceptance filter is set in more than one message buffer, it can be used as multiple message
buffers. This provides sufficient time to perform receiving.
Notes: • Write by words to the message buffer area and general-purpose RAM area. At writing by bytes,
undefined data is written to the upper bytes and writing to the upper bytes is ignored when writing to
the lower bytes is performed.
• The message buffer (x) area disabled by the message buffer enable register (BVALR: BVALx = 0)
can be used as a general-purpose RAM area. However, during transmitting or receiving, it may take
up to 64 machine cycles to access the message buffer area and general-purpose RAM area.
475
CHAPTER 15 CAN CONTROLLER
The ID register (IDR) sets the ID of the message buffer used for transmitting and
receiving. In the standard frame format 11 bits from ID28 to ID18 are used, and in the
extended frame format 29 bits from ID28 to ID0 are used.
■ ID Register (IDR)
15 14 13 12 11 10 9 8 Reset value
BYTE1 ID20 ID19 ID18 ID17 ID16 ID15 ID14 ID13 XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W
7 6 5 4 3 2 1 0 Reset value
BYTE2 ID12 ID11 ID10 ID9 ID8 ID7 ID6 ID5 XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W
R/W : Read/Write
X : Undefined
: Unused
: Used bits in the standard frame format
476
CHAPTER 15 CAN CONTROLLER
bit 0 to bit 7 ID28 to ID21: These bits set the acceptance code or transmit message ID to be collated with the
ID bits 28 to 21 received message ID.
(BYTE0) Standard frame format (IDER: IDEx = 0): 11 bits from ID28 to ID18 are used.
• The old messages left in the receive shift register are stored in ID17 to ID0. This
bit 8 to bit 15 ID20 to ID13: will not affect the operation.
ID bits 20 to 13 • All received message IDs are stored even if specific bits are masked.
(BYTE1) Extended frame format (IDER: IDEx = 1): 29 bits from ID28 to ID0 are used.
Note:
bit 0 to bit 7 ID12 to ID5: • When using the standard frame format (IDER: IDEx = 0), the bits from ID28 to
ID bits 28 to 21 ID22 cannot be all set to 1.
(BYTE2) • When setting the ID register (IDR), perform writing by words. Writing by bytes
bit 11 to bit 15 is disabled.
ID4 to ID 0:
• The ID register (IDR) should be set after disabling the message buffer (x) to be
ID bits 4 to 0
set (BVALR: BVALx = 0). Setting the ID register (IDR) with the message
(BYTE3)
buffer (x) enabled may store a message unnecessary received.
477
CHAPTER 15 CAN CONTROLLER
30 1E 03 C0 30 1E 00 00 00 F0
31 1F 03 E0 31 1F 00 00 00 F8
32 20 04 00 32 20 00 00 01 00
100 64 0C 80 100 64 00 00 03 20
101 65 0C A0 101 65 00 00 03 28
200 C8 19 00 200 C8 00 00 06 40
8190 1FFE 00 00 FF F0
8191 1FFF 00 00 FF F8
8192 2000 00 01 00 00
536870905 1FFFFFF9 FF FF FC 80
536870906 1FFFFFFA FF FF FD 00
536870907 1FFFFFFB FF FF FD 80
536870908 1FFFFFFC FF FF FE 00
536870909 1FFFFFFD FF FF FE 80
536870910 1FFFFFFE FF FF FF 00
536870911 1FFFFFFF FF FF FF 80
478
CHAPTER 15 CAN CONTROLLER
The DLC register (DLCR) sets the data length of the message to be transmitted or
received.
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Reset value
DLC3 DLC2 DLC1 DLC0 XXXXXXXXB
R/W R/W R/W R/W
R/W : Read/Write
X : Undefined
: Unused
bit 0 to bit 3 DLC3 to DLC0: These bits set the data length (byte count) of the message to be transmitted or
Data length setting bits received.
When data frame transmitted: The data length (byte count) of the transmit
message is set.
When remote frame transmitted: The data length (byte count) of the
request message is set.
When data frame received: The data length (byte count) of the received
message is stored.
When remote frame received: The data length (byte count) of the request
message is stored.
Notes:
• The data length should be set within the range of 0 to 8 bytes.
• When setting the DLC register (DLCR), write by words. Writing by bytes
is disabled.
479
CHAPTER 15 CAN CONTROLLER
The data register (DTR) sets the messages at transmitting or receiving a data frame. The
data length can be set from 0 to 8 bytes.
to
bit 15 14 13 12 11 10 9 8 Reset value
BYTE7 D7 D6 D5 D4 D3 D2 D1 D0 XXXXXXXXB
R/W R/W R/W R/W R/W R/W R/W R/W
X : Undefined
R/W : Read/Write
bit 0 to bit 15 D7 to D0 (BYTE7 to • The data register (DTRx) is used only for transmitting or receiving a data
BYTE0): frame, and is not used for a remote frame.
Data bits 7 to 0 • The transmit message is set up to 8 bytes. The message is transmitted on
an MSB-first basis starting with the small message buffer number
(BYTE0 to BYTE7).
• The received message is stored on an MSB-first basis starting with the
small message buffer number (BYTE0 to BYTE7).
• If the received message is less than 8 bytes, undefined data is stored in the
rest of the bytes of the data register (DTRx). However this does not affect
the operation.
Note:
When setting the data register (DTR), write by words. Writing by bytes is
disabled.
480
CHAPTER 15 CAN CONTROLLER
The CAN controller has a transmit complete interrupt, receive complete interrupt and
node state transition interrupt, and can generate interrupts when;
• The transmission complete bit (TCR: TCx) is set.
• The reception complete bit (RCR: RCx) is set.
• The node status transition flag (CSR: NT) is set.
Table 15.4-1 Interrupt Control Bits and Interrupt Factors of CAN Controller
Transmit/ Interrupt Flag Bit Interrupt Factor Interrupt Enable Bit Clearing of Interrupt Request
Receive Flag
Receive Reception complete Message receiving Reception complete Writing 0 to reception complete
bit complete interrupt enable bit bit (RCR: RCx)
RCR: RCx=1 RIER: RIEx=1
Transmit Node status transition Node status transition Node status transition Writing 0 to node status transition
flag interrupt enable bit flag (CSR: NT)
CSR: NT=1 CSR: NIE=1
481
CHAPTER 15 CAN CONTROLLER
482
CHAPTER 15 CAN CONTROLLER
This section explains the procedures for transmitting and receiving messages and the
setting of bit timing, frame format, ID and acceptance filter.
483
CHAPTER 15 CAN CONTROLLER
15.5.1 Transmission
■ Transmission
YES : 1
YES : 1
YES : 1
If there remains message buffer meeting
transmission conditions, the lowest-
numbered message buffer is selected.
NO
Is bus idle state?
YES
NO
Is transmission successful?
YES NO: 0
Transmission cancelled?
(TCANR : TCANx)
Transmission request register is cleared (TREQR : TREQx = 0)
Reception RTR register is cleared (RRTRR : RRTRx = 0)
Transmission complete register is set (TCR : TCx = 1) YES: 1
Transmission is completed
484
CHAPTER 15 CAN CONTROLLER
● Starting transmitting
Setting of transmission request
To start transmitting, set the TREQx bit in the transmission request register to 1 which is corresponding
to the message buffer (x) that transmits the message. When the TREQx bit is set, the transmission
complete register is cleared (TCR: TCx = 0).
Presence or absence of remote frame receive wait
If the RFWTx bit in the remote frame receive wait register is set, transmitting is started after a remote
frame is received (RRTRR: RRTRx = 1).
If the remote frame receive wait register does not wait for receiving of a remote frame (RFWTR:
RFWTx = 0), transmitting is started immediately after the transmission request bit is set (TREQR:
TREQx = 1).
● Performing transmitting
Transmission request set in more than one message buffer
When a transmission request is set in more than one message buffer (TREQR: TREQx = 1),
transmitting is performed starting with the small-numbered message buffer (x = 7 to 0).
Transmitting to CAN bus
Transmitting message to the CAN bus from the transmit output pin (TX) is started when the CAN bus is
idle.
Arbitration
Arbitration is performed when a message buffer conflicts with transmitting from other CAN controllers
on the CAN bus. If arbitration fails or an error occurs during transmitting, retransmitting is performed
automatically until it succeeds after waiting until the bus goes idle again.
Selection of frame format
When 0 is set to the TRTRx bit in the transmit RTR register, a data frame is transmitted. When 1 is set
to the bit, a remote frame is transmitted.
485
CHAPTER 15 CAN CONTROLLER
● Completing transmitting
Success of transmitting
When transmitting is terminated normally, the TCx bit in the transmission complete register is set. The
transmission request register and receive RTR register (TREQR: TREQx = 0, RRTRR: RRTRx = 0) are
cleared.
Generation of transmission interrupt
When the TIEx bit in the transmission complete interrupt enable register is set, an interrupt request is
generated when transmitting is completed (TCR: TCx = 1).
486
CHAPTER 15 CAN CONTROLLER
15.5.2 Reception
■ Reception
YES
NO
Is reception successful?
YES
Determine message buffer (x) where
receive messages to be stored.
Reception YES : 1
complete interrupt enabled?
(RIER : RIEx = 1)
Transmission is completed
487
CHAPTER 15 CAN CONTROLLER
● Starting receiving
Receiving is started when the start-of-frame (SOF) of a data frame or remote frame is detected on the CAN
bus.
● Acceptance filter
The received message in the standard frame format is compared with the message buffer (x) set in the
standard frame format (IDER: IDEx = 0). The received message in the extended frame format is compared
with the message buffer (x) set in the extended frame format (IDER: IDEx = 1).
Passing through acceptance filter
If all bits set to "compare" in the acceptance mask are matched after comparison between the received
message ID and acceptance code (IDR: IDx), the received message passes the acceptance filter in the
message buffer (x).
488
CHAPTER 15 CAN CONTROLLER
Figure 15.5-3 Flowchart of Determining Message Buffer that Stores Received Message
Start
Yes
End
489
CHAPTER 15 CAN CONTROLLER
● Receive overrun
When another received message is stored in the message buffer that has completed receiving (RCR: RCx =
1), a receive overrun occurs. When a receive overrun occurs, 1 is set to the ROVRx bit in the receive
overrun register corresponding to the number of the message buffer (x) where the receive overrun occurs.
Note: Either the request to transmit a data frame or a remote frame is cancelled.
● Completing receiving
When the received message is stored, the reception complete register is set (RCR: RCx = 1). If the
reception complete interrupt enable register is set (RIER: RIEx = 1), an interrupt is generated when
receiving is completed (RCR: RCx = 1).
Note: The CAN controller cannot receive any message transmitted by itself.
490
CHAPTER 15 CAN CONTROLLER
■ Presetting
● Setting of ID
• Set the ID of the message buffer (x) to the ID28 to ID0 bits in the ID register (IDR). In the standard
frame format, it does not have to set the ID17 to ID0 bits. The ID of the message buffer (x) is used as
the transmit message ID at transmitting and as the acceptance code at receiving.
• Set the ID after disabling the message buffer (x) (BVALR: BVALx = 0). Setting the ID with the
message buffer (x) enabled may store a message unnecessary received.
491
CHAPTER 15 CAN CONTROLLER
No
TREQx 1
0
1
TCx
0
End
492
CHAPTER 15 CAN CONTROLLER
Note: Rewrite transmit data after setting the TREQx bit in the transmit request register to 0. There is no need to
set the bit disabled in the message buffer enable register (BVALR: BVALx = 0). When the bit is set to
disabled, no remote frame can be received.
Note: When the RFWTx bit in the remote frame wait register is set to 1, no remote frame can be transmitted.
493
CHAPTER 15 CAN CONTROLLER
494
CHAPTER 15 CAN CONTROLLER
Start
N
Message received?
RCx = 1 ?
Y
Received byte count reading
Message storing Reception overrun bit clear
(storing by reception complete interrupt) ROVRx = 0
Received message reading
Reception overrun? N
ROVRx = 0?
End
495
CHAPTER 15 CAN CONTROLLER
● Starting receiving
To start receiving after the completion of setting, set the BVALx bit in the message buffer enable register
(BVALR) to 1 and enable the message buffer (x).
496
CHAPTER 15 CAN CONTROLLER
Figure 15.5-6 "Example of Reception Interrupt Processing" shows an example of reception interrupt
processing.
Interrupt generation
with RCx = 1
Received message
reading
A : = ROVRx
ROVRx : = 0
No
A = 0?
Yes
RCx : 0
Completion
497
CHAPTER 15 CAN CONTROLLER
Note: When the acceptance mask select register is set to "full-bit comparison" (AMSR: AMSx.1, AMSx.0 =
00B), do not set the same acceptance code. When the register is set to "full-bit comparison", the messages
are always stored in the message buffer with the smaller number, so the message buffers cannot be
formed into a multiple message buffer.
498
CHAPTER 15 CAN CONTROLLER
Message receiving → reception overrun (ROVR5 =1) generated, stored in message buffer 5
499
CHAPTER 15 CAN CONTROLLER
● Condition
When following two conditions occur at the same time, CAN Controller will not perform to receive or
transmit messages normally.
• CAN Controller is participating in the CAN communication. (i.e. The read value of HALT bit is 0 and
CAN Controller is ready to receive or transmit messages)
• Message buffers are read or written when the message buffers are disabled by BVAL bits.
● Work around
Operation for re-configuring receiving message buffers
While CAN Controller is participating in CAN communication (the read value of HALT bit is 0 and
CAN Controller is ready to receive or transmit messages), it is necessary to following one from the two
operations described below to re-configure message buffers by ID, AMS and AMR0/1 register-settings.
• Use of HALT bit
- Write 1 to HALT bit and read it back for checking the result is 1. Then change the settings for ID/
AMS/AMR0/1 registers.
• No Use of Message Buffer 0
- Don't use the message buffer 0. In other words, disable message buffer (BVAL0=0), prohibit receive
interrupt (RIE0=0) and do not request transmission (TREQ0=0).
Operation for processing received message
Don't use the receiving prohibition by BVAL bit to avoid over-written of next message. Use the ROVR
bit for checking if over-write has been performed. For details, refer to section 15.3.16 "Reception
Overrun Register (ROVRR)" and 15.5.3 "Procedures for Transmitting and Receiving"
Operation for suppressing transmission request
Don't use BVAL bit for suppressing transmission request, use TCAN bit instead of it.
Operation for composing transmission message
For composing a transmission message, it is necessary to disable the message buffer by BVAL bit to
change contents of ID and IDE registers. In this case, BVAL bit should reset (BVAL=0) after checking
if TREQ bit is 0 or after completion of the previous message transmission (TC=1).
500
CHAPTER 15 CAN CONTROLLER
● Processing specifications
• Set buffer 5 of CAN to data frame transmit mode and buffer 0 to data frame receive mode.
• Setting of frame format: Standard frame format
• Setting of ID: Buffer 0 ID = 1, Buffer 5 ID = 5
• Baud rate: 100 Kbps (machine clock = 16 MHz)
• Acceptance mask selection: full-bit comparison
• After entering the bus mode (HALT = 0), data A0A0His transmitted.
• A transmission request is made within the transmission complete interrupt routine to transmit the same
data (When TREQx is set to start sending, the transmission complete interrupt bit is cleared).
• The reception interrupt bit is cleared within the reception interrupt routine.
501
CHAPTER 15 CAN CONTROLLER
● Coding example
:
:
:
;//Setting of data format (CAN initialization)
MOVW BTR,#05CC7H ; Setting baud rate 100 Kbps
; (0: Standard, 1:Expanded)
MOVW IDR51,#0A000H ; Setting of data frame 5 ID (ID = 5)
MOVW IDR501,#2000H ; Setting of data frame 0 ID (ID = 1)
MOVW AMSR,#0000H ; Acceptance mask select register
; (full-bit comparison)
MOVW BVALR,#021H ; Message buffers 5 and 0 enabled
;//Transmit setting
MOVW DLCR5,#02H ; Setting of transmission data length
; (00H: 0-byte length, 08H: 8-byte length)
MOVW RFWTR,#0000H ; Remote frame receive wait register
MOVW TRTRR,#0000H ; Transmission RTR register (0: Data frame
; transmission, 1: Remote frame transmission)
MOVW TIER,#0020H ; Transmission complete interrupt enable register
;//Reception setting
MOVW RIER,#0001H ; Reception complete interrupt enable register
;//Bus operation start
MOV CSR0,#80H ; Control status register (HALT=0)
sthlt BBS CSR0:0,sthlt ; Wait until HALT=0
;//Transmission data set
MOVW DTR5,#0A0A0H ; Write A0A0H to data register of message buffer 5.
MOVW TREQR,#0020H ; Transmission request register
; (1: Transmission start, 0: Transmission stop)
:
:
:
;//Reception complete interrupt
CANRX
MOVW RCR0,#0000H ; Reception complete register
RETI
;//Transmission complete interrupt
CANTX
MOVW TREQR,#0020H ; Transmission request register
; (1: Transmission start, 0: Transmission stop)
RETI
502
CHAPTER 16
8/16 ADDRESS MATCH
DETECTION FUNCTION
503
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
504
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
Address latch
Comparator
PADR0 (24bit)
Internal data bus
PACSR
● Address latch
The address latch stores the value of the address output to the internal data bus.
505
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
This section details the registers used by the address match detection function.
Figure 16.3-1 List of Registers and Reset Values of Address Match Detection Function
bit 7 6 5 4 3 2 1 0
bit 7 6 5 4 3 2 1 0
×: Undefined
506
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
7 6 5 4 3 2 1 0
Reset value
00000000 B
507
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
bit 1 AD0E: The address match detection operation with the detect address setting
Address match register 0 (PADR1) is enabled or disabled.
detection enable bit 0 When set to 0: Disables the address match detection operation.
When set to 1: Enables the address match detection operation.
• When the value of detect address setting register 0 (PADR0) matches
with the value of address latch at enabling the address match detect
operation (AD0E = 1), the INT9 instruction is immediately executed.
508
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
The value of an address to be detected is set in the detect address setting registers.
When the address of the instruction processed by the program matches the address set
in the detect address setting registers, the next instruction is forcibly replaced by the
INT9 instruction, and the interrupt processing program is executed.
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Reset value
PADR0, PADR1: High D23 D22 D21 D20 D19 D18 D17 D16 XXXXXXXX B
bit 15 bit 14 bit 13 bit 12 bit 11 bit 10 bit 9 bit 8 Reset value
PADR0, PADR1: Middle D15 D14 D13 D12 D11 D10 D9 D8 XXXXXXXX B
R/W R/W R/W R/W R/W R/W R/W R/W
bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 Reset value
PADR0, PADR1: Low D7 D6 D5 D4 D3 D2 D1 D0 XXXXXXXX B
R/W : Read/Write
X : Undefined
509
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
• In the detect address setting registers (PADR0 and PADR1), starting address (first byte) of instruction to
be replaced by INT9 instruction should be set.
Notes: • When an address of other than the first byte is set to the detect address setting register (PADR0 and
PADR1), the instruction code is not replaced by INT9 instruction and a program of an interrupt
processing is not be performed. When the address is set to the second byte or subsequent, the address
set by the instruction code is replaced by "01" (INT9 instruction code) and, which may cause
malfunction.
• The detect address setting registers (PADR0 and PADR1) should be set after disabling the address
match detection (PACSR: AD0E = 0 or AD1E = 0) of corresponding address match control registers.
If the detect address setting registers are changed without disabling the address match detection, the
address match detection function will work immediately after an address match occurs during writing
address, which may cause malfunction.
• The address match detection function can be used only for addresses of the internal ROM area. If
addresses of the external memory area are set, the address match detection function will not work and
the INT9 instruction will not be executed.
510
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
If the addresses of the instructions executed in the program match those set in the
detection address setting registers (PADR0 and PADR1), the address match detection
function will replace the first instruction with the INT9 instruction (01H) to branch to the
interrupt processing program.
Program execution
Address Instruction code Mnemonic
The instruction address to be FF001C : A8 00 00 MOVW RW0, #0000
executed by program matches FF001F : 4A 00 00 MOVW A, #0000
detect address setting register 0 FF0022 : 4A 80 08 MOVW A, #0880
Replaced by INT9 instruction (01H)
511
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
This section gives an example of patch processing for program correction using the
address match detection function.
● System configuration
Figure 16.4-2 "Example of System Configuration using Address Match Detection Function" gives an
example of the system configuration using the address match detection function.
Figure 16.4-2 Example of System Configuration using Address Match Detection Function
Serial E2PROM
MCU Interface
E2PROM
F2MC16LX Storing patch program
Pull up resistor
512
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
E2PROM
Address
0000H Patch program byte count
0001H Detect address 0 (Low)
For patch program 0
PADR0 0002H Detect address 0 (Middle)
0003H Detect address 0 (High)
0004H Patch program byte count
0005H Detect address 1 (Low)
For patch program 1
PADR1 0006H Detect address 1 (Middle)
0007H Detect address 1 (High)
513
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
● Initialization
• E2PROM data are all cleared to "00H".
● Reset sequence
• After reset, the MCU (F2MC-16LX) reads the byte count of the E2PROM patch program to check the
presence or absence of the correction program.
• If the byte count of the patch program is not "00H", the higher, middle and lower bits at detect addresses
0 and 1 are read and set in the detection address setting registers 0 and 1 (PADR0 and PADR1). The
patch program (main body) is read according to the byte count of the patch program and written to
RAM in the MCU (F2MC-16LX).
• he patch program (main body) is allocated to the address where the patch program is executed in the
INT9 interrupt processing by the address match detection function.
• Address match detection is enabled (PACSR: AD0E = 1, AD1E = 1)
514
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
Figure 16.4-4 Operation of Address Match Detection Function at Storing Patch Program in
E2ROM
000000 H
ROM
(2)
Program error
(4)
FFFFFF H
(1) Execution of detection address setting of reset sequence and normal program
(2) Branch to patch program which expanded in RAM with INT9 interrupt processing by address match detection
(3) Patch program execution by branching of INT9 processing
(4) Execution of nomal program which branches from patch program
515
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
FF0000H
Reset INT9
Execution of normal
program
NO YES
Program address INT9
= PADR0
516
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
This section gives a program example for the address match detection function.
● Processing specifications
If the address of the instruction to be executed by the program matches the address set in the detection
address setting register (PADR0), the INT9 instruction is executed.
● Coding example
517
CHAPTER 16 8/16 ADDRESS MATCH DETECTION FUNCTION
518
CHAPTER 17
MIRRORING FUNCTION
SELECT MODULE
519
CHAPTER 17 MIRRORING FUNCTION SELECT MODULE
The ROM mirroring function select module provides a setting so that ROM data in the
FF bank can be read by access to the 00 bank.
FF bank 00 bank
Data
ROM
004000 H 00 bank
ROM mirror area
00FFFFH
FC0000H
FEFFFF H
FF0000 H MB90V495G
MB90F387/S
FF4000 H FF bank MB90387/S
(ROM mirror-target area)
FFFFFFH
520
CHAPTER 17 MIRRORING FUNCTION SELECT MODULE
000000 H
I/O area I/O area
0000C0 H
000100 H
RAM area RAM area
Address 1
003900 H
Extend I/O area Extend I/O area
004000 H
ROM area
010000 H
Address 2
ROM area ROM area
FFFFFFH
When ROM mirroring When ROM mirroring
function enabled function disabled
■ List of Registers and Reset Values of ROM Mirroring Function Select Module
Figure 17.1-4 List of Registers and Reset Values of ROM Mirroring Function Select Module
bit 15 14 13 12 11 10 9 8
×: Undefined
521
CHAPTER 17 MIRRORING FUNCTION SELECT MODULE
The ROM mirroring function select register (ROMM) enables or disables the ROM
mirroring function. When the ROM mirroring function is enabled, ROM data in the FF
bank can be read by access to the 00 bank.
15 14 13 12 11 10 9 8
Reset value
XXXXXXX1B
W
bit 8
W : Write only MI ROM mirroring function select bit
X : Undefined 0 ROM mirroring function disabled
: Unused
1 ROM mirroring function enabled
: Reset value
bit 8 MI: This bit enables or disables the ROM mirroring function.
ROM mirroring function When set to 0: Disables ROM mirroring function
select bit When set to 1: Enables ROM mirroring function
• When the ROM mirroring function is enabled (MI = 1), data at ROM
addresses "FF4000H" to "FFFFFFH" can be read by accessing addresses
"004000Hto "00FFFFH"H"
Note: While the ROM area at addresses "004000H" to "00FFFFH" is being used, access to the ROM mirroring
function select register (ROMM) is prohibited.
522
CHAPTER 18
512 KBIT FLASH MEMORY
523
CHAPTER 18 512 KBIT FLASH MEMORY
There are three ways of programming and erasing flash memory as follows:
1. Programming and erasing using parallel writer
2. Programming and erasing using serial writer
3. Programming and erasing by executing program
This chapter describes the above "3. Programming and Erasing by Executing Program".
Note: The function for reading the manufacture code and device code is unprovided.
These codes cannot be accessed by any command.
524
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the registers and the sector configuration of flash memory.
bit 7 6 5 4 3 2 1 0
● Sector configuration
For access from the CPU, the FF bank register has SA0 to SA3.
525
CHAPTER 18 512 KBIT FLASH MEMORY
The flash memory control status register (FMCS) functions are shown in Figure 18.3-1
"Functions of Flash Memory Control Status Register (FMCS)".
7 6 5 4 3 2 1 0
Reset value
000X0000 B
bit 0
Reserved Reserved bit
0 Always set to "0"
bit 1
Reserved Reserved bit
0 Always set to "0"
bit 2
Reserved Reserved bit
0 Always set to "0"
bit 3
Reserved Reserved bit
0 Always set to "0"
bit 4
RDY Flash memory programming/erasing status bit
0 Programming/erasing (next data programming/erasing disabled)
1 Programming/erasing terminated (next data programming/erasing enabled)
bit 5
WE Flash memory programming/erasing enable bit
0 Programming/erasing flash memory area disabled
1 Programming/erasing flash memory area enabled
bit 6
Flash memory operation flag bit
RDYINT
Read Write
0 Programming/erasing This RDYIN bit cleared
1 Programming/erasing terminated No effect
bit 7
INTE Flash memory programming/erasing interrupt enable bit
0 Interrupt disabled at end of programming/erasing
R/W : Read/Write 1 Interrupt enabled at end of programming/erasing
R : Read only
W : Write only
X : Undefined
: Reset value
526
CHAPTER 18 512 KBIT FLASH MEMORY
bit 5 WE: This bit enables or disables the programming/erasing of flash memory.
Flash memory The WE bit should be set before starting the command to program/erase flash
programming/erasing memory.
enable bit When set to 0: No program/erase signal is generated even if the command
to program/erase the FF bank is input.
When set to 1: Programming/erasing flash memory is enabled after
inputting program/erase command to the FF bank.
• When not performing programming/erasing, the WE bit should be set to 0
so as not to accidentally program or erase flash memory.
bit 6 RDYINT: This bit shows the operating state of flash memory.
Flash memory operation If programming/erasing flash memory is terminated, the RDYINT bit is set to
flag bit 1 in timing of termination of the automatic flash memory algorithm.
• If the RDYINT bit is set to 1 when an interrupt as programming/erasing
flash memory is terminated is enabled (FMCS: INTE = 1), an interrupt is
requested.
• If the RDYINT bit is 0, programming/erasing flash memory is disabled.
When set to 0: Cleared.
When set to 1: Unaffected.
If the read-modify-write (RMW) instructions are used, 1 is always read.
bit 7 INTE: This bit enables or disables an interrupt as programming/erasing flash
Flash memory memory is terminated.
programming/erasing When set to 1: If the flash memory operation flag bit is set to 1 (FMCS:
interrupt enable bit RDYINT = 1), an interrupt is requested.
527
CHAPTER 18 512 KBIT FLASH MEMORY
Note: The flash memory operation flag bit (RDYINT) and flash memory programming/erasing status bit (RDY)
do not change simultaneously. A program should be created so that either RDYINT bit or RDY bit can
identify the termination of programming/erasing.
Automatic algorithm
end timing
RDYINT bit
RDY bit
1 Machine cycle
528
CHAPTER 18 512 KBIT FLASH MEMORY
There are four commands for starting the automatic algorithm of flash memory: read/
reset, write, chip erase. The sector erase command controls suspension and
resumption of sector erase.
Write Cycle of Write Cycle of Write Cycle of Write Cycle of Write Cycle of Write Cycle of
Command Bus
Write First Bus Second Bus Third Bus Fourth Bus Fifth Bus Sixth Bus
Sequence
Access Address Data Address Data Address Data Address Data Address Data Address Data
Read/
1 FFXXXX XXF0 − − − − − − − − − −
Reset*
Read/
4 FFAAAA XXAA FF5554 XX55 FFAAAA XXF0 RA RD − − − −
Reset*
Write
program 4 FFAAAA XXAA FF5554 XX55 FFAAAA XXA0 PA PD − − − −
(even) (word)
Chip
6 FFAAAA XXAA FF5554 XX55 FFAAAA XX80 FFAAAA XXAA FF5554 XX55 FFAAAA XX10
erace
Sector
6 FFAAAA XXAA FF5554 XX55 FFAAAA XX80 FFAAAA XXAA FF5554 XX55 SA XX30
erase (even)
Sector erase suspend Input of address"FFXXXX"Data (xxB0H) suspends sector erasing.
Sector erase resume Input address"FFXXXX"Data (xx30H) suspends and resume sector erasing.
Auto
3 FFAAAA XXAA FF5554 XX55 FFAAAA XX90 − − − − − −
Select
Notes: • Addresses in the table are the values in the CPU memory map. All addresses and data are
hexadecimal values, where "x" is any value.
• RA: Read address
• PA: Program address. Only even addresses can be specified.
• SA: Sector address (See 18.2 "Registers and Sector Configuration of Flash Memory")
• RD: Read data
• PD: Program data. Only word data can be specified.
*: Two kinds of read/reset commands can reset flash memory to the read mode.
529
CHAPTER 18 512 KBIT FLASH MEMORY
Auto Select in Table 18.4-1 "Address Setting for Auto Select" is the command to check the state of sector
protection. The addresses must be set as indicated below together with the command in Table 18.4-1 "
Address Setting for Auto Select".
530
CHAPTER 18 512 KBIT FLASH MEMORY
Bit No. 7 6 5 4 3 2 1 0
• To identify whether automatic programming/chip and sector erasing is in execution or terminated, check
the hardware sequence flag or the flash memory programming/erasing status bit in the flash memory
control status register (FMCS: RDY). Programming/erasing is terminated, returning to the read/reset
state.
• To create a programming/erasing program, use the DQ7, DQ6, DQ5, DQ3 and DQ2 flags to check that
automatic programming/erasing is terminated and read data.
• The hardware sequence flags can also be used to check whether the second and later sector erase code
writing is enabled.
531
CHAPTER 18 512 KBIT FLASH MEMORY
*: If the DQ5 flag is 1 (timing limit over), the DQ2 flag performs the toggle operation for continuous reading from the
programming/erasing sector but does not perform the toggle operation for reading from other sectors.
532
CHAPTER 18 512 KBIT FLASH MEMORY
The data polling flag (DQ7) is mainly used to notify that the automatic algorithm is
executing or has been completed using the data polling function.
Table 18.5-3 State Transition of Data Polling Flag (State Change at Normal Operation)
DQ7 -->
DQ7 0 --> 1 0 0 --> 1 1 --> 0 DATA:7
DATA:7
Table 18.5-4 State Transition of Data Polling (State Change at Abnormal Operation)
DQ7 DQ7 0
● At programming
• Read access during execution of the auto-programming algorithm causes flash memory to output the
reversed data of bit 7 last written.
• Read access at the end of the auto-programming algorithm causes flash memory to output the value of
bit 7 at the address to which read access was peformed.
● At chip/sector erasing
• During executing chip and sector erasing algorithms, when read access is made to the currently being
erasing sector, bit 7 of flash memory outputs 0. When chip erasing/sector erasing is terminated, bit 7 of
flash memory outputs 1.
533
CHAPTER 18 512 KBIT FLASH MEMORY
Note: Read access to the specified address while the automatic algorithm starts is ignored. At data reading,
other bits can be output at the end of data polling flag (DQ7). Data reading after the end of the automatic
algorithm should be performed following read access after completion of data polling has been checked.
534
CHAPTER 18 512 KBIT FLASH MEMORY
The toggle bit flag is used to notify that the automatic algorithm is being executed or in
the end state using the toggle bit function.
Table 18.5-5 State Transition of Toggle Bit Flag (State Change at Normal Operation)
Toggle -->
DQ6 Toggle --> Stop Toggle Toggle --> 1 1 --> Toggle DATA:6
DATA:6
Table 18.5-6 State Transition of Toggle Bit Flag (State Change at Abnormal Operation)
Reference: If the sector for programming is reprogram-protected, the toggle bit flag (DQ6) produces a toggle output
for approximately 2 µs, and then terminates it without reprogramming data.
If all sectors for erasing are reprogram-protected, the toggle bit flag (DQ6) produces a toggle output for
approximately 100 µs, and then returns to the read/reset state without reprogramming data.
535
CHAPTER 18 512 KBIT FLASH MEMORY
The timing limit over flag (DQ5) is a hardware sequence flag that notifies flash memory
that the execution of the automatic algorithm has exceeded a prescribed time (the time
required for programming/erasing).
Table 18.5-7 State Transition of Timing Limit Over Flag (State Change at Normal Operation)
Table 18.5-8 State Transition of Timing Limit Over Flag (State Change at Abnormal Operation
DQ5 1 1
536
CHAPTER 18 512 KBIT FLASH MEMORY
The sector erase timer flag is used to notify during the period of waiting for sector
erasing after the sector erase command has started.
Table 18.5-9 State Transition of Sector Erase Timer Flag (State Change at Normal Operation)
Table 18.5-10 State Transition of Sector Erase Timer Flag (State Change at Abnormal Operation)
DQ3 0 1
● At sector erasing
• If a read access made after starting the sector erase command is within a sector erasing wait period, the
sector erasing timer flag (DQ3) outputs 0. If it exceeds the period, the sector erasing timer flag (DQ3)
outputs 1.
• If the sector erasing timer flag (DQ3) is 1, indicating that the automatic algorithm for sector erasing by
the data polling or toggle bit function is in progress (DQ = 0; DQ6 produces a toggle output), sector
erasing is performed. If any command other than the sector erasing suspension is set, it is ignored until
sector erasing is terminated.
• If the sector erasing timer flag (DQ3) is 0, flash memory can accept the sector erase command. To
program the sector erase command, check that the sector erasing timer flag (DQ3) is 0. If the flag is 1,
flash memory may not accept the sector erase command of suspending.
537
CHAPTER 18 512 KBIT FLASH MEMORY
The toggle bit 2 flag (DQ2) is a hardware sequence flag that notifies flash memory that
sector erasing is being suspended.
Table 18.5-11 State Transition of Toggle Bit Flag (State Change at Normal Operation)
DQ2 1 --> DATA:2 Toggle --> Stop Toggle Toggle Toggle DATA:2
Table 18.5-12 State Transition of Toggle Bit Flag (State Change at Abnormal Operation)
Chip and
Operating Programmin
Sector
State g
Erasing
DQ2 1 *
*: If the DQ5 flag is 1 (timing limit over), the DQ2 flag performs the toggle operation
for continuous reading from the programming/erasing sector but does not perform
the toggle operation for reading from other sectors.
● At sector erasing
• If a continuous read access is made during the execution of the automatic algorithm for chip erasing/
sector erasing, flash memory toggle-outputs 1 and 0 alternately every reading.
• If a continuous read access is made after the completion of the algorithm for chip erasing/sector erasing,
flash memory outputs bit 2 (DATA: 2) for the read value of the read address every reading.
538
CHAPTER 18 512 KBIT FLASH MEMORY
Reference: If all sectors for erasing are reprogram-protected, the toggle bit flag (DQ2) produces a toggle output for
approximately 100 µs, and then returns to the read/reset state without reprogramming data.
539
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the procedure for inputting commands starting the aoutomatic
algorithm, and for read/reset of flash memory, programming, chip erasing, sector
erasing, sector erasing suspention and sector erasing resumption.
540
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the procedure for inputting the read/reset command to place flash
memory in the read/reset state.
541
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the procedure for inputting the program command to program
data to flash memory.
542
CHAPTER 18 512 KBIT FLASH MEMORY
Start
FMCS : WE (bit 5)
Programming enabled
Data
0 Timing limit
(DQ5)
Data
Data polling
(DQ7)
Data
NO
Programming error Last address
YES
FMCS : WE (bit 5)
Programming enabled
Check by hardware
Completed sequence flag
543
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the procedure for inputting the chip erase command to erase all
data from flash memory.
544
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the procedure for inputting the sector erase command to erase
any data in flash memory. Sector-by-sector erasing is enabled and multiple sectors can
be specified at a time.
545
CHAPTER 18 512 KBIT FLASH MEMORY
Start
FMCS : WE (bit 5)
Erasing enabled
0
Timing limit
(DQ5)
NO
Erasing error Last sector
YES
FMCS : WE (bit 5)
Erasing enabled
Check by hardware
sequence flag Completed
546
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the procedure for inputting the sector erase suspend command to
suspend sector erasing. Data can be read from the sector not being erased.
547
CHAPTER 18 512 KBIT FLASH MEMORY
This section explains the procedure for inputting the sector erase resume command to
resume erasing of the suspended flash memory sector.
■ Erase Resumption
• Suspended sector erasing can be resumed by continuously transmitting the sector erase resume
command in the command sequence table from CPU to flash memory.
• The sector erase resume command resumes sector erasing suspended by the sector erase suspend
command. This command is executed by writing the erase resume code (30H). In this case, address in
the flash memory area is specified.
• Inputting the sector erase resume command during sector erasing is ignored.
548
CHAPTER 18 512 KBIT FLASH MEMORY
A sample program for the 512 Kbit flash memory is given below.
NAME FLASHWE
TITLE FLASHWE
;--------------------------------------------------------------------------------
; 512 Kbit FLASH Sample Program
; 1: Transfer program in flash (address FFBC00 H,
; sector SA2) to RAM (address 000700H).
; 2: Execute program on RAM.
; 3: Program PDR1 value to flash (address FF0000H, sector SA0).
; 4: Read programmed value (address FF0000H, sector SA0) and output to PDR2.
; 5: Erase programmed sector (SA0).
; 6: Output check that data is erased.
; Conditions
; - Count of bytes transferred to RAM: 100H (256 bytes)
; - Completion of programming and erasing checked by:
; Timing limit over flag (DQ5)
; Toggle bit flag (DQ6)
; RDY (FMCS)
; - Action taken at error
; Output H to P00 to P07.
; Issue reset command.
;--------------------------------------------------------------------------------
;
RESOUS IOSEG ABS=00 ; Definition of "RESOUS" I/O segment
ORG 0000H
PDR0 RB 1
PDR1 RB 1
PDR2 RB 1
PDR3 RB 1
ORG 0010H
DDR0 RB 1
DDR1 RB 1
DDR2 RB 1
DDR3 RB 1
ORG 00A1H
CKSCR RB 1
ORG 00AEH
FMCS RB 1
ORG 006FH
ROMM RB 1
RESOUS ENDS
;
549
CHAPTER 18 512 KBIT FLASH MEMORY
SSTA SSEG
RW 0127H
STA_T RW 1
SSTA ENDS
;
DATA DSEG ABS=0FFH ; FLASH command address
ORG 5554H
COMADR2 ORG 1
ORG 0AAAAH
COMADR1 ORG 1
DATA ENDS
;--------------------------------------------------------------------------------
; Main program (SA1)
;--------------------------------------------------------------------------------
CODE CSEG
START:
;------------------------------------------------------------------------
; Initialize
;------------------------------------------------------------------------
MOV CKSCR,#0BAH ; Set to 3-multiplying count
MOV RP,#0
MOV A,#!STA_T
MOV SSB,A
MOVW A,#!STA_T
MOVW SSB, A
MOV ROMM,#00H ; Mirror OFF
MOV ROMM,#00H ; For error check
MOV DDR0,#0FFH
MOV PDR1,#00H ; Data input port
MOV DDR1,#00H
MOV PDR2,#00H ; Data output port
MOV DDR2,#0FF
;------------------------------------------------------------------------
; Transfer FLASH programming/erasing program (FFBC00H) to RAM
; (address 700H)
;------------------------------------------------------------------------
MOVW A,#0700H ; Transfer destination RAM area
MOVW A,#0BC00H ; Transfer source address
; (position where program exist)
MOVW RW0,#100H ; Count of bytes to be transferred
MOVS ADB,PCB ; Transfer 100Hfrom FFBC00Hto 000700H
CALLP 000700H ; Jump to address where transferred program exists
;------------------------------------------------------------------------
; Data output
;------------------------------------------------------------------------
OUT MOV A,#0FFH
MOV ADB,A
MOVW RW2,#0000H
MOVW A,@RW2+00
MOV PDR2,A
END JMP *
CODE ENDS
550
CHAPTER 18 512 KBIT FLASH MEMORY
;--------------------------------------------------------------------------------
Flash programming/erasing program (SA2)
;--------------------------------------------------------------------------------
RAMPRG CSEG ABS=0FFH
ORG 0BC00H
;------------------------------------------------------------------------
; Initialize
;------------------------------------------------------------------------
MOVW RW0,#0500H ; RW0: RAM space for storage of input data
; 00:0500 to
MOVW RW2,#0000H ; RW2: Flash memory programming address
; FD:0000 to
MOV A,#00H ; DTB change
MOV DTB,A ; Specify bank for @RW0
MOV A,#0FFH ; ADB change 1
MOV ADB,A ; Specify bank for program mode specifying address
MOV PDR3,#00H ; Initialize switch
MOV DDR3,#00H
;
WAIT1 BBC PDR3:0,WAIT1 ; PDR3: 0 with High level, start programming
;
;--------------------------------------------------------------------------------
; Program (SA0)
;--------------------------------------------------------------------------------
MOV A,PDR1
MOVW @RW0+00,A ; Save PDR1 data in RAM.
MOV FMCS,#20H ; Set program mode.
MOVW ADB:COMADR1, #00AAH
; Flash program command 1
MOVW ADB:COMADR2, #0055H
; Flash program command 2
MOVW ADB:COMADR1, #00A0H
; Flash program command 3
;
MOVW A, @RW0+00 ; Program input data (RW0) to flash memory (RW2).
;
MOVW @RW2+00, A
WRITE ; Waiting time check
;------------------------------------------------------------------------
;ERROR occurs when the time limit over check flag is set and toggling.
;------------------------------------------------------------------------
MOVW A,@RW2+00
AND A,#20H ; DQ5 time limit check
BZ NTOW ; Time limit over
MOVW A,@RW2+00 ; AH
MOVW A,@RW2+00 ; AL
XORW A ; XOR of AH and AL (1 if value is invalid
AND A,#40H ; Is DQ6 toggle bit?
BNZ ERROR ; If yes, go to ERROR.
;------------------------------------------------------------------------
;Programming end check (FMCS-RDY)
;------------------------------------------------------------------------
NTOW MOVW A,FMCS
AND A,#10H ; Extract RDY bit (bit 4) of FMCS.
BZ WRITE ; Is programming ended?
MOV FMCS,#00H ; Cancel program mode.
551
CHAPTER 18 512 KBIT FLASH MEMORY
;------------------------------------------------------------------------
;Program data output
;------------------------------------------------------------------------
MOVW RW2,#0000H ; Output program data
MOVW A, @RW2+00
MOV PDR2,A
;
WAIT2 BBC PDR3:1,WAIT2 ; PDR3:1 With "H", start sector erasing.
;
;--------------------------------------------------------------------------------
; Sector erasing (SA0)
;--------------------------------------------------------------------------------
MOV @RW2+00,#0000H ; Initialize address
MOV FMCS,#20H ; Set erase mode
MOVW ADB:COMADR1,#00AAH ; Erase command 1
MOVW ADB:COMADR2,#0055H ; Erase command 2
MOVW ADB:COMADR1,#0080H ; Erase command 3
MOVW ADB:COMADR1,#00AAH ; Erase command 4
MOVW ADB:COMADR2,#0055H ; Erase command 5
MOV @RW2+00,#0030H ; Issue erase command to sector to be erased 6.
ELS ; Waiting check
;------------------------------------------------------------------------
;ERROR occurs when time limit over check flag is set and toggling is underway.
;--------------------------------------------------------------------------------
MOVW A,@RW2+0
AND AND A,#20H ; DQ5 time limit check
BZ NOTE ; Time limit over
MOVW A,@RW2+00 ; During AH programming, "H/L" is output
MOVW A,@RW2+00 ; alternately every time AL is read
XORW A ; XOR of AH and AL (1 if DQ6 value invalid,
; indicating programming underway)
AND A, #40H ; Is DQ6 toggle bit "H"?
BNZ ERROR ; If yes, go to ERROR
;------------------------------------------------------------------------
;Erasing end check (FMCS-RDY)
;------------------------------------------------------------------------
NTOE MOVW A,FMCS ;
AND A,#10H ; Extract RDY bit (bit 4) of FMCS
BZ ELS ; Is erasing ended?
MOV FMCS,#00H ; Cancel flash erase mode
RETP ; Return to main program
;--------------------------------------------------------------------------------
;Error
;--------------------------------------------------------------------------------
ERROR MOV ADB:COMADR1,#0F0H ; Reset command (read enabled)
MOV FMCS,#00H ; Cancel flash mode
MOV PDR0,#0FFH ; Check error processing
RETP ; Return to main program
RAMPRG ENDS
;-------------------------------------------------------------------
VECT CSEG ABS=0FFH
ORG 0FFDCH
DSL START
DB 00H
VECT ENDS
;
ENDS START
552
CHAPTER 19
FLASH SERIAL
PROGRAMMING
CONNECTION
553
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
The MB90F387/S supports the serial on-board programming of flash ROM (Fujitsu
standard). The specification for serial on-board programming are explained below.
Note: Inquire of Yokogawa Digital Computer Corporation for details about the functions and operations of the
AF220/AF210/AF120/AF110 flash microcontroller programmer, general-purpose common cable for
connection (AZ210), and connectors
Table 19.1-1 Pins Used for Fujitsu Standard Serial On-board Programming (1/2)
MD2, MD1, Writing 1 to MD2, 1 to MD1 and 0 to MD0 sets the flash serial program
Mode pins
MD0 mode.
In the flash serial program mode, the internal operating clock of the CPU has
a frequency one time that of the PLL clock, so the internal operating clock
frequency is the same as the oscillation clock frequency. Since the
X0, X1 Oscillation pins
oscillation clock frequency serves as an internal operation clock, the
oscillator used for serial programming have frequencies from 1 MHz to 16
MHz
P30, P31 Programming program Input a Low level to P30 and a High level to P31.
start pins
554
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
Table 19.1-1 Pins Used for Fujitsu Standard Serial On-board Programming (2/2)
SOT1 Serial data output pin UART is used in clock synchronous mode
This pin is a capacitance pin for stabilizing voltage. Connect the ceramic
C C pin
capacitor approx. 0.1 µF externally
VCC If the program voltage (5 V 10%) is supplied from the user system, the
Supply voltage pin
flash microcontroller programmer need not be connected.
VSS GND pin GND pin is common to the ground of the flash microcontroller programmer.
Note: Even if the P00, SIN1, SOT1, and SCK1 pins are used for the user system, the controller shown in the
figure above is required. The TICS signal of the flash microcontroller programmer can be used to
disconnect the user circuit during serial programming.
See the following serial programming connection examples given in Sections 19.2 "Connection Example
in Single-chip Mode (User Power Supply)" to 19.5 "Example of Minimum Connection to Flash
Microcontroller Programmer (Writer Power Supply)".
• Connection example in single-chip mode (user power supply)
• Connection example in single-chip mode (write power supply)
• Example of minimum connection with flash microcontroller (user power supply)
• Example of minimum connection with flash microcontroller (writer power supply)
AF220/AF210/AF120/AF110 MB90F387(S)
programming control pin programming control pin
10 KΩ
AF220/AF210/AF120/AF110
/TICS pin
User
555
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
Oscillation Maximum serial clock Maximum serial clock Maximum serial clock
Clock frequency that can be frequency that can be frequency that can be
Frequency input for the set with AF220/AF210/ set with AF200
microcomputer AF120/AF110
Model Function
Note: The AF200 flash microcontroller programmer is an end product but is made available using the control
module FF201. Examples of serial programming connections can correspond to those in the next section.
556
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
When 1 is input to the mode pin MD2 of the user system placed in single-chip mode and
0 to the mode pin MD0 from the TAUX and TMODE pins of the AF220/AF210/AF120/
AF110, the system enters the flash memory serial programming mode. An connection
example using the user power supply is given below.
Figure 19.2-1 Example of Serial Programming Connection for MB90F387/S (User Power Supply Used)
AF220/AF210/AF120/AF110 User system
flash microcontroller Connector
programmer DX10-28S MB90F387/S
10 KΩ
TMODE (12) MD0
X0
1MHz to 16MHz
X1
10 KΩ
/TICS (10)
User
10 KΩ
10 KΩ
/TRES (5) RST
User 10 KΩ
P31
C
0.1 µF
TTXD (13) SIN1
TRXD (27) SOT1
TCK (6) SCK1
Pins 3, 4, 9, 11, 16, 17, 18, 20, 24, 25 and 26 are OPEN DX10-28S
557
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
Note: • Even if the SIN1, SOT1, and SCK1 pins are used for the user system, the controller shown in the
figure above is required in the same as P30. The /TICS signal of the flash microcontroller programmer
can be used to disconnect the user circuit during serial programming.
• Connect the AF220/AF210/AF120/AF110 while the user power is off.
AF220/AF210/AF120/AF110 MB90F387/S
programming control pin programming control pin
10 KΩ
AF220/AF210/AF120/AF110
/TICS pin
User
558
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
When 1 is input to the mode pin MD2 of the user system placed in single-chip mode and
0 to the mode pin MD0 from the TAUX and TMODE pins of the AF220/AF210/AF210/
AF120/AF110, the system enters the flash memory serial programming mode. An
connection example using the writer power supply is given below.
10 KΩ
TMODE (12) MD0
X0
1MHz to 16MHz
X1
10 KΩ
/TICS (10)
User
10 KΩ
10 KΩ
/TRES (5) RST
User 10 KΩ
P31
C
0.1 µF
TTXD (13) SIN1
TRXD (27) SOT1
TCK (6) SCK1
TVcc (2)
Vcc (3)
TVPP1 (16) Vcc
(7, 8, User power supply
GND 14, 15, Vss
21, 22,
1, 28) 14 pin 1 pin
Pins 4, 9, 11, 17, 18, 20, 24, 25 and 26 are OPEN DX10-28S
559
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
Note: • Even if the SIN1, SOT1, and SCK1 pins are used for the user system, the controller shown in the
figure above is required in the same as P30 (Figure 19.3-2 ). The /TICS signal of the flash
microcontroller programmer can be used to disconnect the user circuit during serial programming
• Connect the AF220/AF210/AF120/AF110 while the user power is off.
• When supplying programming power from AF220/AF210/AF120/AF110, do not short-circuit the
programming power and user power.
AF220/AF210/AF120/AF110 MB90F387/S
programming control pin programming control pin
10 KΩ
AF220/AF210/AF120/AF110
/TICS pin
User
560
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
When each pin is set as shown below at programming to flash memory, there is no
need for connections between MD2, MD0, P30 and the flash microcontroller
programmer.
MD2
1 for serial programming 10 KΩ 10 KΩ
MD1
10 KΩ 10 KΩ
MD0
0 for serial programming 10 KΩ
X0
1MHz to 16MHz
X1
10 KΩ P30
0 for serial programming 10 KΩ
User circuit
1 for serial programming P31
User circuit
C
Connector 0.1 µF
DX10-28S
10 KΩ
/TRES (5) RST
Pins 3, 4, 9, 10, 11, 12, 16, 17, 18, 19, 20, 23, 24, 25 DX10-28S
and 26 are OPEN
DX10-28S: Right-angle type 28 pin 15 pin
Connector (made by Hirose Electric Co., Ltd.) pin assignment
561
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
Note: • Even if the SIN1, SOT1, and SCK1 pins are used for the user system, the controller shown in the
figure above is required. The /TICS signal of the flash microcontroller programmer can be used to
disconnect the user circuit during serial programming.
• Connect the AF220/AF210/AF120/AF110 while the user power is off.
AF220/AF210/AF120/AF110 MB90F387/S
programming control pin programming control pin
10 KΩ
AF220/AF210/AF120/AF110
/TICS pin
User
562
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
When each pin is set as shown below at programming to flash memory, there is no
need for connections between MD2, MD0, P30 and the flash microcontroller
programmer.
MD2
MD1
10 KΩ 10 KΩ
MD0
0 for serial programming 10 KΩ
X0
1MHz to 16MHz
X1
10 KΩ P00
0 for serial programming 10 KΩ
User circuit
1 for serial programming P01
User circuit
C
Connector 0.1 µF
DX10-28S
10 KΩ
/TRES (5) RST
Pins 4, 9, 10, 11, 12, 17, 18, 19, 20, 23, 24, 25 DX10-28S
and 26 are OPEN
DX10-28S: Right-angle type 28 pin 15 pin
Connector (made by Hirose Electric Co., Ltd.) pin assignment
563
CHAPTER 19 FLASH SERIAL PROGRAMMING CONNECTION
Note: • Even if the SIN1, SOT1, and SCK1 pins are used for the user system, the controller shown in the
figure above is required. The /TICS signal of the flash microcontroller programmer can be used to
disconnect the user circuit during serial programming.
• Connect the AF220/AF210/AF120/AF110 while the user power is off.
• When supplying programming power from AF220/AF210/AF120/AF110, do not short-circuit the
programming power and user power.
AF220/AF210/AF120/AF110 MB90F387/S
programming control pin programming control pin
10 KΩ
AF220/AF210/AF120/AF110
/TICS pin
User
564
APPENDIX
APPENDIX A "Instructions"
APPENDIX B "Register Index"
APPENDIX C "Pin Function Index"
APPENDIX D "Interrupt Vector Index"
565
APPENDIX
APPENDIX A Instructions
566
APPENDIX A Instructions
■ Instruction Types
The F2MC-16LX supports the following 351 types of instructions:
• 41 transfer instructions (byte)
• 38 transfer instructions (word or long word)
• 42 addition/subtraction instructions (byte, word, or long word)
• 12 increment/decrement instructions (byte, word, or long word)
• 11 comparison instructions (byte, word, or long word)
• 11 unsigned multiplication/division instructions (word or long word)
• 11 signed multiplication/division instructions (word or long word)
• 39 logic instructions (byte or word)
• 6 logic instructions (long word)
• 6 sign inversion instructions (byte or word)
• 1 normalization instruction (long word)
• 18 shift instructions (byte, word, or long word)
• 50 branch instructions
• 6 accumulator operation instructions (byte or word)
• 28 other control instructions (byte, word, or long word)
• 21 bit operation instructions
• 10 string instructions
567
APPENDIX
A.2 Addressing
With the F2MC-16LX, the address format is determined by the instruction effective
address field or the instruction code itself (implied). When the address format is
determined by the instruction code itself, specify an address in accordance with the
instruction code used. Some instructions permit the user to select several types of
addressing.
■ Addressing
The F2MC-16LX supports the following 23 types of addressing:
• Immediate (#imm)
• Register direct
• Direct branch address (addr16)
• Physical direct branch address (addr24)
• I/O direct (io)
• Abbreviated direct address (dir)
• Direct address (addr16)
• I/O direct bit address (io:bp)
• Abbreviated direct bit address (dir:bp)
• Direct bit address (addr16:bp)
• Vector address (#vct)
• Register indirect (@RWj j = 0 to 3)
• Register indirect with post increment (@RWj+ j = 0 to 3)
• Register indirect with displacement (@RWi + disp8 i = 0 to 7, @RWj+ disp16 j = 0 to 3)
• Long register indirect with displacement (@RLi + disp8 i = 0 to 3)
• Program counter indirect with displacement (@PC + disp16)
• Register indirect with base index (@RW0 + RW7, @RW1 + RW7)
• Program counter relative branch address (rel)
• Register list (rlst)
• Accumulator indirect (@A)
• Accumulator indirect branch address (@A)
• Indirectly-specified branch address (@ear)
• Indirectly-specified branch address (@eam)
568
APPENDIX A Instructions
00 R0 RW0 RL0
01 R1 RW1 (RL0)
02 R2 RW2 RL1
03 R3 RW3 (RL1) Register direct: Individual parts correspond to
the byte, word, and long word types in order None
04 R4 RW4 RL2 from the left.
05 R5 RW5 (RL2)
06 R6 RW6 RL3
07 R7 RW7 (RL3)
08 @RW0 DTB
09 @RW1 DTB
Register indirect
0A @RW2 ADB
0B @RW3 SPB
0C @RW0+ DTB
0D @RW1+ DTB
Register indirect with post increment
0E @RW2+ ADB
0F @RW3+ SPB
10 @RW0+disp8 DTB
11 @RW1+disp8 DTB
Register indirect with 8-bit displacement
12 @RW2+disp8 ADB
13 @RW3+disp8 SPB
14 @RW4+disp8 DTB
15 @RW5+disp8 DTB
Register indirect with 8-bit displacement
16 @RW6+disp8 ADB
17 @RW7+disp8 SPB
18 @RW0+disp16 DTB
19 @RW1+disp16 DTB
Register indirect with 16-bit displacement
1A @RW2+disp16 ADB
1B @RW3+disp16 SPB
1C @RW0+RW7 DTB
Register indirect with index
1D @RW1+RW7 Register indirect with index DTB
1E @PC+disp16 PC indirect with 16-bit displacement PCB
Direct address
1F addr16 DTB
569
APPENDIX
■ Direct Addressing
General-purpose register Byte R0, R1, R2, R3, R4, R5, R6, R7
Pointer SP *1
Page DPR
*1: One of the user stack pointer (USP) and system stack pointer (SSP) is selected and used depending on
the value of the S flag bit in the condition code register (CCR). For branch instructions, the program
counter (PC) is not specified in an instruction operand but is specified implicitly.
570
APPENDIX A Instructions
MOV R0, A (This instruction transfers the eight low-order bits of A to the general-purpose
register R0.)
Before execution A 0716 2534 Memory space
R0 ??
After execution A 0716 2564
Memory space
R0 34
JMP 3B20H (This instruction causes an unconditional branch by direct branch addressing
in a bank.)
Before execution PC 3 C 2 0 PCB 4 F
Memory space
4F3C22H 3B
4F3C21H 20
4F3C20H 62 JMP 3B20H
571
APPENDIX
JMPP 333B20H (This instruction causes an unconditional branch by direct branch 24-bit
addressing.)
Before execution PC 3 C 2 0 PCB 4 F
Memory space
4F3C23H 33
4F3C22H 3B
4F3C21H 20
4F3C20H 63 JMPP 333B20H
MOVW A, i:0C0H (This instruction reads data by I/O direct addressing and stores it in A.)
0000C1H FF
0000C0H EE
After execution A 2534 FFEE
572
APPENDIX A Instructions
MOVW S;20H, A (This instruction writes the contents of the eight low-order bits of A in abbreviated
direct addressing mode.)
66 DTB 7 7 776620H ??
66 DTB 7 7 776620H 12
4F3C22H FF
4F3C21H FE
4F3C20H 60 BRA 3B20H
573
APPENDIX
SETB I:0C1H: (This instruction sets bits by I/O direct bit addressing.)
Memory space
SETB S:10H:0 (This instruction sets bits by abbreviated direct bit addressing.)
Memory space
Memory space
After execution DTB 5 5 DPR 6 6 556610H 01
Memory space
Before execution DTB 5 5 552222H 00
Memory space
574
APPENDIX A Instructions
PCB F F FFFFE1H D0
FFFFE0H 00
After execution PC D000
Note:
When the program bank register (PCB) is FFH, the vector area overlaps the vector area of INT #vct8
(#0 to #7). Use vector addressing carefully (see Table A.3-2 "CALLV Vector List").
575
APPENDIX
■ Indirect Addressing
MOVW A, @RW1 (This instruction reads data by register indirect addressing and stores it in A.)
RW1 D 3 0 F DTB 7 8
576
APPENDIX A Instructions
Figure A.4-2 Example of Register Indirect Addressing with Post Increment (@RWj + j = 0 to 3)
MOVW A, @RW1+ (This instruction reads data by register indirect addressing with post
increment and stores it in A.)
Before execution A 0716 2534 Memory space
RW1 D 3 1 1 DTB 7 8
MOVW A, @RW1+10H (This instruction reads data by register indirect addressing with an
offset and stores it in A.)
Before execution A 0716 2534 Memory space
(+10H)
After execution A 2534 FFEE
RW1 D 3 0 F DTB 7 8
Figure A.4-4 Example of Long Register Indirect Addressing with Offset (@RLi + disp8 i = 0 to 3)
MOVW A, @RL2+25H (This instruction reads data by long register indirect addressing with an
offset and stores it in A.)
Before execution A 0716 2534 Memory space
577
APPENDIX
Figure A.4-5 Example of Program Counter Indirect Addressing with Offset (@PC + disp16)
MOVW A, @PC+20H (This instruction reads data by program counter indirect addressing with a
offset and stores it in A.)
Before execution A 0716 2534 Memory space
PCB C 5 PC 4 5 5 6 C5457BH FF
C5457AH EE
● Register indirect addressing with base index (@RW0 + RW7, @RW1 + RW7)
Memory is accessed using the address determined by adding RW0 or RW1 to the contents of general-
purpose register RW7. Address bits 16 to 23 are indicated by the data bank register (DTB).
Figure A.4-6 Example of Register Indirect Addressing with Base Index (@RW0 + RW7, @RW1 + RW7)
MOVW A, @RW1+RW7 (This instruction reads data by register indirect addressing with a
base index and stores it in A.)
Before execution A 0716 2534 Memory space
RW1 D 3 0 F DTB 7 8
RW7 0 1 0 1
578
APPENDIX A Instructions
4F3C22H FF
4F3C21H FE
4F3C20H 60 BRA 3B20H
MSB LSB
RW7 RW6 RW5 RW4 RW3 RW2 RW1 RW0
A register is selected when the corresponding bit is 1 and deselected when the bit is 0.
579
APPENDIX
POPW RW0, RW4 (This instruction transfers memory data indicated by the SP to multiple
word registers indicated by the register list.)
SP 34FA SP 34FE
RW0 RW0 02 01
RW1 RW1
RW2 RW2
RW3 RW3
RW4 RW4 04 03
RW5 RW5
RW6 RW6
RW7 RW7
Memory space Memory space
34FEH SP 34FEH
04 34FDH 04 34FDH
03 34FCH 03 34FCH
02 34FBH 02 34FBH
SP 01 34FAH 01 34FAH
MOVW A, @A (This instruction reads data by accumulator indirect addressing and stores it in A.)
DTB B B BB2535H FF
BB2534H EE
DTB B B
580
APPENDIX A Instructions
A 6677 3B20
JMP @@RW0 (This instruction causes an unconditional branch by register indirect addressing.)
581
APPENDIX
JMP @RW0 (This instruction causes an unconditional branch by register indirect addressing.)
PW0 3 B 2 0 4F3C21H 00
4F3C20H 73 JMP @RW0
PW0 3 B 2 0
582
APPENDIX A Instructions
The number of cycles required for instruction execution (execution cycle count) is
obtained by adding the number of cycles required for each instruction, "correction
value" determined by the condition, and the number of cycles for instruction fetch.
583
APPENDIX
(a) (*1)
Register access count in
Code Operand
Execution cycle count in each addressing mode
each addressing mode
Ri
00 to 07 Rwi See the instruction list. See the instruction list.
RLi
08 to 0B @RWj 2 1
0C to 0F @RWj+ 4 2
10 to 17 @RWi+disp8 2 1
18 to 1B @RWi+disp16 2 1
1C @RW0+RW7 4 2
1D @RW1+RW7 4 2
1E @PC+disp16 2 0
1F addr16 1 0
*1: (a) is used for (cycle count) and B (correction value) in A.8 "F2MC-16LX Instruction List".
584
APPENDIX A Instructions
Table A.5-2 Cycle Count Correction Values for Counting Execution Cycles
Internal register +0 1 +0 1 +0 2
Internal memory
+0 1 +0 1 +0 2
Even address
Internal memory
+0 1 +2 2 +4 4
Odd address
*1: (b), (c), and (d) are used for (cycle count) and B (correction value) in A.8 "F2MC-16LX
Instruction List".
Note:
When an external data bus is used, the cycle counts during which an instruction is made to wait by
ready input or automatic ready must also be added.
Table A.5-3 Cycle Count Correction Values for Counting Instruction Fetch Cycles
Internal memory - +2
Notes:
• When an external data bus is used, the cycle counts during which an instruction is made to wait by
ready input or automatic ready must also be added.
• Actually, instruction execution is not delayed by every instruction fetch. Therefore, use the correction
values to calculate the worst case.
585
APPENDIX
Table A.6-1 "Effective Address Field" shows the effective address field.
Byte count of
Code Representation Address format extended address
part (*1)
00 R0 RW0 RL0
01 R1 RW1 (RL0)
02 R2 RW2 RL1
03 R3 RW3 (RL1) Register direct: Individual parts correspond to
the byte, word, and long word types in order -
04 R4 RW4 RL2 from the left.
05 R5 RW5 (RL2)
06 R6 RW6 RL3
07 R7 RW7 (RL3)
08 @RW0
09 @RW1
Register indirect 0
0A @RW2
0B @RW3
0C @RW0+
0D @RW1+
Register indirect with post increment 0
0E @RW2+
0F @RW3+
10 @RW0+disp8
11 @RW1+disp8
12 @RW2+disp8
13 @RW3+disp8
Register indirect with 8-bit displacement 1
14 @RW4+disp8
15 @RW5+disp8
16 @RW6+disp8
17 @RW7+disp8
18 @RW0+disp16
19 @RW1+disp16
Register indirect with 16-bit displacement 2
1A @RW2+disp16
1B @RW3+disp16
1C @RW0+RW7 Register indirect with index 0
1D @RW1+RW7 Register indirect with index 0
1E @PC+disp16 PC indirect with 16-bit displacement 2
1F addr16 Direct address 2
*1: Each byte count of the extended address part applies to + in the # (byte count) column in A.8 "F2MC-16LX
Instruction List".
586
APPENDIX A Instructions
Table A.7-1 "Description of Items in the Instruction List" describes the items used in the
F2MC-16LX Instruction List, and Table A.7-2 "Explanation on Symbols in the Instruction
List" describes the symbols used in the same list.
Item Description
Indicates the correction value used to calculate the actual number of cycles during
instruction execution.
B
The actual number of cycles during instruction execution can be determined by
adding the value in the ~ column to this value.
587
APPENDIX
Item Description
I Each indicates the state of each flag: I (interrupt enable), S (stack), T (sticky bit),
N (negative), Z (zero), V (overflow), C (carry).
S *: Changes upon instruction execution.
T -: No change
Z: Set upon instruction execution.
N X: Reset upon instruction execution.
V
C
Indicates whether the instruction is a Read Modify Write instruction (reading data
from memory by the I instruction and writing the result to memory).
*: Read Modify Write instruction
RMW
-: Not Read Modify Write instruction
Note: Cannot be used for an address that has different meanings between read and
write operations.
Symbol Explanation
The bit length used varies depending on the 32-bit accumulator instruction.
Byte: Low-order 8 bits of byte AL
A
Word: 16 bits of word AL
Long word: 32 bits of AL and AH
AH 16 high-order bits of A
AL 16 low-order bits of A
SP Stack pointer (USP or SSP)
PC Program counter
588
APPENDIX A Instructions
Symbol Explanation
ext (imm8) 16-bit data obtained by sign extension of 8-bit immediate data
bp Bit offset
( )b Bit address
589
APPENDIX
Table A.8-1 "41 Transfer Instructions (byte)" to Table A.9-19 "MOVW ea, Rwi Instruction
(first byte = 7DH)" list the instructions used by the F2MC-16LX.
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
590
APPENDIX A Instructions
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
591
APPENDIX
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
592
APPENDIX A Instructions
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
593
APPENDIX
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
594
APPENDIX A Instructions
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Notes:
• The execution cycle count found when an overflow occurs in a DIV or DIVW instruction may be a pre-
operation count or a post-operation count depending on the detection timing.
• When an overflow occurs with DIV or DIVW instruction, the contents of the AL are destroyed.
• See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
595
APPENDIX
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
596
APPENDIX A Instructions
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
NRML A,R0 2 *1 1 0 long (A) <-- Shifts to the position where '1' is set for - - - - - - * - - -
the first time.
byte (RD) <-- Shift count at that time
*1: 4 when all accumulators have a value of 0; otherwise, 6+(R0)
597
APPENDIX
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
ASR A,R0 2 *1 1 0 byte (A) <-- Arithmetic right shift (A, 1 bit) - - - - - * * - * -
LSR A,R0 2 *1 1 0 byte (A) <-- Logical right barrel shift (A, R0) - - - - - * * - * -
LSL A,R0 2 *1 1 0 byte (A) <-- Logical left barrel shift (A, R0) - - - - - * * - * -
ASRW A 1 2 0 0 word (A) <-- Arithmetic right shift (A, 1 bit) - - - - * * * - * -
LSRW A/SHRW A 1 2 0 0 word (A) <-- Logical right shift (A, 1 bit) - - - - * R * - * -
LSLW A/SHLW A 1 2 0 0 word (A) <-- Logical left shift (A, 1 bit) - - - - - * * - * -
ASRW A,R0 2 *1 1 0 word (A) <-- Arithmetic right barrel shift (A, R0) - - - - * * * - * -
LSRW A,R0 2 *1 1 0 word (A) <-- Logical right barrel shift (A, R0) - - - - * * * - * -
LSLW A,R0 2 *1 1 0 word (A) <-- Logical left barrel shift (A, R0) - - - - - * * - * -
ASRL A,R0 2 *2 1 0 long (A) <-- Arithmetic right barrel shift (A, R0) - - - - * * * - * -
LSRL A,R0 2 *2 1 0 long (A) <-- Logical right barrel shift (A, R0) - - - - * * * - * -
LSLL A,R0 2 *2 1 0 long (A) <-- Logical left barrel shift (A, R0) - - - - - * * - * -
*1: 6 when R0 is 0; otherwise, 5 + (R0)
*2: 6 when R0 is 0; otherwise, 6 + (R0)
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
598
APPENDIX A Instructions
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
599
APPENDIX
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
600
APPENDIX A Instructions
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
601
APPENDIX
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
Note:
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
602
APPENDIX A Instructions
Mnemonic # RG B Operation L A I S T N Z V C R
H H M
W
FILS / FILSI 2 6m+6 *5 *3 byte fill @AH+ <-- AL, counter RW0 - - - - - * * - - -
FILSW / FILSWI 2 6m+6 *5 *6 word fill @AH+ <-- AL, counter = RW0 - - - - - * * - - -
*1: 5 when RW0 is 0, 4 + 7 x (RW0) when the counter expires, or 7n + 5 when a match occurs
*2: 5 when RW0 is 0; otherwise, 4 + 8 x (RW0)
*3: (b) x (RW0) + (b) x (RW0) When the source and destination access different areas, calculate the (b) item individually.
*4: (b) x n
*5: 2 x (RW0)
*6: (c) x (RW0) + (c) x (RW0) When the source and destination access different areas, calculate the (c) item individually.
*7: (c) x n
Note:
m: RW0 value (counter value), n: Loop count
See Table A.5-1 "Execution Cycle Counts in Each Addressing Mode" and Table A.5-2 "Cycle Count
Correction Values for Counting Execution Cycles" for information on (a) to (d) in the table.
603
APPENDIX
An instruction such as the NOP instruction that ends in one byte is completed within the basic page. An
instruction such as the MOVS instruction that requires two bytes recognizes the existence of byte 2 when it
references byte 1, and can check the following one byte by referencing the map for byte 2. Figure A.9-2
"Correspondence between Actual Instruction Code and Instruction Map" shows the correspondence
between an actual instruction code and instruction map.
604
APPENDIX A Instructions
Figure A.9-2 Correspondence between Actual Instruction Code and Instruction Map
Some instructions do
not contain byte 2.
Length varies depending
on the instruction.
+Z
+W
*1 The extended page map is a generic name of maps for bit operation instructions, character string operation instructions, 2-byte
instructions, and ea instructions. Actually, there are multiple extended page maps for each type of instructions.
Byte 1 Byte 2
Instruction
(from basic page map) (from extended page map)
NOP 00 + 0 = 00 -
AND A, #8 30 + 4 = 34 -
MOV A, ADB 60 + F = 6F 00 + 0 = 00
@RW2+d8, #8rel 70 + 0 = 70 F0 + 2 = F2
605
606
APPENDIX
ea instruc-
tion 1
ea instruc-
tion 2
Table A.9-2 Basic Page Map
ea instruc-
tion 3
ea instruc-
tion 4
ea instruc-
tion 5
ea instruc-
tion 6
ea instruc-
tion 7
ea instruc-
tion 8
ea instruc-
tion 9
Ri,ea
Bit operation
instruction
Character
string opera-
tion instruction
2-byte
instruction
APPENDIX A Instructions
607
APPENDIX
Table A.9-4 Character String Operation Instruction Map (first byte = 6EH)
608
APPENDIX A Instructions
A
MULW
DIVU
MUL
609
610
APPENDIX
Use Use
prohibited prohibited
Use Use
prohibited prohibited
Use Use
prohibited prohibited
Use Use
prohibited prohibited
APPENDIX A Instructions
611
APPENDIX
612
APPENDIX A Instructions
613
APPENDIX
614
APPENDIX A Instructions
615
APPENDIX
616
APPENDIX A Instructions
617
APPENDIX
618
APPENDIX A Instructions
619
APPENDIX
620
APPENDIX A Instructions
621
APPENDIX
622
APPENDIX A Instructions
623
APPENDIX
624
APPENDIX A Instructions
625
APPENDIX
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
626
APPENDIX B Register Index
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
00002CH
to (Reserved area) *1
00002FH
627
APPENDIX
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
000056H 00000000B
TCDT Timer counter data register 227
000057H 00000000B
Timer counter control status
000058H TCCS 00000000B 225
register
000059H (Reserved area) *1
00005AH Input capture data XXXXXXXXB
IPCP2 231
00005BH register 2 XXXXXXXXB 16-bit
00005CH XXXXXXXXB I/O timers
Input capture data
IPCP3 231
00005DH register 3 XXXXXXXXB
00005EH
to (Reserved area) *1
000065H
000066H 00000000B 16-bit reload timer 251
TMCSR0
000067H XXXX0000B 0 249
Timer control status register
000068H 00000000B 16-bit reload timer 251
TMCSR1
000069H XXXX0000B 1 249
00006AH
to (Reserved area) *1
00006EH
ROM
ROM mirroring function select
00006FH ROMM XXXXXXX1B mirroring function 522
register
select module
000070H
to (Reserved area) *1
00007FH
628
APPENDIX B Register Index
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
Address match
00009EH PACSR Address detection control register 00000000B 507
detecting function
Delayed interrupt request Delayed interrupt
00009FH DIRR XXXXXXX0B 321
generate/cancel register generation module
Low-power consumption mode Low-power
0000A0H LPMCR 00011000B 129
control register consumption mode
0000A1H CKSCR Clock select register 11111100B Clock 114
0000A2H
to (Reserved area) *1
0000A7H
0000A8H WDTC Watchdog timer control register XXXXX111B Watchdog timer 208
0000A9H TBTC Timebase timer control register 1XX00100B Timebase timer 193
0000AAH WTC Watch timer control register 1X001000B Watch timer 277
0000ABH
to (Reserved area) *1
0000ADH
Flash memory control status 512-Kbit flash
0000AEH FMCS 000X0000B 526
register memory
629
APPENDIX
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
630
APPENDIX B Register Index
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
003904H
to (Reserved area) *1
00390FH
003910H PRLL0 PPG0 reload register L XXXXXXXXB 302
003911H PRLH0 PPG0 reload register H XXXXXXXXB 302
003912H PRLL1 PPG1 reload register L XXXXXXXXB 302
003913H PRLH1 PPG1 reload register H XXXXXXXXB 302
8/16-bit PPG timer
003914H PRLL2 PPG2 reload register L XXXXXXXXB 302
003915H PRLH2 PPG2 reload register H XXXXXXXXB 302
003916H PRLL3 PPG3 reload register L XXXXXXXXB 302
003917H PRLH3 PPG3 reload register H XXXXXXXXB 302
003918H
to (Reserved area) *1
00392FH
003930H
to (Reserved area) *1
003BFFH
003C00H
to RAM (general-purpose RAM)
003C0FH
003C10H XXXXXXXXB
to IDR0 ID register 0 to 476
003C13H XXXXXXXXB
003C14H XXXXXXXXB
to IDR1 ID register 1 to 476
003C17H XXXXXXXXB
003C18H XXXXXXXXB
to IDR2 ID register 2 to CAN controller 476
003C1BH XXXXXXXXB
003C1CH XXXXXXXXB
to IDR3 ID register 3 to 476
003C1FH XXXXXXXXB
003C20H XXXXXXXXB
to IDR4 ID register 4 to 476
003C23H XXXXXXXXB
631
APPENDIX
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
003C24H XXXXXXXXB
to IDR5 ID register 5 to 476
003C27H XXXXXXXXB
003C28H XXXXXXXXB
to IDR6 ID register 6 to 476
003C2BH XXXXXXXXB
003C2CH XXXXXXXXB
to IDR7 ID register 7 to 476
003C2FH XXXXXXXXB
XXXXXXXXB
003C30H
DLCR0 DLC register 0 to 479
003C31H
XXXXXXXXB
XXXXXXXXB
003C32H
DLCR1 DLC register 1 to 479
003C33H
XXXXXXXXB
XXXXXXXXB
003C34H
DLCR2 DLC register 2 to 479
003C35H
XXXXXXXXB
CAN controller
XXXXXXXXB
003C36H
DLCR3 DLC register 3 to 479
003C37H
XXXXXXXXB
XXXXXXXXB
003C38H
DLCR4 DLC register 4 to 479
003C39H
XXXXXXXXB
XXXXXXXXB
003C3AH
DLCR5 DLC register 5 to 479
003C3BH
XXXXXXXXB
XXXXXXXXB
003C3CH
DLCR6 DLC register 6 to 479
003C3DH
XXXXXXXXB
XXXXXXXXB
003C3EH
DLCR7 DLC register 7 to 479
003C3FH
XXXXXXXXB
003C40H XXXXXXXXB
to DTR0 Data register 0 to 480
003C47H XXXXXXXXB
632
APPENDIX B Register Index
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
003C48H XXXXXXXXB
to DTR1 Data register 1 to 480
003C4FH XXXXXXXXB
003C50H XXXXXXXXB
to DTR2 Data register 2 to 480
003C57H XXXXXXXXB
003C58H XXXXXXXXB
to DTR3 Data register 3 to 480
003C5FH XXXXXXXXB
003C60H XXXXXXXXB
to DTR4 Data register 4 to CAN controller 480
003C67H XXXXXXXXB
003C68H XXXXXXXXB
to DTR5 Data register 5 to 480
003C6FH XXXXXXXXB
003C70H XXXXXXXXB
to DTR6 Data register 6 to 480
003C77H XXXXXXXXB
003C78H XXXXXXXXB
to DTR7 Data register 7 to 480
003C7FH XXXXXXXXB
003C80H
to (Reserved area) *1
003CFFH
003D00H 0XXXX001B
CSR Control status register 437/435
003D01H 00XXX000B CAN controller
003D02H LEIR Last event indicate 000XX000B 439
003D03H (Reserved area) *1
003D04H 00000000B
RTEC Receive/transmit error counter 441
003D05H 00000000B
003D06H 11111111B CAN controller
BTR Bit timing register 443
003D07H X1111111B
003D08H IDER IDE register XXXXXXXXB 449
003D09H (Reserved area) *1
003D0AH TRTRR Transmission RTR register 00000000B CAN controller 453
003D0BH (Reserved area) *1
633
APPENDIX
Abbreviation of Page
Address Register Name Reset Value Resource Name
Register Name Number
003D14H XXXXXXXXB
to AMR0 Acceptance mask register 0 to 473
003D17H XXXXXXXXB
CAN controller
003D18H XXXXXXXXB
to AMR1 Acceptance mask register 1 to 473
003D1BH XXXXXXXXB
003D1CH
to (Reserved area) *1
003DFFH
003E00H
to (Reserved area) *1
003EFFH
003FF0H
to (Reserved area) *1
003FFFH
Explanation of reset value
0: The reset value of this bit is 0.
1: The reset value of this bit is 1.
X: The reset value of this bit is unfixed.
*1: Do not write the data to "(Reserved area)". If the data is read from "(Reserved area)", it is undefined values.
634
APPENDIX C Pin Function Index
635
APPENDIX
636
APPENDIX D Interrupt Vector Index
637
APPENDIX
638
CM44-10118-1E