Professional Documents
Culture Documents
Tmp88fw45afg en Datasheet 081024
Tmp88fw45afg en Datasheet 081024
TLCS-870/X Series
TMP88FW45AFG
The information contained herein is subject to change without notice. 021023_D
TOSHIBA is continually working to improve the quality and reliability of its products. Nevertheless,
semiconductor devices in general can malfunction or fail due to their inherent electrical sensitivity
and vulnerability to physical stress.It is the responsibility of the buyer, when utilizing TOSHIBA
products, to comply with the standards of safety in making a safe design for the entire system, and to
avoid situations in which a malfunction or failure of such TOSHIBA products could cause loss of
human life, bodily injury or damage to property.In developing your designs, please ensure that
TOSHIBA products are used within specified operating ranges as set forth in the most recent TOSH-
IBA products specifications.
Also, please keep in mind the precautions and conditions set forth in the “Handling Guide for Sem-
iconductor Devices,” or “TOSHIBA Semiconductor Reliability Handbook” etc. 021023_A
The TOSHIBA products listed in this document are intended for usage in general electronics appli-
cations (computer, personal equipment, office equipment, measuring equipment, industrial robotics,
domestic appliances, etc.).These TOSHIBA products are neither intended nor warranted for usage in
equipment that requires extraordinarily high quality and/or reliability or a malfunction or failure of
which may cause loss of human life or bodily injury (“Unintended Usage”). Unintended Usage include
atomic energy control instruments, airplane or spaceship instruments, transportation instruments,
traffic signal instruments, combustion control instruments, medical instruments, all types of safety
devices, etc. Unintended Usage of TOSHIBA products listed in this document shall be made at the
customer's own risk. 021023_B
The products described in this document shall not be used or embedded to any downstream products
of which manufacture, use and/or sale are prohibited under any applicable laws and regulations.
060106_Q
The information contained herein is presented only as a guide for the applications of our products.
No responsibility is assumed by TOSHIBA for any infringements of patents or other rights of the
third parties which may result from its use. No license is granted by implication or otherwise under
any patents or other rights of TOSHIBA or the third parties. 070122_C
For a discussion of how the reliability of microcontrollers can be predicted, please refer to Section
1.3 of the chapter entitled Quality and Reliability Assurance/Handling Precautions. 030619_S
UART 2 channels
SIO 1 channels
TMP88FW45AFG
1.1 Features......................................................................................................................................1
1.2 Pin Assignment..........................................................................................................................3
1.3 Block Diagram...........................................................................................................................4
1.4 Pin Names and Functions..........................................................................................................5
2. Functional Description
2.1 Functions of the CPU Core........................................................................................................9
2.1.1 Memory Address Map.........................................................................................................................................................9
2.1.2 Program Memory (ROM)..................................................................................................................................................10
2.1.3 Data Memory (RAM)........................................................................................................................................................10
2.1.4 System Clock Control Circuit............................................................................................................................................11
2.1.4.1 Clock Generator
2.1.4.2 Timing Generator
2.1.4.3 Standby Control Circuit
2.1.4.4 Controlling Operation Modes
2.1.5 Reset Circuit......................................................................................................................................................................23
2.1.5.1 External Reset Input
2.1.5.2 Address Trap Reset
2.1.5.3 Watchdog Timer Reset
2.1.5.4 System Clock Reset
2.1.5.5 Oscillation Frequency Detection Reset
i
4. Special Function Register
4.1 SFR..........................................................................................................................................37
4.2 EBR..........................................................................................................................................39
4.3 DBR.........................................................................................................................................40
5. Input/Output Ports
5.1 Port P0 (P03 to P00)................................................................................................................45
5.2 Port P1 (P17 to P10) ...............................................................................................................47
5.3 Port P2 (P22 to P20) ...............................................................................................................48
5.4 Port P3 (P37 to P30) ...............................................................................................................50
5.5 Port P4 (P47 to P40) ...............................................................................................................52
5.6 Port P5 (P57 to P50) ...............................................................................................................54
5.7 Port P6 (P67 to P60) ...............................................................................................................56
5.8 Port P7 (P77 to P70) ...............................................................................................................58
5.9 Port P8 (P87 to P80)................................................................................................................60
5.10 Port P9 (P97 to P90)..............................................................................................................62
ii
9.2 TimerCounter Control.............................................................................................................82
9.3 Function...................................................................................................................................84
9.3.1 Timer mode........................................................................................................................................................................84
9.3.2 External Trigger Timer Mode............................................................................................................................................86
9.3.3 Event Counter Mode..........................................................................................................................................................88
9.3.4 Window Mode...................................................................................................................................................................89
9.3.5 Pulse Width Measurement Mode.......................................................................................................................................90
9.3.6 Programmable Pulse Generate (PPG) Output Mode.........................................................................................................93
iii
14. Motor Control Circuit (PMD: Programmable motor driver)
14.1 Outline of Motor Control.....................................................................................................136
14.2 Configuration of the Motor Control Circuit........................................................................138
14.3 Position Detection Unit........................................................................................................139
14.3.1 Configuration of the position detection unit..................................................................................................................140
14.3.2 Position Detection Circuit Register Functions...............................................................................................................141
14.3.3 Outline Processing in the Position Detection Unit........................................................................................................145
14.4 Timer Unit...........................................................................................................................146
14.4.1 Configuration of the Timer Unit....................................................................................................................................147
14.4.1.1 Timer Circuit Register Functions
14.4.1.2 Outline Processing in the Timer Unit
14.5 Three-phase PWM Output Unit...........................................................................................152
14.5.1 Configuration of the three-phase PWM output unit......................................................................................................152
14.5.1.1 Pulse width modulation circuit (PWM waveform generating unit)
14.5.1.2 Commutation control circuit
14.5.2 Register Functions of the Waveform Synthesis Circuit.................................................................................................156
14.5.3 Port output as set with UOC/VOC/WOC bits and UPWM/VPWM/WPWM bits........................................................159
14.5.4 Protective Circuit...........................................................................................................................................................161
14.5.5 Functions of Protective Circuit Registers......................................................................................................................163
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit.................................................165
14.6.1 Electrical Angle Timer and Waveform Arithmetic Circuit...........................................................................................166
14.6.1.1 Functions of the Electrical Angle Timer and Waveform Arithmetic Circuit Registers
14.6.1.2 List of PMD Related Control Registers
iv
16.7 Parity....................................................................................................................................194
16.8 Transmit/Receive Operation................................................................................................194
16.8.1 Data Transmit Operation...............................................................................................................................................194
16.8.2 Data Receive Operation.................................................................................................................................................194
16.9 Status Flag...........................................................................................................................195
16.9.1 Parity Error....................................................................................................................................................................195
16.9.2 Framing Error................................................................................................................................................................195
16.9.3 Overrun Error.................................................................................................................................................................195
16.9.4 Receive Data Buffer Full...............................................................................................................................................196
16.9.5 Transmit Data Buffer Empty.........................................................................................................................................196
16.9.6 Transmit End Flag.........................................................................................................................................................197
v
20. Flash Memory
20.1 Flash Memory Control.........................................................................................................228
20.1.1 Flash Memory Command Sequence Execution Control (FLSCR<FLSMD>)..............................................................228
20.2 Command Sequence............................................................................................................229
20.2.1 Byte Program.................................................................................................................................................................229
20.2.2 Sector Erase (4-kbyte Erase)..........................................................................................................................................229
20.2.3 Chip Erase (All Erase)...................................................................................................................................................230
20.2.4 Product ID Entry............................................................................................................................................................230
20.2.5 Product ID Exit..............................................................................................................................................................230
20.2.6 Security Program...........................................................................................................................................................230
20.3 Toggle Bit (D6)....................................................................................................................231
20.4 Access to the Flash Memory Area.......................................................................................231
20.4.1 Flash Memory Control in the Serial PROM Mode........................................................................................................231
20.4.1.1 How to write to the flash memory by executing the control program in the RAM area (in the RAM loader mode within the serial
PROM mode)
20.4.2 Flash Memory Control in the MCU mode.....................................................................................................................233
20.4.2.1 How to write to the flash memory by executing a user write control program in the RAM area (in the MCU mode)
vi
22. Input/Output Circuitry
22.1 Control pins.........................................................................................................................267
22.2 Input/output ports.................................................................................................................267
vii
viii
TMP88FW45AFG
TMP88FW45AFG
ROM
Product No. RAM Package
(FLASH)
122880 4224
TMP88FW45AFG QFP80-P-1420-0.80B
bytes bytes
1.1 Features
1. 8-bit single chip microcomputer TLCS-870/X series
- Instruction execution time :
0.20 μs (at 20 MHz)
- 181 types & 842 basic instructions
2. 36 interrupt sources (External : 5 Internal : 31)
3. Input / Output ports (71 pins)
Large current output: 24pins (Typ. 20mA), LED direct drive
4. Prescaler
- Time base timer
Divider output function (DVO)
5. Watchdog Timer
Select of "internal reset request" or "interrupt request".
6. Oscillation Frequency Detector : 1ch
7. 16-bit timer counter: 1 ch
- Timer, External trigger, Window, Pulse width measurement,
Event counter, Programmable pulse generate (PPG) modes
8. 16-bit timer/counter(CTC): 1ch
- CTC:Timer,event counter or PPG (Programmable Pulse) output
9. 8-bit timer counter : 1 ch
This product uses the Super Flash® technology under the licence of Silicon Storage Technology, Inc. Super Flash® is registered trademark of Silicon
Storage Technology, Inc.
・The information contained herein is subject to change without notice. 021023_D
・TOSHIBA is continually working to improve the quality and reliability of its products. Nevertheless, semiconductor devices in general
can malfunction or fail due to their inherent electrical sensitivity and vulnerability to physical stress. It is the responsibility of the buyer,
when utilizing TOSHIBA products, to comply with the standards of safety in making a safe design for the entire system, and to avoid
situations in which a malfunction or failure of such TOSHIBA products could cause loss of human life, bodily injury or damage to prop-
erty.In developing your designs, please ensure that TOSHIBA products are used within specified operating ranges as set forth in the
most recent TOSHIBA products specifications. Also, please keep in mind the precautions and conditions set forth in the “Handling Guide
for Semiconductor Devices,” or “TOSHIBA Semiconductor Reliability Handbook” etc. 021023_A
・The TOSHIBA products listed in this document are intended for usage in general electronics applications (computer, personal equipment,
office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). These TOSHIBA products are neither intended
nor warranted for usage in equipment that requires extraordinarily high quality and/or reliability or a malfunction or failure of which may
cause loss of human life or bodily injury (“Unintended Usage”). Unintended Usage include atomic energy control instruments, airplane
or spaceship instruments, transportation instruments, traffic signal instruments, combustion control instruments, medical instruments,
all types of safety devices, etc. Unintended Usage of TOSHIBA products listed in this document shall be made at the customer's own
risk. 021023_B
・The products described in this document shall not be used or embedded to any downstream products of which manufacture, use and/
or sale are prohibited under any applicable laws and regulations. 060106_Q
・The information contained herein is presented only as a guide for the applications of our products. No responsibility is assumed by
TOSHIBA for any infringements of patents or other rights of the third parties which may result from its use. No license is granted by
implication or otherwise under any patents or other rights of TOSHIBA or the third parties. 070122_C
・For a discussion of how the reliability of microcontrollers can be predicted, please refer to Section 1.3 of the chapter entitled Quality and
Reliability Assurance/Handling Precautions. 030619_S
Page 1
1.1 Features TMP88FW45AFG
Page 2
TMP88FW45AFG
P01 (TXD2/PDO6/PWM6/PPG6)
P77 (AIN15/DBOUT2)
P00 (RXD2/TC6)
P03 (HPWM1)
P02 (HPWM0)
P80 (RXD3)
P81 (TXD3)
VAREF
AVDD
AVSS
P97
P96
P95
P94
P93
P92
P91
P90
P87
P86
P85
P84
P83
P82
(INT0) P10 P76 (AIN14)
(INT1) P11 P75 (AIN13)
(TC1/INT2) P12 P74 (AIN12)
(TC5/DVO) P13 P73 (AIN11)
(PWM5/PDO5/PPG1) P14 P72 (AIN10)
(PDU2) P15 P71 (AIN9)
(PDV2) P16 P70 (AIN8)
(PDW2) P17 P67 (AIN7/DBOUT1)
(CL2) P50 P66 (AIN6)
(EMG2) P51 P65 (AIN5)
(U2) P52 P64 (AIN4)
(V2) P53 P63 (AIN3)
(W2) P54 P62 (AIN2)
(X2) P55 P61 (AIN1)
(Y2) P56 P60 (AIN0)
(Z2) P57 P47 (CTC)
VSS
XOUT
TEST
VDD
(TC3) P21
(PWM4/PDO4/TC4/INT4) P22
RESET
(STOP/INT5) P20
(Z1) P30
(Y1) P31
(X1) P32
(W1) P33
(V1) P34
(U1) P35
(EMG1) P36
(CL1) P37
(PDW1) P40
(PDV1) P41
(PDU1) P42
(SCK) P43
(BOOT/SI/RXD1) P44
(SO/TXD1) P45
(PPG2) P46
XIN
Page 3
1.3 Block Diagram TMP88FW45AFG
Page 4
TMP88FW45AFG
P03 IO PORT03
64
HPWM1 O High-spped PWM1 output
P02 IO PORT02
63
HPWM0 O High-spped PWM0 output
P01 IO PORT01
TXD2 62 O UART data output 2
PDO6/PWM6/PPG6 O PDO6/PWM6/PPG6 output
P00 IO PORT00
RXD2 61 I UART data input 2
TC6 I TC6 input
P17 IO PORT17
72
PDW2 I PMD control input W2
P16 IO PORT16
71
PDV2 I PMD control input V2
P15 IO PORT15
70
PDU2 I PMD control input U2
P14 IO PORT14
PPG1 69 O PPG1 output
PWM5/PDO5 O PWM5/PDO5 output
P13 IO PORT13
DVO 68 O Divider Output
TC5 I TC5 input
P12 IO PORT12
INT2 67 I External interrupt 2 input
TC1 I TC1 input
P11 IO PORT11
66
INT1 I External interrupt 1 input
P10 IO PORT10
65
INT0 I External interrupt 0 input
P22 IO PORT22
INT4 I External interrupt 4 input
7
TC4 I TC4 input
PWM4/PDO4 O PWM4/PDO4 output
P21 IO PORT21
6
TC3 I TC3 pin input
P20 IO PORT20
INT5 9 I External interrupt 5 input
STOP I STOP mode release signal input
P37 IO PORT37
17
CL1 I PMD over load protection input1
Page 5
1.4 Pin Names and Functions TMP88FW45AFG
P36 IO PORT36
16
EMG1 I PMD emergency stop input1
P35 IO PORT35
15
U1 O PMD control output U1
P34 IO PORT34
14
V1 O PMD control output V1
P33 IO PORT33
13
W1 O PMD control output W1
P32 IO PORT32
12
X1 O PMD control output X1
P31 IO PORT31
11
Y1 O PMD control output Y1
P30 IO PORT30
10
Z1 O PMD control output Z1
P47 I PORT47
25
CTC I CTC input
P46 IO PORT46
24
PPG2 O PPG2 出力
P45 IO PORT45
TXD1 23 O UART data output 1
SO O Serial Data Output
P44 IO PORT44
RXD1 I UART data input 1
22
SI I Serial Data Input
BOOT I Serial PROM mode control input
P43 IO PORT43
21
SCK IO Serial Clock I/O
P42 IO PORT42
20
PDU1 I PMD control input U1
P41 IO PORT41
19
PDV1 I PMD control input V1
P40 IO PORT40
18
PDW1 I PMD control input W1
P57 IO PORT57
80
Z2 O PMD control output Z2
P56 IO PORT56
79
Y2 O PMD control output Y2
P55 IO PORT55
78
X2 O PMD control output X2
P54 IO PORT54
77
W2 O PMD control output W2
Page 6
TMP88FW45AFG
P53 IO PORT53
76
V2 O PMD control output V2
P52 IO PORT52
75
U2 O PMD control output U2
P51 IO PORT51
74
EMG2 I PMD emergency stop input2
P50 IO PORT50
73
CL2 I PMD over load protection input2
P67 IO PORT67
AIN7 33 I Analog Input7
DBOUT1 O PMD debug output1
P66 IO PORT66
32
AIN6 I Analog Input6
P65 IO PORT65
31
AIN5 I Analog Input5
P64 IO PORT64
30
AIN4 I Analog Input4
P63 IO PORT63
29
AIN3 I Analog Input3
P62 IO PORT62
28
AIN2 I Analog Input2
P61 IO PORT61
27
AIN1 I Analog Input1
P60 IO PORT60
26
AIN0 I Analog Input0
P77 IO PORT77
AIN15 41 I Analog Input15
DBOUT2 O PMD debug output2
P76 IO PORT76
40
AIN14 I Analog Input14
P75 IO PORT75
39
AIN13 I Analog Input13
P74 IO PORT74
38
AIN12 I Analog Input12
P73 IO PORT73
37
AIN11 I Analog Input11
P72 IO PORT72
36
AIN10 I Analog Input10
P71 IO PORT71
35
AIN9 I Analog Input9
P70 IO PORT70
34
AIN8 I Analog Input8
Page 7
1.4 Pin Names and Functions TMP88FW45AFG
P87 52 IO PORT87
P86 51 IO PORT86
P85 50 IO PORT85
P84 49 IO PORT84
P83 48 IO PORT83
P82 47 IO PORT82
P81 IO PORT81
46
TXD3 I UART data output 3
P80 IO PORT80
45
RXD3 I UART data input 3
P97 60 IO PORT97
P96 59 IO PORT96
P95 58 IO PORT95
P94 57 IO PORT94
P93 56 IO PORT93
P92 55 IO PORT92
P91 54 IO PORT91
P90 53 IO PORT90
Test pin for out-going test and the Serial PROM mode control
TEST 4 I pin. Usually fix to low level. Fix to high level when the Serial
PROM mode starts.
VDD 5 I +5V
VSS 1 I 0(GND)
Page 8
TMP88FW45AFG
2. Functional Description
This chapter describes the CPU core, program memory, data memory, and reset circuit of the TMP88FW45AFG.
ROM
( 120Kbytes)
21EFFH
FFF00H 64 bytes
FFF3FH Interrupt Vector Table
FFF40H 64 bytes Vector Table for
FFF7FH Vector Call Instructions
FFF80H
128 bytes Interrupt Vector Table
FFFFFH
ROM: Read-Only Memory SFR: Special Function Registers DBR: Data Buffer Registers
Program memory Input/output port Input/output port
Vector Table Peripheral hardware control register Peripheral hardware control register
RAM: Random Access Memory Peripheral hardware status register Peripheral hardware status register
Data memory System control register EBR: Extra Data Buffer Registers
Stack Interrupt control register Input/output port
General-purpose register bank Program status word Peripheral hardware control register
Peripheral hardware status register
Page 9
2. Functional Description
2.1 Functions of the CPU Core TMP88FW45AFG
The content of the data memory is indeterminate at power-on, so be sure to initialize it in the initialize rou-
tine.
Example :Clearing the internal RAM of the TMP88FW45AFG (clear all RAM addresses to 0, except bank 0)
SRAMCLR: LD (HL+), A
DEC BC
JRS F, SRAMCLR
Note:Because general-purpose registers exist in the RAM, never clear the current bank address of RAM. In
the above example, the RAM is cleared except bank 0.
Page 10
TMP88FW45AFG
The Clock Generator generates the fundamental clock which serves as the reference for the system clocks
supplied to the CPU core and peripheral hardware units.
The high-frequency clock (frequency fc) can be obtained easily by connecting a resonator to the XIN and
XOUT pins. Or a clock generated by an external oscillator can also be used. In this case, enter the external
clock from the XIN pin and leave the XOUT pin open. The TMP88FW45AFG does not support the CR
network that produces a time constant.
High-frequency Clock
XIN XOUT XIN XOUT
(Open)
Note:Although no hardware functions are provided that allow the fundamental clock to be monitored directly
from the outside, the oscillation frequency can be adjusted by forwarding the pulse of a fixed frequency
(e.g., clock output) to a port and monitoring it in a program while interrupts and the watchdog timer are
disabled. For systems that require adjusting the oscillation frequency, an adjustment program must be
created beforehand.
The Timing Generator generates various system clocks from the fundamental clock that are supplied to the
CPU core and peripheral hardware units. The Timing Generator has the following functions:
Page 11
2. Functional Description
2.1 Functions of the CPU Core TMP88FW45AFG
The Timing Generator a 3-stage prescaler, 21-stage dividers, and a machine cycle counter.
When reset and when entering/exiting STOP mode, the prescaler and dividers are cleared to 0.
DV1CK
Watchdog
timer
Timer
counter
Time base
timer
Divider
Output
etc.
Page 12
TMP88FW45AFG
CGCR 7 6 5 4 3 2 1 0
(0030H) 0 0 DV1CK 0 0 0 (Initial value: 000* *000)
TBTCR 7 6 5 4 3 2 1 0
(0036H) DVOEN DVOCK 0 TBTEN TBTCK (Initial value: 0000 0000)
Instruction execution and the internal hardware operations are synchronized to the system clocks.
The minimum unit of instruction execution is referred to as the “machine cycle”. The TLCS-870/X
series has 15 types of instructions, from 1-cycle instructions which are executed in one machine cycle
up to 15-cycle instructions that require a maximum of 15 machine cycles.
A machine cycle consists of four states (S0 to S3), with each state comprised of one main system
clock cycle.
1/fc
States S0 S1 S2 S3 S0 S1 S2 S3
Machine cycle
(0.20 µs at 20 MHz)
Page 13
2. Functional Description
2.1 Functions of the CPU Core TMP88FW45AFG
The Standby Control Circuit starts/stops the high-frequency clock oscillator circuit and selects the main
system clock. The System Control Registers (SYSCR1, SYSCR2) are used to control operation modes of this
circuit. Figure 2-6 shows an operation mode transition diagram, followed by description of the System Control
Registers.
Only the high-frequency clock oscillator circuit is used. Because the main system clock is generated
from the high-frequency clock, the machine cycle time in single clock mode is 4/fc [s].
1. NORMAL mode
In this mode, the CPU core and peripheral hardware units are operated with the high-fre-
quency clock. The TMP88FW45AFG enters this NORMAL mode after reset.
2. IDLE mode
In this mode, the CPU and watchdog timer are turned off while the peripheral hardware units
are operated with the high-frequency clock. IDLE mode is entered into by using System Control
Register 2. The device is placed out of this mode and back into NORMAL mode by an interrupt
from the peripheral hardware or an external interrupt. When IMF (interrupt master enable flag)
= 1 (interrupt enabled), the device returns to normal operation after the interrupt has been
serviced. When IMF = 0 (interrupt disabled), the device restarts execution beginning with the
instruction next to one that placed it in IDLE mode.
3. STOP mode
The entire system operation including the oscillator circuit is halted, retaining the internal
state immediately before being stopped, with a minimal amount of power consumed.
STOP mode is entered into by using System Control Register 1, and is exited by STOP pin
input (level or edge selectable). After an elapse of the warm-up time, the device restarts exe-
cution beginning with the instruction next to one that placed it in STOP mode.
Oscillator Circuit
Peripheral Machine Cycle
Operation Mode High Low CPU Core
Circuit Time
Frequency Frequency
RESET
Reset deasserted
Instruction Instruction
IDLE NORMAL STOP
mode mode mode
Interrupt Input for releasing mode
Page 14
TMP88FW45AFG
SYSCR1 7 6 5 4 3 2 1 0
(0038H) STOP RELM RETM OUTEN WUT (Initial value: 0000 00**)
DV1CK = 0 DV1CK = 1
10 214/fc 215/fc
11 Reserved Reserved
Note 1: When entering from NORMAL mode into STOP mode, always be sure to set SYSCR1<RETM> to 0.
Note 2: When the device is released from STOP mode by RESET pin input, it always returns to NORMAL mode regardless of
how SYSCR1<RETM> is set.
Note 3: fc: High-frequency clock [Hz], *: Don’t care
Note 4: The values of the SYSCR1 Register bits 1 and 0 are indeterminate when read.
Note 5: When placed the device in STOP mode, make sure to set "1" to SYSCR1<OUTEN>.
Note 6: Releasing the device from the STOP mode causes the STOP bit to be automatically cleared to “0”.
Note 7: Select an appropriate value for the warm-up time according to the characteristic of the resonator used.
SYSCR2 7 6 5 4 3 2 1 0
(0039H) XEN 0 SYSCK IDLE (Initial value: 1000 ****)
0 NORMAL mode 1 0
1 No operation 0 1
Note 1: When exiting STOP mode, SYSCR2<XEN and SYSCK> are automatically rewritten according to SYSCR1<RETM>.
Note 2: When SYSCR2<XEN>is cleared to 0, the device is reset.
Note 3: WDT: Watchdog Timer, *: Don’t care
Note 4: Be sure to write "0" to SYSCR2 Register bit6.
Note 5: The values of the SYSCR2 Register bits 3 to 0 are indeterminate when read.
Note 6: Change the operation mode after disabling external interrupts. If interrupts are enabled after changing operation mode,
clear interrupt latches as appropriate in advance.
Page 15
2. Functional Description
2.1 Functions of the CPU Core TMP88FW45AFG
STOP mode is controlled by System Control Register 1 (SYSCR1) and the STOP pin input. The
STOP pin is shared with P20 port and INT5 (external interrupt input 5). STOP mode is entered into by
setting STOP (SYSCR1 Register bit 7) to 1. During STOP mode, the device retains the following state.
The device is released from STOP mode by the active level or edge on STOP pin input as selected
by SYSCR1<RELM>.
Note:Before entering STOP mode, be sure to disable interrupts. This is because if the signal on an
external interrupt pin changes state during STOP (from entering STOP mode till completion of
warm-up) the interrupt latch is set to 1, so that the device may accept the interrupt immediately
after exiting STOP mode. Also, when enabling interrupts after exiting STOP mode, be sure to
clear the unnecessary interrupt latches beforehand.
Example 1 :Entering STOP mode from NORMAL mode by testing P20 port
SSTOPH : TEST (P2DR) . 0 ; Wait until STOP pin input goes low
JRS F, SSTOPH
DI ; IMF ← 0
DI ; IMF ← 0
SINT5 : RETI
Page 16
TMP88FW45AFG
XOUT pin
Note 1: Once warm-up starts, the device does not return to STOP mode even when the STOP pin input is pulled
low again.
Note 2: If RELM is changed to 1 (level mode) after being set to 0 (edge mode), STOP mode remains unchanged
unless a rising edge on STOP pin input is detected.
DI ; IMF ← 0
XOUT pin
NORMAL
NORMAL operation STOP mode Warm-up operation STOP mode
Page 17
2. Functional Description
2.1 Functions of the CPU Core TMP88FW45AFG
The device is released from STOP mode following the sequence described below.
DV1CK = 0 DV1CK = 1
00 9.831 19.662
01 3.277 6.554
10 0.819 1.638
11 Reserved Reserved
Note:Because the warm-up time is obtained from the fundamental clock by dividing it, if the oscillation
frequency fluctuates while exiting STOP mode, the warm-up time becomes to have some error.
Therefore, the warm-up time must be handled as an approximate value.
The device can also be released from STOP mode by pulling the RESET pin input low, in which case
the device is immediately reset as is normally reset by RESET. After reset, the device starts operating
from NORMAL mode.
Note:When exiting STOP mode while the device is retained at low voltage, the following caution is
required.
Before exiting STOP mode, the power supply voltage must be raised to the operating voltage.
At this time, the RESET pin level also is high and rises along with the power supply voltage. If
the device has a time-constant circuit added external to the chip, the voltage on RESET pin input
does not rise as fast as the power supply voltage. Therefore, if the voltage level on RESET pin
input is below the RESET pin’s noninverted, high-level input voltage (hysteresis input), the device
may be reset.
Page 18
Oscillator
circuit Oscillation Stop
Main
system clock
Program
counter a+2 a+3
Instruction Stop
SET (SYSCR1). 7
execution
(a) Entering STOP mode (Example: Entered into by the SET (SYSCR1). 7 instruction placed at address a)
Warm-up
STOP pin
Page 19
input
Oscillator
circuit Stop Oscillation
Main
system clock
Instruction Stop
execution Instruction at address a + 2 Instruction at address a + 3 Instruction at address a + 4
Divider 0 Count up 0 1 2 3
IDLE mode is controlled by System Control Register 2 (SYSCR2) and a maskable interrupt. During
IDLE mode, the device retains the following state.
SET (SYSCR2) . 4
Yes
Reset input ? Reset
No
No
Interrupt request ?
Yes
No
IMF = 1
Page 20
TMP88FW45AFG
The device can be released from IDLE mode normally or by an interrupt as selected with the interrupt
master enable flag (IMF).
The device can also be released from IDLE mode by pulling the RESET pin input low, in which case
the device is immediately reset as is normally reset by RESET. After reset, the device starts operating
from NORMAL mode.
Note:If a watchdog timer interrupt occurs immediately before entering IDLE mode, the device pro-
cesses the watchdog timer interrupt without entering IDLE mode.
Page 21
2.
2.1
Main
system clock
Functional Description
Interrupt
request
Functions of the CPU Core
Program
counter a+2 a+3
Instruction IDLE
execution SET (SYSCR2). 4
Watchdog Operating
timer
(a) Entering IDLE mode (Example: Entered into by the SET instruction placed at address a)
Main
system clock
Interrupt
request
Program
counter a+3 a+4
IDLE
Page 22
Instruction
execution Instruction at address a + 2
Watchdog IDLE
Operating
timer
1. Released normally
Main
system clock
Interrupt
request
Instruction IDLE
execution Interrupt accepted
Watchdog IDLE
timer Operating
2. Released by interrupt
(b) Exiting IDLE mode
TMP88FW45AFG
TMP88FW45AFG
Table 2-3 shows how the internal hardware is initialized by reset operation.
At power-on time, the internal cause reset circuits (watchdog timer reset, address trap reset, and system clock
reset) are not initialized.
Stack Pointer (SP) Not initialized Prescaler and divider for the
0
General-purpose Registers timing generator
Not initialized
(W, A, B, C, D, E, H, L)
The RESET pin is a hysteresis input with a pull-up resistor included. By holding the RESET pin low for
at least three machine cycles (12/fc [s]) or more while the power supply voltage is within the rated operating
voltage range and the oscillator is oscillating stably, the device is reset and its internal state is initialized.
When the RESET pin input is released back high, the device is freed from reset and starts executing the
program beginning with the vector address stored at addresses FFFFCH to FFFFEH.
VDD
If the CPU should start looping for reasons of noise, etc. and attempts to fetch instructions from the internal
RAM,SFR or DBR/EBR area, the device generates an internal reset.
The address trap permission/prohibition is set by the address trap reset control register (ATAS,ATKEY).
The address trap is permitted initially and the internal reset is generated by fetching from internal RAM,SFR
or DBR/EBR area. If the address trap is prohibited, instructions in the internal RAM area can be executed.
Page 23
2. Functional Description
2.1 Functions of the CPU Core TMP88FW45AFG
ATAS 7 6 5 4 3 2 1 0
(1F94H) - - - - - - - ATAS (initial value: **** ***0)
ATKEY 7 6 5 4 3 2 1 0
(1F95H) (initial value: **** ****)
Note:Read-modify-write instructions, such as a bit manipulation, cannot access ATAS or ATKEY register because
these register are write only.
Note 1: In development tools, address trap cannot be prohibited in the internal RAM,SFR or DBR/EBR area with
the address trap control registers. When using development tools, even if the address trap permission/
prohibition setting is changed in the user’s program, this change is ineffective. To execute instructions
from the RAM area, development tools must be set accordingly.
Note 2: While the SWI instruction at an address immediately before the address trap area is executing, the
program counter is incremented to point to the next address in the address trap area; an address trap is
therefore taken immediately.
The oscillation frequency detector generates a reset for I/O if the oscillation of high frequency is lower than
a lower detection frequency, or higher than an upper detection frequency. Refer to Section "Oscillation Fre-
quency Detector".
Page 24
TMP88FW45AFG
The TMP88FW45AFG has a total of 36 interrupt sources excluding reset. Interrupts can be nested with priorities.
Two of the internal interrupt sources are pseudo non-maskable while the rest are maskable.
Interrupt sources are provided with interrupt latches (IL), which hold interrupt requests, and independent vectors.
The interrupt latch is set to “1” by the generation of its interrupt request which requests the CPU to accept its interrupts.
Interrupts are enabled or disabled by software using the interrupt master enable flag (IMF) and interrupt enable flag
(EF). If more than one interrupts are generated simultaneously, interrupts are accepted in order which is dominated
by hardware. However, there are no prioritized interrupt factors among non-maskable interrupts.
Internal INTRXD2 (ch2 UART receive interrupt) IMF・ EF30 = 1 IL30 FFF84 30
External INT4 (External interrupt 4) IMF・ EF31 = 1 IL31 FFF80 31
Internal INTRXD (ch1 UART receive interrupt) IMF・ EF32 = 1 IL32 FFF3C 32
Internal INTTXD (ch1 UART transmit interrupt) IMF・ EF33 = 1 IL33 FFF38 33
Internal INTSIO (SIO interrupt) IMF・ EF34 = 1 IL34 FFF34 34
Internal INTTC3 (TC3 interrupt) IMF・ EF35= 1 IL35 FFF30 35
Internal INTTC4 (TC4 interrupt) IMF・ EF36 = 1 IL36 FFF2C 36
Internal INTTC5 (TC5 interrupt) IMF・ EF37 = 1 IL37 FFF28 37
Internal INTADC (A/D converter interrupt) IMF・ EF38 = 1 IL38 FFF24 38
Internal INTTXD2 (ch2 UART transmit interrupt) IMF・ EF39 = 1 IL39 FFF20 Low 39
Page 25
3. Interrupt Control Circuit
3.1 Interrupt latches (IL39 to IL2) TMP88FW45AFG
Note 1: To use the watchdog timer interrupt (INTWDT), clear WDTCR1<WDTOUT> to "0" (It is set for the "Reset request" after
reset is released). It is described in the section "Watchdog Timer" for details.
The interrupt latches are located on address 003CH, 003DH, 002EH, 002FH and 002BH in SFR area. Each latch
can be cleared to "0" individually by instruction. However, IL2 and IL3 should not be cleared to "0" by software. For
clearing the interrupt latch, load instruction should be used and then IL2 should be set to "1". If the read-modify-write
instructions such as bit manipulation or operation instructions are used, interrupt request would be cleared inadequately
if interrupt is requested while such instructions are executed.
Since interrupt latches can be read, the status for interrupt requests can be monitored by software. But interrupt
latches are not set to “1” by an instruction.
Note:In main program, before manipulating the interrupt enable flag (EF) or the interrupt latch (IL), be sure to clear
IMF to "0" (Disable interrupt by DI instruction). Then set IMF newly again as required after operating on the EF
or IL (Enable interrupt by EI instruction)
In interrupt service routine, because the IMF becomes "0" automatically, clearing IMF need not execute normally
on interrupt service routine. However, if using multiple interrupt on interrupt service routine, manipulating EF or
IL should be executed before setting IMF="1".
DI ; IMF ← 0
EI ; IMF ← 1
LD D, (ILC) ; D ← (ILC)
JR F, SSET
Page 26
TMP88FW45AFG
The EIR consists of an interrupt master enable flag (IMF) and the individual interrupt enable flags (EF). These
registers are located on address 003AH, 003BH, 002CH, 002DH and 002AH in SFR area, and they can be read and
written by an instructions (Including read-modify-write instructions such as bit manipulation or operation instructions).
When an interrupt is accepted, IMF is cleared to “0” after the latest status on IMF is stacked. Thus the maskable
interrupts which follow are disabled temporarily. IMF flag is set to "1" by the maskable interrupt return instruction
[RETI] after executing the interrupt service program routine, and MCU can accept the interrupt again. The latest
interrupt request is generated already, it is available immediately after the [RETI] instruction is executed.
On the pseudo non-maskable interrupt, the non-maskable return instruction [RETN] is adopted. In this case,
IMF flag is set to "1" only when it performs the pseudo non-maskable interrupt service routine on the interrupt
acceptable status (IMF=1). However, IMF is set to "0" in the pseudo non-maskable interrupt service routine, it
maintains its status (IMF="0").
The IMF is located on bit0 in EIRL (Address: 003AH in SFR), and can be read and written by an instruction.
The IMF is normally set and cleared by [EI] and [DI] instruction respectively. During reset, the IMF is initialized
to “0”.
Note:In main program, before manipulating the interrupt enable flag (EF) or the interrupt latch (IL), be sure to
clear IMF to "0" (Disable interrupt by DI instruction). Then set IMF newly again as required after operating
on the EF or IL (Enable interrupt by EI instruction)
In interrupt service routine, because the IMF becomes "0" automatically, clearing IMF need not execute
normally on interrupt service routine. However, if using multiple interrupt on interrupt service routine,
manipulating EF or IL should be executed before setting IMF="1".
DI ; IMF ← 0
EI ; IMF ← 1
Page 27
3. Interrupt Control Circuit
3.2 Interrupt enable register (EIR) TMP88FW45AFG
Interrupt Latches
ILH,ILL 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
(003DH, 003CH) IL15 - IL13 IL12 IL11 IL10 IL9 IL8 - IL6 IL5 - IL3 IL2 INF
ILD,ILE 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
(002FH, 002EH) IL31 IL30 IL29 IL28 IL27 IL26 IL25 IL24 IL23 IL22 IL21 IL20 IL19 IL18 IL17 IL16
ILC 7 6 5 4 3 2 1 0
(002BH) IL39 IL38 IL37 IL36 IL35 IL34 IL33 IL32
ILE (002BH)
Read Write
IL39 to IL2 Interrupt latches 0: No interrupt request 0: Clears the interrupt request (Note1)
1: Interrupt request 1: (Unable to set interrupt latch)
Page 28
TMP88FW45AFG
EIRH,EIRL 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
(003BH, 003AH) EF15 - EF13 EF12 EF11 EF10 EF9 EF8 - EF6 EF5 - EF3 IMF
EIRD,EIRE 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
(002DH, 002CH) EF31 EF30 EF29 EF28 EF27 EF26 EF25 EF24 EF23 EF22 EF21 EF20 EF19 EF18 EF17 EF16
EIRE (002AH)
Note 1: Do not set IMF and the interrupt enable flag (EF39 to EF3) to “1” at the same time.
Note 2: In main program, before manipulating the interrupt enable flag (EF) or the interrupt latch (IL), be sure to clear IMF to
"0" (Disable interrupt by DI instruction). Then set IMF newly again as required after operating on the EF or IL (Enable
interrupt by EI instruction)
In interrupt service routine, because the IMF becomes "0" automatically, clearing IMF need not execute normally on
interrupt service routine. However, if using multiple interrupt on interrupt service routine, manipulating EF or IL should be
executed before setting IMF="1".
Page 29
3. Interrupt Control Circuit
3.3 Interrupt Sequence TMP88FW45AFG
Note:When the contents of PSW are saved on the stack, the contents of IMF are also saved.
Interrupt
request
Interrupt
latch (IL)
IMF
Note 1: a: Return address, b: Entry address, c: Address which RETI instruction is stored
Note 2: On condition that interrupt is enabled, it takes 62/fc [s] at maximum (If the interrupt latch is set at the first machine
cycle on 15 cycle instruction) to start interrupt acceptance processing since its interrupt latch is set.
Example: Correspondence between vector table address for INTTBT and the entry address of the interrupt
service program
Page 30
TMP88FW45AFG
A maskable interrupt is not accepted until the IMF is set to “1” even if the maskable interrupt higher than the
level of current servicing interrupt is requested.
In order to utilize nested interrupt service, the IMF is set to “1” in the interrupt service program. In this case,
acceptable interrupt sources are selectively enabled by the individual interrupt enable flags. But don’t use the
read-modify-write instruction for EIRL(0003AH) on the pseudo non-maskable interrupt service task.
To avoid overloaded nesting, clear the individual interrupt enable flag whose interrupt is currently serviced,
before setting IMF to “1”. As for non-maskable interrupt, keep interrupt service shorten compared with length
between interrupt requests; otherwise the status cannot be recovered as non-maskable interrupt would simply
nested.
By switching to non-use register bank, it can restore the general-purpose register at high speed.
Usually the bank register "0" is assigned for main task and the bank register "1 to 15" are for the each
interrupt service task. To make up its data memory efficiency, the common bank is assigned for non-multiple
interrupt factor.
It can return back to main-flow by executing the interrupt return instructions ([RETI]/[RETN]) from the
current interrupt register bank automatically. Thus, no need to restore the RBS by a program.
By switching to non-use register bank, it can restore the general-purpose register at high speed. Usually
the bank register "0" is assigned for main task and the bank register "1 to 15" are for the each interrupt service
task.
Page 31
3. Interrupt Control Circuit
3.3 Interrupt Sequence TMP88FW45AFG
(interrupt processing)
If only a specific register is saved or interrupts of the same source are nested, general-purpose registers can
be saved/restored using the PUSH/POP instructions.
(interrupt processing)
RETI ; RETURN
Address
(Example)
SP
A b-5
SP W SP b-4
PCL PCL PCL b-3
PCH PCH PCH b-2
PSWL PSWL PSWL b-1
PSWH PSWH PSWH SP b
To save only a specific register without nested interrupts, data transfer instructions are available.
(interrupt processing)
RETI ; Return
Page 32
TMP88FW45AFG
Bank n
Interrupt return
(a) Saving/restoring by register bank changeover (b) Saving/restoring general-purpose registers using
PUSH/POP data transfer instruction
1. The contents of the program counter and the 1. The contents of the program counter and the
program status word are restored from the stack. program status word are restored from the stack.
2. The stack pointer is incremented 5 times. 2. The stack pointer is incremented 5 times.
3. The interrupt master enable flag is set to "1". 3. The interrupt master enable flag is set to "1" only
4. The interrupt nesting counter is decremented, when a non-maskable interrupt is accepted in
and the interrupt nesting flag is changed. interrupt enable status. However, the interrupt
master enable flag remains at "0" when so clear
by an interrupt service program.
4. The interrupt nesting counter is decremented,
and the interrupt nesting flag is changed.
Interrupt requests are sampled during the final cycle of the instruction being executed. Thus, the next interrupt
can be accepted immediately after the interrupt return instruction is executed.
Note:When the interrupt processing time is longer than the interrupt request generation time, the interrupt
service task is performed but not the main task.
Page 33
3. Interrupt Control Circuit
3.4 Software Interrupt (INTSW) TMP88FW45AFG
Use the SWI instruction only for detection of the address error or for debugging.
3.4.2 Debugging
Debugging efficiency can be increased by placing the SWI instruction at the software break point setting
address.
Page 34
TMP88FW45AFG
Edge selection is also possible with INT1,INT2 and INT4. The INT0/P10 pin can be configured as either an external
interrupt input pin or an input/output port, and is configured as an input port during reset.
Edge selection, and noise reject control and INT0/P10 pin function selection are performed by the external interrupt
control register (EINTCR).
Source Pin Sub-Pin Enable Conditions Release Edge (level) Digital Noise Reject
Note 1: In NORMAL or IDLE mode, if a signal with no noise is input on an external interrupt pin, it takes a maximum of "signal
establishment time" from the input signal's edge to set the interrupt latch.
(1) INT1 pin 49/fc [s] ( at EINTCR<INT1NC> = "1") , 193/fc [s] ( at EINTCR<INT1NC> = "0")
(2) INT2 , 4 pins 25/fc [s]
Note 2: When EINTCR<INT0EN> = "0", IL3 is not set even if a falling edge is detected on the INT0 pin input.
Note 3: When a pin with more than one function is used as an output and a change occurs in data or input/output status, an
interrupt request signal is generated in a pseudo manner. In this case, it is necessary to perform appropriate processing
such as disabling the interrupt enable flag.
EINTCR 7 6 5 4 3 2 1 0
(0037H) INT1NC INT0EN INT4ES - INT2ES INT1ES (Initial value: 0000 *00*)
Page 35
3. Interrupt Control Circuit
3.5 External Interrupts TMP88FW45AFG
Page 36
TMP88FW45AFG
The TMP88FW45AFG adopts the memory mapped I/O system, and all peripheral control and transfers are per-
formed through the special function register (SFR) or the data buffer register (DBR,EBR). The SFR is mapped on
address 0000H to 003FH, DBR is mappped on address 1F80H to 1FFFH and EBR is mappped on address 1F70H to
1F7FH.
This chapter shows the arrangement of the special function register (SFR) and data buffer register (DBR,EBR) for
TMP88FW45AFG.
4.1 SFR
0000H P0DR
0001H P1DR
0002H P2DR
0003H P3DR
0004H P4DR
0005H P5DR
0006H P6DR
0007H P7DR
0008H P8DR
0009H P9DR
000AH P0CR
000BH P1CR
000CH HPWMCR
000DH HPWMDR0
000EH HPWMDR1
000FH TC1CR
0010H TC1DRAL
0011H TC1DRAH
0012H TC1DRBL
0013H TC1DRBH
0014H CTC1CR1
0015H CTC1CR2
0016H - CTC1DRL
0017H - CTC1DRH
0018H Reserved
0019H Reserved
001AH TC4CR
001BH TC4DR
001CH TC3DRA
001DH TC3DRB -
001EH TC3CR
001FH Reserved
0020H TC5CR
0021H TC6CR
0022H TTREG5
0023H TTREG6
0024H PWREG5
Page 37
4. Special Function Register
4.1 SFR TMP88FW45AFG
0025H PWREG6
0026H ADCCRA
0027H ADCCRB
0028H ADCDRL -
0029H ADCDRH -
002AH EIRC
002BH ILC
002CH EIRE
002DH EIRD
002EH ILE
002FH ILD
0030H CGCR
0031H Reserved
0032H Reserved
0033H Reserved
0034H - WDTCR1
0035H - WDTCR2
0036H TBTCR
0037H EINTCR
0038H SYSCR1
0039H SYSCR2
003AH EIRL
003BH EIRH
003CH ILL
003DH ILH
003EH PSWL
003FH PSWH
Page 38
TMP88FW45AFG
4.2 EBR
1F73H Reserved
1F74H Reserved
1F75H Reserved
1F76H Reserved
1F77H Reserved
1F78H Reserved
1F79H Reserved
1F7AH Reserved
1F7BH Reserved
1F7CH CLKSCR2
1F7DH CLKSMN
1F7EH CLKSMX
1F7FH CLKSCR1
Page 39
4. Special Function Register
4.3 DBR TMP88FW45AFG
4.3 DBR
1F80H P0ODE
1F81H −
1F82H −
1F83H P3ODE
1F84H P4ODE
1F85H P5ODE
1F86H P8ODE
1F87H P9ODE
1F88H −
1F89H P3CR
1F8AH P4CR
1F8BH P5CR
1F8CH P6CR
1F8DH P7CR
1F8EH P8CR
1F8FH P9CR
1F90H UARTSEL
1F92H − UARTCR2
1F94H − ATAS
1F95H − ATKEY
1F96H − SIOCR1
1F98H SIOBR0
1F99H SIOBR1
1F9AH SIOBR2
1F9BH SIOBR3
1F9CH SIOBR4
1F9DH SIOBR5
1F9EH SIOBR6
1F9FH SIOBR7
Page 40
TMP88FW45AFG
1FCBH −
1FCCH Reserved
1FCDH Reserved
1FCEH Reserved
1FCFH Reserved
Page 41
4. Special Function Register
4.3 DBR TMP88FW45AFG
1FFBH −
1FFCH Reserved
1FFDH Reserved
1FFEH SPCR
1FFFH FLSCR
Page 42
TMP88FW45AFG
5. Input/Output Ports
All output ports contain a latch, and the output data therefore are retained by the latch. But none of the input ports
have a latch, so it is desirable that the input data be retained externally until it is read out, or read several times before
being processed. Figure 5-1 shows input/output timing.
The timing at which external data is read in from input/output ports is S1 state in the read cycle of instruction
execution. Because this timing cannot be recognized from the outside, transient input data such as chattering needs to
be dealt with in a program. The timing at which data is forwarded to input/output ports is S2 state in the write cycle
of instruction execution.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and all I/O pins become high impedance.
Page 43
5. Input/Output Ports
TMP88FW45AFG
When an operation is performed for read from any input/output port except programmable input/output ports,
whether the input value of the pin or the content of the output latch is read depends on the instruction executed, as
shown below.
Page 44
TMP88FW45AFG
The P0 port contains bit wise programmable open-drain control. The P0 port open-drain control register (P0ODE)
is used to select open-drain or tri-state mode for the port. When reset, the P0ODE register is initialized to 0, with tri-
state mode selected for the port.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P0 becomes high impedance.
Table 5-1
P0ODE P0CR P0DR Data input (by reading instruction) Control input Output data
1 0 0 Input Data from port (Low) Input Data from port (Low) "0"
1 1 0 Input Data from port (Low) Input Data from port (Low) "0"
OFDRST
STOP
OUTEN
P0CRi
Data input
P0ODEi
Data output
D Q P0i
Output latch
Control output
Control input
Note 1: i = 3 to 0
Note 2: OFDRST shows a reset signal of oscillation frequency detection.
Page 45
5. Input/Output Ports
5.1 Port P0 (P03 to P00) TMP88FW45AFG
7 6 5 4 3 2 1 0
P0DR P03 P02 P01 P00
Read/Write
(00000H) HPWM1 HPWM0 TC6O TC6I
(Initial value: **** 0000)
TXD2 RXD2
P0CR 7 6 5 4 3 2 1 0
(0000AH) (Initial value: **** 0000)
P0ODE 7 6 5 4 3 2 1 0
(01F80H) (Initial value: **** 0000)
Note 1: Even when open-drain mode is selected, the protective diode remains connected. Therefore, do not apply voltages ex-
ceeding VDD.
Note 2: Read-Modify-Write (RMW) operation executes at open-drain mode is selected, read out the output latch states.
When any other instruction is executed, external pin states is read out.
Note 3: *: Don’t care
Note 4: TC6O: PDO6, PWM6, PPG6
Page 46
TMP88FW45AFG
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P1 becomes high impedance.
Table 5-2
P1ODE P1CR P1DR Data input (by reading instruction) Control input Output data
1 0 0 Input Data from port (Low) Input Data from port (Low) "0"
1 1 0 Input Data from port (Low) Input Data from port (Low) "0"
OFDRST
STOP
OUTEN
P1CRi
Data input
P1ODEi
Data output
D Q P1i
Output latch
Control output
Control input
Note 1: i = 7 to 0
Note 2: OFDRST shows a reset signal of oscillation frequency detection.
7 6 5 4 3 2 1 0
P1DR P17 P16 P15 P14 P13 P12 P11 P10 Read/Write
(00001H) PDW2 PDV2 PDU2 PPG1 DVO INT2 INT1 INT0 (Initial value: 0000 0000)
TC5O TC5I TC1 TC5O: PDO5, PWM5
P1CR 7 6 5 4 3 2 1 0
(0000BH) (Initial value: 0000 0000)
Page 47
5. Input/Output Ports
5.3 Port P2 (P22 to P20) TMP88FW45AFG
We recommend using the P20 pin as external interrupt input, STOP mode release signal input, or input port. When
using this port as an output port, note that the interrupt latch is set by a falling edge of output pulse. And note that
outputs on this port during STOP mode go to a high-impedance state even if SYSCR1<OUTEN> is set "1", because
P20 port is also used as STOP port.
When a read instruction is executed on P2 port, indeterminate values are read in from bits 7 to 3.
When any read-modify-write instruction is executed on P2 port, the content of the output latch is read out. When
any other instruction is executed, the external pin state is read out.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P2 becomes high impedance.
Data input
STOP
OFDRST
Data input
OFDRST
STOP
OUTEN
Data output
D Q P21, P22
Output latch
Control output
Control input
7 6 5 4 3 2 1 0
P22 P21 P20
P2DR TC4 TC3 INT5
Read/Write
(00002H) INT4 STOP
(Initial value: **** *111)
PWM4
PDO4
Note 1: When a read instruction is executed on P2 port, indeterminate values are read in from bits 7 to 3.
Page 48
TMP88FW45AFG
Note 2: Port P20 is used as STOP pin. Therefore, when stop mode is started, SYSCR1<OUTEN> does not affect to P20, and
P20 becomes High-Z mode.
Note 3: *: Don’t care
Page 49
5. Input/Output Ports
5.4 Port P3 (P37 to P30) TMP88FW45AFG
The P3 port contains bit wise programmable open-drain control. The P3 Port Open-drain Control Register (P3ODE)
is used to select open-drain or tri-state mode for the port. When reset, the P3ODE Register is initialized to 0, with tri-
state mode selected for the port.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P3 becomes high impedance.
Table 5-3
P3ODE P3CR P3DR Data input (by reading instruction) Control input Output data
1 0 0 Input Data from port (Low) Input Data from port (Low) "0"
1 1 0 Input Data from port (Low) Input Data from port (Low) "0"
OFDRST
STOP
OUTEN
P3CRi
Data input
P3ODEi
Data output
D Q P3i
Output latch
Control output
Control input
Note 1: i = 7 to 0
Note 2: OFDRST shows a reset signal of oscillation frequency detection.
Page 50
TMP88FW45AFG
7 6 5 4 3 2 1 0
P3DR
P37 P36 P35 P34 P33 P32 P31 P30 Read/Write
(00003H)
CL1 EMG1 U1 V1 W1 X1 Y1 Z1 (Initial value: 0000 0000)
P3CR 7 6 5 4 3 2 1 0
(01F89H) (Initial value: 0000 0000)
P3ODE 7 6 5 4 3 2 1 0
(01F83H) (Initial value: 0000 0000)
Note 1: Even when open-drain mode is selected, the protective diode remains connected. Therefore, do not apply voltages ex-
ceeding VDD.
Note 2: Read-Modify-Write (RMW) operation executes at open-drain mode is selected, read out the output latch states.
When any other instruction is executed, external pin states is read out.
Note 3: For PMD circuit output, set the P3DR output latch to 1.
Note 4: When using P3 port as an input/output port, disable the EMG1 circuit.
Page 51
5. Input/Output Ports
5.5 Port P4 (P47 to P40) TMP88FW45AFG
The P4 port contains bit wise programmable open-drain control. The P4 port open-drain control register (P4ODE)
is used to select open-drain or tri-state mode for the port. When reset, the P4ODE register is initialized to 0, with tri-
state mode selected for the port.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P4 becomes high impedance.
Table 5-4
P4ODE P4CR P4DR Data input (by reading instruction) Control input Output data
1 0 0 Input Data from port (Low) Input Data from port (Low) "0"
1 1 0 Input Data from port (Low) Input Data from port (Low) "0"
OFDRST
STOP
OUTEN
P4CRi
Data input
P4ODEi
Data output
D Q P4i
Output latch
Control output
Control input
Note 1: i = 7 to 0
Note 2: OFDRST shows a reset signal of oscillation frequency detection.
Page 52
TMP88FW45AFG
7 6 5 4 3 2 1 0
P47 P46 P45 P44 P43 P42 P41 P40
P4DR
CTC PPG2 SO SI SCK PDU1 PDV1 PDW1
(00004H) (Initial value: 0000 0000)
TXD1 RXD1
BOOT
P4CR 7 6 5 4 3 2 1 0
(01F8AH) (Initial value: 0000 0000)
P4ODE 7 6 5 4 3 2 1 0
(01F84H) (Initial value: 0000 0000)
Note 1: Even when open-drain mode is selected, the protective diode remains connected. Therefore, do not apply voltages ex-
ceeding VDD.
Note 2: Read-Modify-Write (RMW) operation executes at open-drain mode is selected, read out the output latch states.
When any other instruction is executed, external pin states is read out.
Note 3: When using the 16-bit timer (CTC) as an ordinary timer, set P47 (CTC) for output mode.
Page 53
5. Input/Output Ports
5.6 Port P5 (P57 to P50) TMP88FW45AFG
The P5 port contains bit wise programmable open-drain control. The P5 port open-drain control register (P5ODE)
is used to select open-drain or tri-state mode for the port. When reset, the P5ODE register is initialized to 0, with tri-
state mode selected for the port.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P5 becomes high impedance.
Table 5-5
P5ODE P5CR P5DR Data input (by reading instruction) Control input Output data
1 0 0 Input Data from port (Low) Input Data from port (Low) "0"
1 1 0 Input Data from port (Low) Input Data from port (Low) "0"
OFDRST
STOP
OUTEN
P5CRi
Data input
P5ODEi
Data output
D Q P5i
Output latch
Control output
Control input
Note 1: i = 7 to 0
Note 2: OFDRST shows a reset signal of oscillation frequency detection.
7 6 5 4 3 2 1 0
P5DR
P57 P56 P55 P54 P53 P52 P51 P50 Read/Write
(00005H)
Z2 Y2 X2 W2 V2 U2 EMG2 CL2 (Initial value: 0000 0000)
P5CR 7 6 5 4 3 2 1 0
(01F8BH) (Initial value: 0000 0000)
Page 54
TMP88FW45AFG
P5ODE 7 6 5 4 3 2 1 0
(01F85H) (Initial value: 0000 0000)
Note 1: Even when open-drain mode is selected, the protective diode remains connected. Therefore, do not apply voltages ex-
ceeding VDD.
Note 2: Read-Modify-Write (RMW) operation executes at open-drain mode is selected, read out the output latch states.
When any other instruction is executed, external pin states is read out.
Note 3: For PMD circuit output, set the P5DR output latch to 1.
Note 4: When using P5 port as an input/output port, disable the EMG2 circuit.
Page 55
5. Input/Output Ports
5.7 Port P6 (P67 to P60) TMP88FW45AFG
The ports used for analog input must have their output latches set to 0 beforehand. The actual input channels for
AD conversion are selected using ADCCRA<SAIN>.
Although the bits of P6 port not used for analog input can be used as input/output ports, do not execute output
instructions on these ports during AD conversion. This is necessary to maintain the accuracy of AD conversion. Also,
do not apply rapidly changing signals to ports adjacent to analog input during AD conversion.
If an input instruction is executed while the P6DR output latch is cleared to 0, data “0” is read in from said bits.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P6 becomes high impedance.
Analog input
SAIN
AINDS
OFDRST
STOP
OUTEN
P6CRi
D Q
P6CRi input
Data input (P6)
Note 1: i = 7 to 0
Note 2: STOP exists in SYSCR1 register bit 7.
Note 3: SAIN selects AD input channel.
Note 4: OFDRST shows a reset signal of oscillation frequency detection.
Page 56
TMP88FW45AFG
7 6 5 4 3 2 1 0
P6DR P67 P66 P65 P64 P63 P62 P61 P60
Read/Write
(00006H) AIN7 AIN6 AIN5 AIN4 AIN3 AIN2 AIN1 AIN0
(Initial value: 0000 0000)
DBOUT1
P6CR 7 6 5 4 3 2 1 0
(01F8CH) (Initial value: 0000 0000)
Note 1: The pins used for analog input cannot be set for output mode (P6CR = 1) because they become shorted with external
signals.
Note 2: When a read instruction is executed on bits of this port which are set for analog input mode, data "0" is read in.
Note 3: For DBOUT1 output, set the P6DR (P67) output latch to 1.
Note 4: When using this port in input mode (including analog input), do not use bit manipulating or other read-modify-write in-
structions. When a read instruction is executed on the bits of this port that are set for input, the contents of the pins are
read in, so that if a read-modify-write instruction is executed, their output latches may be rewritten, making the pins unable
to accept input. (A read-modify-write instruction first reads data from all of the eight bits and after modifying them (bit
manipulation), writes data for all of the eight bits to the output latches.)
Page 57
5. Input/Output Ports
5.8 Port P7 (P77 to P70) TMP88FW45AFG
The ports used for analog input must have their output latches set to 0 beforehand. The actual input channels for
AD conversion are selected using ADCCRA<SAIN>.
Although the bits of P7 port not used for analog input can be used as input/output ports, do not execute output
instructions on these ports during AD conversion. This is necessary to maintain the accuracy of AD conversion. Also,
do not apply rapidly changing signals to ports adjacent to analog input during AD conversion.
If an input instruction is executed while the P7DR output latch is cleared to 0, data “0” is read in from said bits.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P7 becomes high impedance.
Analog input
SAIN
AINDS
OFDRST
STOP
OUTEN
P7CRi
D Q
P7CRi input
Data input (P7)
Note 1: i = 7 to 0
Note 2: STOP exists in SYSCR1 register bit 7.
Note 3: SAIN selects AD input channel.
Note 4: OFDRST shows a reset signal of oscillation frequency detection.
Page 58
TMP88FW45AFG
7 6 5 4 3 2 1 0
P7DR P77 P76 P75 P74 P73 P72 P71 P70
Read/Write
(00007H) AIN15 AIN14 AIN13 AIN12 AIN11 AIN10 AIN9 AIN8
(Initial value: 0000 0000)
DBOUT2
P7CR 7 6 5 4 3 2 1 0
(01F8DH) (Initial value: 0000 0000)
Note 1: The pins used for analog input cannot be set for output mode (P7CR = 1) because they become shorted with external
signals.
Note 2: When a read instruction is executed on bits of this port which are set for analog input mode, data "0" is read in.
Note 3: For DBOUT2 output, set the P7DR (P77) output latch to 1.
Note 4: When using this port in input mode (including analog input), do not use bit manipulating or other read-modify-write in-
structions. When a read instruction is executed on the bits of this port that are set for input, the contents of the pins are
read in, so that if a read-modify-write instruction is executed, their output latches may be rewritten, making the pins unable
to accept input. (A read-modify-write instruction first reads data from all of the eight bits and after modifying them (bit
manipulation), writes data for all of the 8 bits to the output latches.)
Page 59
5. Input/Output Ports
5.9 Port P8 (P87 to P80) TMP88FW45AFG
The P8 port contains bit wise programmable open-drain control. The P8 port open-drain control register (P8ODE)
is used to select open-drain or tri-state mode for the port. When reset, the P8ODE register is initialized to 0, with tri-
state mode selected for the port.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P8 becomes high impedance.
Table 5-6
P8ODE P8CR P8DR Data input (by reading instruction) Control input Output data
1 0 0 Input Data from port (Low) Input Data from port (Low) "0"
1 1 0 Input Data from port (Low) Input Data from port (Low) "0"
OFDRST
STOP
OUTEN
P8CRj
Data input
P8ODEj
Data output
D Q P8j
Output latch
Control output
Control input
OFDRST
STOP
OUTEN
P8CRi
Data input
P8ODEi
Note 1: i = 7 to 2
Note 2: j = 1, 0
Note 3: OFDRST shows a reset signal of oscillation frequency detection.
Page 60
TMP88FW45AFG
7 6 5 4 3 2 1 0
P8DR
P87 P86 P85 P84 P83 P82 P81 P80 Read/Write
(00008H)
TXD3 RXD3 (Initial value: 0000 0000)
P8CR 7 6 5 4 3 2 1 0
(01F8EH) (Initial value: 0000 0000)
P8ODE 7 6 5 4 3 2 1 0
(01F86H) (Initial value: 0000 0000)
Note 1: Even when open-drain mode is selected, the protective diode remains connected. Therefore, do not apply voltages ex-
ceeding VDD.
Note 2: Read-Modify-Write (RMW) operation executes at open-drain mode is selected, read out the output latch states.
When any other instruction is executed, external pin states is read out.
Page 61
5. Input/Output Ports
5.10 Port P9 (P97 to P90) TMP88FW45AFG
The P9 port contains bit wise programmable open-drain control. The P9 port open-drain control register (P9ODE)
is used to select open-drain or tri-state mode for the port. When reset, the P9ODE register is initialized to 0, with tri-
state mode selected for the port.
If high frequency oscillation stops or becomes abnormal in NORMAL/IDLE mode, the TMP88FW45AFG generates
the oscillation frequency detection reset and Port P9 becomes high impedance.
Table 5-7
P9ODE P9CR P9DR Data input (by reading instruction) Control input Output data
1 0 0 Input Data from port (Low) Input Data from port (Low) "0"
1 1 0 Input Data from port (Low) Input Data from port (Low) "0"
OFDRST
STOP
OUTEN
P9CRi
Data input
P9ODEi
Note 1: i = 7 to 0
Note 2: OFDRST shows a reset signal of oscillation frequency detection.
Page 62
TMP88FW45AFG
7 6 5 4 3 2 1 0
P9DR
Read/Write
(00009H) P97 P96 P95 P94 P93 P92 P91 P90
(Initial value: 0000 0000)
P9CR 7 6 5 4 3 2 1 0
(01F8FH) (Initial value: 0000 0000)
P9ODE 7 6 5 4 3 2 1 0
(01F87H) (Initial value: 0000 0000)
Note 1: Even when open-drain mode is selected, the protective diode remains connected. Therefore, do not apply voltages ex-
ceeding VDD.
Note 2: Read-Modify-Write (RMW) operation executes at open-drain mode is selected, read out the output latch states.
When any other instruction is executed, external pin states is read out.
Page 63
5. Input/Output Ports
5.10 Port P9 (P97 to P90) TMP88FW45AFG
Page 64
TMP88FW45AFG
An INTTBT ( Time Base Timer Interrupt ) is generated on the first falling edge of source clock ( The divider output
of the timing generator which is selected by TBTCK. ) after time base timer has been enabled.
The divider is not cleared by the program; therefore, only the first interrupt may be generated ahead of the set
interrupt period ( Figure 6-2 ).
The interrupt frequency (TBTCK) must be selected with the time base timer disabled (TBTEN="0"). (The interrupt
frequency must not be changed with the disable from the enable state.) Both frequency selection and enabling can be
performed simultaneously.
MPX
fc/223,fc/224
fc/221,fc/222
fc/216,fc/217 Source clock Falling edge
fc/214,fc/215 detector
fc/213,fc/214 INTTBT
fc/212,fc/213 interrupt request
fc/211,fc/212
fc/29,fc/210
TBTCK TBTEN
TBTCR
Time base timer control register
Source clock
TBTCR<TBTEN>
INTTBT
interrupt request
Interrupt period
Enable TBT
Example :Set the time base timer frequency to fc/216 [Hz] and enable an INTTBT interrupt.
DI
SET (EIRL) . 6
EI
Page 65
6. Time Base Timer (TBT)
6.1 Time Base Timer TMP88FW45AFG
Time Base Timer is controled by Time Base Timer control register (TBTCR).
7 6 5 4 3 2 1 0
TBTCR
(DVOEN) (DVOCK) 0 TBTEN TBTCK (Initial Value: 0000 0000)
(00036H)
DV1CK=0 DV1CK=1
101 fc/212
fc/213
Table 6-1 Time Base Timer Interrupt Frequency ( Example : fc = 20.0 MHz )
DV1CK = 0 DV1CK = 1
Page 66
TMP88FW45AFG
Output latch
Data output D Q
DVO pin
MPX
fc/213,fc/214 A
fc/212,fc/213 B
fc/211,fc/212 C Y
fc/210,fc/211
D Port output latch
S
2
TBTCR<DVOEN>
DVOCK DVOEN
TBTCR
DVO pin output
Divider output control register
(a) configuration (b) Timing chart
The Divider Output is controlled by the Time Base Timer Control Register (TBTCR).
7 6 5 4 3 2 1 0
TBTCR
DVOEN DVOCK "0" (TBTEN) (TBTCK) (Initial value: 0000 0000)
(00036H)
DV1CK=0 DV1CK=1
10 fc/211 fc/212
11 fc/210
fc/211
Note 1: Selection of divider output frequency (DVOCK) must be made while divider output is disabled (DVOEN="0"). Also, in other
words, when changing the state of the divider output frequency from enabled (DVOEN="1") to disable(DVOEN="0"), do
not change the setting of the divider output frequency.
Note 2: In case of using DVO output, set output mode by P1CR register after setting the related port output latch to "1" by P1DR
register.
Note 3: fc; High-frequency clock [Hz], *; Don't care
Note 4: Be sure to write "0" to TBTCR Register bit 4.
Port setting
Page 67
6. Time Base Timer (TBT)
6.2 Divider Output (DVO) TMP88FW45AFG
DV1CK=0 DV1CK=1
00 2.4415 k 1.22075 k
01 4.8825 k 2.4415 k
10 9.765 k 4.8825 k
11 19.5325 k 9.765 k
Page 68
TMP88FW45AFG
The watchdog timer is a fail-safe system to detect rapidly the CPU malfunctions such as endless loops due to spurious
noises or the deadlock conditions, and return the CPU to a system recovery routine.
The watchdog timer signal for detecting malfunctions can be programmed only once as “reset request” or “pseudo
non-maskable interrupt request”. Upon the reset release, this signal is initialized to “reset request”.
When the watchdog timer is not used to detect malfunctions, it can be used as the timer to provide a periodic interrupt.
Note:Care must be taken in system design since the watchdog timer functions are not be operated completely due to
effect of disturbing noise.
Reset release
fc/223,fc/224 Binary counters
Selector
fc/221,fc/222 Clock R
fc/219,fc/220 Overflow WDT output
fc/217,fc/218 1 2 Reset
Clear S Q request
2 Interrupt request
INTWDT
interrupt
request
Internal reset
Q
S R
WDTEN
Writing Writing
WDTT WDTOUT
disable code clear code
Controller
0034H 0035H
WDTCR1 WDTCR2
Watchdog timer control registers
Page 69
7. Watchdog Timer (WDT)
7.2 Watchdog Timer Control TMP88FW45AFG
1. Set the detection time, select the output, and clear the binary counter.
2. Clear the binary counter repeatedly within the specified detection time.
If the CPU malfunctions such as endless loops or the deadlock conditions occur for some reason, the watchdog
timer output is activated by the binary-counter overflow unless the binary counters are cleared. When
WDTCR1<WDTOUT> is set to “1” at this time, the reset request is generated and then internal hardware is
initialized. When WDTCR1<WDTOUT> is set to “0”, a watchdog timer interrupt (INTWDT) is generated.
The watchdog timer temporarily stops counting in the STOP mode including the warm-up or IDLE mode, and
automatically restarts (continues counting) when the STOP/IDLE mode is inactivated.
Note:The watchdog timer consists of an internal divider and a two-stage binary counter. When the clear code
4EH is written, only the binary counter is cleared, but not the internal divider. The minimum binary-counter
overflow time, that depends on the timing at which the clear code (4EH) is written to the WDTCR2 register,
may be 3/4 of the time set in WDTCR1<WDTT>. Therefore, write the clear code using a cycle shorter
than 3/4 of the time set to WDTCR1<WDTT>.
Example :Setting the watchdog timer detection time to 221/fc [s], and resetting the CPU malfunction detection
Page 70
TMP88FW45AFG
WDTCR1 7 6 5 4 3 2 1 0
(0034H) WDTEN WDTT WDTOUT (Initial value: **** 1001)
DV1CK = 0 DV1CK = 1
00 2 /fc
25
226/fc Write
WDTT Watchdog timer detection time [s]
01 223/fc 224/fc only
10 2 fc
21
2 fc
22
11 219/fc 220/fc
Note 1: After clearing WDTCR1<WDTOUT> to “0”, the program cannot set it to “1”.
Note 2: fc: High-frequency clock [Hz], *: Don’t care
Note 3: WDTCR1 is a write-only register and must not be used with any of read-modify-write instructions. If WDTCR1 is read, a
unknown data is read.
Note 4: To activate the STOP mode, disable the watchdog timer or clear the counter immediately before entering the STOP mode.
After clearing the counter, clear the counter again immediately after the STOP mode is inactivated.
Note 5: To clear WDTCR1<WDTEN>, set the register in accordance with the procedures shown in “7.2.3 Watchdog Timer Dis-
able”.
Note 6: If the watchdog timer is disabled during watchdog timer interrupt processing, the watchdog timer interrupt will never be
cleared. Therefore, clear the watchdog timer ( set the clear code (4EH) to WDTCR2 ) before disabling it, or disable the
watchdog timer a sufficient time before it overflows.
Note 7: The watchdog timer consists of an internal divider and a two-stage binary counter. When clear code (4EH) is written, only
the binary counter is cleared, not the internal divider.
Depending on the timing at which clear code (4EH) is written on the WDTCR2 register, the overflow time of the binary
counter may be at minimum 3/4 of the time set in WDTCR1<WDTT>. Thus, write the clear code using a shorter cycle
than 3/4 of the time set in WDTCR1<WDTT>.
WDTCR2 7 6 5 4 3 2 1 0
(0035H) (Initial value: **** ****)
Page 71
7. Watchdog Timer (WDT)
7.2 Watchdog Timer Control TMP88FW45AFG
Note:While the watchdog timer is disabled, the binary counters of the watchdog timer are cleared.
DI : IMF ← 0
EI : IMF ← 1
DV1CK = 0 DV1CK = 1
00 1.678 3.355
01 419.430 m 838.861 m
10 104.858 m 209.715 m
11 26.214 m 52.429 m
Note:If the watchdog timer is disabled during watchdog timer interrupt processing, the watchdog timer interrupt will
never be cleared. Therefore, clear the watchdog timer ( set the clear code (4EH) to WDTCR2 ) before disabling
it, or disable the watchdog timer a sufficient time before it overflows.
A watchdog timer interrupt is the non-maskable interrupt which can be accepted regardless of the interrupt
master flag (IMF).
When a watchdog timer interrupt is generated while the other interrupt including a watchdog timer interrupt
is already accepted, the new watchdog timer interrupt is processed immediately and the previous interrupt is held
pending. Therefore, if watchdog timer interrupts are generated continuously without execution of the RETN
instruction, too many levels of nesting may cause a malfunction of the microcontroller.
To generate a watchdog timer interrupt, set the stack pointer before setting WDTCR1<WDTOUT>.
Page 72
TMP88FW45AFG
219/fc [s]
217/fc
Clock (WDTT=11B)
Binary counter 1 2 3 0 1 2 3 0
Overflow
Internal reset
(WDTCR1<WDTOUT>= "1") A reset occurs
Page 73
7. Watchdog Timer (WDT)
7.2 Watchdog Timer Control TMP88FW45AFG
Page 74
TMP88FW45AFG
8.1 Configuration
The oscillation frequency detector generates a reset for I/O if the oscillation of high frequency is lower than a lower
detection frequency, or higher than an upper detection frequency. Each frequency is specified by CLKSMN and
CLKSMX register. An initial value of lower detection frequency is 8.8MHz which is a harmonics of +10% of 16MHz,
and that of upper detection frequency is 20MHz which is a maximum frequency in operating condition. For details,
refer to Figure 8-1. To change the detection frequency, CLKSMN and CLKSMX registers are used. CLKSMN and
CLKSMX can be written when the oscillation frequency detection is disabled and writing to CLKSMN/CLKSMX is
enabled by setting "F9H" to CLKSCR1. Since the oscillation frequency detection is disabled after an external reset
input, write "F9H" to CLKSCR1 and write "E4H" to CLKSCR2 register to enable its function.
When the TMP88FW45AFG detects the out of frequency specified CLKSMN and CLKSMX register, all I/Os
become high impedance by reset. By the oscillation frequency detection reset, all I/Os except power supply pins,
RESET, XIN and XOUT become high impedance. If oscillation frequency detection reset is generated by detecting
the stopping of high frequency, the internal circuities such as registers hold the condition at the timing of oscillation
stop. To initialize these internal circuitries, an at external re-starting of oscillation is needed.
Note 1: Though the harmonics of 16MHz is 32MHz, upper detection frequency is set to 20MHz to avoid an erratic operation
caused by exceeding 20MHz.
Note 2: The oscillation frequency detection reset is available only in NORMAL and IDLE modes. In STOP modes, the
oscillation frequency detection reset is disabled automatically.
Operating Conditions
Area 16MHzr
VDD [V] Harmonics
Subharmonics of 16MHz-10%
of 16MHz
5.5
4.5
fc [MHz]
If the calculated detection frequency is lower than 8MHz or higher than 20MHz, the detection frequency
should be set within operating condition.
Oscillation Frequency
Osc. enable fc Oscillation Detection Reset
Frequency
Detector
VDD VDD
Rf
RO
XIN XOUT
Page 75
8. Oscillation Frequency Detector
8.2 Control TMP88FW45AFG
8.2 Control
The oscillation frequency detection is controlled by oscillation frequency detection control register 2 (CLKSCR2).
The detection frequency is specified by lower/higher detection frequency setting register (CLKSMN, CLKSMX).
Writing to CLKSCR2/CLKSMN/CLKSMX is controlled by oscillation frequency control register 1 (CLKSCR1).
CLKSCR1 7 6 5 4 3 2 1 0
(1F7FH) Initial value( 0000 0110)
Note 1: Only "06H" and "F9H" is valid to CLKSCR1. If other value than "06H" and "F9H" is written to CLKSCR1, "06H" is
written to CLKSCR1 automatically.
Note 2: CLKSCR1 is not initialized by an internal factor reset including oscillation frequency detection reset. To initialize
this registers, set the RESET pin (external factor reset) to the low level.
CLKSCR2 7 6 5 4 3 2 1 0
(1F7CH) Initial value( 0000 0000)
Note 1: Only "00H" and "E4H" is valid to CLKSCR2. Writing other value than "00H" and "E4H" to CLKSCR2 with
CLKSCR1="F9H" is ignored.
Note 2: Writing to CLKSCR2 is protected by setting "06H" to CLKSCR1 but reading from CLKSCR2 is always enabled
without setting of CLKSCR1.
Note 3: CLKSCR2 is not initialized by an internal factor reset including oscillation frequency detection reset. To initialize
this registers, set the RESET pin (external factor reset) to the low level.
CLKSMN 7 6 5 4 3 2 1 0
(1F7DH) Read/Write
Initial value( 0010 0000)
CLKSMX 7 6 5 4 3 2 1 0
(1F7EH) Read/Write
Initial value(0100 0000)
Note 1: CLKSMN and CLKSMX can not be written when the oscillation frequency detection circuit is enabled (CLKSCR2="E4H")
or writing is disabled with CLKSCR1="06H". An attempt to write CLKSMN and CLKSMX can not complete a write oper-
ation.
Note 2: Writing to CLKSMN/CLKSMX is protected by setting "06H" to CLKSCR1 but reading from CLKSMN/CLKSMX is always
enabled without setting of CLKSCR1.
Note 3: Specify an appropriate value to CLKSMN and CLKSMX depending on the clock frequency to be used under the condition
of CLKSMN<CLKSMX. For how to calculate the value, refer to "8.3.2 Setting the Lower and Higher Frequency for De-
tection".
Note 4: CLKSMN and CLKSMX are not initialized by an internal factor reset including oscillation frequency detection reset. To
initialize these registers, set the RESET pin (external factor reset) to the low level.
Page 76
TMP88FW45AFG
8.3 Function
Setting "F9H" to CLKSCR1 enables writing to CLKSCR2 and setting "06H" to CLKSCR1 disables writing
to CLKSCR2. Reading from CLKSCR2 is always enabled without setting of CLKSCR1. CLKSCR1 is initialized
to "06H" by external reset and CLKSCR2 is initialized to "00H" by external reset. However, CLKSCR1 and
CLKSCR2 are not initialized by internal reset which are system clock, address trap, watchdog timer reset and
oscillation frequency detection reset.
Note:After writing data to CLKSCR2, set "06H" to CLKSCR1 to protect CLKSCR2 register.
When STOP mode is executed with CLKSCR2=E4H, the oscillation frequency detection is automatically
disabled. After releasing STOP and warming up period, the oscillation frequency detection is enabled. In serial
PROM mode for Flash, the oscillation frequency detection is disabled. The oscillation frequency detection is
available only in NORMAL and IDLE mode. Table 8-1 shows the availability of oscillation frequency detector.
Operating Mode Oscillation Frequency Detection All I/Os condition after Oscillation Frequency Detection RESET
STOP
Oscillation Frequency Detection is disabled automatically.
(Including warming up period)
Note 1: Internal reset ; Watchdog timer reset, Address trap reset, System clock reset and Oscillation frequency detection reset.
VDD
High-frequency
clock
External RESET
input
Internal RESET
Oscillation Frequency
Detector control
External NORMAL or STOP mode NORMAL or Internal NORMAL or External NORMAL or
RESET IDLE mode including warming up IDLE mode RESET IDLE mode RESET IDLE mode
Page 77
8. Oscillation Frequency Detector
8.3 Function TMP88FW45AFG
In the TMP88FW45AFG, the initial value of CLKSMN is 20H which is set to 8.8MHz and the initial value of
CLKSMX is 40H which is set to 20MHz. The detection frequency should be set within the operation condition
which is from 8MHz to 20MHz.
CLKSMN and CLKSMX are not initialized with an internal factor reset including the oscillation frequency
detection reset, and the values are held. To initialize these registers, set the RESET pin (external factor reset) to
the low level.
When the oscillation resumes its normal frequency and continues for some period (TOFD), the oscillation
frequency detection reset is released.
Page 78
TMP88FW45AFG
High-frequency
clock
Stable Abnormal Stable
Hi-Z
All I/Os
Clocked RESET
Clocked reset is generated
Hi-Z after resuming of frequency.
All I/Os
Page 79
8. Oscillation Frequency Detector
8.3 Function TMP88FW45AFG
Page 80
MCAP1
9.1
S
A TC1S
Y INTTC1 interript
Configuration
2
B
Decoder
Command start PPG output
Start
External mode
MPPG1
trigger start Set Q
Pulse width External
trigger
measurement TC1S clear
mode
Clear
Rising Falling
Edge detector
METT1
TC1㩷㫇㫀㫅 Port D
(Note)
9. 16-Bit TimerCounter 1 (TC1)
11 12 Clear
fc/2 , fc/2 A
Page 81
B Pulse width
fc/27, fc/28 B Y 16-bit up-counter measurement
Y A Source
mode
fc/23, fc/24 C clock
S S
Match
CMP Toggle
2 Window mode
Port
PPG output Q
Clear (Note)
S Q mode Set
Selector 㪧㪧㪞
Internal
Set reset Clear pin
Note: Function I/O may not operate depending on I/O port setting. For more details, see the chapter "I/O Port".
TMP88FW45AFG
9. 16-Bit TimerCounter 1 (TC1)
9.2 TimerCounter Control TMP88FW45AFG
Timer Register
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
7 6 5 4 3 2 1 0
ACAP1
TC1CR
MCAP1 Read/Write
(000FH) TFF1 TC1S TC1CK TC1M
METT1 (Initial value: 0000 0000)
MPPG1
DV1CK = 0 DV1CK = 1
10 fc/23 fc/24
Page 82
TMP88FW45AFG
Note 3: To set the mode, source clock, PPG output control and timer F/F control, write to TC1CR during TC1CR<TC1S>=00. Set
the timer F/F1 control until the first timer start after setting the PPG mode.
Note 4: Auto-capture can be used only in the timer, event counter, and window modes.
Note 5: To set the timer registers, the following relationship must be satisfied.
TC1DRA > TC1DRB > 1 (PPG output mode), TC1DRA > 1 (other modes)
Note 6: Set TC1CR<TFF1> to “0” in the mode except PPG output mode.
Note 7: Set TC1DRB after setting TC1CR<TC1M> to the PPG output mode.
Note 8: When the STOP mode is entered, the start control (TC1CR<TC1S>) is cleared to “00” automatically, and the timer stops.
After the STOP mode is exited, set the TC1CR<TC1S> to use the timer counter again.
Note 9: Use the auto-capture function in the operative condition of TC1. A captured value may not be fixed if it's read after the
execution of the timer stop or auto-capture disable. Read the capture value in a capture enabled condition.
Note 10: Since the up-counter value is captured into TC1DRB by the source clock of up-counter after setting TC1CR<ACAP1> to
"1". Therefore, to read the captured value, wait at least one cycle of the internal source clock before reading TC1DRB for
the first time.
Page 83
9. 16-Bit TimerCounter 1 (TC1)
9.3 Function TMP88FW45AFG
9.3 Function
TimerCounter 1 has six types of operating modes: timer, external trigger timer, event counter, window, pulse width
measurement, programmable pulse generator output modes.
DV1CK = 0 DV1CK = 1
Example 1 :Setting the timer mode with source clock fc/211 [Hz] and generating an interrupt 1 second later
(fc = 20 MHz, CGCR<DV1CK> = “0”)
DI ; IMF= “0”
EI ; IMF= “1”
Example 2 :Auto-capture
Page 84
TMP88FW45AFG
Timer start
Source clock
Counter 0 1 2 3 4 n−1 n 0 1 2 3 4 5 6 7
TC1DRA ? n
Source clock
Capture Capture
TC1DRB ? m−1 m m+1 m+2 n−1 n n+1
ACAP1
(b) Auto-capture
Page 85
9. 16-Bit TimerCounter 1 (TC1)
9.3 Function TMP88FW45AFG
Since the TC1 pin input has the noise rejection, pulses of 4/fc [s] or less are rejected as noise. A pulse width
of 12/fc [s] or more is required to ensure edge detection.
Example 1 :Generating an interrupt 1 ms after the rising edge of the input pulse to the TC1 pin
(fc = 20 MHz, CGCR<DV1CK> = “1”)
DI ; IMF= “0”
EI ; IMF= “1”
Example 2 :Generating an interrupt when the low-level pulse with 4 ms or more width is input to the TC1 pin
(fc = 20 MHz, CGCR<DV1CK> = “1”)
DI ; IMF= “0”
EI ; IMF= “1”
Page 86
TMP88FW45AFG
At the rising
Count start Count start edge (TC1S = 10)
Source clock
Up-counter 0 1 2 3 4 n−1 n 0 1 2 3
INTTC1
interrupt request
At the rising
Count start Count clear Count start edge (TC1S = 10)
Source clock
Up-counter 0 1 2 3 m−1 m 0 1 2 3 n 0
INTTC1
interrupt request
Note: m < n
(b) Trigger start and stop (METT1 = 1)
Page 87
9. 16-Bit TimerCounter 1 (TC1)
9.3 Function TMP88FW45AFG
When a match between the up-counter and the TC1DRA value is detected, an INTTC1 interrupt is generated
and the up-counter is cleared. After being cleared, the up-counter restarts counting at each edge of the input pulse
to the TC1 pin. Since a match between the up-counter and the value set to TC1DRA is detected at the edge
opposite to the selected edge, an INTTC1 interrupt request is generated after a match of the value at the edge
opposite to the selected edge.
Two or more machine cycles are required for the low-or high-level pulse input to the TC1 pin.
Setting TC1CR<ACAP1> to “1” captures the up-counter value into TC1DRB with the auto capture function.
Use the auto-capture function in the operative condition of TC1. A captured value may not be fixed if it's read
after the execution of the timer stop or auto-capture disable. Read the capture value in a capture enabled condition.
Since the up-counter value is captured into TC1DRB by the source clock of up-counter after setting
TC1CR<ACAP1> to "1". Therefore, to read the captured value, wait at least one cycle of the internal source
clock before reading TC1DRB for the first time.
Timer start
TC1DRA ? n
High-going 23/fc
Low-going 23/fc
Page 88
TMP88FW45AFG
When a match between the up-counter and the TC1DRA value is detected, an INTTC1 interrupt is generated
and the up-counter is cleared.
Define the window pulse to the frequency which is sufficiently lower than the internal source clock programmed
with TC1CR<TC1CK>.
Timer start
TC1 pin input
Internal clock
Counter 0 1 2 3 4 5 6 7 0 1 2 3
TC1DRA ? 7
Internal clock
Counter 0 1 2 3 4 5 6 7 8 9 0 1
TC1DRA ? 9
Match detect
INTTC1
interrput request Counter
clear
(b) Negative logic (TC1S = 11)
Page 89
9. 16-Bit TimerCounter 1 (TC1)
9.3 Function TMP88FW45AFG
Note 1: The captured value must be read from TC1DRB until the next trigger edge is detected. If not read, the
captured value becomes a don’t care. It is recommended to use a 16-bit access instruction to read the
captured value from TC1DRB.
Note 2: For the single-edge capture, the counter after capturing the value stops at “1” until detecting the next edge.
Therefore, the second captured value is “1” larger than the captured value immediately after counting starts.
Note 3: The first captured value after the timer starts may be read incorrectively, therefore, ignore the first captured
value.
Page 90
TMP88FW45AFG
DI ; IMF= “0”
EI ; IMF= “1”
PINTTC1: CPL (INTTC1SW). 0 ; INTTC1 interrupt, inverts and tests INTTC1 service switch
JRS F, SINTTC1
LD W,(TC1DRBH)
RETI
LD W,(TC1DRBH)
WIDTH
HPULSE
TC1 pin
INTTC1SW
Page 91
9. 16-Bit TimerCounter 1 (TC1)
9.3 Function TMP88FW45AFG
Internal clock
Counter 0 1 2 3 4 n-1 n 0 1 2 3
Capture
TC1DRB n
INTTC1
interrupt request
[Application] High-or low-level pulse width measurement
Internal clock
INTTC1
interrupt request
[Application] (1) Cycle/frequency measurement
(2) Duty measurement
(b) Double-edge capture (MCAP1 = "0")
Page 92
TMP88FW45AFG
Since the output level of the PPG pin can be set with TC1CR<TFF1> when the timer starts, a positive or
negative pulse can be generated. Since the inverted level of the timer F/F1 output level is output to the PPG pin,
specify TC1CR<TFF1> to “0” to set the high level to the PPG pin, and “1” to set the low level to the PPG pin.
Upon reset, the timer F/F1 is initialized to “0”.
Note 1: To change TC1DRA or TC1DRB during a run of the timer, set a value sufficiently larger than the count value
of the counter. Setting a value smaller than the count value of the counter during a run of the timer may
generate a pulse different from that specified.
Note 2: Do not change TC1CR<TFF1> during a run of the timer. TC1CR<TFF1> can be set correctly only at initial-
ization (after reset). When the timer stops during PPG, TC1CR<TFF1> can not be set correctly from this
point onward if the PPG output has the level which is inverted of the level when the timer starts. (Setting
TC1CR<TFF1> specifies the timer F/F1 to the level inverted of the programmed value.) Therefore, the timer
F/F1 needs to be initialized to ensure an arbitrary level of the PPG output. To initialize the timer F/F1, change
TC1CR<TC1M> to the timer mode (it is not required to start the timer mode), and then set the PPG mode.
Set TC1CR<TFF1> at this time.
Note 3: In the PPG mode, the following relationship must be satisfied.
TC1DRA > TC1DRB
Note 4: Set TC1DRB after changing the mode of TC1M to the PPG mode.
Example :Generating a pulse which is high-going for 800 µs and low-going for 200 μs
(fc = 20 MHz, CGCR<DV1CK> = “0”)
Setting port
LD (TC1CR), 10001011B ; Sets the PPG mode, selects the source clock
LDW (TC1DRB), 00FAH ; Sets the low-level pulse width (200 μs ÷ 24/fc = 00FAH)
Page 93
9. 16-Bit TimerCounter 1 (TC1)
9.3 Function TMP88FW45AFG
Port output
I/O port output latch enable
shared with PPG output
Function output
TC1CR<TFF1> Set
Write to TC1CR
Internal reset Clear Q
TC1CR<TC1S> clear
Timer start
Internal clock
TC1DRB n
Match detect
TC1DRA m
INTTC1
interrupt request
Note: m > n
(a) Continuous pulse generation (TC1S = 01)
Count start
TC1 pin input Trigger
Internal clock
Counter 0 1 n n+1 m 0
TC1DRB n
TC1DRA m
INTTC1
interrupt request
[Application] One-shot pulse output
Note: m > n
(b) One-shot pulse generation (TC1S = 10)
Page 94
10.1
CTC1S Stop
CTC1SM
CTC1SE
CTC1CY Start Trigger clear
CTC1E control
Rising edge Start
Configuration
Falling edge
Edge detection
S
CTC pin A
Y
B
10. 16-Bit Timer (CTC)
Page 95
2 2 Read/Write control Interrupt INTCTC1
CTC1REG and interrupt
3 clear interrupt 3
CTC1CK
CTC1S Select write Select read Comparator
register register
CTC1SM
CTC1E Toggle
CTC1DRA
CTC1SE
CTC1RES
CTC1CR1
CTC1REG CTC1CK CTC1FF0
EXTRGDIS
2 3
CTC1FF0 PPGFF0
CTC1CR2
TMP88FW45AFG
10. 16-Bit Timer (CTC)
10.2 Control TMP88FW45AFG
10.2 Control
Compare timer/counter 1 is controlled using Compare timer/counter 1 Control Registers (CTC1CR1 and
CTC1CR2), as well as three 16-bit Timer Registers (CTC1DRA, CTC1DRB, and CTC1DRC).
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Write only
CTC1DRA CTC1DRAH CTC1DRAL (Initial value: ******** ********)
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Write only
CTC1DRB CTC1DRBH CTC1DRBL (Initial value: ******** ********)
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Write only
CTC1DRC CTC1DRCH CTC1DRCL (Initial value: ******** ********)
Note:CTC1DRA, CTC1DRB, and CTC1DRC are write-only registers and must not be used with any of the read-modify-
write instructions such as SET, CLR, etc.
CTC1CR1 7 6 5 4 3 2 1 0 R/W
lower address CTC1RES PPGFF0 CTC1M CTC1CY CTC1SE CTC1E CTC1SM CTC1S (Initial value: 00000000)
7 6 5 4 3 2 1 0
CTC1CR2 R/W
upper address EX- (Initial value: *0000000)
* CTC1REG CTC1CK CTC1FF0
TRGDIS
Page 96
TMP88FW45AFG
0: Software start ο ο ο
CTC1SM Select start
1: External trigger start ο × ο
0: Successive ο ο ο
CTC1CY Select cycle
1: One shot ο × ο
0: Timer/Event counter modes
CTC1M Set operation mode
1: PPG (programmable pulse generator) output mode
0: Forward output immediately after start
PPGFF0 Select PPG output
1: Reverse output immediately after start
0: Normal operation
CTC1RES Reset all
1: CTC1 reset
0: Clear
CTC1FF0 Control timer output F/F0
1: Set
NORMAL and IDLE Modes
001 fc/2 7
fc/2 8
ο − ×
110 − − × × ×
External clock input
111 - ○ ×
(CTC1 pin input)
00: CTC1DRA 1REG
Set registers used by timer/ 01: CTC1DRA + CTC1DRB 2REG
CTC1REG
counter 10: CTC1DRA + CTC1DRB + CTC1DRC 3REG
11: Reserved
0: Enable external trigger input
EXTRGDIS External trigger input Note4
1: Disable external trigger input
Page 97
10. 16-Bit Timer (CTC)
10.2 Control TMP88FW45AFG
Note 10: Specifying CTC1CR1<CTC1RES> = 1 causes all conditions to be reset. Even when the CTC circuit is operating, they are
reset, and the PPG output becomes “0”. However, only the INTCTC1 signal is not reset if the signal is being generated.
Note 11: For event counter mode (when CTC pin input is selected in timer mode), the active edge of the external trigger to count
can be selected with CTC1CR1<CTC1SE>.
Note 12: Disabling external trigger input with CTC1CR2<EXTRGDIS> creates the 0 input state.
Note 13: To stop the counter by software at trigger start, set CTC1CR2<CTC1SM, CTC1S> = 00.
Note 14: The number of registers set and the values set in the timer registers must meet the conditions shown below.
1 Register CTC1DRA ≥ 2
CTC1REG 2 Register CTC1DRB > CTC1DRA + 1, and CTC1DRA ≥ 2
3 Register CTC1DRC > CTC1DRB + 1, CTC1DRB > CTC1DRA + 1, and CTC1DRA ≥ 2
Page 98
TMP88FW45AFG
10.3 Function
Compare timer/counter 1 has three modes: timer, event counter, and programmable pulse generator output modes.
Table 10-1 Internal Clock Source for Compare Timer/Counter 1 (Example: fc = 20 MHz)
Resolution [μs] Maximum Setting Time [s] Resolution [μs] Maximum Setting Time [s]
Internal clock
Counter 0 1 2 3 n-1 n 1 2 3 4 5 6 7 8 9
Timer Register A n
INTCTC1 interrupt
Successive
Note:If the CTC input port (P47) is set for input mode, the timer/counter is reset by an input edge on port.
When using the timer/counter as an ordinary timer, set CTC1CR2<EXTRGDIS> to 1 or set P47 for output
mode.
Page 99
10. 16-Bit Timer (CTC)
10.3 Function TMP88FW45AFG
(I) When rising edge start is selected, with counting enabled on one edge
( CTC1SE = 0, CTC1E = 0 )
a) Successive
Count start Stop Count start
Internal clock
Counter 0 1 2 n-1 n 1 2 3 4 Ǿ 1 2
Clear
Timer n
Register A
INTCTC1
interrupt
Successive
b) OneShot
Count start Count start
Internal clock
Counter 0 1 2 n-1 n 0 1 2 3 4 5 6
Stop
Timer n
Register A
INTCTC1
interrupt
One Shot
Page 100
TMP88FW45AFG
(II) When rising start edge is selected, with counting enabled on both edges
( CTC1SE = 0, CTC1E = 1 )
a) Successive
Count start Count stop Count start
Internal clock
Counter 0 1 2 m 0 1 n-1 n 1 2 3
Timer n
Register A
INTCTC1
interrupt
Successive Note) m < n
b) One Shot
Count start Count start Count clear
Internal clock
2 3
Counter 0 1 2 n 0 1 2 3 4 5 0 1
Timer n
Register A
INTCTC1
interrupt
One Shot
Counter 0 1 2 n-1 n 0 1
Timer Register n
INTCTC1
interrupt
Page 101
10. 16-Bit Timer (CTC)
10.3 Function TMP88FW45AFG
Table 10-3 Internal Clock Source for Compare Timer/Counter 1 (Example: fc = 20 MHz)
Resolution [μs] Maximum Setting Time [s] Resolution [μs] Maximum Setting Time [s]
000 − − − −
001 − − − −
010 − − − −
011 − − − −
Note:When Port P47 is set as a CTC input port, an edge input resets the timer/counter. when PPG output
mode is selected and external trigger start is not used, set CTC1CR2<EXTRGDIS> to "1" or set P47 as
an output port.
Page 102
TMP88FW45AFG
Command start
Counter 0 1 n 1 n 1 n 1 n 1 2 3
Timer Register A n
INTCTC1
interrupt
Successive
a) Successive
Start Stop
CTC pin input
Internal clock
Timer Register A m
Timer Register B n
INTCTC1
interrupt
Successive
b) One shot
Start Start
CTC pin input
Internal clock
Counter 0 1 m m+1 n 0 1
Timer Register A m
Timer Register B n
INTCTC1
interrupt
One shot
Figure 10-7 Two Register One Edge Trigger Start Mode Timing Chart
Page 103
10. 16-Bit Timer (CTC)
10.3 Function TMP88FW45AFG
When set to the external trigger rising edge start and the both edges enable.
a) Successive
Start Stop Start
CTC pin input
Internal clock
Counter 0 1 m m+1 n 1 m 0 1
Timer Register A m
Timer Register B n
Initial value
PPG2 pin output
INTCTC1
interrupt
Successive
b) One shot
Start Start Start Start
Internal clock
Timer Register A m
Timer Register B n
INTCTC1
interrupt
One shot
Figure 10-8 Two Register Both edges Trigger Start Mode Timing Chart
Page 104
TMP88FW45AFG
Timer Register A m
Timer Register B n
Timer Register C s
INTCTC1
interrupt
Successive
b) One shot
Command start Command restart
CTC pin input
Timer Register A m
Timer Register B n
Timer Register C s
INTCTC1
interrupt
One shot
Note:In the single-shot mode, the PPG pin output is not toggled at the last register match; it stays at the value
specified with CTC1CR2<CTC1FF0>.
Page 105
10. 16-Bit Timer (CTC)
10.3 Function TMP88FW45AFG
Detail operation at start that varies depending on how CTC1CR2<CTC1FF0> and CTC1CR1<PPGFF0> are
set during PPG output.
PPG output
PPG output
PPG output
PPG output
By changing the port-shared output for PPG output before the counter starts counting after setting
CTC1CR2<CTC1FF0>, it is possible to determine the initial value of PPG output.
Page 106
TMP88FW45AFG
11.1 Configuration
Falling
TC3S INTTC3
Edge detector
interrupt
Rising
Port
TC3 pin Clear
(Note)
H
Source clock Overflow detect
fc/213, fc/2 14 A Y 8-bit up-counter
TC3S
fc/212, fc/2 13 B
fc/211 , fc/2 12 C
fc/210, fc/2 11 D CMP A Y
fc/2 9 , fc/210 E Match detect
fc/2 8 , fc/2 9 F B
fc/2 7 , fc/2 8 G S
S TC3DRB TC3DRA
3 Capture Capture
8-bit timer register
TC3CK
TC3M
ACAP
TC3S
TC3CR
Note:Function input may not operate depending on I/O port setting. For more details, see the chapter "I/O Port".
Page 107
11. 8-Bit TimerCounter 3 (TC3)
11.2 TimerCounter Control TMP88FW45AFG
TC3DRA 7 6 5 4 3 2 1 0
(001CH) Read/Write (Initial value: 1111 1111)
TC3DRB
(001DH) Read only (Initial value: 1111 1111)
TC3CR 7 6 5 4 3 2 1 0
(001EH) ACAP TC3S TC3CK TC3M (Initial value: *0*0 0000)
0: -
ACAP Auto capture control R/W
1: Auto capture
0: Stop and counter clear
TC3S TC3 start control R/W
1: Start
NORMAL, IDLE mode
DV1CK=0 DV1CK=1
000 fc/213
fc/214
001 fc/212 fc/213
Page 108
TMP88FW45AFG
11.3 Function
TimerCounter 3 has three types of operating modes: timer, event counter and capture modes.
Note:00H which is stored in the up-counter immediately after detection of a match is not captured into TC3DRB.
(Figure 11-2)
Clock
Up-counter C6 C7 C8 00 01
TC3DRB C6 C7 C8 01
DV1CK = 0 DV1CK = 1
Page 109
11. 8-Bit TimerCounter 3 (TC3)
11.3 Function TMP88FW45AFG
Timer start
Source clock
Counter 0 1 2 3 4 n 0 1 2 3 4 5 6 7
TC3DRA ? n
Source clock
Capture Capture
TC3DRB ? m m+1 m+2 n n+1
TC3CR<ACAP>
Page 110
TMP88FW45AFG
When a match between the up-counter and TC3DRA value is detected, an INTTC3 interrupt is generated and
up-counter is cleared. After being cleared, the up-counter restarts counting at each rising edge of the input pulse
to the TC3 pin. Since a match is detected at the falling edge of the input pulse to TC3 pin, an INTTC3 interrupt
request is generated at the falling edge immediately after the up-counter reaches the value set in TC3DRA.
The maximum applied frequencies are shown in Table 11-2. The pulse width larger than one machine cycle
is required for high-going and low-going pulses.
Setting TC3CR<ACAP> to 1 captures the up-counter value into TC3DRB with the auto-capture function. The
count value during a timer operation can be checked by the read instruction to TC3DRB.
Note:00H which is stored in the up-counter immediately after detection of a match is not captured into TC3DRB.
(Figure 11-2)
High-going 22/fc
Low-going 22/fc
Timer start
Counter 0 1 2 3 n 0 1 2 3
INTTC3 interrupt
Page 111
11. 8-Bit TimerCounter 3 (TC3)
11.3 Function TMP88FW45AFG
When the falling edge of the TC3 input is detected after the timer starts, the up-counter value is captured into
TC3DRB. Hereafter, whenever the rising edge is detected, the up-counter value is captured into TC3DRA and
the INTTC3 interrupt request is generated. The up-counter is cleared at this time. Generally, read TC3DRB and
TC3DRA during INTTC3 interrupt processing. After the up-counter is cleared, counting is continued and the
next up-counter value is captured into TC3DRB.
When the rising edge is detected immediately after the timer starts, the up-counter value is captured into
TC3DRA only, but not into TC3DRB. The INTTC3 interrupt request is generated. When the read instruction is
executed to TC3DRB at this time, the value at the completion of the last capture (FF immediately after a reset)
is read.
The minimum input pulse width must be larger than one cycle width of the source clock programmed in
TC3CR<TC3CK>.
The INTTC3 interrupt request is generated if the up-counter overflow (FFH) occurs during capture operation
before the edge is detected. TC3DRA is set to FFH and the up-counter is cleared. Counting is continued by the
up-counter, but capture operation and overflow detection are stopped until TC3DRA is read. Generally, read
TC3DRB first because capture operation and overflow detection resume by reading TC3DRA.
Timer start
TC3CR<TC3S>
Source
clock
Internal waveform
Capture Capture
TC3DRA k n FF (Overflow)
Capture Capture Capture
TC3DRB i m FE
INTTC3 Overflow
interrupt request
Read of TC3DRA
Page 112
TMP88FW45AFG
12.1 Configuration
TC4S
fc/211, fc212 A
fc/27, fc28 B
fc/25, fc26 C Source
fc/23, fc24 D Clock Clear
fc/22, fc23 E Y Overflow detect
Y 8-bit up-counter 0 Y
fc/2, fc22 F
fc, fc/2 G 1
S
㪧㫆㫋㪼
(Note) H
TC4 pin S Match
CMP
detect Timer F/F
3
TC4CK
Port
Toggle (Note)
Clear PWM4/
TC4S TC4M 0 1
S
Y PDO4/
2 pin
PWM output
TC4CR TC4DR mode TC4S
PDO mode
INTTC4
interrupt
Note: Function I/O may not operate depending on I/O port setting. For more details, see the chapter "I/O Port".
Page 113
12. 8-Bit TimerCounter 4 (TC4)
12.2 TimerCounter Control TMP88FW45AFG
TC4DR 7 6 5 4 3 2 1 0
(001BH) Read/Write (Initial value: 1111 1111)
TC4CR 7 6 5 4 3 2 1 0
(001AH) TC4S TC4CK TC4M Read/Write (Initial value: **00 0000)
DV1CK = 0 DV1CK = 1
000 fc/2 11
fc/212
001 fc/27 fc/28
101 fc/22
110 (fc)Note8
(fc/2)Note8
000 O − O −
001 O − O −
010 O − O −
TC4CK 011 O − − O
100 − − − O
101 − − − O
110 − − − O
111 − O − ×
Page 114
TMP88FW45AFG
12.3 Function
TimerCounter 4 has four types of operating modes: timer, event counter, programmable divider output (PDO), and
pulse width modulation (PWM) output modes.
DV1CK = 0 DV1CK = 1
When a match between the up-counter and the TC4DR value is detected, an INTTC4 interrupt is generated
and the up-counter is cleared. After being cleared, the up-counter restarts counting at rising edge of the TC4 pin.
Since a match is detected at the falling edge of the input pulse to the TC4 pin, the INTTC4 interrupt request is
generated at the falling edge immediately after the up-counter reaches the value set in TC4DR.
The minimum pulse width applied to the TC4 pin are shown in Table 12-2. The pulse width larger than two
machine cycles is required for high- and low-going pulses.
Note:The event counter mode can used in the NORMAL and IDLE modes only.
High-going 23/fc
Low-going 23/fc
When a match between the up-counter and the TC4DR value is detected, the logic level output from the
PDO4 pin is switched to the opposite state and INTTC4 interrupt request is generated. The up-counter is cleared
at this time and then counting is continued. When a match between the up-counter and the TC4DR value is
detected, the logic level output from the PDO4 pin is switched to the opposite state again and INTTC4 interrupt
request is generated. The up-counter is cleared at this time, and then counting and PDO are continued.
Page 115
12. 8-Bit TimerCounter 4 (TC4)
12.3 Function TMP88FW45AFG
When the timer is stopped, the PDO4 pin is high. Therefore, if the timer is stopped when the PDO4 pin is
low, the duty pulse may be shorter than the programmed value.
LD (TC4CR), 00000110B : Sets the PDO mode. (TC4M = 10, TC4CK = 001)
Internal clock
Counter 0 1 2 n 0 1 2 n 0 1 2 n 0 1 2 n 0 1
TC4DR n
Match detect
Timer F/F
PDO4 pin
INTTC4 interrupt
request
When a match between the up-counter and the TC4DR value is detected, the logic level output from the
PWM4 pin becomes low. The up-counter continues counting. When the up-counter overflow occurs, the
PWM4 pin becomes high. The INTTC4 interrupt request is generated at this time.
When the timer is stopped, the PWM4 pin is high. Therefore, if the timer is stopped when the PWM4 pin is
low, one PMW cycle may be shorter than the programmed value.
TC4DR is serially connected to the shift register. If TC4DR is programmed during PWM output, the data set
to TC4DR is not shifted until one PWM cycle is completed. Therefore, a pulse can be modulated periodically.
For the first time, the data written to TC4DR is shifted when the timer is started by setting TC4CR<TC4S> to 1.
Note 1: The PWM output mode can be used only in the NORMAL and IDEL modes.
Note 2: In the PWM output mode, program TC4DR immediately after the INTTC4 interrupt request is generated
(typically in the INTTC4 interrupt service routine.) When the programming of TC4DR and the INTTC4 interrupt
occur at the same time, an unstable value is shifted, that may result in generation of pulse different from the
programmed value until the next INTTC4 interrupt request is issued.
Page 116
TMP88FW45AFG
TC4CR<TC4S>
Internal clock
Shift register ? n m
PWM4 pin n n m
INTTC4
interrupt request
PWM cycle
DV1CK = 0 DV1CK = 1
000 - - - -
001 - - - -
010 - - - -
Page 117
12. 8-Bit TimerCounter 4 (TC4)
12.3 Function TMP88FW45AFG
Page 118
TMP88FW45AFG
13.1 Configuration
PWM mode
Overflow
INTTC6
interrupt request
fc/211, fc/212 A Clear
7
fc/2 , fc/2
8
B Y A Y 8-bit up-counter
5
fc/2 , fc/2
6
C B TC6S
3 4
fc/2 , fc/2 D S PDO, PPG mode
E A
F Toggle
16-bit mode Y
G B Q
TC6 pin H S Set
16-bit PDO6/PWM6/
S Timer, Event
mode Counter mode Clear PPG6 pin
TC6M S
TC6S TC6CK Timer F/F6
TFF6 A
Y
TC6CR B
TTREG6 PWREG6 PWM, PPG mode DecodeEN PDO, PWM,
PPG mode
TFF6
16-bit
mode
TC5S
PWM mode
INTTC5
fc/211, fc/212
Clear interrupt request
A
7 8
B Y 8-bit up-counter 16-bit mode
fc/2 , fc/2 Overflow
5
fc/2 , fc/2
6
C PDO mode
fc/23, fc/24 D
E Toggle
F
G 16-bit mode Q
TC5 pin H Timer, Set PDO5/PWM5/
S Event Couter mode pin
Clear
TC5M Timer F/F5
TC5S TC5CK
TFF5
TC5CR PWM mode
DecodeEN PDO, PWM mode
TTREG5 PWREG5 16-bit mode
TFF5
Page 119
13. 8-Bit TimerCounter 5,6(TC5, 6)
13.2 TimerCounter Control TMP88FW45AFG
TTREG5 7 6 5 4 3 2 1 0
(0022H)
(Initial value: 1111 1111)
R/W
PWREG5 7 6 5 4 3 2 1 0
(0024H)
(Initial value: 1111 1111)
R/W
Note 1: Do not change the timer register (TTREG5) setting while the timer is running.
Note 2: Do not change the timer register (PWREG5) setting in the operating mode except the 8-bit and 16-bit PWM modes while
the timer is running.
TC5CR 7 6 5 4 3 2 1 0
(0020H) TFF5 TC5CK TC5S TC5M (Initial value: 0000 0000)
0: Clear
TFF5 Time F/F5 control R/W
1: Set
NORMAL, IDLE mode
DV1CK = 0 DV1CK = 1
100 - -
101 - -
110 - -
Page 120
TMP88FW45AFG
The TimerCounter 6 is controlled by the TimerCounter 6 control register (TC6CR) and two 8-bit timer registers
(TTREG6 and PWREG6).
TTREG6 7 6 5 4 3 2 1 0
(0023H)
(Initial value: 1111 1111)
R/W
PWREG6 7 6 5 4 3 2 1 0
(0025H) R/
W (Initial value: 1111 1111)
Note 1: Do not change the timer register (TTREG6) setting while the timer is running.
Note 2: Do not change the timer register (PWREG6) setting in the operating mode except the 8-bit and 16-bit PWM modes while
the timer is running.
TC6CR 7 6 5 4 3 2 1 0
(0021H) TFF6 TC6CK TC6S TC6M (Initial value: 0000 0000)
0: Clear
TFF6 Timer F/F6 control R/W
1: Set
NORMAL, IDLE mode
DV1CK = 0 DV1CK = 1
000 fc/2 11
fc/212
001 fc/2 7
fc/28
100 - -
101 - -
110 - -
Page 121
13. 8-Bit TimerCounter 5,6(TC5, 6)
13.2 TimerCounter Control TMP88FW45AFG
Note 7: The operating clock settings are limited depending on the timer operating mode. For the detailed descriptions, see Table
13-1.
Note 8: The timer register settings are limited depending on the timer operating mode. For the detailed descriptions, see Table
13-2.
Table 13-1 Operating Mode and Selectable Source Clock (NORMAL and IDLE Modes)
TC5 TC6
Operating mode fc/211 fc/27 fc/25 fc/23
pin input pin input
8-bit timer Ο Ο Ο Ο - -
8-bit PDO Ο Ο Ο Ο - -
8-bit PWM Ο Ο Ο Ο - -
16-bit timer Ο Ο Ο Ο - -
16-bit PWM Ο Ο Ο Ο Ο -
16-bit PPG Ο Ο Ο Ο Ο -
Note 1: For 16-bit operations (16-bit timer/event counter, warm-up counter, 16-bit PWM and 16-bit PPG), set its source clock on
lower bit (TC5CK).
Note 2: Ο : Available source clock
Note:n = 5 to 6
Page 122
TMP88FW45AFG
13.3 Function
The TimerCounter 5 and 6 have the 8-bit timer, 8-bit event counter, 8-bit programmable divider output (PDO), 8-
bit pulse width modulation (PWM) output modes. The TimerCounter 5 and 6 (TC5, 6) are cascadable to form a 16-
bit timer. The 16-bit timer has the operating modes such as the 16-bit timer, 16-bit event counter, 16-bit pulse width
modulation (PWM) output and 16-bit programmable pulse generation (PPG) modes.
Example :Setting the timer mode with source clock fc/27 Hz and generating an interrupt 64 μs later
(TimerCounter6, fc = 20.0 MHz)
DI
EI
LD (TC6CR), 00010000B : Sets the operating cock to fc/27, and 8-bit timer mode.
Page 123
13. 8-Bit TimerCounter 5,6(TC5, 6)
13.3 Function TMP88FW45AFG
TC6CR<TC6S>
Internal
Source Clock
TTREG6 ? n
TC6CR<TC6S>
TTREG6 ? n
In the PDO mode, the up-counter counts up using the internal clock. When a match between the up-counter
and the TTREGj value is detected, the logic level output from the PDOj pin is switched to the opposite state and
the up-counter is cleared. The INTTCj interrupt request is generated at the time. The logic state opposite to the
timer F/Fj logic level is output from the PDOj pin. An arbitrary value can be set to the timer F/Fj by TCjCR<TFFj>.
Upon reset, the timer F/Fj value is initialized to 0.
To use the programmable divider output, set the output latch of the I/O port to 1.
Page 124
TMP88FW45AFG
Setting port
LD (TC6CR), 00010001B : Sets the operating clock to fc/27, and 8-bit PDO mode.
Note 1: In the programmable divider output mode, do not change the TTREGj setting while the timer is running. Since TTREGj
is not in the shift register configuration in the programmable divider output mode, the new value programmed in
TTREGj is in effect immediately after programming. Therefore, if TTREGi is changed while the timer is running, an
expected operation may not be obtained.
Note 2: When the timer is stopped during PDO output, the PDOj pin holds the output status when the timer is stopped. To
change the output status, program TCjCR<TFFj> after the timer is stopped. Do not change the TCjCR<TFFj> setting
upon stopping of the timer.
Example: Fixing the PDOj pin to the high level when the TimerCounter is stopped
CLR (TCjCR).3: Stops the timer.
CLR (TCjCR).7: Sets the PDOj pin to the high level.
Note 3: j = 5, 6
Page 125
13.
13.3
Function
8-Bit TimerCounter 5,6(TC5, 6)
TC6CR<TC6S>
Internal
source clock
Counter 0 1 2 n 0 1 2 n 0 1 2 n 0 1 2 n 0 1 2 3 0
Page 126
TTREG6 ? n
Match detect Match detect Match detect Match detect
Timer F/F6 Set F/F
PDO6 pin
When a match between the up-counter and the PWREGj value is detected, the logic level output from the timer
F/Fj is switched to the opposite state. The counter continues counting. The logic level output from the timer F/
Fj is switched to the opposite state again by the up-counter overflow, and the counter is cleared. The INTTCj
interrupt request is generated at this time.
Since the initial value can be set to the timer F/Fj by TCjCR<TFFj>, positive and negative pulses can be
generated. Upon reset, the timer F/Fj is cleared to 0.
(The logic level output from the PWMj pin is the opposite to the timer F/Fj logic level.)
Since PWREGj in the PWM mode is serially connected to the shift register, the value set to PWREGj can be
changed while the timer is running. The value set to PWREGj during a run of the timer is shifted by the INTTCj
interrupt request and loaded into PWREGj. While the timer is stopped, the value is shifted immediately after the
programming of PWREGj. If executing the read instruction to PWREGj during PWM output, the value in the
shift register is read, but not the value set in PWREGj. Therefore, after writing to PWREGj, the reading data of
PWREGj is previous value until INTTCj is generated.
For the pin used for PWM output, the output latch of the I/O port must be set to 1.
Note 1: In the PWM mode, program the timer register PWREGj immediately after the INTTCj interrupt request is
generated (normally in the INTTCj interrupt service routine.) If the programming of PWREGj and the interrupt
request occur at the same time, an unstable value is shifted, that may result in generation of the pulse different
from the programmed value until the next INTTCj interrupt request is generated.
Note 2: When the timer is stopped during PWM output, the PWMj pin holds the output status when the timer is
stopped. To change the output status, program TCjCR<TFFj> after the timer is stopped. Do not change the
TCjCR<TFFj> upon stopping of the timer.
Example: Fixing the PWMj pin to the high level when the TimerCounter is stopped
CLR (TCjCR).3: Stops the timer.
CLR (TCjCR).7: Sets the PWMj pin to the high level.
Note 3: To enter the STOP mode during PWM output, stop the timer and then enter the STOP mode. If the STOP
mode is entered without stopping the timer when fc or fc/2 is selected as the source clock, a pulse is output
from the PWMj pin during the warm-up period time after exiting the STOP mode.
Note 4: j = 5, 6
Page 127
13.
13.3
Function
8-Bit TimerCounter 5,6(TC5, 6)
TC6CR<TC6S>
TC6CR<TFF6>
Internal
source clock
Page 128
Shift Shift Shift Shift
Shift registar ? n m p
Match detect Match detect Match detect Match detect
Timer F/F6
PWM6 pin
n n m p
When a match between the up-counter and the timer register (TTREG5, TTREG6) value is detected after the
timer is started by setting TC6CR<TC6S> to 1, an INTTC6 interrupt is generated and the up-counter is cleared.
After being cleared, the up-counter continues counting. Program the lower byte and upper byte in this order in
the timer register. (Programming only the upper or lower byte should not be attempted.)
Note 1: In the timer mode, fix TCjCR<TFFj> to 0. If not fixed, the PDOj, PWMj, and PPGj pins may output a pulse.
Note 2: In the timer mode, do not change the TTREGj setting while the timer is running. Since TTREGj is not in the
shift register configuration in the timer mode, the new value programmed in TTREGj is in effect immediately
after programming of TTREGj. Therefore, if TTREGj is changed while the timer is running, an expected
operation may not be obtained.
Note 3: j = 5, 6
Example :Setting the timer mode with source clock fc/27 [Hz], and generating an interrupt 240 ms later
(fc = 20.0 MHz)
LDW (TTREG5), 927CH : Sets the timer register (300 ms ÷ 27/fc = 927CH).
DI
EI
(TC5CR), 13H :Sets the operating cock to fc/27, and 16-bit timer mode
LD
(lower byte).
Page 129
13. 8-Bit TimerCounter 5,6(TC5, 6)
13.3 Function TMP88FW45AFG
TC6CR<TC6S>
Internal
source clock
TTREG5 ? n
(Lower byte)
TTREG6 ? m
(Upper byte)
Match Counter Match Counter
detect clear detect clear
INTTC6 interrupt request
Figure 13-6 16-Bit Timer Mode Timing Chart (TC5 and TC6)
When a match between the up-counter and the timer register (TTREG5, TTREG6) value is detected after the
timer is started by setting TC6CR<TC6S> to 1, an INTTC6 interrupt is generated and the up-counter is cleared.
After being cleared, the up-counter restarts counting at the falling edge of the input pulse to the TC5 pin. Two
machine cycles are required for the low- or high-level pulse input to the TC5 pin.
Therefore, a maximum frequency to be supplied is fc/24 Hz in the NORMAL or IDLE mode. Program the
lower byte (TTREG5), and upper byte (TTREG6) in this order in the timer register. (Programming only the upper
or lower byte should not be attempted.)
Note 1: In the event counter mode, fix TCjCR<TFFj> to 0. If not fixed, the PDOj, PWMj and PPGj pins may output
pulses.
Note 2: In the event counter mode, do not change the TTREGj setting while the timer is running. Since TTREGj is
not in the shift register configuration in the event counter mode, the new value programmed in TTREGj is in
effect immediately after the programming. Therefore, if TTREGj is changed while the timer is running, an
expected operation may not be obtained.
Note 3: j = 5, 6
13.3.7 16-Bit Pulse Width Modulation (PWM) Output Mode (TC5 and 6)
This mode is used to generate a pulse-width modulated (PWM) signals with up to 16 bits of resolution. The
TimerCounter 5 and 6 are cascadable to form the 16-bit PWM signal generator.
When a match between the up-counter and the timer register (PWREG5, PWREG6) value is detected, the logic
level output from the timer F/F6 is switched to the opposite state. The counter continues counting. The logic level
output from the timer F/F6 is switched to the opposite state again by the counter overflow, and the counter is
cleared. The INTTC6 interrupt is generated at this time.
Two machine cycles are required for the high- or low-level pulse input to the TC5 pin. Therefore, a maximum
frequency to be supplied is fc/24 Hz in the NORMAL1 or IDLE1 mode.
Since the initial value can be set to the timer F/F6 by TC6CR<TFF6>, positive and negative pulses can be
generated. Upon reset, the timer F/F6 is cleared to 0.
(The logic level output from the PWM6 pin is the opposite to the timer F/F6 logic level.)
Since PWREG6 and 5 in the PWM mode are serially connected to the shift register, the values set to PWREG6
and 5 can be changed while the timer is running. The values set to PWREG6 and 5 during a run of the timer are
Page 130
TMP88FW45AFG
shifted by the INTTCj interrupt request and loaded into PWREG6 and 5. While the timer is stopped, the values
are shifted immediately after the programming of PWREG6 and 5. Set the lower byte (PWREG5) and upper byte
(PWREG5) in this order to program PWREG6 and 5. (Programming only the lower or upper byte of the register
should not be attempted.)
If executing the read instruction to PWREG6 and 5 during PWM output, the values set in the shift register is
read, but not the values set in PWREG6 and 5. Therefore, after writing to the PWREG6 and 5, reading data of
PWREG6 and 5 is previous value until INTTC6 is generated.
For the pin used for PWM output, the output latch of the I/O port must be set to 1.
Note 1: In the PWM mode, program the timer register PWREG6 and 5 immediately after the INTTC6 interrupt request
is generated (normally in the INTTC6 interrupt service routine.) If the programming of PWREGj and the
interrupt request occur at the same time, an unstable value is shifted, that may result in generation of pulse
different from the programmed value until the next INTTC6 interrupt request is generated.
Note 2: When the timer is stopped during PWM output, the PWM6 pin holds the output status when the timer is
stopped. To change the output status, program TC6CR<TFF6> after the timer is stopped. Do not program
TC6CR<TFF6> upon stopping of the timer.
Example: Fixing thePWM6 pin to the high level when the TimerCounter is stopped
CLR (TC6CR).3: Stops the timer.
CLR (TC6CR).7 : Sets the PWM6 pin to the high level.
Note 3: To enter the STOP mode, stop the timer and then enter the STOP mode. If the STOP mode is entered without
stopping of the timer when fc or fc/2 is selected as the source clock, a pulse is output from the PWM6 pin
during the warm-up period time after exiting the STOP mode.
Example :Generating a pulse with 1-ms high-level width and a period of 32.768 ms (fc = 20.0 MHz)
Setting ports
(TC5CR), 33H : Sets the operating clock to fc/23, and 16-bit PWM output
LD
mode (lower byte).
(TC6CR), 056H : Sets TFF6 to the initial value 0, and 16-bit PWM signal
LD
generation mode (upper byte).
Page 131
13.
13.3
Function
8-Bit TimerCounter 5,6(TC5, 6)
TC6CR<TC6S>
TC6CR<TFF6>
Internal
source clock
Page 132
(Upper byte) ? a b c
Shift Shift Shift Shift
16-bit ? an bm cp
shift register
Match detect Match detect Match detect Match detect
Timer F/F6
PWM6 pin an cp
an bm
Figure 13-7 16-Bit PWM Mode Timing Chart (TC5 and TC6)
TMP88FW45AFG
TMP88FW45AFG
13.3.8 16-Bit Programmable Pulse Generate (PPG) Output Mode (TC5 and 6)
This mode is used to generate pulses with up to 16-bits of resolution. The timer counter 5 and 6 are cascadable
to enter the 16-bit PPG mode.
The counter counts up using the internal clock or external clock. When a match between the up-counter and
the timer register (PWREG5, PWREG6) value is detected, the logic level output from the timer F/F6 is switched
to the opposite state. The counter continues counting. The logic level output from the timer F/F6 is switched to
the opposite state again when a match between the up-counter and the timer register (TTREG5, TTREG6) value
is detected, and the counter is cleared. The INTTC6 interrupt is generated at this time.
Since the initial value can be set to the timer F/F6 by TC6CR<TFF6>, positive and negative pulses can be
generated. Upon reset, the timer F/F6 is cleared to 0.
(The logic level output from the PPG6 pin is the opposite to the timer F/F6.)
Set the lower byte and upper byte in this order to program the timer register. (TTREG5 → TTREG6, PWREG5
→ PWREG6) (Programming only the upper or lower byte should not be attempted.)
For PPG output, set the output latch of the I/O port to 1.
Example :Generating a pulse with 1-ms high-level width and a period of 16.385 ms (fc = 20.0 MHz)
Setting ports
Note 1: In the PPG mode, do not change the PWREGi and TTREGi settings while the timer is running. Since PWREGi and
TTREGi are not in the shift register configuration in the PPG mode, the new values programmed in PWREGi and
TTREGi are in effect immediately after programming PWREGi and TTREGi. Therefore, if PWREGi and TTREGi are
changed while the timer is running, an expected operation may not be obtained.
Note 2: When the timer is stopped during PPG output, the PPG6 pin holds the output status when the timer is stopped. To
change the output status, program TC6CR<TFF6> after the timer is stopped. Do not change TC6CR<TFF6> upon
stopping of the timer.
Example: Fixing the PPG6 pin to the high level when the TimerCounter is stopped
CLR (TC6CR).3: Stops the timer
CLR (TC6CR).7: Sets the PPG6 pin to the high level
Note 3: i = 5, 6
Page 133
13.
13.3
Function
8-Bit TimerCounter 5,6(TC5, 6)
TC6CR<TC6S>
Internal
source clock
PWREG5
(Lower byte) ? n
PWREG6
(Upper byte) ? m
Page 134
Match detect Match detect Match detect
TTREG5
(Lower byte) ? r
TTREG6
(Upper byte) ? q
Match detect Match detect F/F clear
Timer F/F6
Held at the level when the timer
stops
PPG6 pin
mn mn mn
Figure 13-8 16-Bit PPG Mode Timing Chart (TC5 and TC60)
TMP88FW45AFG
TMP88FW45AFG
The TMP88FW45AFG contains two channels of motor control circuits used for sinusoidal waveform output. This
motor control circuit can control brushless DC motors or AC motors with or without sensors. With its primary functions
like those listed below incorporated in hardware, it helps to accomplish sine wave motor control easily, with the
software load significantly reduced.
Page 135
14. Motor Control Circuit (PMD: Programmable motor driver)
14.1 Outline of Motor Control TMP88FW45AFG
For brushless DC motors, the number of revolutions is controlled by an applied voltage, and the voltage application
is controlled by PWM. At this time, the current on windings need to be changed in synchronism with the phases of
the voltage induced by revolutions. Control timing in cases where the current on windings are changed by means of
sensorless control is illustrated in Figure 14-4. For three-phase motors, zero-crossing occurs six times during one cycle
of the induced voltage (electrical angle 360 degrees), so that the electrical angle from one zero-cross point to the next
is 60 degrees. Assuming that this period comprises one mode, the rotor position can be divided into six modes by zero-
cross points. The six current application patterns shown above correspond one for one to these six modes. The timing
at which the current application patterns are changed (commutation) is out of phase by 30 degrees of electrical angle,
with respect to the position detection by an induced voltage.
Mode time is obtained by detecting a zero-cross point at some timing and finding an elapsed time from the preceding
zero-cross point. Because mode time corresponds to 60 degrees of electrical angle, the following applies for the case
illustrated in Figure 14-4.
Timings are calculated in this way. The position detection start timing in 2 is needed to prevent erroneous detection
of the induced voltage for reasons that even after current application is turned off, the current continues flowing due
to the motor reactance.
Control is exercised by calculating the above timings successively for each of the zero-cross points detected six
times during 360 degrees of electrical angle and activating commutation, position detection start, and other operations
according to that timing.
In this way, operations can be synchronized to the phases of the induced voltage of the motor.
The timing needed for motor control as in this example can be set freely as desired by using the internal timers of
the microcontroller’s PMD unit.
Page 136
TMP88FW45AFG
Also, sine wave control requires controlling the PWM duty cycle for each pulse. Control of PWM duty cycles is
accomplished by counting degrees of electrical angle and calculating the sine wave data and voltage data at the counted
degree of electrical angle.
DC current
MCU
PMD circuit U, V, W, X, Y, Z
Three-phase PWM Power drive
Protective control CL, EMG Upper phase: u, v, w
Speed control Lower phase: x, y, z
Error handling, Position detection
etc. Electrical angle timer
Waveform calculation PDU, PDV, PDW
DC motor
$ # % & ' (
!
"
)$
&$
'(
#%$
Page 137
14. Motor Control Circuit (PMD: Programmable motor driver)
14.2 Configuration of the Motor Control Circuit TMP88FW45AFG
!
Note 1: Always use the LDW instruction to set data in the 9, 12 and 16-bit data registers.
Note 2: The EMG circuit initially is enabled. For PMD output, fix the EMG input port (P36 and P51) "H" high level or disable the
EMG circuit before using for PMD output.
Note 3: The EMG circuit initially is enabled. When using Port P3 and P5 as input/output IO ports, disable EMG.
Note 4: When going to STOP mode, be sure to turn all of the PMD functions off before entering STOP mode.
Page 138
TMP88FW45AFG
For three-phase brushless DC motors, there are six patterns of position signals, one for each mode, as summarized
in Table 14-2 from the timing chart in Figure 14-2. Once a predicted position signal pattern is set in the MDOUT
register, a position detection interrupt is generated the moment the position signal input port goes to mode indicated
by this expected value. The position signals at each phase in the diagram are internal signals which cannot be observed
from the outside.
Position
U Phase (PDU) V Phase (PDV) W Phase (PDW)
Detection Mode
Mode 0 H L H
Mode 1 H L L
Mode 2 H H L
Mode 3 L H L
Mode 4 L H H
Mode 5 L L H
Page 139
14. Motor Control Circuit (PMD: Programmable motor driver)
14.3 Position Detection Unit TMP88FW45AFG
!#
- '+ + - - - - )& (
!#
!
! & &
"
' & (
&
$#
#
$## %
-+ ,+ -+
+ %+ + .+ / 1+ , -+ %+ + .+ / 1+ ,+ -+ % . /
'* 2 0
& &
・ The position detection unit is controlled by the Position Detection Control Register (PDCRA, PDCRB).
After the position detection function is enabled, the unit starts sampling the position detection port with
Timer 2 or in software. For the case of ordinary mode, when the status of the position detection input
port matches the expected value of the PMD Output Register, the unit generates a position detection
interrupt and finishes sampling, waiting for start of the next sampling.
・ When unmatch detection mode is selected for position detection, the unit stores the sampled status of
the position detection port in memory at the time it started sampling. When the port input status changes
from the status in which it was at start of sampling, an interrupt is generated.
・ In unmatch detection mode, the port status at start of sampling can be read (PDCRC<PDTCT>).
・ When starting and stopping position detection synchronously with the timer, position detection is started
by Timer 2 and position detection is stopped by Timer 3.
・ Sampling mode can be selected from three modes available: mode where sampling is performed only
while PWM is on, mode where sensors such as Hall elements are sampled regularly, and mode where
sampling is performed while the lower side is conducting current (when performing sampling only
while PWM is on, DUTY must be set for all three phases in common).
・ When sampling mode is selected for detecting position while the lower phases are conducting current,
sampling is performed for a period from when the set sampling delay time has elapsed after the lower
side started conducting current till when the current application is turned off. Sampling is performed
independently at each phase, and the sampling result is retained while sampling is idle. If while sampling
at some phase is idle, the input and the expected value at other phase being sampled match, position is
detected and an interrupt is generated.
Page 140
TMP88FW45AFG
・ A sampling delay is provided for use in modes where sampling is made while PWM is on or the lower
phases are conducting current. It helps to prevent erroneous detection due to noise that occurs imme-
diately after the transistor turns on, by starting sampling a set time after the PWM signal turned on.
・ When detecting position while PWM is on or the lower phases are conducting current, a method can
be selected whether to recount occurrences of matched position detection after being compared for each
PWM signal on (logical sum of three-phase PWM signals) (e.g., starting from 0 in each PWM cycle)
or counting occurrences of matching continuously ( PDCRB<SPLMD> is used to enable/disable re-
counting occurrences of matching while PWM is on).
PDCRC
Hold result of position detec- These bits hold the comparison result of position detection at falling or rising edge of PWM
tion at PWM edge pulse. Bits 5 and 4 are set to 1 when position is detected at the falling or the rising edge,
5, 4 EMEM
(Detect position detected po- respectively. They show whether position is detected in the current PWM pulse, during
sition) PWM off, or in the immediately preceding PWM pulse.
3 SMON Monitor sampling status When read, this bit shows the sampling status.
Hold position signal input sta- This bit holds the status of the position signal input at the time position detection started in
2 to 0 PDTCT
tus unmatch mode.
PDCRB
7, 6 SPLCK Sampling period Select fc/22, fc/23, fc/24, or fc/25 for the position detection sampling period.
Select one of three modes: sampling only when PWM signal is active (when PWM is on),
5, 4 SPLMD Sampling mode sampling regularly, or sampling when the lower side (X, Y, Z) phases are conducting cur-
rent.
In ordinary mode, when the port status and the set expected value match and continuously
match as many times as the sampling counts set, a position detection signal is output and
3 to 0 PDCMP Sampling count an interrupt is generated. In unmatch detection mode, when the said status and value do
not match and continuously unmatch as many times as the sampling counts set, a position
detection signal is output and an interrupt is generated.
PDCRA
Sampling can be stopped in software by setting this bit to 1 (e.g., by writing to this register).
7 SWSTP Stop sampling in software Sampling is performed before stopping and when position detection results match, a po-
sition detection interrupt is generated, with sampling thereby stopped.
6 SWSTT Start sampling in software Sampling can be started by setting this bit to 1 (e.g., by writing to this register).
Sampling can be stopped by a trigger from Timer 3 by setting this bit to 1.
5 SPTM3 Stop sampling using Timer 3 Sampling is performed before stopping and when position detection results match, a po-
sition detection interrupt is generated, with sampling thereby stopped.
4 STTM2 Start sampling using Timer 2 Sampling can be started by a trigger from Timer 3 by setting this bit to 1.
Select whether to use three pins (PDU/PDV/PDW) or one pin (PDU only) for position signal
Number of position signal in- input. When one pin is selected, the expected values of PDV and PDW are ignored. When
3 PDNUM
put pins performing position detection with two pins or a pin other than PDU, position signal input
can be masked as 0 by setting unused pin(s) for output.
When performing sampling while PWM is on, occurrences of matching are recounted each
Recount occurrences of time PWM signal turns on by setting this bit to 1 (when recounting occurrences of matching,
2 RCEN
matching when PWM is on the count is reset each time PWM turns off). When this bit is set to 0, occurrences of
matching are counted continuously regardless PWM interval.
Setting this bit to 0 selects ordinary mode where position is detected when the expected
value set in the register and the port input unmatch and then match.
1 DTMD Position detection mode Setting this bit to 1 selects unmatch detection mode where position is detected at the time
the port status changes to another one from the status in which it was when sampling
started.
0 PDCEN Position detection function The position detection function is activated by setting this bit to 1.
SDREG
Set a time for which to stop sampling in order to prevent erroneous detection due to noise
6 to 0 SDREG Sampling delay that occurs immediately after PWM output turns on (immediately after the transistor turns
on). (Figure 14-5)
Page 141
14. Motor Control Circuit (PMD: Programmable motor driver)
14.3 Position Detection Unit TMP88FW45AFG
!"# $
$#%
& "#
& "# "'
& "#
Figure 14-5 Position Detection Sampling Timing with the PWMON Period Selected
! "#
% & "
)
) ))
'(
'**
+ , $
& " #
) )
) ) ))
) )
$
Page 142
TMP88FW45AFG
PDCRC 7 6 5 4 3 2 1 0
PDCRB 7 6 5 4 3 2 1 0
Note:When changing setting, keep the PDCEN bit reset to “0” (disable position detection function).
PDCRA 7 6 5 4 3 2 1 0
(01FA0H) SWSTP SWSTT SPTM3 STTM2 PDNUM RCEN DTMD PDCEN (Initial value: 0000 0000)
(01FD0H)
0: No operation
7 SWSTP Stop sampling in software
1: Stop sampling
W
0: No operation
6 SWSTT Start sampling in software
1: Start sampling
0: Disable
5 SPTM3 Stop sampling using Timer 3
1: Enable
0: Disable
4 STTM2 Start sampling using Timer 2
1: Enable
Page 143
14. Motor Control Circuit (PMD: Programmable motor driver)
14.3 Position Detection Unit TMP88FW45AFG
Note:Read-modify-write instructions, such as a bit manipulation instruction, cannot access the PDCRA because it
contains a write only bit.
Page 144
TMP88FW45AFG
SDREG 7 6 5 4 3 2 1 0
Note:When changing setting, keep the PDCEN bit reset to “0” (disable position detection function).
Software Hardware
Set mode
pattern
MDOUT
Write expected (E, D, C) INTTMR2
value Start position Timer unit
detection
Sample position
signal input
Match with No
expected value?
Yes
Increment
matching counts
Specified No
count reached?
Yes
Interrupt INTPDC Generate INTPDC
handling interrupt
Page 145
14. Motor Control Circuit (PMD: Programmable motor driver)
14.4 Timer Unit TMP88FW45AFG
. '
. '
/
. ' !"#
/
The timer unit has an up counter (mode timer) which is cleared by a position detection interrupt (INTPDC). Using
this counter, it can generate three types of timer interrupts (INTTMR1 to 3). These timer interrupts may be used to
produce a commutation trigger, position detection start trigger, etc. Also, the mode timer has a capture function which
automatically captures register data in synchronism with position detection or overload protection. This capture func-
tion allows motor revolutions to be calculated by measuring position detection intervals.
Page 146
TMP88FW45AFG
・ The mode timer can be reset by a signal from the position detection circuit, Timer 3, or overload
protective circuit. If the mode timer overflows without being reset, it stops at FFFFH and sets an
overflow flag in the control register.
・ The value of the mode timer during counting can be read by capturing the count in software and reading
the capture register.
・ Timer 1 and Timers 2 and 3 generate an interrupt signal by magnitude comparison and matching com-
parison, respectively. Therefore, Timer 1 can generate an interrupt signal even when it could not write
to the compare register in time and the counter value at the time of writing happens to exceed the
register’s set value.
・ When any one of Timers 1 to 3 interrupts occurs, the next interrupts can be enabled by writing a new
value to the respective compare registers (CMP1, CMP2, CMP3).
・ When capturing by position detection is enabled, the capture register has the timer value captured in it
each time position is detected. In this way, the capture register always holds the latest value.
Page 147
14. Motor Control Circuit (PMD: Programmable motor driver)
14.4 Timer Unit TMP88FW45AFG
MTCRB
Debug output can be produced by setting this bit to 1. Because interrupt signals to the
interrupt control circuit are used for each interrupt, hardware debugging without software
7 DBOUT Debug output
delays are possible. See the debug output diagram (Figure 14-8). Output ports: P67 for
PMD1, P77 for PMD2.
5 TMOF Mode timer overflow This bit shows that the timer has overflowed.
Capture mode timer by over- When this bit is set to 1, the timer value can be captured using the overload protection
3 CLCP
load protection signal (CL) as a trigger.
Capture mode timer in soft- When this bit is set to 1, the timer value can be captured in software
2 SWCP
ware (e.g., by writing to this register).
Capture mode timer by posi- When this bit is set to 1, the timer value can be captured using the position detection signal
1 PDCCP
tion detection as a trigger.
MTCRA
CMP1 Timer 1 (commutation) Timers 1 to 3 are enabled while the mode timer is operating. An interrupt can be generated
once by setting the corresponding bit in this register. The interrupt is disable when an in-
CMP2 Timer 2 (position detection start)
terrupt is generated or the timer is reset. To use the timer again, set the register back again
CMP3 Timer 3 (overflow) even if data is same.
Page 148
TMP88FW45AFG
MTCRB 7 6 5 4 3 2 1 0
(01FA5H) DBOUT - TMOF - CLCP SWCP PDCCP - (Initial value: 0*0*0 000*)
(01FD5H)
0: Disable
7 DBOUT Debug output R/W
1: Enable (P67 for PMD1, P77 for PMD2)
0: No overflow
5 TMOF Mode timer overflow R
1: Overflowed
Note:Read-modify-write instructions, such as a bit manipulation instruction, cannot access the MTCRB because it
contains a write-only bit.
MTCRA 7 6 5 4 3 2 1 0
(01FA4H) TMCK RBTM3 RBCL SWRES RBPDC TMEN (Initial value: 0000 0000)
(01FD4H)
111: Reserved
0: Disable
4 RBTM3 Reset mode timer from Timer 3
1: Enable
Note 1: When changing MTCRA<TMCK> setting, keep the MTCRA<TMEN> bit reset to “0” (disable mode timer).
Note 2: Read-modify-write instructions, such as a bit manipulation instruction, cannot access the MTCRA because it contains a
write-only bit.
Page 149
14. Motor Control Circuit (PMD: Programmable motor driver)
14.4 Timer Unit TMP88FW45AFG
MCAP F E D C B A 9 8 7 6 5 4 3 2 1 0
(01FA7H, 01FA6H) (Initial value: 0000 0000 0000
DF DE DD DC DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0000)
(01FD7H, 01FD6H)
CMP1 F E D C B A 9 8 7 6 5 4 3 2 1 0
(01FA9H, 01FA8H) (Initial value: 0000 0000 0000
DF DE DD DC DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0000)
(01FD9H, 01FD8H)
CMP2 F E D C B A 9 8 7 6 5 4 3 2 1 0
(01FABH, 01FAAH) (Initial value: 0000 0000 0000
DF DE DD DC DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0000)
(01FDBH, 01FDAH)
CMP3 F E D C B A 9 8 7 6 5 4 3 2 1 0
(01FADH, 01FACH) (Initial value: 0000 0000 0000
DF DE DD DC DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 0000)
(01FDDH, 01FDCH)
Note:Read-modify-write instructions, such as a bit manipulation instruction, cannot access the MTCRB or MTCRA
register because these registers contain write-only bits.
Page 150
TMP88FW45AFG
$ % $
!
)
&
´ ' ¯
´ '(
´
# #
)
*
+
"
)
$
*
"
"
$
)
)
Page 151
14. Motor Control Circuit (PMD: Programmable motor driver)
14.5 Three-phase PWM Output Unit TMP88FW45AFG
For the PWM output pin (U,V,W,X,Y,Z), set the port register PxDR and PxCR (x = 3,5) to 1. The PWM output
initially is set to be active low, so that if the output needs to be used active high, set up the MDCRA Register accord-
ingly.
This circuit produces three-phase independent PWM waveforms with an equal PWM frequency. For PWM
waveform mode, triangular wave modulation or sawtooth wave modulation can be selected by using the PMD
Control Register (MDCRA) bit 1. The PWM frequency is set by using the PMD Period Register (MDPRD).
The following shows the relationship between the value of this register and the PWM counter clock set by
the MDCRB Register, PWMCK.
The PMD Period Register (MDPRD) is comprised of dual-buffers, so that CMPU, V, W Register is updated
with PWM period.
When the waveform arithmetic circuit is operating, the PWM waveform output unit receives calculation
results from the waveform arithmetic circuit and by using the results as CMPU, V, W Register set value, it
outputs independent three-phase PWM waveforms. When the waveform calculation function is enabled by
the waveform arithmetic circuit and transfer of calculation results into the CMPU to W Registers is enabled
(with EDCRA Register bit 2), the CMPU to W Registers are disabled against writing.
When the waveform calculation function is enabled (with EDCRA Register bit 1) and transfer of calculation
results into the CMPU, V, W Registers is disabled (with EDCRA Register bit 4), the calculation results are
transferred to the buffers of CMPU, V, W Registers, but not output to the port.
Read-accessing the CMPU, V, and W registers can read the calculation results of the waveform arithmetic
circuit that have been input to a buffer. After changing the read calculation result data by software, writing
the changed data to the CMPU, V, and W registers enables an arbitrary waveform other than a sinusoidal
wave to be output. When the registers are read after writing, the values written to the registers are read out if
accessed before the calculation results are transferred after calculation is finished.
Page 152
TMP88FW45AFG
The values of the PWM Compare Registers (CMPU/V/W) and the carrier wave generated by the PWM
Counter (MDCNT) are compared for the relative magnitude by the comparator to produce PWM waveforms.
The PWM Counter is a 12-bit up/down counter with a 100 ns (at fc = 20 MHz) resolution.
For three-phase output control, two methods of generating three-phase PWM waveforms can be set.
1. Three-phase independent mode: Values are set independently in the three-phase PMD Compare
Registers to produce three-phase independent PWM waveforms. This method may be used to
produce sinusoidal or any other desired drive waveforms.
2. Three-phase common mode: A value is set in only the U-phase PMD Compare Register to produce
three in-phase PWM waveforms using the U phase set value. This method may be used for DC
motor square wave drive.
The three-phase PMD Compare Registers each have a comparison register to comprise a dual-buffer struc-
ture. The values of the PMD Compare Registers are loaded into their respective comparison registers
synchronously with PWM period.
Page 153
14. Motor Control Circuit (PMD: Programmable motor driver)
14.5 Three-phase PWM Output Unit TMP88FW45AFG
Output ports are controlled depending on the contents set in the PMD Output Register (MDOUT). The
contents set in this register are divided into two, one for selecting the synchronizing signal for port output,
and one for setting up port output. The synchronizing signal can be selected from Timers 1 or 2, position
detection signal, or without sync. Port output can be synchronized to this synchronizing signal before being
further synchronized to the PWM signal sync. The MDOUT Register's synchronizing signal select bit becomes
effective immediately after writing. Other bits are dual-buffered, and are updated by the selected synchro-
nizing signal.
Example: Commutation timing for one timer period with PWM synchronization specified
INTTMR
PWM
Commutation
Output on six ports can be set to be active high or active low independently of each other by using the
MDCRA Register bits 5 and 4. Furthermore, the U, V, and W phases can individually be selected between
PWM output and H/L output by using the MDOUT Register bits A to 8 and 5 to 0. When PWM output is
selected, PWM waveforms are output; when H/L output is selected, a waveform which is fixed high or low
is output. The MDOUT Register bits E to C set the expected position signal value for the position detection
circuit.
PWM interrupt
PWM
INTPWM
control
PWM synchronizing clock
Up/Down
PWM counter
MDCNT
fc/2
MDCRB Stop MDCNT
B to 0
1 to 0
Clock selector
Selector/
Latch
PMD period register
MDPRD Selector/
B to 0
Latch
PWMW
CMPW Buffer W
B to 0
Page 154
TMP88FW45AFG
3 2 6
PWM synchronizing clock S
fc/4 Selector
S Gate Latch
Position detection
interrupt INTPDC control
Selector
Timer 1 interrupt INTTMR1 Set
Timer 2 interrupt INTTMR2
Reset
MDOUT sync
u
PWMU
x
v
PWMV
y
w
PWMW
z
fc/8 ON delay
circuit U
u' X
x'
ON delay
circuit V
v' Y
y'
ON delay
circuit W
w' Z
z'
Page 155
14. Motor Control Circuit (PMD: Programmable motor driver)
14.5 Three-phase PWM Output Unit TMP88FW45AFG
MDCRB
Page 156
TMP88FW45AFG
MDCRA
When this bit is set to 1, INTPWM is generated every half period (at triangular wave peak
7 HLFINT Select half-period interrupt and valley) in the case of center PWM output and PINT = 00. In other cases, this setting
has no meaning.
Select whether to set the duty cycle independently for three phases using the CMPU to W
6 DTYMD DUTY mode
Registers or in common for all three phases by setting the CMPU Register only.
Select the upper-phase output port polarity. Make sure the waveform synthesis function
5 POLH Upper-phase port polarity
(MDCRA Register bit 0) is idle before selecting this port polarity.
Select the lower-phase output port polarity. Make sure the waveform synthesis function
4 POLL Lower-phase port polarity
(MDCRA Register bit 0) is idle before selecting this port polarity.
Select the frequency at which to generate a PWM interrupt from four choices available:
3, 2 PINT PWM interrupt frequency every PWM period or once every 2, 4, or 8 PWM periods. When setting of this bit is altered
while operating, an interrupt may be generated at the time the bit is altered.
Select PWM mode. PWM mode 0 is an edge PWM (sawtooth wave), and PWM mode 1 is
1 PWMMD PWM mode
a center PWM (triangular wave).
Enable/Disable waveform When enabling this circuit (for waveform output), be sure to set the output port polarity and
0 PWMEN
generation circuit other bits of this register (other than MDCRA bit 0) beforehand.
DTR
DTR Dead time Set the dead time between the upper-phase and lower-phase outputs.
MDOUT
This bit indicates whether the PWM counter is counting up or down. When edge PWM
F UPDWN PWM counter flag
(sawtooth wave) is selected, it is always set to 0.
Set the data to be compared with the position detection input port. The comparison data is
adopted as the expected value simultaneously when port output sync settings made with
E, D, C PDEXP Mode compare register MDOUT are reflected in the ports.
(This is the expected position detection input value for the output set with MDOUT next
time.)
Select whether or not to synchronize port output to PWM period after being synchronized
to the synchronizing signal selected with SYNCS. If selected to be synchronized to PWM,
B PSYNC Select PWM synchronization output is kept waiting for the next PWM after being synchronized with SYNCS. Waveform
settings are overwritten if new settings are written to the register during this time, and output
is generated with those settings.
A WPWM
Control UVW-phase PWM
9 VPWM Set U, V, and W-phase port outputs. (See the Table 14-3)
outputs
8 UPWM
Select the synchronizing signal with which to output UVW-phase settings to ports. The
synchronizing signal can be selected from Timers 1 or 2, position detection, or asynchro-
7, 6 SYNCS Select port output sync signal
nous. Select asynchronous when the initial setting, otherwise the above setting isn’t
reflected immediately.
5, 4 WOC
3, 2 VOC Control UVW-phase outputs Set U, V, and W-phase port outputs. (See the Table 14-3)
1, 0 UOC
MDCNT PWM counter This is a 12-bit read-only register used to count PWM periods.
This register determines PWM period, and is dual-buffered, allowing PWM period to be
altered even while the PWM counter is operating. The buffers are loaded every PWM pe-
MDPRD Set PWM period
riod. When 100 ns is selected for the PWM counter clock, make sure the least significant
bit is set to 0.
CMPU This comparison register determines the pulse widths output in the respective UVW pha-
CMPV Set PWM pulse width ses. This register is dual-buffered, and the pulse widths are determined by comparing the
CMPW buffer and PWM counter.
Page 157
14. Motor Control Circuit (PMD: Programmable motor driver)
14.5 Three-phase PWM Output Unit TMP88FW45AFG
MDCRB 7 6 5 4 3 2 1 0
Note:When changing setting, keep the PWMEN bit reset to “0” (disable wave form synthesis function).
MDCRA 7 6 5 4 3 2 1 0
(01FAEH) HLFINT DTYMD POLH POLL PINT PWMMD PWMEN (Initial value: 0000 0000)
(01FDEH)
DTR 7 6 5 4 3 2 1 0
Note:When changing setting, keep the MDCRA<PWMEN> bit reset to "0" (disable wave form synthesis function).
Page 158
TMP88FW45AFG
MDOUT F E D C B A 9 8
(01FB3H, UPDWN PDEXP PSYNC WPWM VPWM UPWM
01FB2H)
7 6 5 4 3 2 1 0
(01FE3H,
01FE2H) SYNCS WOC VOC UOC (Initial value: 00000000 00000000)
0: Counting up
F UPDWN PWM counter flag R
1: Counting down
bit E: W-phase expected value
Comparison register for position
E, D, C PDEXP bit D: V-phase expected value
detection
bit C: U-phase expected value
0: Asynchronous
B PSYNC Select PWM synchronization
1: Synchronized
0: H/L level output
A WPWM W-phase PWM output
1: PWM waveform output
0: H/L level output
9 VPWM V-phase PWM output
1: PWM waveform output
R/W
0: H/L level output
8 UPWM U-phase PWM output
1: PWM waveform output
00: Asynchronous
Select port output 01: Synchronized to position detection
7, 6 SYNCS
synchronizing signal 10: Synchronized to Timer 1
11: Synchronized to Timer 2
5, 4 WOC Control W-phase output
14.5.3 Port output as set with UOC/VOC/WOC bits and UPWM/VPWM/WPWM bits
U-phase output polarity: Active high U-phase output polarity: Active low
(POLH,POLL = 1) (POLH,POLL = 0)
UPWM UPWM
UOC 1: PWM output 0: H/L level output UOC 1: PWM output 0: H/L level output
01 L PWM L H 01 H PWM H L
10 PWM L H L 10 PWM H L H
Page 159
14. Motor Control Circuit (PMD: Programmable motor driver)
14.5 Three-phase PWM Output Unit TMP88FW45AFG
F E D C B A 9 8 7 6 5 4 3 2 1 0
MDCNT
(Initial value:
(01FB5H, 01FB4H) - - - - DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 ****000000000000)
(01FE5H, 01FE4H)
F E D C B A 9 8 7 6 5 4 3 2 1 0
MDPRD
(Initial value:
(01FB7H, 01FB6H) - - - - DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 ****000000000000)
(01FE7H, 01FE6H)
F E D C B A 9 8 7 6 5 4 3 2 1 0
CMPU
(Initial value:
(01FB9H, 01FB8H) - - - - DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 ****000000000000)
(01FE9H, 01FE8H)
F E D C B A 9 8 7 6 5 4 3 2 1 0
CMPV
(Initial value:
(01FBBH, 01FBAH) - - - - DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 ****000000000000)
(01FEBH, 01FEAH)
F E D C B A 9 8 7 6 5 4 3 2 1 0
CMPW
(Initial value:
(01FBDH, 01FBCH) - - - - DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 ****000000000000)
(01FEDH, 01FECH)
Page 160
TMP88FW45AFG
2 4 4 2
EMG disable code register
Under EMGREL MDOUT
prote- 7, 6, 5, 4, 3, 2, 1, 0 A to 0
CL detection ction
Overload protective input CL 8 Set "0"
u u'
x x'
v v'
y y'
w w'
z z'
Page 161
14. Motor Control Circuit (PMD: Programmable motor driver)
14.5 Three-phase PWM Output Unit TMP88FW45AFG
The number of times the overload protective input is sampled can be set by using the EMG-
CRA<CLCNT>. The sampling times can be set in the range of 1 to 15 times at 200 ns period (when fc
= 20 MHz). If a low level is detected as many times as the specified number, overload protection is
assumed.
The output disabled phases during overload protection are set by using the EMGCRB<CLMD>. This
facility allows selecting to disable no phases, all phases, PWM phases, or all upper phases/all lower
phases. When selected to disable all upper phases/all lower phases, port output is determined by their
turn-on status immediately before being disabled. When two or more upper phases are active, all upper
phases are turned on and all lower phases are turned off; when two or more lower phases are active, all
upper phases are turned off and all lower phases are turned on.
When output phase are cut off, output is inactive (low in the case of high active). When the overload
protective circuit is disabled, overload protective interrupts (INTCLM) are not generated.
I (Current)
Overload protection
setting current
t (time)
Input EMG pin
Input CL pin
PWM output
("H" active)
Overload protection EMG protection
(Output cut off) (High-Z output)
Page 162
TMP88FW45AFG
The EMG protective circuit is disable from the disabled state by writing “5AH“ and “A5H“
EMGREL EMG disable
to this register in that order. After that, the EMGCRA Register needs to be set.
EMGCRB
When this bit is set to 1, the motor control circuit is returned from overload protective state
Return from overload protec- in software (e.g., by writing to this register). Also, the current state can be known by reading
7 RTCL
tive state this bit. MDOUT outputs at return from the overload protective state remain as set before
the overload protective input was driven active.
When this bit is set to 1, the motor control circuit is returned from overload protective state
6 RTPWM Return by PWM sync
by PWM sync. If RTCL is set to 1, RTCL has priority.
When this bit is set to 1, the motor control circuit is returned from overload protective state
5 RTTM1 Return by timer sync
by Timer 1 sync. If RTCL is set to 1, RTCL has priority.
4 CLST Overload protective state The status of overload protection can be known by reading this bit.
Select the phases to be disabled against output during overload protection. This facility
Select output disabled phases
3, 2 CLMD allows selecting to disable no phases, all phases, PWM phases, or all upper phases/all
during overload protection
lower phases.
Stop counter during overload
1 CNTST Can stop the PWM counter during overload protection.
protection
Enable/Disable overload pro-
0 CLEN Enable or disable the overload protective function.
tection
EMGCRA
EMGREL 7 6 5 4 3 2 1 0
7 to 0 EMGREL EMG disable Can disable by writing 5AH and then A5H. W
Note:Read-modify-write instructions, such as a bit manipulation instruction, cannot access the EMGREL register be-
cause this register is write only.
Page 163
14. Motor Control Circuit (PMD: Programmable motor driver)
14.5 Three-phase PWM Output Unit TMP88FW45AFG
EMGCRB 7 6 5 4 3 2 1 0
(01FB1H) RTCL RTPWM RTTM1 CLST CLMD CNTST CLEN (Initial value: 0000 0000)
(01FE1H)
0: No operation
4 CLST Overload protective state R
1: Under protection
00: No phases disabled against output
Select output disabled phases 01: All phases disabled against output
3, 2 CLMD
during overload protection 10: PWM phases disabled against output
11: All upper/All lower phases disabled against output (Note)
R/W
Stop PWM counter during over- 0: Do not stop
1 CNTST
load protection 1: Stop the counter
Note:If during overload protection the port output state in two or more upper phases is on, all lower phases are disabled
and all upper phases are enabled for output; when two or more lower phases are on, all upper phases are disabled
and all lower phases are enabled for output.
EMGCRA 7 6 5 4 3 2 1 0
Note 1: An instruction specifying a return from the EMG state is invalid if the EMG input is “L”.
Note 2: Read-modify-write instructions, such as a bit manipulation instruction, cannot access the EMGCRB or EMGCRA register
because these registers contain write-only bits.
Page 164
TMP88FW45AFG
$%
! #! &! "! ! '! ! ! (
# - "! -! -! -! - . - -
+ , (
)*
-
Page 165
14. Motor Control Circuit (PMD: Programmable motor driver)
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit TMP88FW45AFG
The Waveform Arithmetic Circuit has a sine wave data table, which is used to extract sine wave data based
on the electrical angle data received from the Electrical Angle Timer. This sine wave data is multiplied by the
value of the Voltage Amplitude Register. For 2-phase modulation, the product obtained by this multiplication is
presented to the waveform synthesis circuit. For 3-phase modulation, waveform data is further calculated based
on the product of multiplication and the electrical angle data and the value of the PWM Period Register. The
calculation is performed each time the Electrical Angle Timer finishes counting or when a value is set in the
Electrical Angle Register, and the calculation results consisting of the U phase, the V phase (+120 degrees), and
the W phase (+240 degrees) are sequentially presented to the PWM waveform output circuit. The sine wave data
table is stored in the RAM and requires initialization.
・ To correct the period, set the number of times ‘n’ to be corrected in the Period Correction Register
(EDSET Register F to C bits). The period is corrected by adding 1 to electrical angle counts 16 for ‘n’
times. For example, when a value 3 is set in the Period Correction Register, the period for 13 times out
of electrical angle counts 16 is the value “mH” set in the Period Set Register, and that for 3 times is “m
+ 1H”. (Correction is made almost at equal intervals.)
・ Because the electrical angle counter (ELDEG) can be accessed even while the Electrical Angle Timer
is operating, the electrical angles can be corrected during operation.
・ The Electrical Angle Capture EDCAP captures the electrical angle value from the Electrical Angle
Counter at the time the position is detected.
・ When the waveform calculation function is enabled, waveform calculation is performed each time the
electrical angle counter (ELDEG) are accessed for write or the Electrical Angle Timer finishes counting.
・ The calculation is performed in 35 machine cycle of execution time, or 7 μs (at 20 MHz).
・ When transfer of calculation result to the CMP Registers is enabled (EDCRA<RWREN>), the calcu-
lation results are transferred to the CMPU to W Registers. (This applies only when the waveform
calculation function is enabled with the EDCRA<CALCEN>.) The CMPU to W Registers are disabled
against write while the transfer remains enabled. The calculation results can be read from the CMPU
to W Registers while the waveform calculation function remains enabled.
・ The calculated results can be modified and the modified data can be set in the CMPU to W Registers
in software. This makes it possible to output any desired waveform other than sine waves.
If a transfer (EDCRA register bit 2) of the calculated results to the CMP register is disabled, read-
accessing the CMPU to W registers can read the calculated results. (Before read-accessing these
registers, make sure that the calculation is completed.)
・ To initialize the entire RAM data of the sine wave data table, set the addresses at which to set, sequen-
tially from 000H to 17FH, in the ELDEG Register, and write waveform data to the WFMDR Register
each time. Make sure the Waveform Arithmetic Circuit is disabled when writing this data.
Note 1: The value set in the Period Set Register (EDSET Register EDT bits) must be equal to or greater than 010H.
Any value smaller than this is assumed to be 010H.
Note 2: The sine wave data that is read consists of the U phase, the V phase whose electrical angle is +120 degrees
relative to the U phase, and the W phase whose electrical angle is +240 degrees relative to the U phase.
Note 3: If a period corresponding to an electrical angle of one degree is shorter than the required calculation time,
the previously calculated results are used.
Page 166
TMP88FW45AFG
14.6.1.1 Functions of the Electrical Angle Timer and Waveform Arithmetic Circuit Registers
EDCRB
Forcefully start calculation. When this bit is written while the waveform arithmetic circuit is
3 CALCST Start calculation by software
calculating, the calculation is terminated and then newly started.
2 CALCBSY Calculation flag By reading this bit, the operation status of the waveform arithmetic circuit can be obtained.
Enable/disable calculation Select whether to start calculation when the electrical angle timer finishes counting or when
1 EDCALEN start synchronized with elec- a value is set in the electrical angle register. When disabled, calculation is only started when
trical angle CALCST is set to 1.
Set the electrical angle interrupt signal request timing to either when the electrical angle
0 EDISEL Electrical angle interrupt
timer finishes counting or upon end of calculation.
EDCRA
EDSET
Correct the period by adding 1 to electrical angle counts 16 for “n” times. The timer counts
F to C EDTH Correct electrical angle period
the electrical angle period set value “m”’for (16 − n) times and counts (m + 1) for “n” times
B to 0 EDT Electrical angle period Set the electrical angle period.
Read the electrical angle. This register can also be set to initialize or correct the angle while
ELDEG Electrical angle
counting. Any value greater than 17FH cannot be set.
Set the voltage amplitude. The waveform arithmetic circuit multiplies the data set here by
AMP Set voltage amplitude the sine wave data read out from the sine wave RAM. The amplitude has its upper limit
determined by the set value of the MDPRD register when performing this multiplication.
EDCAP Capture electrical angle Capture the value from the electrical angle timer when the position is detected.
To initialize the entire RAM data of the sine wave table, set the addresses at which to set,
sequentially from 000H to 17FH, in the ELDEG register, and write waveform data to the
WFMDR Set sine wave data
WFMDR register each time. Make sure the waveform arithmetic circuit is disabled when
writing this data.
Page 167
14. Motor Control Circuit (PMD: Programmable motor driver)
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit TMP88FW45AFG
! !! "# "$
! ! " % % '
! !! "# "$
! ! " % % '
Note:During 3-phase modulation, the sign changes at 180 degrees of electrical angle.
List of the Electrical Angle Timer and Waveform Arithmetic Circuit Registers [Addresses (PMD1 and PMD2)]
EDCRB 7 6 5 4 3 2 1 0
0: No operation
3 CALCST Start calculation by software W
1: Start calculation
0: Waveform Arithmetic Circuit stopped
2 CALCBSY Calculation flag R
1: Waveform Arithmetic Circuit calculating
Enable/disable calculation start 0: Start calculation insync with electrical angle
1 EDCALEN synchronized with electrical an-
gle 1: Do not calculation insync with electrical angle
R/W
0: Interrupt when the Electrical Angle Timer finishes counting
0 EDISEL Electrical angle interrupt
1: Interrupt upon end of calculation
Note:Read-modify-write instructions, such as a bit manipulation instruction, cannot access the EDCRB register be-
cause this register is write only.
Page 168
TMP88FW45AFG
EDCRA 7 6 5 4 3 2 1 0
(01FC0H) EDCNT EDRV EDCK C2PEN RWREN CALCEN EDTEN (Initial value: 0000 0000)
(01FF0H)
0: Count up
7 EDCNT Electrical angle count up/down
1: Count down
0: V = U + 120°, W = U + 240°
6 EDRV Select V-, W-phase
1: V = U − 120°, W = U − 240°
00: fc/23 (400 ns at 20 MHz)
01: fc/24 (800 ns at 20 MHz)
5, 4 EDCK Select clock
10: fc/25 (1.6 μs at 20 MHz)
11: fc/26 (3.2 μs at 20 MHz)
R/W
Switch between 2-/3-phase 0: 2-phase modulation
3 C2PEN
modulations 1: 3-phase modulation
Note:When changing the EDCRA<EDCK> setting, keep the EDCRA<EDTEN> bit reset “0” (Disable electrical angle
timer).
F E D C B A 9 8 7 6 5 4 3 2 1 0
EDSET
(Initial value: 00000000
(01FC3H, 01FC2H) EDTH EDT 00010000)
(01FF3H, 01FF2H)
One period of the Electrical Angle Timer, T, is expressed by the equation below.
Page 169
14. Motor Control Circuit (PMD: Programmable motor driver)
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit TMP88FW45AFG
ELDEG F E D C B A 9 8 7 6 5 4 3 2 1 0
(01FC5H, 01FC4H)
- - - - - - - D8 D7 D6 D5 D4 D3 D2 D1 D0 (Initial value: *******0 00000000)
(01FF5H, 01FF4H)
8 to 0 ELDEG Electrical angle Set the Initially and the count values of electrical angle. R/W
AMP F E D C B A 9 8 7 6 5 4 3 2 1 0
(01FC7H, 01FC6H) (Initial value: ****0000
- - - - DB DA D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 00000000)
(01FF7H, 01FF6H)
B to 0 AMP Set voltage Set the voltage to be used during waveform calculation. R/W
EDCAP F E D C B A 9 8 7 6 5 4 3 2 1 0
(01FC9H, 01FC8H)
- - - - - - - D8 D7 D6 D5 D4 D3 D2 D1 D0 (Initial value: ******0 00000000)
(01FF9H, 01FF8H)
WFMDR 7 6 5 4 3 2 1 0
7 to 0 WFMDR Sine wave data Write sine wave data to RAM of sine wave W
Note:Read-modify-write instructions, such as a bit manipulation instruction, cannot access the WFMDR register be-
cause this register is write only.
Page 170
TMP88FW45AFG
PMD1 Input/Output Pins (P3, P4) and Port Input/Output Control Registers (P3CR, P4CR)
PMD2 Input/Output Pins (P5, P1) and Port Input/Output Control Registers (P5CR, P1CR)
Note:When using these pins as PMD function or input port, set the Output Latch (P*DR) to 1.
CL1 Input * 0 - -
EMG1 Input * 0 - -
U1 Output 1 1 - -
PDU1 Input - - * 0
CL2 Input * 0 - -
EMG2 Input * 0 - -
U2 Output 1 1 - -
PDU2 Input - - * 0
Page 171
14. Motor Control Circuit (PMD: Programmable motor driver)
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit TMP88FW45AFG
(2) Motor Control Circuit Control Registers [Address Upper Stage: PMD1, Lower Stage:
PMD2]
Position Detection Control Register (PDCR) and Sampling Delay Register (SDREG)
Page 172
TMP88FW45AFG
Mode Timer Control Register (MTCR), Mode Capture Register (MCAP), and Compare Registers
(CMP1, CMP2, CMP3)
Debug output.
7 R/W 0: Disable
1: Enable (P67 for PMD1, P77 for PMD2)
Mode timer overflow.
5 R 0: No overflow
1: Overflowed occurred
Capture mode timer by overload protection.
01FA5H
MTCRB 3 R/W 0: Disable
01FD5H
1: Enable
Capture mode timer by software.
2 W 0: No operation
1: Capture
Capture mode timer by position detection.
1 R/W 0: Disable
1: Enable
Select clock for mode timer [Hz].
000: fc/23 (400 ns at 20 MHz)
010: fc/24 (800 ns at 20 MHz)
100: fc/25 (1.6 μs at 20 MHz)
7, 6, 5 R/W 110: fc/26 (3.2 μs at 20 MHz)
001: fc/27 (6.4 μs at 20 MHz)
011: Reserved
101: Reserved
111: Reserved
Reset timer by Timer 3.
4 R/W 0: Disable
01FA4H 1: Enable
MTCRA
01FD4H Reset timer by overload protection.
3 R/W 0: Disable
1: Enable
Reset timer by software.
2 W 0: No operation
1: Reset
Reset timer by position detection.
1 R/W 0: Disable
1: Enable
Enable/Disable mode timer.
0 R/W 0: Disable
1: Enable (timer starts)
01FA7H, 01FA6H
MCAP F to 0 R Mode capture register.
01FD7H, 01FD6H
01FA9H, 01FA8H
CMP1 F to 0 R/W Compare Register 1.
01FD9H, 01FD8H
01FABH, 01FAAH
CMP2 F to 0 R/W Compare Register 2.
01FDBH, 01FDAH
01FADH, 01FACH
CMP3 F to 0 R/W Compare Register 3.
01FDDH, 01FDCH
Page 173
14. Motor Control Circuit (PMD: Programmable motor driver)
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit TMP88FW45AFG
PMD Control Register (MDCR), Dead Time Register (DTR), and PMD Output Register (MDOUT)
Page 174
TMP88FW45AFG
PWM Counter (MDCNT), PMD Period Register (MDPRD), and PMD Compare Registers (CMPU,
CMPV, CMPW)
01FB5H, 01FB4H
MDCNT B to 0 R Read the PWM period counter value.
01FE5H, 01FE4H
01FB7H, 01FB6H
MDPRD B to 0 R/W PWM period MDPRD ≥ 010H.
01FE7H, 01FE6H
01FB9H, 01FB8H
CMPU B to 0 R/W Set U-phase PWM duty cycle.
01FE9H, 01FE8H
01FBBH, 01FBAH
CMPV B to 0 R/W Set V-phase PWM duty cycle.
01FEBH, 01FEAH
01FBDH, 01FBCH
CMPW B to 0 R/W Set W-phase PWM duty cycle.
01FEDH, 01FECH
EMG Disable Code Register (EMGREL) and EMG Control Register (EMGCR)
Page 175
14. Motor Control Circuit (PMD: Programmable motor driver)
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit TMP88FW45AFG
0 R/W 1: Enable
(This circuit initially is enabled (= 1). To disable this circuit, make sure
key code 5AH and A5H are written to the EMGREL1 Register before-
hand.)
Page 176
TMP88FW45AFG
Electrical Angle Control Register (EDCR), Electrical Angle Period Register (EDSET), Electrical
Angle Set Register (ELDEG), Voltage Set Register (AMP), and Electrical Angle Capture Register
(EDCAP).
0: No operation
3 W
1: Start calculation
0: Waveform Arithmetic Circuit stopped
2 R
01FC1H 1: Waveform Arithmetic Circuit calculation
EDCRB
01FF1H 0: Start calculation insync with electrical angle
1 R/W
1: Do not calculation insync with electrical angle
0: Interrupt when the Electrical Angle Timer finishes counting
0 R/W
1: Interrupt upon end of calculation
0: Count up
7 R/W
1: Count down
0: V = U + 120°, W = U + 240°
6 R/W
1: V = U − 120°, W = U − 240°
Select clock.
5, 4 R/W 00: fc/23 01: fc/24
10: fc/25 11: fc/26
Switch between 2/3-phase modulations.
3 R/W 0: Two-phase modulation
01FC0H
EDCRA 1: Three-phase modulation
01FF0H
Transfer calculation result to CMP registers.
2 R/W 0: Disable
1: Enable
Enable/disable waveform calculation function.
1 R/W 0: Disable
1: Enable
Electrical angle timer.
0 R/W 0: Disable
1: Enable
Page 177
14. Motor Control Circuit (PMD: Programmable motor driver)
14.6 Electrical Angle Timer and Waveform Arithmetic Circuit TMP88FW45AFG
Page 178
TMP88FW45AFG
The TMP88FW45AFG has a asynchronous serial interface (UART) . It can connect the peripheral circuits through
TXD and RXD pin. TXD and RXD pin are also used as the general port. For TXD pin, the corresponding general port
should be set output mode (Set its output control register to "1" after its output port latch to "1"). For RXD pin, should
be set input mode.
The asynchronous serial interface (UART1) can select the connection pin with the peripheral circuits. RXD1 and
TXD1 are correspond to P44 and P45 pins, RXD2 and TXD2 are to P00 and P01 pins. But the synchronous serial
interface (SIO) also use P44 and P45 pins, therefore these P44 and P45 are not available for UART when SIO is on
working.
15.1 Configuration
3 2
2
Receive control circuit
Shift register
Transmit control circuit
Parity bit
Shift register
Stop bit
INTTXD Noise rejection
M RXD1
circuit
P
X RXD2
Page 179
15. Asynchronous Serial interface (UART1)
15.2 Control TMP88FW45AFG
15.2 Control
UART1 is controlled by the UART1 Control Registers (UARTCR1, UARTCR2). The operating status can be
monitored using the UART status register (UARTSR).
TXD pin and RXD pin can be selected a port assignment by UART Pin Select Register (UARTSEL).
UARTCR1 7 6 5 4 3 2 1 0
(01F91H) TXE RXE STBT EVEN PE BRG (Initial value: 0000 0000)
0: Disable
TXE Transfer operation
1: Enable
0: Disable
RXE Receive operation
1: Enable
0: 1 bit
STBT Transmit stop bit length
1: 2 bits
0: Odd-numbered parity
EVEN Even-numbered parity
1: Even-numbered parity
0: No parity Write
PE Parity addition only
1: Parity
000: fc/13 [Hz]
001: fc/26
010: fc/52
011: fc/104
BRG Transmit clock select
100: fc/208
101: fc/416
110: Input INTTC4
111: fc/96
Note 1: When operations are disabled by setting UARTCR1<TXE and RXE> bits to “0”, the setting becomes valid when data
transmit or receive complete. When the transmit data is stored in the transmit data buffer, the data are not transmitted.
Even if data transmit is enabled, until new data are written to the transmit data buffer, the current data are not transmitted.
Note 2: The transmit clock and the parity are common to transmit and receive.
Note 3: UARTCR1<RXE> and UARTCR1<TXE> should be set to “0” before UARTCR1<BRG> is changed.
Note 4: In case fc = 20MHz, the timer counter 4 (TC4) is available as a baud rate generator.
UARTCR2 7 6 5 4 3 2 1 0
(01F92H) RXDNC STOPBR (Initial value: **** *000)
Note 1: Settings of RXDNC are limited depending on the transfer clock specified by BRG. The combination "Ο" is available but
please do not select the combination "-". The transfer clock is calculated by the following equation : Transfer clock [Hz]
=INTTC4 sourcec clock [Hz] ÷ TC4DR set value
Page 180
TMP88FW45AFG
RXDNC setting
Transfer clock 01 10 11
BRG setting 00
[Hz]
(Reject pulses shorter (Reject pulses shorter (Reject pulses shorter
(No noise rejection)
than 31/fc[s] as noise) than 63/fc[s] as noise) than 127/fc[s] as noise)
000 fc/13 Ο Ο Ο -
110 fc/8 Ο - - -
(When the transfer clock gen- fc/16 Ο Ο - -
erated by timer/counter inter-
rupt is the same as the right
fc/32 Ο Ο Ο -
side column)
The setting except the above Ο Ο Ο Ο
UARTSR 7 6 5 4 3 2 1 0
(01F91H) PERR FERR OERR RBFL TEND TBEP (Initial value: 0000 11**)
0: No parity error
PERR Parity error flag
1: Parity error
0: No framing error
FERR Framing error flag
1: Framing error
0: No overrun error
OERR Overrun error flag
1: Overrun error Read
0: Receive data buffer empty only
RBFL Receive data buffer full flag
1: Receive data buffer full
0: On transmitting
TEND Transmit end flag
1: Transmit end
0: Transmit data buffer full (Transmit data writing is finished)
TBEP Transmit data buffer empty flag
1: Transmit data buffer empty
Page 181
15. Asynchronous Serial interface (UART1)
15.2 Control TMP88FW45AFG
7 6 5 4 3 2 1 0
UARTSEL
TXD RXD
(01F90H) (Initial value: **** **00)
SEL SEL
0: RXD1
RXDSEL RXD connect pin select
1: RXD2
R/W
0: TXD1
TXDSEL TXD connect pin select
1: TXD2
Page 182
TMP88FW45AFG
Frame Length
PE STBT
1 2 3 8 9 10 11 12
Note:In order to switch the transfer data format, perform transmit operations in the above Figure 15-3 sequence except
for the initial setting.
Page 183
15. Asynchronous Serial interface (UART1)
15.4 Transfer Rate TMP88FW45AFG
Source Clock
BRG
16 MHz 8 MHz
When INTTC4 is used as the UART1 transfer rate (when UARTCR1<BRG> = “110”), the transfer clock and transfer
rate are determined as follows:
Transfer clock [Hz] = TC4 source clock [Hz] / TC4DR setting value
RT0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11
RT clock
RT0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11
RT clock
Page 184
TMP88FW45AFG
15.7 Parity
Set parity / no parity by UARTCR1<PE> and set parity type (Odd- or Even-numbered) by UARTCR1<EVEN>.
While UARTCR1<TXE> = “0” and from when “1” is written to UARTCR1<TXE> to when send data are
written to TDBUF, the TXD pin is fixed at high level. When transmitting data, first read UARTSR, then write
data in TDBUF. Otherwise, UARTSR<TBEP> is not zero-cleared and transmit does not start.
If an overrun error (OERR) occurs when data are received, the data are not transferred to RDBUF (Receive
data buffer) but discarded; data in the RDBUF are not affected.
Note:When a receive operation is disabled by setting UARTCR1<RXE> bit to “0”, the setting becomes valid
when data receive is completed. However, if a framing error occurs in data receive, the receive-disabling
setting may not become valid. If a framing error occurs, be sure to perform a re-receive operation.
Page 185
15. Asynchronous Serial interface (UART1)
15.9 Status Flag TMP88FW45AFG
INTRXD interrupt
INTRXD interrupt
Page 186
TMP88FW45AFG
UARTSR<RBFL>
RDBUF yyyy
INTRXD interrupt
Note:Receive operations are disabled until the overrun error flag UARTSR<OERR> is cleared.
INTRXD interrupt
Note:If the overrun error flag UARTSR<OERR> is set during the period between reading the UARTSR and
reading the RDBUF, it cannot be cleared by only reading the RDBUF. Therefore, after reading the
RDBUF, read the UARTSR again to check whether or not the overrun error flag which should have been
cleared still remains set.
Page 187
15. Asynchronous Serial interface (UART1)
15.9 Status Flag TMP88FW45AFG
UARTSR<TBEP>
UARTSR<TBEP>
UARTSR<TEND>
INTTXD interrupt
Figure 15-10 Generation of Transmit End Flag and Transmit Data Buffer Empty
Page 188
TMP88FW45AFG
The TMP88FW45AFG has a asynchronous serial interface (UART) . It can connect the peripheral circuits through
TXD and RXD pin. TXD and RXD pin are also used as the general port. For TXD pin, the corresponding general port
should be set output mode (Set its output control register to "1" after its output port latch to "1"). For RXD pin, should
be set input mode.
RXD3 and TXD3 are correspond to P81 and P80 pins as the connection pins with the peripheral circuits in the
asynchronous serial interface (UART2).
16.1 Configuration
3 2
2
Receive control circuit
Shift register
Transmit control circuit
Parity bit
Shift register
Stop bit
INTTXD2 Noise rejection
circuit RXD3
TXD3
INTRXD2
Transmit/receive clock
Y
M A fc/26
7
P B fc/2
S X C fc/2
8
fc/13 A S
fc/26 B
fc/52 C 2 4
fc/104 D Y Counter 2
fc/208 E UARTSR2 UARTCR22
fc/416 F
INTTC4 G UART status register UART control register 2
fc/96 H MPX: Multiplexer
Baud rate generator
Page 189
16. Asynchronous Serial interface (UART2)
16.2 Control TMP88FW45AFG
16.2 Control
UART2 is controlled by the UART2 Control Registers (UARTCR21, UARTCR22). The operating status can be
monitored using the UART status register (UARTSR2).
UARTCR21 7 6 5 4 3 2 1 0
(01F70H) TXE RXE STBT EVEN PE BRG (Initial value: 0000 0000)
0: Disable
TXE Transfer operation
1: Enable
0: Disable
RXE Receive operation
1: Enable
0: 1 bit
STBT Transmit stop bit length
1: 2 bits
0: Odd-numbered parity
EVEN Even-numbered parity
1: Even-numbered parity
0: No parity Write
PE Parity addition only
1: Parity
000: fc/13 [Hz]
001: fc/26
010: fc/52
011: fc/104
BRG Transmit clock select
100: fc/208
101: fc/416
110: Input INTTC4
111: fc/96
Note 1: When operations are disabled by setting UARTCR21<TXE and RXE> bits to “0”, the setting becomes valid when data
transmit or receive complete. When the transmit data is stored in the transmit data buffer, the data are not transmitted.
Even if data transmit is enabled, until new data are written to the transmit data buffer, the current data are not transmitted.
Note 2: The transmit clock and the parity are common to transmit and receive.
Note 3: UARTCR21<RXE> and UARTCR21<TXE> should be set to “0” before UARTCR21<BRG> is changed.
Note 4: In case fc = 20MHz, the timer counter 4 (TC4) is available as a baud rate generator.
UARTCR22 7 6 5 4 3 2 1 0
(01F71H) RXDNC STOPBR (Initial value: **** *000)
Note 1: Settings of RXDNC are limited depending on the transfer clock specified by BRG. The combination "Ο" is available but
please do not select the combination "-". The transfer clock is calculated by the following equation : Transfer clock [Hz]
=INTTC4 sourcec clock [Hz] ÷ TC4DR set value
Page 190
TMP88FW45AFG
RXDNC setting
Transfer clock 01 10 11
BRG setting 00
[Hz]
(Reject pulses shorter (Reject pulses shorter (Reject pulses shorter
(No noise rejection)
than 31/fc[s] as noise) than 63/fc[s] as noise) than 127/fc[s] as noise)
000 fc/13 Ο Ο Ο -
110 fc/8 Ο - - -
(When the transfer clock gen- fc/16 Ο Ο - -
erated by timer/counter inter-
rupt is the same as the right
fc/32 Ο Ο Ο -
side column)
The setting except the above Ο Ο Ο Ο
UARTSR2 7 6 5 4 3 2 1 0
(01F70H) PERR FERR OERR RBFL TEND TBEP (Initial value: 0000 11**)
0: No parity error
PERR Parity error flag
1: Parity error
0: No framing error
FERR Framing error flag
1: Framing error
0: No overrun error
OERR Overrun error flag
1: Overrun error Read
0: Receive data buffer empty only
RBFL Receive data buffer full flag
1: Receive data buffer full
0: On transmitting
TEND Transmit end flag
1: Transmit end
0: Transmit data buffer full (Transmit data writing is finished)
TBEP Transmit data buffer empty flag
1: Transmit data buffer empty
Page 191
16. Asynchronous Serial interface (UART2)
16.3 Transfer Data Format TMP88FW45AFG
Frame Length
PE STBT
1 2 3 8 9 10 11 12
Note:In order to switch the transfer data format, perform transmit operations in the above Figure 16-3 sequence except
for the initial setting.
Page 192
TMP88FW45AFG
Source Clock
BRG
16 MHz 8 MHz
When INTTC4 is used as the UART2 transfer rate (when UARTCR21<BRG> = “110”), the transfer clock and
transfer rate are determined as follows:
Transfer clock [Hz] = TC4 source clock [Hz] / TC4DR setting value
RT0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11
RT clock
RT0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 8 9 10 11
RT clock
Page 193
16. Asynchronous Serial interface (UART2)
16.6 STOP Bit Length TMP88FW45AFG
16.7 Parity
Set parity / no parity by UARTCR21<PE> and set parity type (Odd- or Even-numbered) by UARTCR21<EVEN>.
While UARTCR21<TXE> = “0” and from when “1” is written to UARTCR21<TXE> to when send data are
written to TDBUF2, the TXD pin is fixed at high level. When transmitting data, first read UARTSR2, then write
data in TDBUF2. Otherwise, UARTSR2<TBEP> is not zero-cleared and transmit does not start.
If an overrun error (OERR) occurs when data are received, the data are not transferred to RDBUF2 (Receive
data buffer) but discarded; data in the RDBUF2 are not affected.
Note:When a receive operation is disabled by setting UARTCR21<RXE> bit to “0”, the setting becomes valid
when data receive is completed. However, if a framing error occurs in data receive, the receive-disabling
setting may not become valid. If a framing error occurs, be sure to perform a re-receive operation.
Page 194
TMP88FW45AFG
INTRXD interrupt
INTRXD interrupt
Page 195
16. Asynchronous Serial interface (UART2)
16.9 Status Flag TMP88FW45AFG
UARTSR2<RBFL>
RDBUF2 yyyy
INTRXD interrupt
Note:Receive operations are disabled until the overrun error flag UARTSR2<OERR> is cleared.
INTRXD interrupt
Note:If the overrun error flag UARTSR2<OERR> is set during the period between reading the UARTSR2 and
reading the RDBUF2, it cannot be cleared by only reading the RDBUF2. Therefore, after reading the
RDBUF2, read the UARTSR2 again to check whether or not the overrun error flag which should have
been cleared still remains set.
Page 196
TMP88FW45AFG
UARTSR2<TBEP>
UARTSR2<TBEP>
UARTSR2<TEND>
INTTXD interrupt
Figure 16-10 Generation of Transmit End Flag and Transmit Data Buffer Empty
Page 197
16. Asynchronous Serial interface (UART2)
16.9 Status Flag TMP88FW45AFG
Page 198
TMP88FW45AFG
The TMP88FW45AFG has a clocked-synchronous 8-bit serial interface. Serial interface has an 8-byte transmit and
receive data buffer that can automatically and continuously transfer up to 64 bits of data.
Serial interface is connected to outside peripheral devices via SO, SI, SCK port.
17.1 Configuration
CPU
Transmit and
receive data buffer
Buffer control (8 bytes in DBR)
Control circuit circuit
Shift register
Shift 7 6 5 4 3 2 1 0
SO
clock
Serial data output
8-bit transfer 4-bit transfer
SI
Serial data input
Page 199
17. Synchronous Serial Interface (SIO)
17.2 Control TMP88FW45AFG
17.2 Control
The serial interface is controlled by SIO control registers (SIOCR1/SIOCR2). The serial interface status can be
determined by reading SIO status register (SIOSR).
The transmit and receive data buffer is controlled by the SIOCR2<BUF>. The data buffer is assigned to address
01F98H to 01F9FH for SIO in the DBR area, and can continuously transfer up to 8 words (bytes or nibbles) at one
time. When the specified number of words has been transferred, a buffer empty (in the transmit mode) or a buffer full
(in the receive mode or transmit/receive mode) interrupt (INTSIO) is generated.
When the internal clock is used as the serial clock in the 8-bit receive mode and the 8-bit transmit/receive mode, a
fixed interval wait can be applied to the serial clock for each word transferred. Four different wait times can be selected
with SIOCR2<WAIT>.
SIOCR1 7 6 5 4 3 2 1 0
0: Stop
SIOS Indicate transfer start / stop
1: Start
0: Continuously transfer
SIOINH Continue / abort transfer
1: Abort transfer (Automatically cleared after abort)
DV1CK = 0 DV1CK = 0
101 fc/24
fc/25
110 Reserved
111 External clock (Input from SCK pin)
Page 200
TMP88FW45AFG
SIOCR2 7 6 5 4 3 2 1 0
Note 1: The lower 4 bits of each buffer are used during 4-bit transfers. Zeros (0) are stored to the upper 4bits when receiving.
Note 2: Transmitting starts at the lowest address. Received data are also stored starting from the lowest address to the highest
address. ( The first buffer address transmitted is 01F98H ).
Note 3: The value to be loaded to BUF is held after transfer is completed.
Note 4: SIOCR2 must be set when the serial interface is stopped (SIOF = 0).
Note 5: *: Don't care
Note 6: SIOCR2 is write-only register, which cannot access any of in read-modify-write instruction such as bit operate, etc.
Note 7: Tf; Frame time, TD; Data transfer time
(output)
SCK output
TD
Tf
Figure 17-2 Frame time (Tf) and Data transfer time (TD)
SIOSR 7 6 5 4 3 2 1 0
0: Transfer terminated
SIOF Serial transfer operating status monitor
1: Transfer in process Read
0: Shift operation terminated only
SEF Shift operating status monitor
1: Shift operation in process
Note 1: After SIOCR1<SIOS> is cleared to "0", SIOSR<SIOF> is cleared to "0" at the termination of transfer or the setting of
SIOCR1<SIOINH> to "1".
Page 201
17. Synchronous Serial Interface (SIO)
17.3 Serial clock TMP88FW45AFG
Any of six frequencies can be selected. The serial clock is output to the outside on the SCK pin. The
SCK pin goes high when transfer starts.
When data writing (in the transmit mode) or reading (in the receive mode or the transmit/receive mode)
cannot keep up with the serial clock rate, there is a wait function that automatically stops the serial clock and
holds the next shift operation until the read/write processing is completed.
001 fc/2 8
78.13 Kbps
010 fc/2 7
156.25 Kbps
100 fc/2 5
625.00 Kbps
101 fc/2 4
125.00 Kbps
110 - -
Automatically
wait function
SCK
pin (output)
SO a0 a1 a2 a3 b0 b1 b2 b3 c0 c1
pin (output)
Written transmit
data a b c
An external clock connected to the SCK pin is used as the serial clock. In this case, the SCK (P43) port
should be set to input mode. To ensure shifting, a pulse width of more than 24/fc is required. This pulse is
needed for the shift operation to execute certainly. Actually, there is necessary processing time for interrupting,
writing, and reading. The minimum pulse is determined by setting the mode and the program.
Page 202
TMP88FW45AFG
SCK
pin (Input)
Transmitted data are shifted on the leading edge of the serial clock (falling edge of the SCK pin input/
output).
Received data are shifted on the trailing edge of the serial clock (rising edge of the SCK pin input/output).
SCK pin
SCK pin
The data is transferred in sequence starting at the least significant bit (LSB).
Page 203
17. Synchronous Serial Interface (SIO)
17.6 Transfer Mode TMP88FW45AFG
An INTSIO interrupt is generated when the specified number of words has been transferred. If the number of words
is to be changed during transfer, the serial interface must be stopped before making the change. The number of words
can be changed during automatic-wait operation of an internal clock. In this case, the serial interface is not required
to be stopped.
SCK pin
SO pin a0 a1 a2 a3
INTSIO interrupt
SCK pin
SO pin a0 a1 a2 a3 b0 b1 b2 b3 c0 c1 c2 c3
INTSIO interrupt
SCK pin
SI pin a0 a1 a2 a3 b0 b1 b2 b3 c0 c1 c2 c3
INTSIO interrupt
After the data are written, the transmission is started by setting SIOCR1<SIOS> to “1”. The data are then
output sequentially to the SO pin in synchronous with the serial clock, starting with the least significant bit (LSB).
As soon as the LSB has been output, the data are transferred from the data buffer register to the shift register.
When the final data bit has been transferred and the data buffer register is empty, an INTSIO (Buffer empty)
interrupt is generated to request the next transmitted data.
When the internal clock is used, the serial clock will stop and an automatic-wait will be initiated if the next
transmitted data are not loaded to the data buffer register by the time the number of data words specified with
the SIOCR2<BUF> has been transmitted. Writing even one word of data cancels the automatic-wait; therefore,
when transmitting two or more words, always write the next word before transmission of the previous word is
completed.
Note:Automatic waits are also canceled by writing to a DBR not being used as a transmit data buffer register;
therefore, during SIO do not use such DBR for other applications. For example, when 3 words are trans-
mitted, do not use the DBR of the remained 5 words.
Page 204
TMP88FW45AFG
When an external clock is used, the data must be written to the data buffer register before shifting next data.
Thus, the transfer speed is determined by the maximum delay time from the generation of the interrupt request
to writing of the data to the data buffer register by the interrupt service program.
The transmission is ended by clearing SIOCR1<SIOS> to “0” or setting SIOCR1<SIOINH> to “1” in buffer
empty interrupt service program.
SIOCR1<SIOS> is cleared, the operation will end after all bits of words are transmitted.
That the transmission has ended can be determined from the status of SIOSR<SIOF> because SIOSR<SIOF>
is cleared to “0” when a transfer is completed.
When SIOCR1<SIOINH> is set, the transmission is immediately ended and SIOSR<SIOF> is cleared to “0”.
When an external clock is used, it is also necessary to clear SIOCR1<SIOS> to “0” before shifting the next
data; If SIOCR1<SIOS> is not cleared before shift out, dummy data will be transmitted and the operation will
end.
If it is necessary to change the number of words, SIOCR1<SIOS> should be cleared to “0”, then
SIOCR2<BUF> must be rewritten after confirming that SIOSR<SIOF> has been cleared to “0”.
Clear SIOS
SIOCR1<SIOS>
SIOSR<SIOF>
SIOSR<SEF>
SCK pin
(Output)
SO pin a0 a1 a2 a3 a4 a5 a6 a7 b0 b1 b2 b3 b4 b5 b6 b7
INTSIO interrupt
DBR a b
Write Write
(a) (b)
Figure 17-7 Transfer Mode (Example: 8bit, 1word transfer, Internal clock)
Page 205
17. Synchronous Serial Interface (SIO)
17.6 Transfer Mode TMP88FW45AFG
Clear SIOS
SIOCR1<SIOS>
SIOSR<SIOF>
SIOSR<SEF>
SCK pin
(Input)
SO pin a0 a1 a2 a3 a4 a5 a6 a7 b0 b1 b2 b3 b4 b5 b6 b7
INTSIO interrupt
DBR a b
Write Write
(a) (b)
Figure 17-8 Transfer Mode (Example: 8bit, 1word transfer, External clock)
SCK pin
SIOSR<SIOF>
When the internal clock is used, and the previous data are not read from the data buffer register before the next
data are received, the serial clock will stop and an automatic-wait will be initiated until the data are read. A wait
will not be initiated if even one data word has been read.
Note:Waits are also canceled by reading a DBR not being used as a received data buffer register is read;
therefore, during SIO do not use such DBR for other applications.
When an external clock is used, the shift operation is synchronized with the external clock; therefore, the
previous data are read before the next data are transferred to the data buffer register. If the previous data have
not been read, the next data will not be transferred to the data buffer register and the receiving of any more data
will be canceled. When an external clock is used, the maximum transfer speed is determined by the delay between
the time when the interrupt request is generated and when the data received have been read.
Page 206
TMP88FW45AFG
The receiving is ended by clearing SIOCR1<SIOS> to “0” or setting SIOCR1<SIOINH> to “1” in buffer full
interrupt service program.
When SIOCR1<SIOS> is cleared, the current data are transferred to the buffer. After SIOCR1<SIOS> cleared,
the receiving is ended at the time that the final bit of the data has been received. That the receiving has ended can
be determined from the status of SIOSR<SIOF>. SIOSR<SIOF> is cleared to “0” when the receiving is ended.
After confirmed the receiving termination, the final receiving data is read. When SIOCR1<SIOINH> is set, the
receiving is immediately ended and SIOSR<SIOF> is cleared to “0”. (The received data is ignored, and it is not
required to be read out.)
If it is necessary to change the number of words in external clock operation, SIOCR1<SIOS> should be cleared
to “0” then SIOCR2<BUF> must be rewritten after confirming that SIOSR<SIOF> has been cleared to “0”. If it
is necessary to change the number of words in internal clock, during automatic-wait operation which occurs after
completion of data receiving, SIOCR2<BUF> must be rewritten before the received data is read out.
Note:The buffer contents are lost when the transfer mode is switched. If it should become necessary to switch
the transfer mode, end receiving by clearing SIOCR1<SIOS> to “0”, read the last data and then switch
the transfer mode.
Clear SIOS
SIOCR1<SIOS>
SIOSR<SIOF>
SIOSR<SEF>
SCK pin
(Output)
SI pin a0 a1 a2 a3 a4 a5 a6 a7 b0 b1 b2 b3 b4 b5 b6 b7
INTSIO Interrupt
DBR a b
Figure 17-10 Receive Mode (Example: 8bit, 1word transfer, Internal clock)
When the internal clock is used, a wait is initiated until the received data are read and the next transfer data
are written. A wait will not be initiated if even one transfer data word has been written.
When an external clock is used, the shift operation is synchronized with the external clock; therefore, it is
necessary to read the received data and write the data to be transmitted next before starting the next shift operation.
When an external clock is used, the transfer speed is determined by the maximum delay between generation of
an interrupt request and the received data are read and the data to be transmitted next are written.
Page 207
17. Synchronous Serial Interface (SIO)
17.6 Transfer Mode TMP88FW45AFG
When SIOCR1<SIOS> is cleared, the current data are transferred to the buffer. After SIOCR1<SIOS> cleared,
the transmitting/receiving is ended at the time that the final bit of the data has been transmitted.
That the transmitting/receiving has ended can be determined from the status of SIOSR<SIOF>. SIOSR<SIOF>
is cleared to “0” when the transmitting/receiving is ended.
When SIOCR1<SIOINH> is set, the transmit/receive operation is immediately ended and SIOSR<SIOF> is
cleared to “0”.
If it is necessary to change the number of words in external clock operation, SIOCR1<SIOS> should be cleared
to “0”, then SIOCR2<BUF> must be rewritten after confirming that SIOSR<SIOF> has been cleared to “0”.
If it is necessary to change the number of words in internal clock, during automatic-wait operation which occurs
after completion of transmit/receive operation, SIOCR2<BUF> must be rewritten before reading and writing of
the receive/transmit data.
Note:The buffer contents are lost when the transfer mode is switched. If it should become necessary to switch
the transfer mode, end receiving by clearing SIOCR1<SIOS> to “0”, read the last data and then switch
the transfer mode.
Clear SIOS
SIOCR1<SIOS>
SIOSR<SIOF>
SIOSR<SEF>
SCK pin
(output)
SO pin a0 a1 a2 a3 a4 a5 a6 a7 b0 b1 b2 b3 b4 b5 b6 b7
SI pin c0 c1 c2 c3 c4 c5 c6 c7 d0 d1 d2 d3 d4 d5 d6 d7
INTSIO interrupt
DBR a c b d
Write (a) Read out (c) Write (b) Read out (d)
Figure 17-11 Transfer / Receive Mode (Example: 8bit, 1word transfer, Internal clock)
Page 208
TMP88FW45AFG
SCK pin
SIOSR<SIOF>
Page 209
17. Synchronous Serial Interface (SIO)
17.6 Transfer Mode TMP88FW45AFG
Page 210
TMP88FW45AFG
18.1 Configuration
The circuit configuration of the 10-bit AD converter is shown in Figure 18-1.
It consists of control register ADCCRA and ADCCRB, converted value register ADCDRH and ADCDRL, a DA
converter, a sample-hold circuit, a comparator, and a successive comparison circuit.
DA converter
VAREF AVSS
R/2 R R/2
AVDD Reference
Analog input
Sample hold voltage
multiplexer
circuit
AIN0 A Y
10
Analog
comparator
AIN15 n Successive approximate circuit
S EN Shift clock
INTADC
Control circuit
4
IREFON
AINDS
ADRS
Note:Before using AD converter, set appropriate value to I/O port register combining a analog input port. For details,
see the section on "I/O ports".
Page 211
18. 10-bit AD Converter (ADC)
18.2 Register configuration TMP88FW45AFG
ADCCRA 7 6 5 4 3 2 1 0
(0026H) ADRS AMD AINDS SAIN (Initial value: 0001 0000)
0: -
ADRS AD conversion start
1: AD conversion start
00: AD operation disable
01: Software start mode
AMD AD operating mode
10: Reserved
11: Repeat mode
0: Analog input enable
AINDS Analog input control
1: Analog input disable
0000: AIN0
0001: AIN1
0010: AIN2
0011: AIN3 R/W
0100: AIN4
0101: AIN5
0110: AIN6
0111: AIN7
SAIN Analog input channel select
1000: AIN8
1001: AIN9
1010: AIN10
1011: AIN11
1100: AIN12
1101: AIN13
1110: AIN14
1111: AIN15
Note 1: Select analog input channel during AD converter stops (ADCDRL<ADBF> = "0").
Note 2: When the analog input channel is all use disabling, the ADCCRA<AINDS> should be set to "1".
Note 3: During conversion, Do not perform port output instruction to maintain a precision for all of the pins because analog input
port use as general input port. And for port near to analog input, Do not input intense signaling of change.
Note 4: The ADCCRA<ADRS> is automatically cleared to "0" after starting conversion.
Note 5: Do not set ADCCRA<ADRS> newly again during AD conversion. Before setting ADCCRA<ADRS> newly again, check
ADCDRL<EOCF> to see that the conversion is completed or wait until the interrupt signal (INTADC) is generated (e.g.,
interrupt handling routine).
Note 6: After STOP mode is started, AD converter control register1 (ADCCRA) is all initialized and no data can be written in this
register. Therefore, to use AD converter again, set the ADCCRA newly after returning to NORMAL mode.
Note 7: After RESET, ADCCRA<SAIN> is initialized Reserved setting. Therefore, set the appropriate analog input channel to
ADCCRA<SAIN> when use AD converter.
Page 212
TMP88FW45AFG
Note 8: After ADCCRA is set to 00H, AD conversion can not be started for four cycles. Thus, four NOPs must be inserted before
setting the ADCCRA<ADRS>.
ADCCRB 7 6 5 4 3 2 1 0
(0027H) IREFON "1" ACK "0" (Initial value: **0* 000*)
Note 1: Always set bit0 in ADCCRB to "0" and set bit4 in ADCCRB to "1".
Note 2: When a read instruction for ADCCRB, bit6 to 7 in ADCCRB read in as undefined data.
Note 3: After STOP mode is started, AD converter control register2 (ADCCRB) is all initialized and no data can be written in this
register. Therefore, to use AD converter again, set the ADCCRB newly after returning to NORMAL mode.
Condition Conversion
20 MHz 16 MHz 8 MHz
ACK time
000 39/fc - - -
001 Reserved
010 78/fc - - -
111 Reserved
Condition Conversion
20 MHz 16 MHz 8 MHz
ACK time
000 39/fc - - -
001 Reserved
010 78/fc - - -
111 Reserved
Note 1: Setting for "−" in the above table are inhibited. fc: High Frequency oscillation clock [Hz]
Note 2: Set conversion time setting should be kept more than the following time by Analog reference voltage (VAREF).
Page 213
18. 10-bit AD Converter (ADC)
18.2 Register configuration TMP88FW45AFG
ADCDRH 7 6 5 4 3 2 1 0
(0029H) AD09 AD08 AD07 AD06 AD05 AD04 AD03 AD02 (Initial value: 0000 0000)
ADCDRL 7 6 5 4 3 2 1 0
(0028H) AD01 AD00 EOCF ADBF (Initial value: 0000 ****)
Note 1: The ADCDRL<EOCF> is cleared to "0" when reading the ADCDRH. Therefore, the AD conversion result should be read
to ADCDRL more first than ADCDRH.
Note 2: The ADCDRL<ADBF> is set to "1" when AD conversion starts, and cleared to "0" when AD conversion finished. It also is
cleared upon entering STOP mode.
Note 3: If a read instruction is executed for ADCDRL, read data of bit3 to bit0 are unstable.
Page 214
TMP88FW45AFG
18.3 Function
After completion of the AD conversion, the conversion result is stored in AD converted value registers
(ADCDRH, ADCDRL) and at the same time ADCDRL<EOCF> is set to 1, the AD conversion finished interrupt
(INTADC) is generated.
ADRS is automatically cleared after AD conversion has started. Do not set ADCCRA<ADRS> newly again
(Restart) during AD conversion. Before setting ADCCRA<ADRS> newly again, check ADCDRL<EOCF> to
see that the conversion is completed or wait until the interrupt signal (INTADC) is generated (e.g., interrupt
handling routine).
ADCDRL<ADBF>
ADCDRH
Conversion result Conversion result
read read
ADCDRL
Conversion result Conversion result
read read
After completion of the AD conversion, the conversion result is stored in AD converted value registers
(ADCDRH, ADCDRL) and at the same time ADCDRL<EOCF> is set to 1, the AD conversion finished interrupt
(INTADC) is generated.
In repeat mode, each time one AD conversion is completed, the next AD conversion is started. To stop AD
conversion, set ADCCRA<AMD> to “00” (Disable mode) by writing 0s. The AD convert operation is stopped
immediately. The converted value at this time is not stored in the AD converted value register.
Page 215
18. 10-bit AD Converter (ADC)
18.3 Function TMP88FW45AFG
AD conversion start
ADCCRA<ADRS>
ADCDRH,ADCDRL Indeterminate 1st conversion result 2nd conversion result 3rd conversion result
ADCDRL<EOCF>
ADCDRH
Conversion Conversion Conversion
ADCDRL result read result read result read
Page 216
TMP88FW45AFG
Example :After selecting the conversion time 15.6 μs at 20 MHz and the analog input channel AIN4 pin, perform AD
conversion once. After checking EOCF, read the converted value, store the lower 2 bits in address 0009EH and
store the upper 8 bits in address 0009FH in RAM. The operation mode is software start mode.
JRS T, SLOOP
LD (9EH) , A
LD (9FH), A
Page 217
18. 10-bit AD Converter (ADC)
18.5 Analog Input Voltage and AD Conversion Result TMP88FW45AFG
3FFH
3FEH
3FDH
AD
conversion
result
03H
02H
01H
VAREF AVSS
Page 218
TMP88FW45AFG
Figure 18-5 Analog Input Equivalent Circuit and Example of Input Pin Processing
Page 219
18. 10-bit AD Converter (ADC)
18.6 Precautions about AD Converter TMP88FW45AFG
Page 220
TMP88FW45AFG
The TMP88FW45AFG contains two-channels of high-speed PWM. The high-speed PWM works in such a way
that when data are written to the data registers for the respective channels, waveforms differing from each other can
be output.
The high-speed PWM is shared with ports, P02 (HPWM0) and P03 (HPWM1). When using these pins for high-
speed PWM, set the port output latches for P02 and P03 to 1.
19.1 Configuration
HPWM0 HPWM1
X1
fc
8-bit up counter
HPE0
HPE1
PWMST
Comparator
Additional Pulse
Generator circuit
HPWM0 HPWM1
HPE1 section section
HPE0
PWMMOD
Page 221
19. 8-Bit High-speed PWM (
19.2 Control TMP88FW45AFG
19.2 Control
Control Register
HPWMCR 7 6 5 4 3 2 1 0
(000CH) HPE1 HPE0 PWMST PWMMOD R/W (Initial value: 00** 0*00)
Data Register
HPWMDR0 7 6 5 4 3 2 1 0
(000DH) DATA7 DATA6 DATA5 DATA4 DATA3 DATA2 DATA1 DATA0 R/W (Initial value: **** ****)
HPWMDR1 7 6 5 4 3 2 1 0
(000EH) DATA7 DATA6 DATA5 DATA4 DATA3 DATA2 DATA1 DATA0 R/W (Initial value: **** ****)
Note 1: The PWM output pulse width varies with the clock duty cycle.
Note 2: For the data registers, set data 10H to F0H.
Note 3: When HPWMCR<PWMST> = 0, the internal counter is cleared and data “1” is output to the port.
Note 4: Before selecting PWM mode, make sure HPWMCR<PWMST> = 0.
Note 5: Before entering STOP mode, set HPWMCR<PWMST, HPE0, and HPE1> all to 0.
Note 6: If HPWMCR<HPE0 or HPE1> is altered in the middle of PWM period, the waveform may be distorted. To avoid waveform
distortion, make sure HPWMCR<PWMST> = 0 when enabling HPWM output.
Note:These values apply to the case where the source clock (X1) is 20 MHz.
Use the HPWMCR<PWMMOD> to select operation mode. Note that operation mode is common to both
channels, and cannot be set separately for each channel.
Page 222
TMP88FW45AFG
In 8-bit mode, it is possible to generate a pulse with 12.8 μs period and approximately 78 kHz frequency
(when X1 = 20 MHz).
12.8 µs 12.8 µs
7 0
Data register
8-bit data
The minimum width of the pulse is 0.8 μs (data “10”), and the maximum width of the pulse is 12.0 μs (data
“F0”).
Figure 19-2 shows a typical waveform in 8-bit mode. (The values are for X1 = 20 MHz.)
12.8 µs 12.8 µs
Data
800 ns 800 ns
"10h"
850 ns 850 ns
"11h"
12.0 µs 12.0 µs
"F0h"
In 7-bit mode, it is possible to generate a pulse with 6.4 μs period and approximately 156 kHz frequency
(when X1 = 20 MHz).
Value of 1
low-order bits × 25 ns
Value of 7 Value of 7
high-order bits high-order bits
× 50 ns × 50 ns
6.4 µs 6.4 µs
In 7-bit mode, the period is comprised of 7 bits (period = 27 × 50 ns) and one other bit provides a 25 ns
resolution (half period of the source clock (X1)). Therefore, when the one low-order bit = 1, a plus-25 ns
pulse is output.
The minimum width of the pulse is 0.4 μs (data “10”), and the maximum width of the pulse is 6.0 μs (data
“F0”: “78” + “0”).
7 0
Data register
Page 223
19. 8-Bit High-speed PWM (
19.3 Functional Description TMP88FW45AFG
Pulse width = (7 high-order Bits of data × 50 ns) + (1 low-order Bit of data × 25 ns)
Figure 19-3 shows a typical waveform in 7-bit mode. (The values are for X1 = 20 MHz.)
6.4 µs 6.4 µs
Data
400 ns 400 ns
"10h"
425 ns 425 ns
"11h"
6.000 µs 6.000 µs
"F0h"
Note:The resolution of the LSB 1 bit (25 nsec) is a typical value and its precision is not guaranteed.
In 6-bit mode, it is possible to generate a pulse with 3.2 μs period and approximately 313 kHz frequency
(when X1 = 20 MHz).
3.2 µs 3.2 µs
In 6-bit mode, the period is comprised of 6 bits (period = 26 × 50 ns) and two other bits provide a 12.5 ns
resolution. However, because the actually obtained resolution is 25 ns, said resolution is accomplished arti-
ficially. To obtain a 12.5 ns resolution, the first, second, and third pulses are output by adding 25 ns, 0 ns,
and 25 ns, respectively. In this way, a 12.5 ns resolution is realized as being “equivalent to.”
The minimum equivalent width of the pulse is 0.2 μs (data “10”), and the maximum equivalent width of
the pulse is 3.0 μs (data “F0”: “3B” + “0”).
7 0
Data register
* The equivalent plus times in 2 low-order bits of data are shown below.
00 0 ns
01 12.5 ns
10 25 ns
11 37.5 ns
Figure 19-4 Shows a typical waveform in 6-bit mode. (The values are for X1 = 20 MHz.)
Page 224
TMP88FW45AFG
Note:The resolution of the LSB 2 bit (12.5 nsec) is a typical value and its precision is not guaranteed.
Example: To output a 5.75 μs waveform in 7-bit mode using HPWM0 when the source clock (X1) = 20 MHz
5.75 µs
6.4 µs
Because 73H is placed in the 7 high-order bits, the value is shifted one bit to become E6H. Therefore, set E6H
in the Data Register (HPWMDR0).
Page 225
19. 8-Bit High-speed PWM (
19.3 Functional Description TMP88FW45AFG
Page 226
TMP88FW45AFG
TMP88FW45AFG has 122880 bytes flash memory (address: 04000H to 21EFFH and FFF00H to FFFFH). The
write and erase operations to the flash memory are controlled in the following three types of mode.
- MCU mode
The flash memory is accessed by the CPU control in the MCU mode. This mode is used for software bug
correction and firmware change after shipment of the device since the write operation to the flash memory
is available by retaining the application behavior.
In the MCU and serial PROM modes, the flash memory control register (FLSCR) is used for flash memory control.
This chapter describes how to access the flash memory using the flash memory control register (FLSCR) in the MCU
and serial PROM modes.
Page 227
20. Flash Memory
20.1 Flash Memory Control TMP88FW45AFG
FLSCR 7 6 5 4 3 2 1 0
Note 1: The command sequence of the flash memory can be executed only when FLSCR<FLSMD>="0011B". In other cases,
any attempts to execute the command sequence are ineffective.
Note 2: FLSCR<FLSMD> must be set to either "1100B" or "0011B".
Note 3: Bits 3 to 0 in FLSCR register are always read as don’t care.
Page 228
TMP88FW45AFG
1st Bus Write Cy- 2nd Bus Write Cy- 3rd Bus Write Cy- 4th Bus Write Cy- 5th Bus Write Cy- 6th Bus Write Cy-
Command Sequence cle cle cle cle cle cle
Address Data Address Data Address Data Address Data Address Data Address Data
04AAA BA Data
1 1 Byte program 04555H AAH 55H 04555H A0H - - - -
H (Note 1) (Note 1)
04AAA
4 Product ID Entry 04555H AAH 55H 04555H 90H - - - - - -
H
04AAA
6 Security Program 04555H AAH 55H 04555H A5H 04F7FH 00H - - - -
H
Note:To rewrite data to Flash memory addresses at which data (including FFH) is already written, make sure
to erase the existing data by "sector erase" or "chip erase" before rewriting data.
A maximum of 30 ms is required to erase 4 kbytes. The next command sequence cannot be executed until the
erase operation is completed. To check the completion of the erase operation, perform read operations repeatedly
for data polling until the same data is read twice from the same address in the flash memory. During the erase
operation, any consecutive attempts to read from the same address is reversed bit 6 of the data (toggling between
0 and 1).
Page 229
20. Flash Memory
20.2 Command Sequence TMP88FW45AFG
0BH: 48 kbytes
07H: 32 kbytes
1 04002H Flash size
05H: 24 kbytes
03H: 16 kbytes
01H: 8 kbytes
00H: 4 kbytes
Note:The value at address 04002H (flash size) depends on the size of flash memory incorporated in each product.
For example, if the product has 16-kbyte flash memory, "03H" is read from address 04002H.
To disable the security program setting, it is necessary to execute the chip erase command sequence. Whether
or not the security program is enabled can be checked by reading 04F7FH in the Product ID mode. For details,
see Table 20-2.
It takes a maximum of 40 μs to set security program in the flash memory. The next command sequence cannot
be executed until this operation is completed. To check the completion of the sequrity program operation, perform
read operations repeatedly for data polling until the same data is read twice from the same address in the flash
memory. During the security program operation, any attempts to read from the same address is reversed bit 6 of
the data (toggling between 0 and 1).
Page 230
TMP88FW45AFG
To access to the flash memory by using peripheral functions in the serial PROM mode, run the RAM loader
command to execute the control program in the RAM area. The procedures to execute the control program in the
RAM area is shown in "20.4.1.1 How to write to the flash memory by executing the control program in the RAM
area (in the RAM loader mode within the serial PROM mode)".
20.4.1.1 How to write to the flash memory by executing the control program in the RAM area (in the RAM
loader mode within the serial PROM mode)
(Steps 1 and 2 are controlled by the BOOTROM, and steps 3 to 9 are controlled by the control program
executed in the RAM area.)
1. Transfer the write control program to the RAM area in the RAM loader mode.
2. Jump to the RAM area.
3. Disable (DI) the interrupt master enable flag (IMF←"0").
4. Set FLSCR<FLSMD> to "0011B" (to enable command sequence execution).
5. Execute the erase command sequence.
6. Read the same flash memory address twice.
(Repeat step 6 until the same data is read by two consecutive reads operations.)
7. Execute the write command sequence.
8. Read the same flash memory address twice.
(Repeat step 8 until the same data is read by two consecutive reads operations.)
9. Set FLSCR<FLSMD> to "1100B" (to disable command sequence execution).
Note 1: Before writing to the flash memory in the RAM area, disable interrupts by setting the interrupt master
enable flag (IMF) to "0". Usually disable interrupts by executing the DI instruction at the head of the write
control program in the RAM area.
Page 231
20. Flash Memory
20.4 Access to the Flash Memory Area TMP88FW45AFG
Note 2: Since the watchdog timer is disabled by the BOOTROM in the RAM loader mode, it is not required to
disable the watchdog timer by the RAM loader program.
Example :After chip erasure, the program in the RAM area writes data 3FH to address F000H.
LD IX,04555H
LD IY,04AAAH
LD HL,0F000H
sLOOP1: LD A,(IX)
CMP A,(IX)
sLOOP2: LD A,(HL)
CMP A,(HL)
sLOOP3: JP sLOOP3
Page 232
TMP88FW45AFG
20.4.2.1 How to write to the flash memory by executing a user write control program in the RAM area (in
the MCU mode)
(Steps 1 and 2 are controlled by the program in the flash memory, and steps 3 through 11 are controlled by
the control program in the RAM area.)
Page 233
20. Flash Memory
20.4 Access to the Flash Memory Area TMP88FW45AFG
Example :After sector erasure (E000H-EFFFH), the program in the RAM area writes data 3FH to address E000H.
LD IX,04555H
LD IY,04AAAH
LD HL,0E000H
sLOOP1: LD A,(IX)
CMP A,(IX)
sLOOP2: LD A,(HL)
CMP A,(HL)
Example :This write control program reads data from address F000H and stores it to 98H in the RAM area.
Page 234
TMP88FW45AFG
21.1 Outline
The TMP88FW45AFG has a 4096 byte BOOTROM (Mask ROM) for programming to flash memory. The BOOT-
ROM is available in the serial PROM mode, and controlled by TEST, BOOT, RESET and some pins. Communication
is performed via UART. The serial PROM mode has seven types of operating mode: Flash memory writing, RAM
loader, Flash memory SUM output, Product ID code output, Flash memory status output, Flash memory erasing and
Flash memory security program setting. Memory address mapping in the serial PROM mode differs from that in the
MCU mode. Figure 21-1 shows memory address mapping in the serial PROM mode.
Note 1: Though included in above operating range, some of high frequencies are not supported in the serial PROM mode. For
details, refer to “Table 21-5”.
Note 2: In Serial PROM mode, accessing to registers of oscillation frequency detection is disabled. Therefore oscillation frequency
detection is not available in the Serial PROM mode.
In the serial PROM mode, the BOOTROM (Mask ROM) is mapped in addresses from 3000H to 3FFFH.
00000H 00000H
SFR 64 bytes SFR 64 bytes
0003FH 0003FH
00040H 00040H
RAM 4096 +128 bytes RAM 4096 +128 bytes
010BFH 010BFH
01F70H 01F70H
EBR, DBR 144 bytes EBR, DBR 144 bytes
01FFFH 01FFFH
03000H
BOOTROM 4096 bytes
03FFFH
04000H 04000H
21EFFH 21EFFH
FFF00H FFF00H
Vector table Vector table
(256 bytes) (256 bytes)
FFFFFH FFFFFH
Serial PROM mode MCU mode
Page 235
21. Serial PROM Mode
21.3 Serial PROM Mode Setting TMP88FW45AFG
Pin Setting
RESET pin
Note:The BOOT pin is shared with the UART communication pin (RXD1 pin) in the serial PROM mode. This pin is
used as UART communication pin after activating serial PROM mode
I/O ports except These ports are in the high-impedance state in the serial PROM mode. The input level is fixed to
I/O the port inputs with a hardware feature to prevent overlap current. (The port inputs are invalid.) To
P45, P44 make the port inputs valid, set the pin of the SPCR register to “1” by the RAM loader control program.
XIN Input
Self-oscillate with an oscillator. (Note 2)
XOUT Output
Note 1: During on-board programming with other parts mounted on a user board, be careful no to affect these communication
control pins.
Note 2: Operating range of high frequency in serial PROM mode is 8 MHz to 20 MHz.
Note 3: TXD port is set a open-drain port in seriarl PROM mode and it needs pull-up resistor.
Page 236
TMP88FW45AFG
TMP88FW45AFG
VDD(4.5 V to 5.5 V)
VDD
XIN
Pull-up
BOOT / RXD1 (P44)
XOUT TXD1 (P45) External control
VSS RESET
GND
Note 1: For connection of other pins, refer to "Table 21-3 Pin Function in the Serial PROM Mode".
VDD(4.5 V to 5.5 V)
VDD
Serial PROM mode
TEST Pull-up
MCU mode
BOOT / RXD1 (P44)
Level
converter PC control
TXD1 (P45)
(Note 2)
XIN
Other RESET
XOUT parts control
(Note 1)
RESET RC power-on
reset circuit
VSS
P10
P11 GND
Note 1: When other parts on the application board effect the UART communication in the serial PROM mode, isolate these
pins by a jumper or switch.
Note 2: When the reset control circuit on the application board effects activation of the serial PROM mode, isolate the pin by
a jumper or switch.
Note 3: For connection of other pins, refer to "Table 21-3 Pin Function in the Serial PROM Mode".
Page 237
21. Serial PROM Mode
21.3 Serial PROM Mode Setting TMP88FW45AFG
VDD
TEST(Input)
RESET(Input)
BOOT/RXD1 (Input) High level setting Setup time for serial PROM mode (Rxsup)
Matching data
input
Page 238
TMP88FW45AFG
To perform on-board programming, the communication format of the write controller must also be set in the same
manner.
The default baud rate is 9600 bps regardless of operating frequency of the microcontroller. The baud rate can be
modified by transmitting the baud rate modification data shown in Table 21-4 to TMP88FW45AFG. The Table
21-5 shows an operating frequency and baud rate. The frequencies which are not described in Table 21-5 can not be
used.
Baud rate modification data 04H 05H 06H 07H 0AH 18H 28H
Baud rate (bps) 76800 62500 57600 38400 31250 19200 9600
Table 21-5 Operating Frequency and Baud Rate in the Serial PROM Mode
Reference Baud Rate (bps) 76800 62500 57600 38400 31250 19200 9600
1 8 7.64 to 8.39 - - 62500 0.00 - - 38462 +0.16 31250 0.00 19231 +0.16 9615 +0.16
9.8304 9.40 to 10.32 76800 0.00 - - - - 38400 0.00 - - 19200 0.00 9600 0.00
2
10 9.40 to 10.32 78125 +1.73 - - - - 39063 +1.73 - - 19531 +1.73 9766 +1.73
12 11.75 to 12.90 - - - - 57692 +0.16 - - 31250 0.00 18750 -2.34 9375 -2.34
3 12.288 11.75 to 12.90 - - - - 59077 +2.56 - - 32000 +2.40 19200 0.00 9600 0.00
12.5 11.75 to 12.90 - - 60096 -3.85 60096 +4.33 - - 30048 -3.85 19531 +1.73 9766 +1.73
4 14.7456 14.10 to 15.48 - - - - 57600 0.00 38400 0.00 - - 19200 0.00 9600 0.00
5 16 15.27 to 16.77 76923 +0.16 62500 0.00 - - 38462 +0.16 31250 0.00 19231 +0.16 9615 +0.16
7 20 18.80 to 20.64 76923 +1.73 - - - - 39063 +0.16 31250 0.00 19531 +1.73 9766 +1.73
Note 1: “Ref. Frequency” and “Rating” show frequencies available in the serial PROM mode. Though the frequency is supported
in the serial PROM mode, the serial PROM mode may not be activated correctly due to the frequency difference in the
external controller (such as personal computer) and oscillator, and load capacitance of communication pins.
Note 2: It is recommended that the total frequency difference is within ±3% so that auto detection is performed correctly by the
reference frequency.
Note 3: The external controller must transmit the matching data (5AH) repeatedly till the auto detection of baud rate is performed.
This number indicates the number of times the matching data is transmitted for each frequency.
Page 239
21. Serial PROM Mode
21.5 Operation Command TMP88FW45AFG
5AH Setup Matching data. Execute this command after releasing the reset.
Erases the flash memory area (address 4000H to 21EFFH, and FFF00 to
F0H Flash memory erasing
FFFFFH).
Writes to the flash memory area (address 4000H to 21EFFH, and FFF00 to
30H Flash memory writing
FFFFFH) .
60H RAM loader Writes to the specified RAM area (address 0040H to 10BFH).
Outputs the 2-byte checksum upper byte and lower byte in this order for the
90H Flash memory SUM output entire area of the flash memory (address 4000H to 21EFFH, and FFF00 to
FFFFFH).
C0H Product ID code output Outputs the product ID code (13-byte data).
C3H Flash memory status output Outputs the status code (7-byte data) such as the security program condition.
FAH Flash memory security program setting Enables the security program.
Page 240
TMP88FW45AFG
Page 241
21. Serial PROM Mode
21.6 Operation Mode TMP88FW45AFG
Transfer Data from the External Transfer Data from TMP88FW45AFG to the
Transfer Byte Baud Rate
Controller to TMP88FW45AFG External Controller
1st byte Matching data (5AH) 9600 bps - (Automatic baud rate adjustment)
2nd byte - 9600 bps OK: Echo back data (5AH)
Error: No data transmitted
3rd byte Baud rate change data (Table 21-4) 9600 bps -
4th byte - 9600 bps OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
7th byte Password count storage address bit 23 Modified baud rate -
8th byte to 16 (Note 4, 5) Modified baud rate OK: Nothing transmitted
Error: Nothing transmitted
9th byte Password count storage address bit 15 Modified baud rate -
10th byte to 08 (Note 4, 5) Modified baud rate OK: Nothing transmitted
Error: Nothing transmitted
11th byte Password count storage address bit 07 Modified baud rate -
12th byte to 00 (Note 4, 5) Modified baud rate OK: Nothing transmitted
Error: Nothing transmitted
BOOT 13th byte Password comparison start address bit Modified baud rate -
ROM 14th byte 23 to 16 (Note 4, 5) Modified baud rate OK: Nothing transmitted
Error: Nothing transmitted
15th byte Password comparison start address bit Modified baud rate -
16th byte 15 to 08 (Note 4, 5) Modified baud rate OK: Nothing transmitted
Error: Nothing transmitted
17th byte Password comparison start address bit Modified baud rate -
18th byte 07 to 00 (Note 4, 5) Modified baud rate OK: Nothing transmitted
Error: Nothing transmitted
n’th - 1 byte - Modified baud rate OK: Checksum (Upper byte) (Note 3)
Error: Nothing transmitted
Note 1: “xxH × 3” indicates that the device enters the halt condition after transmitting 3 bytes of xxh.
Note 2: Refer to "21.13 Specifying the Erasure Area".
Note 3: Refer to "21.8 Checksum (SUM)".
Note 4: Refer to "21.10 Passwords".
Note 5: Do not transmit the password string for a blank product.
Note 6: When a password error occurs, TMP88FW45AFG stops UART communication and enters the halt mode. Therefore, when
a password error occurs, initialize TMP88FW45AFG by the RESET pin and reactivate the serial PROM mode.
Note 7: If an error occurs during transfer of a password address or a password string, TMP88FW45AFG stops UART communi-
cation and enters the halt condition. Therefore, when a password error occurs, initialize TMP88FW45AFG by the
RESET pin and reactivate the serial PROM mode.
Page 242
TMP88FW45AFG
1. The 1st through 4th bytes of the transmitted and received data contain the same data as in the flash
memory writing mode.
2. The 5th byte of the received data contains the command data in the flash memory erasing mode (F0H).
3. When the 5th byte of the received data contains the operation command data shown in Table 21-6, the
device echoes back the value which is the same data in the 6th byte position of the received data (in
this case, F0H). If the 5th byte of the received data does not contain the operation command data, the
device enters the halt condition after sending 3 bytes of the operation command error code (63H).
4. The 7th thorough m'th bytes of the transmitted and received data contain the same data as in the flash
memory writing mode. In the case of a blank product, do not transmit a password string. (Do not transmit
a dummy password string.)
5. The n’th - 2 byte contains the erasure area specification data. The upper 4 bits and lower 4 bits specify
the start address and end address of the erasure area, respectively. For the detailed description, see
"21.13 Specifying the Erasure Area" .
6. The n’th - 1 byte and n’th byte contain the upper and lower bytes of the checksum, respectively. For
how to calculate the checksum, refer to "21.8 Checksum (SUM)" . Checksum is calculated unless a
receiving error or Intel Hex format error occurs. After sending the end record, the external controller
judges whether the transmission is completed correctly by receiving the checksum sent by the device.
7. After sending the checksum, the device waits for the next operation command data.
Page 243
21. Serial PROM Mode
21.6 Operation Mode TMP88FW45AFG
1st byte Matching data (5Ah) 9600 bps - (Automatic baud rate adjustment)
2nd byte - 9600 bps OK: Echo back data (5AH)
Error: Nothing transmitted
7th byte Password count storage address bit 23 Modified baud rate -
8th byte to 16 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
9th byte Password count storage address bit 15 Modified baud rate -
10th byte to 08 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
11th byte Password count storage address bit 07 Modified baud rate -
12th byte to 00 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
13th byte Password comparison start address bit Modified baud rate -
BOOT 14th byte 23 to 16 (Note 4) OK: Nothing transmitted
ROM Error: Nothing transmitted
15th byte Password comparison start address bit Modified baud rate -
16th byte 15 to 08 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
17th byte Password comparison start address bit Modified baud rate -
18th byte 07 to 00 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
n’th - 1 byte - Modified baud rate OK: SUM (Upper byte) (Note 3)
Error: Nothing transmitted
n’th byte - Modified baud rate OK: SUM (Lower byte) (Note 3)
Error: Nothing transmitted
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to "21.7 Error
Code".
Note 2: Refer to "21.9 Intel Hex Format (Binary)".
Note 3: Refer to "21.8 Checksum (SUM)".
Note 4: Refer to "21.10 Passwords".
Note 5: If addresses from FFFE0H to FFFFFH are filled with “FFH”, the passwords are not compared because the device is
considered as a blank product. Transmitting a password string is not required. Even in the case of a blank product , it is
required to specify the password count storage address and the password comparison start address. Transmit these data
Page 244
TMP88FW45AFG
from the external controller. If a password error occurs due to incorrect password count storage address or password
comparison start address, TMP88FW45AFG stops UART communication and enters the halt condition. Therefore, when
a password error occurs, initialize TMP88FW45AFG by the RESET pin and reactivate the serial ROM mode.
Note 6: If the security program is enabled or a password error occurs, TMP88FW45AFG stops UART communication and enters
the halt confition. In this case, initialize TMP88FW45AFG by the RESET pin and reactivate the serial ROM mode.
Note 7: If an error occurs during the reception of a password address or a password string, TMP88FW45AFG stops UART com-
munication and enters the halt condition. In this case, initialize TMP88FW45AFG by the RESET pin and reactivate the
serial PROM mode.
Note 8: Do not write only the address from FFFE0H to FFFFFH when all flash memory data is the same. If only these area are
written, the subsequent operation can not be executed due to password error.
Note 9: To rewrite data to Flash memory addresses at which data (including FFH) is already written, make sure to erase the
existing data by "sector erase" or "chip erase" before rewriting data.
1. The 1st byte of the received data contains the matching data. When the serial PROM mode is activated,
TMP88FW45AFG (hereafter called device), waits to receive the matching data (5AH). Upon reception
of the matching data, the device automatically adjusts the UART’s initial baud rate to 9600 bps.
2. When receiving the matching data (5AH), the device transmits an echo back data (5AH) as the second
byte data to the external controller. If the device can not recognize the matching data, it does not transmit
the echo back data and waits for the matching data again with automatic baud rate adjustment. There-
fore, the external controller should transmit the matching data repeatedly till the device transmits an
echo back data. The transmission repetition count varies depending on the frequency of device. For
details, refer to Table 21-5.
3. The 3rd byte of the received data contains the baud rate modification data. The five types of baud rate
modification data shown in Table 21-4 are available. Even if baud rate is not modified, the external
controller should transmit the initial baud rate data (28H: 9600 bps).
4. Only when the 3rd byte of the received data contains the baud rate modification data corresponding to
the device's operating frequency, the device echoes back data the value which is the same data in the
4th byte position of the received data. After the echo back data is transmitted, baud rate modification
becomes effective. If the 3rd byte of the received data does not contain the baud rate modification data,
the device enters the halts condition after sending 3 bytes of baud rate modification error code (62H).
5. The 5th byte of the received data contains the command data (30H) to write the flash memory.
6. When the 5th byte of the received data contains the operation command data shown in Table 21-6, the
device echoes back the value which is the same data in the 6th byte position of the received data (in
this case, 30H). If the 5th byte of the received data does not contain the operation command data, the
device enters the halt condition after sending 3 bytes of the operation command error code (63H).
7. The 7th byte contains the data for 23 to 16 bits of the password count storage address. When the data
received with the 7th byte has no receiving error, the device does not send any data. If a receiving error
or password error occurs, the device does not send any data and enters the halt condition.
8. The 9th byte contains the data for 15 to 8 bits of the password count storage address. When the data
received with the 9th byte has no receiving error, the device does not send any data. If a receiving error
or password error occurs, the device does not send any data and enters the halt condition.
9. The 11th byte contains the data for 7 to 0 bits of the password count storage address. When the data
received with the 11th byte has no receiving error, the device does not send any data. If a receiving
error or password error occurs, the device does not send any data and enters the halt condition.
10. The 13th byte contains the data for 23 to 16 bits of the password comparison start address. When the
data received with the 13th byte has no receiving error, the device does not send any data. If a receiving
error or password error occurs, the device does not send any data and enters the halt condition.
11. The 15th byte contains the data for 15 to 8 bits of the password comparison start address. When the
data received with the 15th byte has no receiving error, the device does not send any data. If a receiving
error or password error occurs, the device does not send any data and enters the halt condition.
12. The 17th byte contains the data for 7 to 0 bits of the password comparison start address. When the data
received with the 17th byte has no receiving error, the device does not send any data. If a receiving
error or password error occurs, the device does not send any data and enters the halt condition.
13. The 19th through m’th bytes contain the password data. The number of passwords becomes the data
(N) stored in the password count storage address. The external password data is compared with N-byte
Page 245
21. Serial PROM Mode
21.6 Operation Mode TMP88FW45AFG
data from the address specified by the password comparison start address. The external controller should
send N-byte password data to the device. If the passwords do not match, the device enters the halt
condition without returning an error code to the external controller. If the addresses from FFFE0H to
FFFFFH are filled with “FFH”, the passwords are not conpared because the device is considered as a
blank product.
14. The m’th + 1 through n’th - 2 bytes of the received data contain the binary data in the Intel Hex format.
No received data is echoed back to the external controller. After receiving the start mark (3AH for “:”)
in the Intel Hex format, the device starts data record reception. Therefore, the received data except 3AH
is ignored until the start mark is received. After receiving the start mark, the device receives the data
record, that consists of data length, address, record type, write data and checksum. Since the device
starts checksum calculation after receiving an end record, the external controller should wait for the
checksum after sending the end record. If a receiving error or Intel Hex format error occurs, the device
enters the halts condition without returning an error code to the external controller.
15. The n’th - 1 and n’th bytes contain the checksum upper and lower bytes. For details on how to calculate
the SUM, refer to "21.8 Checksum (SUM)". The checksum is calculated only when the end record is
detected and no receiving error or Intel Hex format error occurs. After sending the end record, the
external controller judges whether the transmission is completed correctly by receiving the checksum
sent by the device.
16. After transmitting the checksum, the device waits for the next operation command data.
Page 246
TMP88FW45AFG
1st byte Matching data (5AH) 9600 bps - (Automatic baud rate adjustment)
2nd byte - 9600 bps OK: Echo back data (5AH)
Error: Nothing transmitted
7th byte Password count storage address bit 23 Modified baud rate -
8th byte to 16 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
9th byte Password count storage address bit 15 Modified baud rate -
10th byte to 08 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
11th byte Password count storage address bit 07 Modified baud rate -
12th byte to 00 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
BOOT
13th byte Password comparison start address bit Modified baud rate -
ROM
14th byte 23 to 16 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
15th byte Password comparison start address bit Modified baud rate -
16th byte 15 to 08 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
17th byte Password comparison start address bit Modified baud rate -
18th byte 07 to 00 (Note 4) OK: Nothing transmitted
Error: Nothing transmitted
n’th - 1 byte - Modified baud rate OK: SUM (Upper byte) (Note 3)
Error: Nothing transmitted
n’th byte - Modified baud rate OK: SUM (Lower byte) (Note 3)
Error: Nothing transmitted
RAM - The program jumps to the start address of RAM in which the first transferred data is written.
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to "21.7 Error
Code".
Note 2: Refer to "21.9 Intel Hex Format (Binary)".
Note 3: Refer to "21.8 Checksum (SUM)".
Note 4: Refer to "21.10 Passwords".
Note 5: If addresses from FFFE0H to FFFFFH are filled with “FFH”, the passwords are not compared because the device is
considered as a blank product. Transmitting a password string is not required. Even in the case of a blank product , it is
required to specify the password count storage address and the password comparison start address. Transmit these data
Page 247
21. Serial PROM Mode
21.6 Operation Mode TMP88FW45AFG
from the external controller. If a password error occurs due to incorrect password count storage address or password
comparison start address, TMP88FW45AFG stops UART communication and enters the halt condition. Therefore, when
a password error occurs, initialize TMP88FW45AFG by the RESET pin and reactivate the serial ROM mode.
Note 6: After transmitting a password string, the external controller must not transmit only an end record. If receiving an end record
after a password string, the device may not operate correctly.
Note 7: If the security program is enabled or a password error occurs, TMP88FW45AFG stops UART communication and enters
the halt condition. In this case, initialize TMP88FW45AFG by the RESET pin and reactivate the serial PROM mode.
Note 8: If an error occurs during the reception of a password address or a password string, TMP88FW45AFG stops UART com-
munication and enters the halt condition. In this case, initialize TMP88FW45AFG by the RESET pin and reactivate the
serial PROM mode.
Note 9: To re-write data for the address of flash memory which has already written data ( include "FF" ), make sure to erase the
data first by the sector erase or chip erase, and then write new data to the flash memory.
1. The 1st through 4th bytes of the transmitted and received data contains the same data as in the flash
memory writing mode.
2. In the 5th byte of the received data contains the RAM loader command data (60H).
3. When th 5th byte of the received data contains the operation command data shown in Table 21-6, the
device echoes back the value which is the same data in the 6th byte position (in this case, 60H). If the
5th byte does not contain the operation command data, the device enters the halt condition after sending
3 bytes of operation command error code (63H).
4. The 7th through m’th bytes of the transmitted and received data contain the same data as in the flash
memory writing mode.
5. The m’th + 1 through n’th - 2 bytes of the received data contain the binary data in the Intel Hex format.
No received data is echoed back to the external controller. After receiving the start mark (3AH for “:”)
in the Intel Hex format, the device starts data record reception. Therefore, the received data except 3AH
is ignored until the start mark is received. After receiving the start mark, the device receives the data
record, that consists of data length, address, record type, write data and checksum. The writing data of
the data record is written into RAM specified by address. Since the device starts checksum calculation
after receiving an end record, the external controller should wait for the checksum after sending the
end record. If a receiving error or Intel Hex format error occurs, the device enters the halts condition
without returning an error code to the external controller.
6. The n’th - 1 and n’th bytes contain the checksum upper and lower bytes. For details on how to calculate
the SUM, refer to "21.8 Checksum (SUM)". The checksum is calculated only when the end record is
detected and no receiving error or Intel Hex format error occurs. After sending the end record, the
external controller judges whether the transmission is completed correctly by receiving the checksum
sent by the device.
7. After transmitting the checksum to the external controller, the boot program jumps to the RAM address
that is specified by the first received data record.
Note 1: To rewrite data to Flash memory addresses at which data (including FFH) is already written, make sure to
erase the existing data by "sector erase" or "chip erase" before rewriting data.
Page 248
TMP88FW45AFG
1st byte Matching data (5AH) 9600 bps - (Automatic baud rate adjustment)
2nd byte - 9600 bps OK: Echo back data (5AH)
Error: Nothing transmitted
BOOT 5th byte Operation command data (90H) Modified baud rate -
ROM 6th byte - Modified baud rate OK: Echo back data (90H)
Error: A1H × 3, A3H × 3, 63H × 3 (Note 1)
7th byte - Modified baud rate OK: SUM (Upper byte) (Note 2)
Error: Nothing transmitted
8th byte - Modified baud rate OK: SUM (Lower byte) (Note 2)
Error: Nothing transmitted
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to "21.7 Error
Code".
Note 2: Refer to "21.8 Checksum (SUM)".
1. The 1st through 4th bytes of the transmitted and received data contains the same data as in the flash
memory writing mode.
2. The 5th byte of the received data contains the command data in the flash memory SUM output mode
(90H).
3. When the 5th byte of the received data contains the operation command data shown in Table 21-6, the
device echoes back the value which is the same data in the 6th byte position of the received data (in
this case, 90H). If the 5th byte of the received data does not contain the operation command data, the
device enters the halt condition after transmitting 3 bytes of operation command error code (63H).
4. The 7th and the 8th bytes contain the upper and lower bits of the checksum, respectively. For how to
calculate the checksum, refer to "21.8 Checksum (SUM)".
5. After sending the checksum, the device waits for the next operation command data.
Page 249
21. Serial PROM Mode
21.6 Operation Mode TMP88FW45AFG
1st byte Matching data (5AH) 9600 bps - (Automatic baud rate adjustment)
2nd byte - 9600 bps OK: Echo back data (5AH)
Error: Nothing transmitted
3rd byte Baud rate modification data (Table 21-4) 9600 bps -
4th byte - 9600 bps OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
14th byte Modified baud rate 02H ROM block count (2 block)
28th byte (Wait for the next operation command data) Modified baud rate -
Page 250
TMP88FW45AFG
Note:“xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to
"21.7 Error Code".
1. The 1st through 4th bytes of the transmitted and received data contain the same data as in the flash
memory writing mode.
2. The 5th byte of the received data contains the product ID code output mode command data (C0H).
3. When the 5th byte contains the operation command data shown in Table 21-6, the device echoes back
the value which is the same data in the 6th byte position of the received data (in this case, C0H). If the
5th byte data does not contain the operation command data, the device enters the halt condition after
sending 3 bytes of operation command error code (63H).
4. The 9th through 26th bytes contain the product ID code. For details, refer to "21.11 Product ID
Code".
5. After sending the checksum, the device waits for the next operation command data.
Page 251
21. Serial PROM Mode
21.6 Operation Mode TMP88FW45AFG
Transfer Data from External Con- Transfer Data from TMP88FW45AFG to Ex-
Transfer Bytes Baud Rate
troller to TMP88FW45AFG ternal Controller
1st byte Matching data (5AH) 9600 bps - (Automatic baud rate adjustment)
2nd byte - 9600 bps OK: Echo back data (5AH)
Error: Nothing transmitted
13th byte Modified baud rate Checksum 2’s complement for the sum of 9th
through 12th bytes
9th byte Checksum
00H: 00H
01H: FFH
02H: FEH
03H: FDH
14th byte (Wait for the next operation com- Modified baud rate -
mand data)
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to "21.7 Error
Code".
Note 2: For the details on status code 1, refer to "21.12 Flash Memory Status Code".
1. The 1st through 4th bytes of the transmitted and received data contain the same data as in the Flash
memory writing mode.
2. The 5th byte of the received data contains the flash memory status output mode command data (C3H).
3. When the 5th byte contains the operation command data shown in Table 21-6, the device echoes back
the value which is the same data in the 6th byte position of the received data (in this case, C3H). If the
5th byte does not contain the operation command data, the device enters the halt condition after sending
3 bytes of operation command error code (63H).
4. The 9th through 13th bytes contain the status code. For details on the status code, refer to "21.12 Flash
Memory Status Code".
5. After sending the status code, the device waits for the next operation command data.
Page 252
TMP88FW45AFG
21.6.7 Flash Memory Security Program Setting Mode (Operation Command: FAH)
Table 21-13 shows Flash memory security program setting mode process.
Transfer Data from External Control- Transfer Data from TMP88FW45AFG to Ex-
Transfer Bytes Baud Rate
ler to TMP88FW45AFG ternal Controller
1st byte Matching data (5AH) 9600 bps - (Automatic baud rate adjustment)
2nd byte - 9600 bps OK: Echo back data (5AH)
Error: Nothing transmitted
n’+1th byte (Wait for the next operation com- Modified baud rate -
mand data)
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to "21.7 Error
Code".
Note 2: Refer to "21.10 Passwords".
Note 3: If the security program is enabled for a blank product or a password error occurs for a non-blank product, TMP88FW45AFG
stops UART communication and enters the halt mode. In this case, initialize TMP88FW45AFG by the RESET pin and
reactivate the serial PROM mode.
Note 4: If an error occurs during reception of a password address or a password string, TMP88FW45AFG stops UART commu-
nication and enters the halt mode. In this case, initialize TMP88FW45AFG by the RESET pin and reactivate the serial
PROM mode.
Page 253
21. Serial PROM Mode
21.6 Operation Mode TMP88FW45AFG
1. The 1st through 4th bytes of the transmitted and received data contain the same data as in the Flash
memory writing mode.
2. The 5th byte of the received data contains the command data in the flash memory status output mode
(FAH).
3. When the 5th byte of the received data contains the operation command data shown in Table 21-6, the
device echoes back the value which is the same data in the 6th byte position of the received data (in
this case, FAH). If the 5th byte does not contain the operation command data, the device enters the halt
condition after transmitting 3 bytes of operation command error code (63H).
4. The 7th through m’th bytes of the transmitted and received data contain the same data as in the flash
memory writing mode.
5. The n'th byte contains the status to be transmitted to the external controller in the case of the successful
security program.
Page 254
TMP88FW45AFG
Note:If a password error occurs, TMP88FW45AFG does not transmit an error code.
The data is read for each byte unit and the calculated result is returned as a word.
Example:
The checksum which is transmitted by executing the flash memory write command, RAM loader command,
or flash memory SUM output command is calculated in the manner, as shown above.
Page 255
21. Serial PROM Mode
21.8 Checksum (SUM) TMP88FW45AFG
Flash memory writing mode Even when a part of the flash memory is written, the checksum
of the entire flash memory area (04000H to 21EFFH, and
Data in the entire area of the flash memory FFF00H to FFFFFH) is calculated.
Flash memory SUM output mode The data length, address, record type and checksum in Intel Hex
format are not included in the checksum.
RAM data written in the first received RAM ad- The length of data, address, record type and checksum in Intel
RAM loader mode
dress through the last received RAM address Hex format are not included in the checksum.
Product ID Code Output mode 9th through 18th bytes of the transferred data For details, refer to "21.11 Product ID Code".
Flash Memory Status Output mode 9th through 12th bytes of the transferred data For details, refer to "21.12 Flash Memory Status Code"
When the sector erase is executed, only the erased area is used
All data in the erased area of the flash memory
Flash Memory Erasing mode to calculate the checksum. In the case of the chip erase, an
(the whole or part of the flash memory)
entire area of the flash memory is used.
Page 256
TMP88FW45AFG
21.10 Passwords
The consecutive eight or more-byte data in the flash memory area can be specified to the password.
TMP88FW45AFG compares the data string specified to the password with the password string transmitted from the
external controller. The area in which passwords can be specified is located at addresses 04000H to 21EFFH, and
FFF00H to FFFFFH. The area from FFA0H to FFFFH can not be specified as the passwords area.
If addresses from FFFE0H through FFFFFH are filled with “FFH”, the passwords are not compared because the
product is considered as a blank product. Even in this case, the password count storage addresses and password
comparison start address must be specified. Table 21-16 shows the password setting in the blank product and non-
blank product.
Table 21-16 Password Setting in the Blank Product and Non-Blank Product
PNSA
04000H ≤ PNSA ≤ 21EFFH 04000H ≤ PNSA ≤ 21EFFH
(Password count storage address)
PCSA
04000H ≤ PCSA ≤ 21EFFH 04000H ≤ PCSA ≤ 21F00H - N
(Password comparison start address)
N
* 8≤N
(Password count)
Note 1: When addresses from FFFE0H through FFFFFH are filled with “FFH”, the product is recognized as a blank product.
Note 2: The data including the same consecutive data (three or more bytes) can not be used as a password. (This causes a
password error data. TMP88FW45AFG transmits no data and enters the halt condition.)
Note 3: *: Don’t care.
Note 4: When the above condition is not met, a password error occurs. If a password error occurs, the device enters the halt
condition without returning the error code.
Note 5: In the flash memory writing mode or RAM loader mode, the blank product receives the Intel Hex format data immediately
after receiving PCSA without receiving password strings. In this case, the subsequent processing is performed correctly
because the blank product ignores the data except the start mark (3AH “:”) as the Intel Hex format data, even if the external
controller transmits the dummy password string. However, if the dummy password string contains “3AH”, it is detected as
the start mark erroneously. The microcontroller enters the halt mode. If this causes the problem, do not transmit the dummy
password strings.
Note 6: In the flash memory erasing mode, the external controller must not transmit the password string for the blank product.
Page 257
21. Serial PROM Mode
21.10 Passwords TMP88FW45AFG
UART RXD pin F0H 12H F1H 07H 01H 02H 03H 04H 05H 06H 07H 08H
Flash memory
F012H 08H
"08H" becomes
the umber of
01H passwords Compare
F107H
F108H 02H
F109H 03H
F10AH 04H
05H 8 bytes
F10BH
F10CH 06H
Example
PNSA = F012H F10DH 07H
PCSA = F107H
Password string = 01H,02H,03H,04H,05H 08H
F10EH
06H,07H,08H
Example :Specify PNSA to F000H, and the password string to 8 bytes from address F001H
(PCSA becomes F001H.)
Page 258
TMP88FW45AFG
2nd The number of transfer data (18 bytes from 3rd to 20th byte) 12H
Page 259
21. Serial PROM Mode
21.12 Flash Memory Status Code TMP88FW45AFG
In the Case of
Data Description
TMP88FW45AFG
00H to 03H
3rd Status code
(See figure below)
Status Code 1
7 6 5 4 3 2 1 0
The status from FFFE0H 0: All data is FFH in the area from FFFE0H to FFFFFH.
BLANK
to FFFFFH. 1: The value except FFH is included in the area from FFFE0H to FFFFFH.
Some operation commands are limited by the flash memory status code 1. If the security program is enabled, flash
memory writing mode command and RAM loader mode command can not be executed. Erase all flash memory before
executing these command.
0 0 O O O O O O ×
0 1 Pass Pass O O O Pass Pass
1 0 × × O O O O ×
1 1 × × O O O Pass Pass
Page 260
TMP88FW45AFG
The sector erase (flash memory erasing every 4K bytes) is performed if the address data from "00H" to "1DH" is
specified by ERAREA.
The chip erase (all flash memory erasing) is performed if the address data from "C0H" to "FFH" is specified by
ERAREA. At the same time, the security program for flash memory is also disabled.
Therefore, make sure to execute the chip erase (not sector erase) to disable the security program for flash memory.
Executing the sector erase while the security program is enabled results in an infinite loop.
7 6 5 4 3 2 1 0
ERASTA
Note 1: When the sector erase is executed for the area containing no flash cell, TMP88FW45AFG stops the UART communi cation
and enters the halt condition.
Note 2: Executing the sector erase while the security program is enabled results in an infinite loop.
0Z04000
Page 261
21. Serial PROM Mode
21.13 Specifying the Erasure Area TMP88FW45AFG
Page 262
TMP88FW45AFG
SPCR 7 6 5 4 3 2 1 0
(1FFEH) PIN (Initial value: **** ***0)
0 : Invalid port inputs (The input level is fixed with a hardware feature.)
PIN Port input control in the serial PROM mode R/W
1 : Valid port inputs
Note 1: The SPCR register can be read or written only in the serial PROM mode. When the write instruction is executed to the
SPCR register in the MCU mode, the port input control can not be performed. When the read instruction is executed for
the SPCR register in the MCU mode, read data of bit7 to 1 are unstable.
Note 2: All I/O ports except P45 and P44 ports are controlled by the SPCR register.
Page 263
21.
21.15
Flowchart
21.15
Serial PROM Mode
START
Modify the baud rate
based on the receive data
Setup
Flowchart
Receive data = 30H Receive data = 90H Receive data = 60H Receive data = C0H Receive data = FAH Receive data = C3H Receive data = F0H
Receive data = (Flash memory (Flash memory sum (RAM loader (Product ID (Security program (Flash memory status (Flash memory
5AH No writing mode) output mode) mode) code output mode) setting mode) output mode) erasing mode)
Page 264
OK
Verify the password NG Verify the password NG Verify the password NG
Transmit UART data (Compare the receive (Compare the receive
(Compare the receive
(Echo back the baud rate data and flash data and flash data and flash Receive UART data
modification data) memory data) memory data) memory data)
Infinite loop Infinite loop Infinite loop Upper 4 bits < Lower 4 bits
OK OK OK Receive data
Transmit UART data Transmit UART data Jump to the start address Transmit UART data Transmit UART data
Transmit UART data Transmit UART data Transmit UART data
(Checksum of an entire area) (Checksum of an entire area) (Status of the security (Checksum of
of RAM program (Product ID code) (Transmit data = FBH) (Checksum of an entire area)
program and blank product) the erased area)
TMP88FW45AFG
TMP88FW45AFG
Table 21-19 UART Timing-1 (VDD = 4.5 to 5.5 V, fc = 8 to 20 MHz, Topr = -10 to 40˚C)
Time from matching data reception to the echo back CMeb1 Approx. 930 116.3μs 46.5 μs
Time from baud rate modification data reception to the echo back CMeb2 Approx. 980 122.5 μs 49.0 μs
Time from operation command reception to the echo back CMeb3 Approx. 800 100 μs 40 μs
Erasure time for a sector of a flash memory (in 4-kbyte units) CEsec - 15 ms 15 ms
Table 21-20 UART Timing-2 (VDD = 4.5 to 5.5 V, fc = 8 to 20 MHz, Topr = -10 to 40˚C)
Time from the reset release to the acceptance of start bit of RXD pin RXsup 2100 262.5 μs 105.0 μs
Time from the echo back of matching data to the acceptance of baud rate
CMtr2 380 47.5 μs 19.0 μs
modification data
Time from the echo back of baud rate modification data to the acceptance
CMtr3 650 81.25 μs 32.5 μs
of an operation command
Time from the echo back of operation command to the acceptance of pass-
CMtr4 800 100 μs 40 μs
word count storage addresses (Upper byte)
RESET pin
(5AH) (28H) (30H)
RXD pin
(5AH) (28H) (30H)
TXD pin
TXD pin
CMtr1
Page 265
21. Serial PROM Mode
21.16 UART Timing TMP88FW45AFG
Page 266
TMP88FW45AFG
Osc. enable fc
XIN XOUT
VDD
RIN Hysteresis input
RESET Input Pull-up resistor included
RIN = 220 kΩ (typ.)
R
Fix the TEST pin at “L” level in MCU
TEST Input mode.
R=100Ω(typ.).
Initial "High-Z"
P0
Data output
P3 Tri-state output
P4 Output control Programmable open-drain
I/O
P5 P3, P4, P5: Large-current port
P8 Disable Hysteresis input
Pin input
Initial "High-Z"
Data output
Pin input
Page 267
22. Input/Output Circuitry
22.2 Input/output ports TMP88FW45AFG
Initial "High-Z"
Data output
P6
I/O Tri-state output
P7
Disable
Pin input
Initial "High-Z"
Data output
Tri-state output
P1 I/O
Hysteresis input
Disable
Pin input
Initial "High-Z"
Open-drain output
P2 I/O
Hysteresis input
Data output
Pin input
Page 268
TMP88FW45AFG
(VSS = 0 V)
Page 269
23. Electrical Characteristics
23.2 Operating Conditions TMP88FW45AFG
Page 270
TMP88FW45AFG
Page 271
23. Electrical Characteristics
23.3 DC Characteristics TMP88FW45AFG
23.3 DC Characteristics
IIN1 TEST
Input current IIN2 Sink open drain, tri - state port VDD = 5.5 V, VIN = 5.5 V/0 V - - ±2 μA
IIN3 RESET, STOP
Input resistance RIN2 RESET VDD = 5.5 V, VIN = 5.5 V 90 220 510 kΩ
Output leakage current ILO1 Sink open drain, tri - state port VDD = 5.5 V, VOUT = 5.5 V/0 V - - ±2 μA
Output high voltage VOH Tri - state port VDD = 4.5 V, IOH = -0.7 mA 4.1 - - V
IOL1 P0,P1,P2,P6,P7,P8,P9 ports VDD = 4.5 V, VOL = 0.4 V - 1.6 -
Output low current mA
IOL2 P3,P4,P5 ports VDD = 4.5 V, VOL = 1.0 V - 20 -
Peak current on inter-
mittent operation IDD-P VDD = 5.5 V - 10 -
(Note 4)
Supply current in VDD = 5.5 V mA
- 15 22
NORMAL mode VIN = 5.3 V/0.2 V
Supply current in fc = 16 MHz
- 8 14.5
IDLE mode IDD VTEST = 5.3 V / 0.1 V (Note 6)
VDD = 5.5 V
Supply current in
VIN = 5.3 V/0.2 V - 2 100 μA
STOP mode
VTEST = 5.3 V / 0.1 V (Note 6)
MCU current
Page 272
TMP88FW45AFG
23.4 AD Characteristics
Max
Parameter Symbol Condition Min Typ. Unit
8 bit 10 bit
Analog reference voltage VAREF AVDD = VAREF , VSS = 0.0 V VDD - 1.0 - VDD
V
Analog input voltage VAIN VASS - VAREF
Note 1: The total error includes all errors except a quantization error, and is defined as a maximum deviation from the ideal
conversion line.
Note 2: Conversion time is different in recommended value by power supply voltage.
Note 3: The voltage to be input on the AIN input pin must not exceed the range between VAREF and VSS. If a voltage outside this
range is input, conversion values will become unstable and conversion values of other channels will also be affected.
Note 4: Analog reference voltage range: ΔVAREF = VAREF - VSS
Note 5: When AD converter is not used, fix the AVDD and VAREF pin on the VDD level.
23.5 AC Characteristics
NORMAL mode
Machine cycle time tcy 0.2 - 0.5 μs
IDLE mode
High-level clock pulse width tWCH For external clock operation (XIN input)
25 - - ns
Low-level clock pulse width tWCL fc = 20 MHz
Page 273
23. Electrical Characteristics
23.6 Oscillation Frequency Detection AC Characteristics TMP88FW45AFG
TOFD TOFD
High-frequency
clock
Stable Abnormal or Stop Stable
(VSS = 0 V)
Number of guaranteed writes to flash memory Topr = -10 to 40°C - - 100 Times
Page 274
TMP88FW45AFG
XIN XOUT
C1 C2
Note 1: To ensure stable oscillation, the resonator position, load capacitance, etc. must be appropriate. Because these factors
are greatly affected by board patterns, please be sure to evaluate operation on the board on which the device will
actually be mounted.
Note 2: The product numbers and specifications of the resonators by Murata Manufacturing Co., Ltd. are subject to change.
For up-to-date information, please refer to the following URL:
http://www.murata.com
Page 275
23. Electrical Characteristics
23.9 Handling Precaution TMP88FW45AFG
Page 276
TMP88FW45AFG
Page 277
24. Package Dimensions
TMP88FW45AFG
Page 278
This is a technical document that describes the operating functions and electrical specifications of the 8-bit
microcontroller series TLCS-870/X (LSI).
Toshiba provides a variety of development tools and basic software to enable efficient software development.
These development tools have specifications that support advances in microcomputer hardware (LSI) and
can be used extensively. Both the hardware and software are supported continuously with version updates.
The recent advances in CMOS LSI production technology have been phenomenal and microcomputer sys-
tems for LSI design are constantly being improved. The products described in this document may also be
revised in the future. Be sure to check the latest specifications before using.
Toshiba is developing highly integrated, high-performance microcomputers using advanced MOS produc-
tion technology and especially well proven CMOS technology.
We are prepared to meet the requests for custom packaging for a variety of application areas.
We are confident that our products can satisfy your application needs now and in the future.