TOSHIBA TMP86FS28FG

8 Bit Microcontroller
TLCS-870/C Series
TMP86FS28FG
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 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
The products described in this document are subject to foreign exchange and foreign trade control
laws. 060925_E
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
© 2007 TOSHIBA CORPORATION
All Rights Reserved
Revision History
Date
Revision
2006/2/9
Tentative 1
First Release
2006/3/6
Tentative 2
First Release
2006/4/13
1
First Release
2006/6/29
2
Periodical updating.No change in contents.
2006/9/28
3
Contents Revised
2007/7/23
4
Contents Revised
Table of Contents
TMP86FS28FG
1.1
1.2
1.3
1.4
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Pin Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Pin Names and Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
3
4
5
2. Operational Description
2.1
CPU Core Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.1.1
2.1.2
2.1.3
Memory Address Map............................................................................................................................... 9
Program Memory (Flash) .......................................................................................................................... 9
Data Memory (RAM) ................................................................................................................................. 9
2.2.1
2.2.2
Clock Generator...................................................................................................................................... 10
Timing Generator .................................................................................................................................... 12
2.2
System Clock Controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2.2.1
2.2.2.2
Configuration of timing generator
Machine cycle
2.2.3.1
2.2.3.2
2.2.3.3
Single-clock mode
Dual-clock mode
STOP mode
2.2.4.1
2.2.4.2
2.2.4.3
2.2.4.4
STOP mode
IDLE1/2 mode and SLEEP1/2 mode
IDLE0 and SLEEP0 modes (IDLE0, SLEEP0)
SLOW mode
2.2.3
2.2.4
2.3
Operation Mode Control Circuit .............................................................................................................. 13
Operating Mode Control ......................................................................................................................... 18
Reset Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.3.1
2.3.2
2.3.3
2.3.4
External Reset Input ...............................................................................................................................
Address trap reset ..................................................................................................................................
Watchdog timer reset..............................................................................................................................
System clock reset..................................................................................................................................
31
32
32
32
3. Interrupt Control Circuit
3.1
3.2
Interrupt latches (IL29 to IL2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Interrupt enable register (EIR) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.2.1
3.2.2
Interrupt master enable flag (IMF) .......................................................................................................... 36
Individual interrupt enable flags (EF29 to EF4) ...................................................................................... 37
3.3.1
3.3.2
Interrupt acceptance processing is packaged as follows........................................................................ 39
Saving/restoring general-purpose registers ............................................................................................ 40
Note 3: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.3 Interrupt Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3.2.1
3.3.2.2
Using PUSH and POP instructions
Using data transfer instructions
3.3.3
Interrupt return ........................................................................................................................................ 41
3.4.1
3.4.2
Address error detection .......................................................................................................................... 42
Debugging .............................................................................................................................................. 42
3.4
Software Interrupt (INTSW) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
i
3.5
3.6
3.7
Undefined Instruction Interrupt (INTUNDEF). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Address Trap Interrupt (INTATRAP) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
External Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4. Special Function Register (SFR)
4.1
4.2
SFR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
DBR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5. I/O Ports
5.1
5.2
5.3
5.4
5.5
5.6
5.7
5.8
5.9
Port P0 (P00 to P02) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P1 (P10 to P17) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P2 (P20 to P22) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P3 (P30 to P37) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P4 (P40 to P47) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P5 (P50 to P57) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P6 (P60 to P67) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P7 (P70 to P77) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Port P8 (P80 to P87) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
53
55
58
59
61
63
65
67
69
6. Watchdog Timer (WDT)
6.1
6.2
Watchdog Timer Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Watchdog Timer Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.2.1
6.2.2
6.2.3
6.2.4
6.2.5
Malfunction Detection Methods Using the Watchdog Timer ...................................................................
Watchdog Timer Enable .........................................................................................................................
Watchdog Timer Disable ........................................................................................................................
Watchdog Timer Interrupt (INTWDT)......................................................................................................
Watchdog Timer Reset ...........................................................................................................................
72
73
74
74
75
6.3.1
6.3.2
6.3.3
6.3.4
Selection of Address Trap in Internal RAM (ATAS) ................................................................................
Selection of Operation at Address Trap (ATOUT) ..................................................................................
Address Trap Interrupt (INTATRAP).......................................................................................................
Address Trap Reset ................................................................................................................................
76
76
76
77
6.3
Address Trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
7. Time Base Timer (TBT)
7.1
Time Base Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
7.1.1
7.1.2
7.1.3
Configuration .......................................................................................................................................... 79
Control .................................................................................................................................................... 79
Function .................................................................................................................................................. 80
7.2.1
7.2.2
Configuration .......................................................................................................................................... 81
Control .................................................................................................................................................... 81
7.2
Divider Output (DVO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
8. 16-Bit TimerCounter (TC10,TC11)
8.1
ii
16-Bit TimerCounter 10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
8.1.1
8.1.2
8.1.3
8.2
Configuration .......................................................................................................................................... 83
TimerCounter Control ............................................................................................................................. 84
Function .................................................................................................................................................. 85
8.1.3.1
8.1.3.2
8.1.3.3
8.1.3.4
8.1.3.5
8.1.3.6
Timer mode
External Trigger Timer Mode
Event Counter Mode
Window Mode
Pulse Width Measurement Mode
Programmable Pulse Generate (PPG) Output Mode
16-Bit TimerCounter 11 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
8.2.1
8.2.2
8.2.3
Configuration .......................................................................................................................................... 97
TimerCounter Control ............................................................................................................................. 98
Function .................................................................................................................................................. 99
8.2.3.1
8.2.3.2
8.2.3.3
8.2.3.4
8.2.3.5
8.2.3.6
Timer mode
External Trigger Timer Mode
Event Counter Mode
Window Mode
Pulse Width Measurement Mode
Programmable Pulse Generate (PPG) Output Mode
9. 8-Bit TimerCounter (TC3, TC4)
9.1
9.2
9.3
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
TimerCounter Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
9.3.1
9.3.2
9.3.3
9.3.4
9.3.5
9.3.6
9.3.7
9.3.8
9.3.9
8-Bit Timer Mode (TC3 and 4) ..............................................................................................................
8-Bit Event Counter Mode (TC3, 4) ......................................................................................................
8-Bit Programmable Divider Output (PDO) Mode (TC3, 4)...................................................................
8-Bit Pulse Width Modulation (PWM) Output Mode (TC3, 4)................................................................
16-Bit Timer Mode (TC3 and 4) ............................................................................................................
16-Bit Event Counter Mode (TC3 and 4) ..............................................................................................
16-Bit Pulse Width Modulation (PWM) Output Mode (TC3 and 4)........................................................
16-Bit Programmable Pulse Generate (PPG) Output Mode (TC3 and 4) .............................................
Warm-Up Counter Mode.......................................................................................................................
9.3.9.1
9.3.9.2
117
118
118
121
123
124
124
127
129
Low-Frequency Warm-up Counter Mode
(NORMAL1 → NORMAL2 → SLOW2 → SLOW1)
High-Frequency Warm-Up Counter Mode
(SLOW1 → SLOW2 → NORMAL2 → NORMAL1)
10. 8-Bit TimerCounter (TC5, TC6)
10.1
10.2
10.3
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
TimerCounter Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
10.3.1
10.3.2
10.3.3
10.3.4
10.3.5
10.3.6
10.3.7
10.3.8
10.3.9
8-Bit Timer Mode (TC5 and 6) ............................................................................................................
8-Bit Event Counter Mode (TC5, 6) ....................................................................................................
8-Bit Programmable Divider Output (PDO) Mode (TC5, 6).................................................................
8-Bit Pulse Width Modulation (PWM) Output Mode (TC5, 6)..............................................................
16-Bit Timer Mode (TC5 and 6) ..........................................................................................................
16-Bit Event Counter Mode (TC5 and 6) ............................................................................................
16-Bit Pulse Width Modulation (PWM) Output Mode (TC5 and 6)......................................................
16-Bit Programmable Pulse Generate (PPG) Output Mode (TC5 and 6) ...........................................
Warm-Up Counter Mode.....................................................................................................................
10.3.9.1
10.3.9.2
137
138
138
141
143
144
144
147
149
Low-Frequency Warm-up Counter Mode
(NORMAL1 → NORMAL2 → SLOW2 → SLOW1)
High-Frequency Warm-Up Counter Mode
(SLOW1 → SLOW2 → NORMAL2 → NORMAL1)
11. Synchronous Serial Interface (SIO)
11.1
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
iii
11.2
11.3
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
11.3.1
Internal clock
External clock
11.3.2.1
11.3.2.2
Leading edge
Trailing edge
11.3.2
11.4
11.5
11.6
Clock source ....................................................................................................................................... 153
11.3.1.1
11.3.1.2
Shift edge............................................................................................................................................ 155
Number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Transfer Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
11.6.1
11.6.2
11.6.3
4-bit and 8-bit transfer modes ............................................................................................................. 156
4-bit and 8-bit receive modes ............................................................................................................. 158
8-bit transfer / receive mode ............................................................................................................... 159
12. Asynchronous Serial interface (UART1 )
12.1
12.2
12.3
12.4
12.5
12.6
12.7
12.8
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transfer Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transfer Rate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Sampling Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
STOP Bit Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transmit/Receive Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12.8.1
12.8.2
Data Transmit Operation .................................................................................................................... 166
Data Receive Operation ..................................................................................................................... 166
12.9.1
12.9.2
12.9.3
12.9.4
12.9.5
12.9.6
Parity Error..........................................................................................................................................
Framing Error......................................................................................................................................
Overrun Error ......................................................................................................................................
Receive Data Buffer Full.....................................................................................................................
Transmit Data Buffer Empty ...............................................................................................................
Transmit End Flag ..............................................................................................................................
12.9
161
162
164
165
165
166
166
166
Status Flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
167
167
167
168
168
169
13. Asynchronous Serial interface (UART0 )
13.1
13.2
13.3
13.4
13.5
13.6
13.7
13.8
13.8.1
13.8.2
Data Transmit Operation .................................................................................................................... 176
Data Receive Operation ..................................................................................................................... 176
13.9.1
13.9.2
13.9.3
13.9.4
13.9.5
13.9.6
Parity Error..........................................................................................................................................
Framing Error......................................................................................................................................
Overrun Error ......................................................................................................................................
Receive Data Buffer Full.....................................................................................................................
Transmit Data Buffer Empty ...............................................................................................................
Transmit End Flag ..............................................................................................................................
13.9
iv
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transfer Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transfer Rate. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Data Sampling Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
STOP Bit Length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Transmit/Receive Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
171
172
174
175
175
176
176
176
Status Flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
177
177
177
178
178
179
14. 10-bit AD Converter (ADC)
14.1
14.2
14.3
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Register configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182
Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
14.3.1
14.3.2
14.3.3
Software Start Mode ........................................................................................................................... 185
Repeat Mode ...................................................................................................................................... 185
Register Setting ................................................................................................................................ 186
14.6.1
14.6.2
14.6.3
Analog input pin voltage range ........................................................................................................... 189
Analog input shared pins .................................................................................................................... 189
Noise Countermeasure ....................................................................................................................... 189
14.4
14.5
14.6
STOP/SLOW Modes during AD Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Analog Input Voltage and AD Conversion Result . . . . . . . . . . . . . . . . . . . . . . . 188
Precautions about AD Converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
15. Key-on Wakeup (KWU)
15.1
15.2
15.3
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
16. LCD Driver
16.1
16.2
Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193
Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
16.2.1
16.2.2
16.2.3
16.3
LCD driving methods .......................................................................................................................... 195
Frame frequency................................................................................................................................. 196
Driving method for LCD driver ............................................................................................................ 197
16.2.3.1
16.2.3.2
When using the booster circuit (LCDCR<BRES>="1")
When using an external resistor divider (LCDCR<BRES>="0")
LCD Display Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
16.3.1
16.3.2
Display data setting ............................................................................................................................ 199
Blanking .............................................................................................................................................. 200
16.4.1
16.4.2
16.4.3
Initial setting ........................................................................................................................................ 201
Store of display data ........................................................................................................................... 201
Example of LCD drive output .............................................................................................................. 204
16.4
Control Method of LCD Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
17. Flash Memory
17.1
Flash Memory Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
17.1.1
17.1.2
17.1.3
Flash Memory Command Sequence Execution Control (FLSCR<FLSMD>) ..................................... 210
Flash Memory Bank Select Control (FLSCR<BANKSEL>) ................................................................ 210
Flash Memory Standby Control (FLSSTB<FSTB>) ............................................................................ 211
17.2.1
17.2.2
17.2.3
17.2.4
17.2.5
17.2.6
Byte Program ......................................................................................................................................
Sector Erase (4-kbyte Erase) .............................................................................................................
Chip Erase (All Erase) ........................................................................................................................
Product ID Entry .................................................................................................................................
Product ID Exit ....................................................................................................................................
Read Protect .......................................................................................................................................
17.2
17.3
17.4
Command Sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
212
212
213
213
213
213
Toggle Bit (D6) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Access to the Flash Memory Area. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215
v
17.4.1
17.4.2
Flash Memory Control in the Serial PROM Mode............................................................................... 215
Flash Memory Control in the MCU mode............................................................................................ 216
17.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)
18. Serial PROM Mode
18.1
18.2
18.3
Outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Memory Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Serial PROM Mode Setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
18.3.1
18.3.2
18.3.3
18.3.4
Serial PROM Mode Control Pins ........................................................................................................
Pin Function........................................................................................................................................
Example Connection for On-Board Writing.........................................................................................
Activating the Serial PROM Mode ......................................................................................................
220
220
221
222
18.6.1
18.6.2
18.6.3
18.6.4
18.6.5
18.6.6
Flash Memory Erasing Mode (Operating command: F0H) .................................................................
Flash Memory Writing Mode (Operation command: 30H) ..................................................................
Flash Memory SUM Output Mode (Operation Command: 90H) .........................................................
Product ID Code Output Mode (Operation Command: C0H)..............................................................
Flash Memory Status Output Mode (Operation Command: C3H) ......................................................
Flash Memory Read Protection Setting Mode (Operation Command: FAH) ......................................
226
228
231
232
234
235
18.8.1
18.8.2
Calculation Method ............................................................................................................................. 237
Calculation data .................................................................................................................................. 238
18.10.1
18.10.2
18.10.3
Password String................................................................................................................................ 240
Handling of Password Error .............................................................................................................. 240
Password Management during Program Development .................................................................... 240
18.4
18.5
18.6
18.7
18.8
Interface Specifications for UART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
Operation Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Operation Mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Error Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
Checksum (SUM) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
18.9 Intel Hex Format (Binary) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
18.10 Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
18.11
18.12
18.13
18.14
18.15
Product ID Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Flash Memory Status Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Specifying the Erasure Area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
UART Timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
241
241
243
244
245
19. Input/Output Circuitry
19.1
19.2
Control Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Input/Output Ports
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
20. Electrical Characteristics
20.1
20.2
Absolute Maximum Ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
Operating Condition. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
20.2.1
20.2.2
20.2.3
20.3
20.4
20.5
20.6
vi
MCU mode (Flash Programming or erasing) ..................................................................................... 250
MCU mode (Except Flash Programming or erasing) ......................................................................... 250
Serial PROM mode ............................................................................................................................. 251
DC Characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
AD Conversion Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
AC Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Flash Characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
252
253
254
254
20.7
20.8
Recommended Oscillating Conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Handling Precaution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
21. Package Dimensions
This is a technical document that describes the operating functions and electrical
specifications of the 8-bit microcontroller series TLCS-870/C (LSI).
vii
viii
TMP86FS28FG
CMOS 8-Bit Microcontroller
TMP86FS28FG
The TMP86FS28FG is a single-chip 8-bit high-speed and high-functionality microcomputer incorporating 61440
bytes of Flash Memory. It is pin-compatible with the TMP86CS28FG (Mask ROM version). The TMP86FS28FG
can realize operations equivalent to those of the TMP86CS28FG by programming the on-chip Flash Memory.
Product No.
ROM
(FLASH)
RAM
Package
MASK ROM MCU
Emulation Chip
TMP86FS28FG
61440
bytes
2048
bytes
QFP80-P-1420-0.80B
TMP86CS28FG
TMP86C989XB
1.1 Features
1. 8-bit single chip microcomputer TLCS-870/C series
- Instruction execution time :
0.25 µs (at 16 MHz)
122 µs (at 32.768 kHz)
- 132 types & 731 basic instructions
2. 23interrupt sources (External : 6 Internal : 17)
3. Input / Output ports (62 pins)
4. Watchdog Timer
5. Prescaler
- Time base timer
- Divider output function
6. 16-bit timer counter: 2 ch
- Timer, External trigger, Window, Pulse width measurement,
Event counter, Programmable pulse generate (PPG) modes
7. 8-bit timer counter : 4 ch
- Timer, Event counter, Programmable divider output (PDO),
Pulse width modulation (PWM) output,
Programmable pulse generation (PPG) modes
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 property.
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 malfunctionor 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
• The products described in this document are subject to foreign exchange and foreign trade control laws. 060925_E
• 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
TMP86FS28FG
8. 8-bit UART/SIO: 1 ch
9. 8-bit UART : 1 ch
10. 10-bit successive approximation type AD converter
- Analog input: 8 ch
11. Key-on wakeup : 4 ch
12. LCD driver/controller
Built-in voltage booster for LCD driver With display memory
LCD direct drive capability (MAX 40 seg × 4 com)
1/4,1/3,1/2duties or static drive are programmably selectable
13. Clock operation
Single clock mode
Dual clock mode
14. Low power consumption operation
STOP mode: Oscillation stops. (Battery/Capacitor back-up.)
SLOW1 mode: Low power consumption operation using low-frequency clock.(High-frequency clock
stop.)
SLOW2 mode: Low power consumption operation using low-frequency clock.(High-frequency clock
oscillate.)
IDLE0 mode: CPU stops, and only the Time-Based-Timer(TBT) on peripherals operate using high frequency clock. Release by falling edge of the source clock which is set by TBTCR<TBTCK>.
IDLE1 mode: CPU stops and peripherals operate using high frequency clock. Release by interruputs(CPU restarts).
IDLE2 mode: CPU stops and peripherals operate using high and low frequency clock. Release by interruputs. (CPU restarts).
SLEEP0 mode: CPU stops, and only the Time-Based-Timer(TBT) on peripherals operate using low frequency clock.Release by falling edge of the source clock which is set by TBTCR<TBTCK>.
SLEEP1 mode: CPU stops, and peripherals operate using low frequency clock. Release by interruput.(CPU restarts).
SLEEP2 mode: CPU stops and peripherals operate using high and low frequency clock.
interruput.
15. Wide operation voltage:
2.7 V to 5.5 V at 8MHz /32.768 kHz
4.0 V to 5.5 V at 16 MHz /32.768 kHz
Page 2
Release by
RESET
(INT5/STOP) P20
P00
P01
(INT3/PPG10) P02
AVDD
VAREF
(AIN0) P10
(AIN1) P11
(STOP2/AIN2) P12
(STOP3/AIN3) P13
(STOP4/AIN4) P14
(STOP5/AIN5) P15
(AIN6) P16
(AIN7) P17
AVSS
(INT0) P30
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
64
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
(SEG6) P81
(SEG5) P82
(SEG4) P83
(SEG3) P84
(SEG2) P85
(SEG1) P86
(SEG0) P87
COM3
COM2
COM1
COM0
V3
V2
V1
C1
C0
VSS
XIN
XOUT
TEST
VDD
(XTIN) P21
(XTOUT) P22
P80 (SEG7)
P77 (SEG8)
P76 (SEG9)
P75 (SEG10)
P74 (SEG11)
P73 (SEG12)
P72 (SEG13)
P71 (SEG14)
P70 (SEG15)
P67 (SEG16)
P66 (SEG17)
P65 (SEG18)
P64 (SEG19)
P63 (SEG20)
P62 (SEG21)
P61 (SEG22)
P60 (SEG23)
P57 (SEG24)
P56 (SEG25)
P55 (SEG26/TC6/PDO6/PWM6/PPG6)
P54 (SEG27/TC5/PDO5/PWM5)
P53 (SEG28/TC4/PDO4/PWM4/PPG4)
P52 (SEG29/TC3/PDO3/PWM3)
P51 (SEG30/RXD0)
TMP86FS28FG
1.2 Pin Assignment
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
Figure 1-1 Pin Assignment
Page 3
P50 (SEG31/TXD0)
P47 (SEG32)
P46 (SEG33)
P45 (SEG34)
P44 (SEG35)
P43 (SEG36/TC11)
P42 (SEG37/PPG11)
P41 (SEG38/INT2)
P40 (SEG39/INT1)
P37 (TC10/INT4)
P36(SCK)
P35(SI/TXD1)
P34(SO/RXD1)
P33
P32
P31(DVO)
1.3 Block Diagram
TMP86FS28FG
1.3 Block Diagram
Figure 1-2 Block Diagram
Page 4
TMP86FS28FG
1.4 Pin Names and Functions
The TMP86FS28FG has MCU mode, parallel PROM mode, and serial PROM mode. Table 1-1 shows the pin
functions in MCU mode. The serial PROM mode is explained later in a separate chapter.
Table 1-1 Pin Names and Functions(1/4)
Pin Name
Pin Number
Input/Output
Functions
12
IO
O
I
PORT02
PPG10 output
External interrupt 3 input
P01
11
IO
PORT01
P00
10
IO
PORT00
P17
AIN7
22
IO
I
PORT17
Analog Input7
P16
AIN6
21
IO
I
PORT16
Analog Input6
P15
AIN5
STOP5
20
IO
I
I
PORT15
Analog Input5
STOP5 input
P14
AIN4
STOP4
19
IO
I
I
PORT14
Analog Input4
STOP4 input
P13
AIN3
STOP3
18
IO
I
I
PORT13
Analog Input3
STOP3 input
P12
AIN2
STOP2
17
IO
I
I
PORT12
Analog Input2
STOP2 input
P11
AIN1
16
IO
I
PORT11
Analog Input1
P10
AIN0
15
IO
I
PORT10
Analog Input0
P22
XTOUT
7
IO
O
PORT22
Resonator connecting pins(32.768kHz) for inputting external
clock
P21
XTIN
6
IO
I
PORT21
Resonator connecting pins(32.768kHz) for inputting external
clock
9
IO
I
I
PORT20
STOP mode release signal input
External interrupt 5 input
31
IO
I
I
PORT37
TC10 input
External interrupt 4 input
30
IO
IO
PORT36
Serial Clock I/O
P35
SI
TXD1
29
IO
I
O
PORT35
Serial Data Input
UART data output 1
P34
SO
RXD1
28
IO
O
I
PORT34
Serial Data Output
UART data input 1
P02
PPG10
INT3
P20
STOP
INT5
P37
TC10
INT4
P36
SCK
Page 5
1.4 Pin Names and Functions
TMP86FS28FG
Table 1-1 Pin Names and Functions(2/4)
Pin Name
Pin Number
Input/Output
Functions
P33
27
IO
PORT33
P32
26
IO
PORT32
25
IO
O
PORT31
Divider Output
24
IO
I
PORT30
External interrupt 0 input
P47
SEG32
39
IO
O
PORT47
LCD segment output 32
P46
SEG33
38
IO
O
PORT46
LCD segment output 33
P45
SEG34
37
IO
O
PORT45
LCD segment output 34
P44
SEG35
36
IO
O
PORT44
LCD segment output 35
P43
SEG36
TC11
35
IO
O
I
PORT43
LCD segment output 36
TC11 input
34
IO
O
O
PORT42
LCD segment output 37
PPG11 output
P41
SEG38
INT2
33
IO
O
I
PORT41
LCD segment output 38
External interrupt 2 input
P40
SEG39
INT1
32
IO
O
I
PORT40
LCD segment output 39
External interrupt 1 input
P57
SEG24
47
IO
O
PORT57
LCD segment output 24
P56
SEG25
46
IO
O
PORT56
LCD segment output 25
45
IO
O
I
O
PORT55
LCD segment output 26
TC6 input
PDO6/PWM6/PPG6 output
44
IO
O
I
O
PORT54
LCD segment output 27
TC5 input
PDO5/PWM5 output
43
IO
O
I
O
PORT53
LCD segment output 28
TC4 input
PDO4/PWM4/PPG4 output
42
IO
O
I
O
PORT52
LCD segment output 29
TC3 input
41
IO
O
I
PORT51
LCD segment output 30
UART data input 0
P31
DVO
P30
INT0
P42
SEG37
PPG11
P55
SEG26
TC6
PDO6/PWM6/PPG6
P54
SEG27
TC5
PDO5/PWM5
P53
SEG28
TC4
PDO4/PWM4/PPG4
P52
SEG29
TC3
PDO3/PWM3
P51
SEG30
RXD0
Page 6
TMP86FS28FG
Table 1-1 Pin Names and Functions(3/4)
Pin Name
Pin Number
Input/Output
Functions
P50
SEG31
TXD0
40
IO
O
O
PORT50
LCD segment output 31
UART data output 0
P67
SEG16
55
IO
O
PORT67
LCD segment output 16
P66
SEG17
54
IO
O
PORT66
LCD segment output 17
P65
SEG18
53
IO
O
PORT65
LCD segment output 18
P64
SEG19
52
IO
O
PORT64
LCD segment output 19
P63
SEG20
51
IO
O
PORT63
LCD segment output 20
P62
SEG21
50
IO
O
PORT62
LCD segment output 21
P61
SEG22
49
IO
O
PORT61
LCD segment output 22
P60
SEG23
48
IO
O
PORT60
LCD segment output 23
P77
SEG8
63
IO
O
PORT77
LCD segment output 8
P76
SEG9
62
IO
O
PORT76
LCD segment output 9
P75
SEG10
61
IO
O
PORT75
LCD segment output 10
P74
SEG11
60
IO
O
PORT74
LCD segment output 11
P73
SEG12
59
IO
O
PORT73
LCD segment output 12
P72
SEG13
58
IO
O
PORT72
LCD segment output 13
P71
SEG14
57
IO
O
PORT71
LCD segment output 14
P70
SEG15
56
IO
O
PORT70
LCD segment output 15
P87
SEG0
71
IO
O
PORT87
LCD segment output 0
P86
SEG1
70
IO
O
PORT86
LCD segment output 1
P85
SEG2
69
IO
O
PORT85
LCD segment output 2
P84
SEG3
68
IO
O
PORT84
LCD segment output 3
P83
SEG4
67
IO
O
PORT83
LCD segment output 4
P82
SEG5
66
IO
O
PORT82
LCD segment output 5
Page 7
1.4 Pin Names and Functions
TMP86FS28FG
Table 1-1 Pin Names and Functions(4/4)
Pin Name
Pin Number
Input/Output
Functions
P81
SEG6
65
IO
O
PORT81
LCD segment output 6
P80
SEG7
64
IO
O
PORT80
LCD segment output 7
COM3
72
O
LCD common output 3
COM2
73
O
LCD common output 2
COM1
74
O
LCD common output 1
COM0
75
O
LCD common output 0
V3
76
I
LCD voltage booster pin
V2
77
I
LCD voltage booster pin
V1
78
I
LCD voltage booster pin
C1
79
I
LCD voltage booster pin
C0
80
I
LCD voltage booster pin
XIN
2
I
Resonator connecting pins for high-frequency clock
XOUT
3
O
Resonator connecting pins for high-frequency clock
RESET
8
I
Reset signal
TEST
4
I
Test pin for out-going test. Normally, be fixed to low.
VAREF
14
I
Analog Base Voltage Input Pin for A/D Conversion
AVDD
13
I
Analog Power Supply
AVSS
23
I
Analog Power Supply
VDD
5
I
+5V
VSS
1
I
0(GND)
Page 8
TMP86FS28FG
2. Operational Description
2.1 CPU Core Functions
The CPU core consists of a CPU, a system clock controller, and an interrupt controller.
This section provides a description of the CPU core, the program memory, the data memory, and the reset circuit.
2.1.1
Memory Address Map
The TMP86FS28FG memory is composed Flash, RAM, DBR(Data buffer register) and SFR(Special function register). They are all mapped in 64-Kbyte address space. Figure 2-1 shows the TMP86FS28FG memory
address map.
0000H
SFR
SFR:
64 bytes
003FH
0040H
2048
bytes
RAM
RAM:
Special function register includes:
I/O ports
Peripheral control registers
Peripheral status registers
System control registers
Program status word
Random access memory includes:
Data memory
Stack
083FH
0F00H
DBR:
256
bytes
DBR
0FFFH
1000H
Flash:
Data buffer register includes:
Peripheral control registers
Peripheral status registers
LCD display memory
Program memory
61440
bytes
Flash
FFA0H
Vector table for interrupts
(32 bytes)
FFBFH
FFC0H
Vector table for vector call instructions
(32 bytes)
FFDFH
FFE0H
Vector table for interrupts
FFFFH
(32 bytes)
Figure 2-1 Memory Address Map
2.1.2
Program Memory (Flash)
The TMP86FS28FG has a 61440 bytes (Address 1000H to FFFFH) of program memory (Flash ).
2.1.3
Data Memory (RAM)
The TMP86FS28FG has 2048 bytes (Address 0040H to 083FH) of internal RAM. The first 192 bytes
(0040H to 00FFH) of the internal RAM are located in the direct area; instructions with shorten operations are
available against such an area.
Page 9
2. Operational Description
2.2 System Clock Controller
TMP86FS28FG
The data memory contents become unstable when the power supply is turned on; therefore, the data memory
should be initialized by an initialization routine.
Example :Clears RAM to “00H”. (TMP86FS28FG)
SRAMCLR:
LD
HL, 0040H
; Start address setup
LD
A, H
; Initial value (00H) setup
LD
BC, 07FFH
LD
(HL), A
INC
HL
DEC
BC
JRS
F, SRAMCLR
2.2 System Clock Controller
The system clock controller consists of a clock generator, a timing generator, and a standby controller.
Timing generator control register
TBTCR
0036H
Clock
generator
XIN
fc
High-frequency
clock oscillator
Timing
generator
XOUT
Standby controller
0038H
XTIN
Low-frequency
clock oscillator
SYSCR1
fs
System clocks
0039H
SYSCR2
System control registers
XTOUT
Clock generator control
Figure 2-2 System Colck Control
2.2.1
Clock Generator
The clock generator generates the basic clock which provides the system clocks supplied to the CPU core
and peripheral hardware. It contains two oscillation circuits: One for the high-frequency clock and one for the
low-frequency clock. Power consumption can be reduced by switching of the standby controller to low-power
operation based on the low-frequency clock.
The high-frequency (fc) clock and low-frequency (fs) clock can easily be obtained by connecting a resonator
between the XIN/XOUT and XTIN/XTOUT pins respectively. Clock input from an external oscillator is also
possible. In this case, external clock is applied to XIN/XTIN pin with XOUT/XTOUT pin not connected.
Page 10
TMP86FS28FG
Low-frequency clock
High-frequency clock
XIN
XOUT
XIN
XOUT
XTIN
XTOUT
(Open)
(a) Crystal/Ceramic
resonator
XTIN
XTOUT
(Open)
(c) Crystal
(b) External oscillator
(d) External oscillator
Figure 2-3 Examples of Resonator Connection
Note:The function to monitor the basic clock directly at external is not provided for hardware, however, with disabling all interrupts and watchdog timers, the oscillation frequency can be adjusted by monitoring the pulse
which the fixed frequency is outputted to the port by the program.
The system to require the adjustment of the oscillation frequency should create the program for the adjustment in advance.
Page 11
2. Operational Description
2.2 System Clock Controller
2.2.2
TMP86FS28FG
Timing Generator
The timing generator generates the various system clocks supplied to the CPU core and peripheral hardware
from the basic clock (fc or fs). The timing generator provides the following functions.
1. Generation of main system clock
2. Generation of divider output (DVO) pulses
3. Generation of source clocks for time base timer
4. Generation of source clocks for watchdog timer
5. Generation of internal source clocks for timer/counters
6. Generation of warm-up clocks for releasing STOP mode
7. LCD
2.2.2.1
Configuration of timing generator
The timing generator consists of a 2-stage prescaler, a 21-stage divider, a main system clock generator,
and machine cycle counters.
An input clock to the 7th stage of the divider depends on the operating mode, SYSCR2<SYSCK> and
TBTCR<DV7CK>, that is shown in Figure 2-4. As reset and STOP mode started/canceled, the prescaler
and the divider are cleared to “0”.
fc or fs
Main system clock generator
Machine cycle counters
SYSCK
DV7CK
High-frequency
clock fc
Low-frequency
clock fs
1 2
fc/4
S
A
Divider
Y
1 2 3 4 5 6
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
B
Multiplexer
S
B0
B1
A0 Y0
A1 Y1
Multiplexer
Warm-up
controller
Watchdog
timer
Timer counter, Serial interface, Time-base-timer, divider output, etc. (Peripheral functions)
Figure 2-4 Configuration of Timing Generator
Page 12
TMP86FS28FG
Timing Generator Control Register
TBTCR
(0036H)
7
6
(DVOEN)
5
(DVOCK)
DV7CK
4
3
DV7CK
(TBTEN)
Selection of input to the 7th stage
of the divider
2
1
0
(TBTCK)
(Initial value: 0000 0000)
0: fc/28 [Hz]
1: fs
R/W
Note 1: In single clock mode, do not set DV7CK to “1”.
Note 2: Do not set “1” on DV7CK while the low-frequency clock is not operated stably.
Note 3: fc: High-frequency clock [Hz], fs: Low-frequency clock [Hz], *: Don’t care
Note 4: In SLOW1/2 and SLEEP1/2 modes, the DV7CK setting is ineffective, and fs is input to the 7th stage of the divider.
Note 5: When STOP mode is entered from NORMAL1/2 mode, the DV7CK setting is ineffective during the warm-up period after
release of STOP mode, and the 6th stage of the divider is input to the 7th stage during this period.
2.2.2.2
Machine cycle
Instruction execution and peripheral hardware operation are synchronized with the main system clock.
The minimum instruction execution unit is called an “machine cycle”. There are a total of 10 different
types of instructions for the TLCS-870/C Series: Ranging from 1-cycle instructions which require one
machine cycle for execution to 10-cycle instructions which require 10 machine cycles for execution. A
machine cycle consists of 4 states (S0 to S3), and each state consists of one main system clock.
1/fc or 1/fs [s]
Main system clock
State
S0
S1
S2
S3
S0
S1
S2
S3
Machine cycle
Figure 2-5 Machine Cycle
2.2.3
Operation Mode Control Circuit
The operation mode control circuit starts and stops the oscillation circuits for the high-frequency and lowfrequency clocks, and switches the main system clock. There are three operating modes: Single clock mode,
dual clock mode and STOP mode. These modes are controlled by the system control registers (SYSCR1 and
SYSCR2). Figure 2-6 shows the operating mode transition diagram.
2.2.3.1
Single-clock mode
Only the oscillation circuit for the high-frequency clock is used, and P21 (XTIN) and P22 (XTOUT)
pins are used as input/output ports. The main-system clock is obtained from the high-frequency clock. In
the single-clock mode, the machine cycle time is 4/fc [s].
(1)
NORMAL1 mode
In this mode, both the CPU core and on-chip peripherals operate using the high-frequency clock.
The TMP86FS28FG is placed in this mode after reset.
Page 13
2. Operational Description
2.2 System Clock Controller
TMP86FS28FG
(2)
IDLE1 mode
In this mode, the internal oscillation circuit remains active. The CPU and the watchdog timer are
halted; however on-chip peripherals remain active (Operate using the high-frequency clock).
IDLE1 mode is started by SYSCR2<IDLE> = "1", and IDLE1 mode is released to NORMAL1
mode by an interrupt request from the on-chip peripherals or external interrupt inputs. When the IMF
(Interrupt master enable flag) is “1” (Interrupt enable), the execution will resume with the acceptance
of the interrupt, and the operation will return to normal after the interrupt service is completed. When
the IMF is “0” (Interrupt disable), the execution will resume with the instruction which follows the
IDLE1 mode start instruction.
(3)
IDLE0 mode
In this mode, all the circuit, except oscillator and the timer-base-timer, stops operation.
This mode is enabled by SYSCR2<TGHALT> = "1".
When IDLE0 mode starts, the CPU stops and the timing generator stops feeding the clock to the
peripheral circuits other than TBT. Then, upon detecting the falling edge of the source clock selected
with TBTCR<TBTCK>, the timing generator starts feeding the clock to all peripheral circuits.
When returned from IDLE0 mode, the CPU restarts operating, entering NORMAL1 mode back
again. IDLE0 mode is entered and returned regardless of how TBTCR<TBTEN> is set. When IMF =
“1”, EF6 (TBT interrupt individual enable flag) = “1”, and TBTCR<TBTEN> = “1”, interrupt processing is performed. When IDLE0 mode is entered while TBTCR<TBTEN> = “1”, the INTTBT
interrupt latch is set after returning to NORMAL1 mode.
2.2.3.2
Dual-clock mode
Both the high-frequency and low-frequency oscillation circuits are used in this mode. P21 (XTIN) and
P22 (XTOUT) pins cannot be used as input/output ports. The main system clock is obtained from the
high-frequency clock in NORMAL2 and IDLE2 modes, and is obtained from the low-frequency clock in
SLOW and SLEEP modes. The machine cycle time is 4/fc [s] in the NORMAL2 and IDLE2 modes, and
4/fs [s] (122 µs at fs = 32.768 kHz) in the SLOW and SLEEP modes.
The TLCS-870/C is placed in the signal-clock mode during reset. To use the dual-clock mode, the lowfrequency oscillator should be turned on at the start of a program.
(1)
NORMAL2 mode
In this mode, the CPU core operates with the high-frequency clock. On-chip peripherals operate
using the high-frequency clock and/or low-frequency clock.
(2)
SLOW2 mode
In this mode, the CPU core operates with the low-frequency clock, while both the high-frequency
clock and the low-frequency clock are operated. As the SYSCR2<SYSCK> becomes "1", the hardware changes into SLOW2 mode. As the SYSCR2<SYSCK> becomes “0”, the hardware changes
into NORMAL2 mode. As the SYSCR2<XEN> becomes “0”, the hardware changes into SLOW1
mode. Do not clear SYSCR2<XTEN> to “0” during SLOW2 mode.
(3)
SLOW1 mode
This mode can be used to reduce power-consumption by turning off oscillation of the high-frequency clock. The CPU core and on-chip peripherals operate using the low-frequency clock.
Page 14
TMP86FS28FG
Switching back and forth between SLOW1 and SLOW2 modes are performed by
SYSCR2<XEN>. In SLOW1 and SLEEP modes, the input clock to the 1st stage of the divider is
stopped; output from the 1st to 6th stages is also stopped.
(4)
IDLE2 mode
In this mode, the internal oscillation circuit remain active. The CPU and the watchdog timer are
halted; however, on-chip peripherals remain active (Operate using the high-frequency clock and/or
the low-frequency clock). Starting and releasing of IDLE2 mode are the same as for IDLE1 mode,
except that operation returns to NORMAL2 mode.
(5)
SLEEP1 mode
In this mode, the internal oscillation circuit of the low-frequency clock remains active. The CPU,
the watchdog timer, and the internal oscillation circuit of the high-frequency clock are halted; however, on-chip peripherals remain active (Operate using the low-frequency clock). Starting and releasing of SLEEP mode are the same as for IDLE1 mode, except that operation returns to SLOW1 mode.
In SLOW1 and SLEEP1 modes, the input clock to the 1st stage of the divider is stopped; output from
the 1st to 6th stages is also stopped.
(6)
SLEEP2 mode
The SLEEP2 mode is the idle mode corresponding to the SLOW2 mode. The status under the
SLEEP2 mode is same as that under the SLEEP1 mode, except for the oscillation circuit of the highfrequency clock.
(7)
SLEEP0 mode
In this mode, all the circuit, except oscillator and the timer-base-timer, stops operation. This mode
is enabled by setting “1” on bit SYSCR2<TGHALT>.
When SLEEP0 mode starts, the CPU stops and the timing generator stops feeding the clock to the
peripheral circuits other than TBT. Then, upon detecting the falling edge of the source clock selected
with TBTCR<TBTCK>, the timing generator starts feeding the clock to all peripheral circuits.
When returned from SLEEP0 mode, the CPU restarts operating, entering SLOW1 mode back
again. SLEEP0 mode is entered and returned regardless of how TBTCR<TBTEN> is set. When IMF
= “1”, EF6 (TBT interrupt individual enable flag) = “1”, and TBTCR<TBTEN> = “1”, interrupt processing is performed. When SLEEP0 mode is entered while TBTCR<TBTEN> = “1”, the INTTBT
interrupt latch is set after returning to SLOW1 mode.
2.2.3.3
STOP mode
In this mode, the internal oscillation circuit is turned off, causing all system operations to be halted. The
internal status immediately prior to the halt is held with a lowest power consumption during STOP mode.
STOP mode is started by the system control register 1 (SYSCR1), and STOP mode is released by a
inputting (Either level-sensitive or edge-sensitive can be programmably selected) to the STOP pin. After
the warm-up period is completed, the execution resumes with the instruction which follows the STOP
mode start instruction.
Page 15
2. Operational Description
2.2 System Clock Controller
TMP86FS28FG
IDLE0
mode
RESET
Reset release
Note 2
SYSCR2<TGHALT> = "1"
SYSCR1<STOP> = "1"
SYSCR2<IDLE> = "1"
NORMAL1
mode
Interrupt
STOP pin input
IDLE1
mode
(a) Single-clock mode
SYSCR2<XTEN> = "0"
SYSCR2<XTEN> = "1"
SYSCR2<IDLE> = "1"
IDLE2
mode
NORMAL2
mode
Interrupt
SYSCR1<STOP> = "1"
STOP pin input
SYSCR2<SYSCK> = "0"
SYSCR2<SYSCK> = "1"
STOP
SYSCR2<IDLE> = "1"
SLEEP2
mode
SLOW2
mode
Interrupt
SYSCR2<XEN> = "0"
SYSCR2<XEN> = "1"
SYSCR2<IDLE> = "1"
SLEEP1
mode
Interrupt
(b) Dual-clock mode
SYSCR1<STOP> = "1"
SLOW1
mode
STOP pin input
SYSCR2<TGHALT> = "1"
Note 2
SLEEP0
mode
Note 1: NORMAL1 and NORMAL2 modes are generically called NORMAL; SLOW1 and SLOW2 are called SLOW; IDLE0, IDLE1
and IDLE2 are called IDLE; SLEEP0, SLEEP1 and SLEEP2 are called SLEEP.
Note 2: The mode is released by falling edge of TBTCR<TBTCK> setting.
Figure 2-6 Operating Mode Transition Diagram
Table 2-1 Operating Mode and Conditions
Oscillator
Operating Mode
High
Frequency
Low
Frequency
RESET
NORMAL1
Single clock
IDLE1
Oscillation
Reset
Operate
Halt
Operate
Halt
Operate with
high frequency
Machine Cycle
Time
4/fc [s]
–
4/fc [s]
Halt
Oscillation
Operate with
low frequency
Oscillation
Halt
Operate
Operate
Operate with
low frequency
SLOW1
4/fs [s]
Stop
SLEEP0
STOP
Reset
Stop
SLEEP2
SLEEP1
Reset
Halt
SLOW2
Dual clock
Other
Peripherals
Stop
NORMAL2
IDLE2
TBT
Operate
IDLE0
STOP
CPU Core
Halt
Stop
Halt
Page 16
Halt
–
TMP86FS28FG
System Control Register 1
SYSCR1
7
6
5
4
(0038H)
STOP
RELM
RETM
OUTEN
3
2
1
0
WUT
(Initial value: 0000 00**)
STOP
STOP mode start
0: CPU core and peripherals remain active
1: CPU core and peripherals are halted (Start STOP mode)
R/W
RELM
Release method for STOP
mode
0: Edge-sensitive release
1: Level-sensitive release
R/W
RETM
Operating mode after STOP
mode
0: Return to NORMAL1/2 mode
1: Return to SLOW1 mode
R/W
Port output during STOP mode
0: High impedance
1: Output kept
R/W
OUTEN
WUT
Warm-up time at releasing
STOP mode
Return to NORMAL mode
Return to SLOW mode
00
3 x 216/fc
3 x 213/fs
01
216/fc
213/fs
10
3 x 214/fc
3 x 26/fs
11
214/fc
26/fs
R/W
Note 1: Always set RETM to “0” when transiting from NORMAL mode to STOP mode. Always set RETM to “1” when transiting
from SLOW mode to STOP mode.
Note 2: When STOP mode is released with RESET pin input, a return is made to NORMAL1 regardless of the RETM contents.
Note 3: fc: High-frequency clock [Hz], fs: Low-frequency clock [Hz], *; Don’t care
Note 4: Bits 1 and 0 in SYSCR1 are read as undefined data when a read instruction is executed.
Note 5: As the hardware becomes STOP mode under OUTEN = “0”, input value is fixed to “0”; therefore it may cause external
interrupt request on account of falling edge.
Note 6: When the key-on wakeup is used, RELM should be set to "1".
Note 7: Port P20 is used as STOP pin. Therefore, when stop mode is started, OUTEN does not affect to P20, and P20 becomes
High-Z mode.
Note 8: The warmig-up time should be set correctly for using oscillator.
System Control Register 2
SYSCR2
(0039H)
7
6
5
4
XEN
XTEN
SYSCK
IDLE
3
2
1
TGHALT
0
(Initial value: 1000 *0**)
XEN
High-frequency oscillator control
0: Turn off oscillation
1: Turn on oscillation
XTEN
Low-frequency oscillator control
0: Turn off oscillation
1: Turn on oscillation
SYSCK
Main system clock select
(Write)/main system clock monitor (Read)
0: High-frequency clock (NORMAL1/NORMAL2/IDLE1/IDLE2)
1: Low-frequency clock (SLOW1/SLOW2/SLEEP1/SLEEP2)
IDLE
CPU and watchdog timer control
(IDLE1/2 and SLEEP1/2 modes)
0: CPU and watchdog timer remain active
1: CPU and watchdog timer are stopped (Start IDLE1/2 and SLEEP1/2 modes)
TGHALT
TG control (IDLE0 and SLEEP0
modes)
0: Feeding clock to all peripherals from TG
1: Stop feeding clock to peripherals except TBT from TG.
(Start IDLE0 and SLEEP0 modes)
R/W
R/W
Note 1: A reset is applied if both XEN and XTEN are cleared to “0”, XEN is cleared to “0” when SYSCK = “0”, or XTEN is cleared
to “0” when SYSCK = “1”.
Note 2: *: Don’t care, TG: Timing generator, *; Don’t care
Note 3: Bits 3, 1 and 0 in SYSCR2 are always read as undefined value.
Note 4: Do not set IDLE and TGHALT to “1” simultaneously.
Note 5: Because returning from IDLE0/SLEEP0 to NORMAL1/SLOW1 is executed by the asynchronous internal clock, the period
of IDLE0/SLEEP0 mode might be shorter than the period setting by TBTCR<TBTCK>.
Note 6: When IDLE1/2 or SLEEP1/2 mode is released, IDLE is automatically cleared to “0”.
Note 7: When IDLE0 or SLEEP0 mode is released, TGHALT is automatically cleared to “0”.
Note 8: Before setting TGHALT to “1”, be sure to stop peripherals. If peripherals are not stopped, the interrupt latch of peripherals
may be set after IDLE0 or SLEEP0 mode is released.
Page 17
2. Operational Description
2.2 System Clock Controller
2.2.4
TMP86FS28FG
Operating Mode Control
2.2.4.1
STOP mode
STOP mode is controlled by the system control register 1, the STOP pin input and key-on wakeup input
(STOP5 to STOP2) which is controlled by the STOP mode release control register (STOPCR).
The STOP pin is also used both as a port P20 and an INT5 (external interrupt input 5) pin. STOP mode is
started by setting SYSCR1<STOP> to “1”. During STOP mode, the following status is maintained.
1. Oscillations are turned off, and all internal operations are halted.
2. The data memory, registers, the program status word and port output latches are all held in the
status in effect before STOP mode was entered.
3. The prescaler and the divider of the timing generator are cleared to “0”.
4. The program counter holds the address 2 ahead of the instruction (e.g., [SET (SYSCR1).7])
which started STOP mode.
STOP mode includes a level-sensitive mode and an edge-sensitive mode, either of which can be
selected with the SYSCR1<RELM>. Do not use any key-on wakeup input (STOP5 to STOP2) for releasing STOP mode in edge-sensitive mode.
Note 1: The STOP mode can be released by either the STOP or key-on wakeup pin (STOP5 to STOP2).
However, because the STOP pin is different from the key-on wakeup and can not inhibit the release
input, the STOP pin must be used for releasing STOP mode.
Note 2: During STOP period (from start of STOP mode to end of warm up), due to changes in the external
interrupt pin signal, interrupt latches may be set to “1” and interrupts may be accepted immediately
after STOP mode is released. Before starting STOP mode, therefore, disable interrupts. Also, before
enabling interrupts after STOP mode is released, clear unnecessary interrupt latches.
(1)
Level-sensitive release mode (RELM = “1”)
In this mode, STOP mode is released by setting the STOP pin high or setting the STOP5 to STOP2
pin input which is enabled by STOPCR. This mode is used for capacitor backup when the main
power supply is cut off and long term battery backup.
Even if an instruction for starting STOP mode is executed while STOP pin input is high or STOP5
to STOP2 input is low, STOP mode does not start but instead the warm-up sequence starts immediately. Thus, to start STOP mode in the level-sensitive release mode, it is necessary for the program to
first confirm that the STOP pin input is low or STOP5 to STOP2 input is high. The following two
methods can be used for confirmation.
1. Testing a port.
2. Using an external interrupt input INT5 (INT5 is a falling edge-sensitive input).
Example 1 :Starting STOP mode from NORMAL mode by testing a port P20.
SSTOPH:
LD
(SYSCR1), 01010000B
; Sets up the level-sensitive release mode
TEST
(P2PRD). 0
; Wait until the STOP pin input goes low level
JRS
F, SSTOPH
; IMF ← 0
DI
SET
(SYSCR1). 7
; Starts STOP mode
Page 18
TMP86FS28FG
Example 2 :Starting STOP mode from NORMAL mode with an INT5 interrupt.
PINT5:
TEST
(P2PRD). 0
; To reject noise, STOP mode does not start if
JRS
F, SINT5
LD
(SYSCR1), 01010000B
port P20 is at high
; Sets up the level-sensitive release mode.
; IMF ← 0
DI
SET
SINT5:
(SYSCR1). 7
; Starts STOP mode
RETI
VIH
STOP pin
XOUT pin
NORMAL
operation
STOP
operation
Warm up
Confirm by program that the
STOP pin input is low and start
STOP mode.
NORMAL
operation
STOP mode is released by the hardware.
Always released if the STOP
pin input is high.
Figure 2-7 Level-sensitive Release Mode
Note 1: Even if the STOP pin input is low after warm-up start, the STOP mode is not restarted.
Note 2: In this case of changing to the level-sensitive mode from the edge-sensitive mode, the release
mode is not switched until a rising edge of the STOP pin input is detected.
(2)
Edge-sensitive release mode (RELM = “0”)
In this mode, STOP mode is released by a rising edge of the STOP pin input. This is used in applications where a relatively short program is executed repeatedly at periodic intervals. This periodic
signal (for example, a clock from a low-power consumption oscillator) is input to the STOP pin. In
the edge-sensitive release mode, STOP mode is started even when the STOP pin input is high level.
Do not use any STOP5 to STOP2 pin input for releasing STOP mode in edge-sensitive release mode.
Example :Starting STOP mode from NORMAL mode
; IMF ← 0
DI
LD
(SYSCR1), 10010000B
; Starts after specified to the edge-sensitive release mode
VIH
STOP pin
XOUT pin
NORMAL
operation
STOP
operation
Warm up
NORMAL
operation
STOP mode started
by the program.
STOP
operation
STOP mode is released by the hardware at the rising
edge of STOP pin input.
Figure 2-8 Edge-sensitive Release Mode
Page 19
2. Operational Description
2.2 System Clock Controller
TMP86FS28FG
STOP mode is released by the following sequence.
1. In the dual-clock mode, when returning to NORMAL2, both the high-frequency and lowfrequency clock oscillators are turned on; when returning to SLOW1 mode, only the lowfrequency clock oscillator is turned on. In the single-clock mode, only the high-frequency
clock oscillator is turned on.
2. A warm-up period is inserted to allow oscillation time to stabilize. During warm up, all
internal operations remain halted. Four different warm-up times can be selected with the
SYSCR1<WUT> in accordance with the resonator characteristics.
3. When the warm-up time has elapsed, normal operation resumes with the instruction following the STOP mode start instruction.
Note 1: When the STOP mode is released, the start is made after the prescaler and the divider of the
timing generator are cleared to "0".
Note 2: STOP mode can also be released by inputting low level on the RESET pin, which immediately
performs the normal reset operation.
Note 3: When STOP mode is released with a low hold voltage, the following cautions must be observed.
The power supply voltage must be at the operating voltage level before releasing STOP mode.
The RESET pin input must also be “H” level, rising together with the power supply voltage. In this
case, if an external time constant circuit has been connected, the RESET pin input voltage will
increase at a slower pace than the power supply voltage. At this time, there is a danger that a
reset may occur if input voltage level of the RESET pin drops below the non-inverting high-level
input voltage (Hysteresis input).
Table 2-2 Warm-up Time Example (at fc = 16.0 MHz, fs = 32.768 kHz)
Warm-up Time [ms]
WUT
00
01
10
11
Return to NORMAL Mode
Return to SLOW Mode
12.288
4.096
3.072
1.024
750
250
5.85
1.95
Note 1: The warm-up time is obtained by dividing the basic clock by the divider. Therefore, the warm-up
time may include a certain amount of error if there is any fluctuation of the oscillation frequency
when STOP mode is released. Thus, the warm-up time must be considered as an approximate
value.
Page 20
Page 21
Figure 2-9 STOP Mode Start/Release
Divider
Instruction
execution
Program
counter
Main
system
clock
Oscillator
circuit
STOP pin
input
Divider
Instruction
execution
Program
counter
Main
system
clock
Oscillator
circuit
0
Halt
Turn off
Turn on
Turn on
n
Count up
a+3
Warm up
a+2
n+2
n+3
n+4
0
(b) STOP mode release
1
Instruction address a + 2
a+4
2
Instruction address a + 3
a+5
(a) STOP mode start (Example: Start with SET (SYSCR1). 7 instruction located at address a)
n+1
SET (SYSCR1). 7
a+3
3
Instruction address a + 4
a+6
0
Halt
Turn off
TMP86FS28FG
2. Operational Description
2.2 System Clock Controller
2.2.4.2
TMP86FS28FG
IDLE1/2 mode and SLEEP1/2 mode
IDLE1/2 and SLEEP1/2 modes are controlled by the system control register 2 (SYSCR2) and maskable
interrupts. The following status is maintained during these modes.
1. Operation of the CPU and watchdog timer (WDT) is halted. On-chip peripherals continue to
operate.
2. The data memory, CPU registers, program status word and port output latches are all held in the
status in effect before these modes were entered.
3. The program counter holds the address 2 ahead of the instruction which starts these modes.
Starting IDLE1/2 and
SLEEP1/2 modes by
instruction
CPU and WDT are halted
Yes
Reset input
Reset
No
No
Interrupt request
Yes
“0”
IMF
“1” (Interrupt release mode)
Normal
release mode
Interrupt processing
Execution of the instruction which follows the
IDLE1/2 and SLEEP1/2
modes start instruction
Figure 2-10 IDLE1/2 and SLEEP1/2 Modes
Page 22
TMP86FS28FG
• Start the IDLE1/2 and SLEEP1/2 modes
After IMF is set to "0", set the individual interrupt enable flag (EF) which releases IDLE1/2
and SLEEP1/2 modes. To start IDLE1/2 and SLEEP1/2 modes, set SYSCR2<IDLE> to “1”.
• Release the IDLE1/2 and SLEEP1/2 modes
IDLE1/2 and SLEEP1/2 modes include a normal release mode and an interrupt release mode.
These modes are selected by interrupt master enable flag (IMF). After releasing IDLE1/2 and
SLEEP1/2 modes, the SYSCR2<IDLE> is automatically cleared to “0” and the operation mode
is returned to the mode preceding IDLE1/2 and SLEEP1/2 modes.
IDLE1/2 and SLEEP1/2 modes can also be released by inputting low level on the RESET pin.
After releasing reset, the operation mode is started from NORMAL1 mode.
(1)
Normal release mode (IMF = “0”)
IDLE1/2 and SLEEP1/2 modes are released by any interrupt source enabled by the individual
interrupt enable flag (EF). After the interrupt is generated, the program operation is resumed from the
instruction following the IDLE1/2 and SLEEP1/2 modes start instruction. Normally, the interrupt
latches (IL) of the interrupt source used for releasing must be cleared to “0” by load instructions.
(2)
Interrupt release mode (IMF = “1”)
IDLE1/2 and SLEEP1/2 modes are released by any interrupt source enabled with the individual
interrupt enable flag (EF) and the interrupt processing is started. After the interrupt is processed, the
program operation is resumed from the instruction following the instruction, which starts IDLE1/2
and SLEEP1/2 modes.
Note: When a watchdog timer interrupts is generated immediately before IDLE1/2 and SLEEP1/2
modes are started, the watchdog timer interrupt will be processed but IDLE1/2 and SLEEP1/2
modes will not be started.
Page 23
Page 24
Figure 2-11 IDLE1/2 and SLEEP1/2 Modes Start/Release
Watchdog
timer
Instruction
execution
Program
counter
Interrupt
request
Main
system
clock
Watchdog
timer
Instruction
execution
Program
counter
Interrupt
request
Main
system
clock
Watchdog
timer
Instruction
execution
Program
counter
Interrupt
request
Main
system
clock
Halt
Halt
Halt
Halt
Operate
Operate
Operate
Acceptance of interrupt
Instruction address a + 2
a+4
(b) IDLE1/2 and SLEEP1/2 modes release
㽳㩷Interrupt release mode
a+3
㽲㩷Normal release mode
a+3
(a) IDLE1/2 and SLEEP1/2 modes start (Example: Starting with the SET instruction located at address a)
Operate
SET (SYSCR2). 4
a+2
Halt
a+3
2.2 System Clock Controller
2. Operational Description
TMP86FS28FG
TMP86FS28FG
2.2.4.3
IDLE0 and SLEEP0 modes (IDLE0, SLEEP0)
IDLE0 and SLEEP0 modes are controlled by the system control register 2 (SYSCR2) and the time base
timer control register (TBTCR). The following status is maintained during IDLE0 and SLEEP0 modes.
1. Timing generator stops feeding clock to peripherals except TBT.
2. The data memory, CPU registers, program status word and port output latches are all held in the
status in effect before IDLE0 and SLEEP0 modes were entered.
3. The program counter holds the address 2 ahead of the instruction which starts IDLE0 and
SLEEP0 modes.
Note: Before starting IDLE0 or SLEEP0 mode, be sure to stop (Disable) peripherals.
Stopping peripherals
by instruction
Starting IDLE0, SLEEP0
modes by instruction
CPU and WDT are halted
Reset input
Yes
Reset
No
No
TBT
source clock
falling
edge
Yes
No
TBTCR<TBTEN>
= "1"
Yes
No
TBT interrupt
enable
Yes
(Normal release mode)
No
IMF = "1"
Yes (Interrupt release mode)
Interrupt processing
Execution of the instruction
which follows the IDLE0,
SLEEP0 modes start
instruction
Figure 2-12 IDLE0 and SLEEP0 Modes
Page 25
2. Operational Description
2.2 System Clock Controller
TMP86FS28FG
• Start the IDLE0 and SLEEP0 modes
Stop (Disable) peripherals such as a timer counter.
To start IDLE0 and SLEEP0 modes, set SYSCR2<TGHALT> to “1”.
• Release the IDLE0 and SLEEP0 modes
IDLE0 and SLEEP0 modes include a normal release mode and an interrupt release mode.
These modes are selected by interrupt master flag (IMF), the individual interrupt enable flag
of TBT and TBTCR<TBTEN>.
After releasing IDLE0 and SLEEP0 modes, the SYSCR2<TGHALT> is automatically
cleared to “0” and the operation mode is returned to the mode preceding IDLE0 and SLEEP0
modes. Before starting the IDLE0 or SLEEP0 mode, when the TBTCR<TBTEN> is set to “1”,
INTTBT interrupt latch is set to “1”.
IDLE0 and SLEEP0 modes can also be released by inputting low level on the RESET pin.
After releasing reset, the operation mode is started from NORMAL1 mode.
Note: IDLE0 and SLEEP0 modes start/release without reference to TBTCR<TBTEN> setting.
(1)
Normal release mode (IMF•EF6•TBTCR<TBTEN> = “0”)
IDLE0 and SLEEP0 modes are released by the source clock falling edge, which is setting by the
TBTCR<TBTCK>. After the falling edge is detected, the program operation is resumed from the
instruction following the IDLE0 and SLEEP0 modes start instruction. Before starting the IDLE0 or
SLEEP0 mode, when the TBTCR<TBTEN> is set to “1”, INTTBT interrupt latch is set to “1”.
(2)
Interrupt release mode (IMF•EF6•TBTCR<TBTEN> = “1”)
IDLE0 and SLEEP0 modes are released by the source clock falling edge, which is setting by the
TBTCR<TBTCK> and INTTBT interrupt processing is started.
Note 1: Because returning from IDLE0, SLEEP0 to NORMAL1, SLOW1 is executed by the asynchronous internal clock, the period of IDLE0, SLEEP0 mode might be the shorter than the period setting by TBTCR<TBTCK>.
Note 2: When a watchdog timer interrupt is generated immediately before IDLE0/SLEEP0 mode is
started, the watchdog timer interrupt will be processed but IDLE0/SLEEP0 mode will not be
started.
Page 26
Page 27
Figure 2-13 IDLE0 and SLEEP0 Modes Start/Release
Watchdog
timer
Instruction
execution
Program
counter
TBT clock
Halt
Halt
Halt
Watchdog
timer
Main
system
clock
Halt
Instruction
execution
Program
counter
TBT clock
Main
system
clock
Watchdog
timer
Instruction
execution
Program
counter
Interrupt
request
Main
system
clock
a+3
Halt
Operate
Operate
(b) IDLE and SLEEP0 modes release
㽳㩷Interrupt release mode
a+3
㽲㩷Normal release mode
a+3
Acceptance of interrupt
Instruction address a + 2
a+4
(a) IDLE0 and SLEEP0 modes start (Example: Starting with the SET instruction located at address a
Operate
SET (SYSCR2). 2
a+2
TMP86FS28FG
2. Operational Description
2.2 System Clock Controller
2.2.4.4
TMP86FS28FG
SLOW mode
SLOW mode is controlled by the system control register 2 (SYSCR2).
The following is the methods to switch the mode with the warm-up counter.
(1)
Switching from NORMAL2 mode to SLOW1 mode
First, set SYSCR2<SYSCK> to switch the main system clock to the low-frequency clock for
SLOW2 mode. Next, clear SYSCR2<XEN> to turn off high-frequency oscillation.
Note: The high-frequency clock can be continued oscillation in order to return to NORMAL2 mode from
SLOW mode quickly. Always turn off oscillation of high-frequency clock when switching from
SLOW mode to stop mode.
Example 1 :Switching from NORMAL2 mode to SLOW1 mode.
SET
(SYSCR2). 5
; SYSCR2<SYSCK> ← 1
(Switches the main system clock to the low-frequency
clock for SLOW2)
CLR
(SYSCR2). 7
; SYSCR2<XEN> ← 0
(Turns off high-frequency oscillation)
Example 2 :Switching to the SLOW1 mode after low-frequency clock has stabilized.
SET
(SYSCR2). 6
; SYSCR2<XTEN> ← 1
LD
(TC3CR), 43H
; Sets mode for TC4, 3 (16-bit mode, fs for source)
LD
(TC4CR), 05H
; Sets warming-up counter mode
LDW
(TTREG3), 8000H
; Sets warm-up time (Depend on oscillator accompanied)
; IMF ← 0
DI
SET
(EIRE). 5
; IMF ← 1
EI
SET
; Enables INTTC4
(TC4CR). 3
; Starts TC4, 3
CLR
(TC4CR). 3
; Stops TC4, 3
SET
(SYSCR2). 5
; SYSCR2<SYSCK> ← 1
:
PINTTC4:
(Switches the main system clock to the low-frequency clock)
CLR
(SYSCR2). 7
; SYSCR2<XEN> ← 0
(Turns off high-frequency oscillation)
RETI
:
VINTTC4:
DW
PINTTC4
; INTTC4 vector table
Page 28
TMP86FS28FG
(2)
Switching from SLOW1 mode to NORMAL2 mode
First, set SYSCR2<XEN> to turn on the high-frequency oscillation. When time for stabilization
(Warm up) has been taken by the timer/counter (TC4,TC3), clear SYSCR2<SYSCK> to switch the
main system clock to the high-frequency clock.
SLOW mode can also be released by inputting low level on the RESET pin. After releasing reset, the
operation mode is started from NORMAL1 mode.
Note: After SYSCK is cleared to “0”, executing the instructions is continiued by the low-frequency clock
for the period synchronized with low-frequency and high-frequency clocks.
High-frequency clock
Low-frequency clock
Main system clock
SYSCK
Example :Switching from the SLOW1 mode to the NORMAL2 mode (fc = 16 MHz, warm-up time is 4.0 ms).
SET
(SYSCR2). 7
; SYSCR2<XEN> ← 1 (Starts high-frequency oscillation)
LD
(TC3CR), 63H
; Sets mode for TC4, 3 (16-bit mode, fc for source)
LD
(TC4CR), 05H
; Sets warming-up counter mode
LD
(TTREG4), 0F8H
; Sets warm-up time
; IMF ← 0
DI
SET
(EIRE). 5
; IMF ← 1
EI
SET
; Enables INTTC4
(TC4CR). 3
; Starts TC4, 3
CLR
(TC4CR). 3
; Stops TC4, 3
CLR
(SYSCR2). 5
; SYSCR2<SYSCK> ← 0
:
PINTTC4:
(Switches the main system clock to the high-frequency clock)
RETI
:
VINTTC4:
DW
PINTTC4
; INTTC4 vector table
Page 29
Page 30
Figure 2-14 Switching between the NORMAL2 and SLOW Modes
SET (SYSCR2). 7
SET (SYSCR2). 5
SLOW1 mode
Instruction
execution
XEN
SYSCK
Highfrequency
clock
Lowfrequency
clock
Main
system
clock
NORMAL2
mode
Instruction
execution
XEN
SYSCK
Highfrequency
clock
Lowfrequency
clock
Main
system
clock
(b) Switching to the NORMAL2 mode
Warm up during SLOW2 mode
CLR (SYSCR2). 5
(a) Switching to the SLOW mode
SLOW2 mode
CLR (SYSCR2). 7
NORMAL2
mode
SLOW1 mode
Turn off
2.2 System Clock Controller
2. Operational Description
TMP86FS28FG
TMP86FS28FG
2.3 Reset Circuit
The TMP86FS28FG has four types of reset generation procedures: An external reset input, an address trap reset, a
watchdog timer reset and a system clock reset. Of these reset, the address trap reset, the watchdog timer and the system clock reset are a malfunction reset. When the malfunction reset request is detected, reset occurs during the maximum 24/fc[s].
The malfunction reset circuit such as watchdog timer reset, address trap reset and system clock reset is not initialized when power is turned on. Therefore, reset may occur during maximum 24/fc[s] (1.5µs at 16.0 MHz) when
power is turned on.
Table 2-3 shows on-chip hardware initialization by reset action.
Table 2-3 Initializing Internal Status by Reset Action
On-chip Hardware
Initial Value
Program counter
(PC)
(FFFEH)
Stack pointer
(SP)
Not initialized
General-purpose registers
(W, A, B, C, D, E, H, L, IX, IY)
(JF)
Not initialized
Zero flag
(ZF)
Not initialized
Carry flag
(CF)
Not initialized
Half carry flag
(HF)
Not initialized
Sign flag
(SF)
Not initialized
Overflow flag
(VF)
Not initialized
(IMF)
0
(EF)
0
(IL)
0
Interrupt individual enable flags
Interrupt latches
2.3.1
Initial Value
Prescaler and divider of timing generator
0
Not initialized
Jump status flag
Interrupt master enable flag
On-chip Hardware
Watchdog timer
Enable
Output latches of I/O ports
Refer to I/O port circuitry
Control registers
Refer to each of control
register
LCD data buffer
Not initialized
RAM
Not initialized
External Reset Input
The RESET pin contains a Schmitt trigger (Hysteresis) with an internal pull-up resistor.
When the RESET pin is held at “L” level for at least 3 machine cycles (12/fc [s]) with the power supply voltage within the operating voltage range and oscillation stable, a reset is applied and the internal state is initialized.
When the RESET pin input goes high, the reset operation is released and the program execution starts at the
vector address stored at addresses FFFEH to FFFFH.
VDD
RESET
Internal reset
Watchdog timer reset
Malfunction
reset output
circuit
Address trap reset
System clock reset
Figure 2-15 Reset Circuit
Page 31
2. Operational Description
2.3 Reset Circuit
TMP86FS28FG
2.3.2
Address trap reset
If the CPU should start looping for some cause such as noise and an attempt be made to fetch an instruction
from the on-chip RAM (when WDTCR1<ATAS> is set to “1”), DBR or the SFR area, address trap reset will be
generated. The reset time is maximum 24/fc[s] (1.5µs at 16.0 MHz).
Note:The operating mode under address trapped is alternative of reset or interrupt. The address trap area is alternative.
Instruction
execution
Reset release
JP a
Instruction at address r
Address trap is occurred
Internal reset
maximum 24/fc [s]
4/fc to 12/fc [s]
16/fc [s]
Note 1: Address “a” is in the SFR, DBR or on-chip RAM (WDTCR1<ATAS> = “1”) space.
Note 2: During reset release, reset vector “r” is read out, and an instruction at address “r” is fetched and decoded.
Figure 2-16 Address Trap Reset
2.3.3
Watchdog timer reset
Refer to Section “Watchdog Timer”.
2.3.4
System clock reset
If the condition as follows is detected, the system clock reset occurs automatically to prevent dead lock of the
CPU. (The oscillation is continued without stopping.)
- In case of clearing SYSCR2<XEN> and SYSCR2<XTEN> simultaneously to “0”.
- In case of clearing SYSCR2<XEN> to “0”, when the SYSCR2<SYSCK> is “0”.
- In case of clearing SYSCR2<XTEN> to “0”, when the SYSCR2<SYSCK> is “1”.
The reset time is maximum 24/fc (1.5 µs at 16.0 MHz).
Page 32
TMP86FS28FG
Page 33
2. Operational Description
2.3 Reset Circuit
TMP86FS28FG
Page 34
TMP86FS28FG
3. Interrupt Control Circuit
The TMP86FS28FG has a total of 23 interrupt sources excluding reset. Interrupts can be nested with priorities.
Four of the internal interrupt sources are 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.
Interrupt Factors
Internal/External
Enable Condition
Interrupt
Latch
Vector
Address
Priority
(Reset)
Non-maskable
–
FFFE
1
Internal
INTSWI (Software interrupt)
Non-maskable
–
FFFC
2
Internal
INTUNDEF (Executed the undefined instruction
interrupt)
Non-maskable
–
FFFC
2
Internal
INTATRAP (Address trap interrupt)
Non-maskable
IL2
FFFA
2
Internal
INTWDT (Watchdog timer interrupt)
Non-maskable
IL3
FFF8
2
External
INT0
IMF• EF4 = 1, INT0EN = 1
IL4
FFF6
5
External
INT1
IMF• EF5 = 1
IL5
FFF4
6
Internal
INTTBT
IMF• EF6 = 1
IL6
FFF2
7
Internal
INTTC10
IMF• EF7 = 1
IL7
FFF0
8
Internal
INTRXD0
IMF• EF8 = 1
IL8
FFEE
9
Internal
INTTXD0
IMF• EF9 = 1
IL9
FFEC
10
Internal
INTTC11
IMF• EF10 = 1
IL10
FFEA
11
External
INT2
IMF• EF11 = 1
IL11
FFE8
12
-
Reserved
IMF• EF12 = 1
IL12
FFE6
13
-
INTSIO
IMF• EF13 = 1
IL13
FFE4
14
-
Reserved
IMF• EF14 = 1
IL14
FFE2
15
-
Reserved
IMF• EF15 = 1
IL15
FFE0
16
-
Reserved
IMF• EF16 = 1
IL16
FFBE
17
-
Reserved
IMF• EF17 = 1
IL17
FFBC
18
-
Reserved
IMF• EF18 = 1
IL18
FFBA
19
-
Reserved
IMF• EF19 = 1
IL19
FFB8
20
Internal
INTTC3
IMF• EF20 = 1
IL20
FFB6
21
Internal
INTTC4
IMF• EF21 = 1
IL21
FFB4
22
External
INT3
IMF• EF22 = 1
IL22
FFB2
23
Internal
INTTC5
IMF• EF23 = 1
IL23
FFB0
24
Internal
INTTC6
IMF• EF24 = 1
IL24
FFAE
25
External
INT4
IMF• EF25 = 1
IL25
FFAC
26
External
INT5
IMF• EF26 = 1
IL26
FFAA
27
Internal
INTRXD1
IMF• EF27 = 1
IL27
FFA8
28
Internal
INTTXD1
IMF• EF28 = 1
IL28
FFA6
29
Internal
INTADC
IMF• EF29 = 1
IL29
FFA4
30
-
Reserved
IMF• EF30 = 1
IL30
FFA2
31
-
Reserved
IMF• EF31 = 1
IL31
FFA0
32
Note 1: To use the address trap interrupt (INTATRAP), clear WDTCR1<ATOUT> to “0” (It is set for the “reset request” after reset is
cancelled). For details, see “Address Trap”.
Note 2: To use the watchdog timer interrupt (INTWDT), clear WDTCR1<WDTOUT> to "0" (It is set for the "Reset request" after
reset is released). For details, see "Watchdog Timer".
Page 35
3. Interrupt Control Circuit
3.1 Interrupt latches (IL29 to IL2)
TMP86FS28FG
3.1 Interrupt latches (IL29 to IL2)
An interrupt latch is provided for each interrupt source, except for a software interrupt and an executed the undefined instruction interrupt. When interrupt request is generated, the latch is set to “1”, and the CPU is requested to
accept the interrupt if its interrupt is enabled. The interrupt latch is cleared to "0" immediately after accepting interrupt. All interrupt latches are initialized to “0” during reset.
The interrupt latches are located on address 002EH, 002FH, 003CH and 003DH 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 and IL3 should be set to "1". If the read-modifywrite 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.
Interrupt latches are not set to “1” by an instruction.
Since interrupt latches can be read, the status for interrupt requests can be monitored by software.
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".
Example 1 :Clears interrupt latches
; IMF ← 0
DI
LDW
(ILL), 1110100000111111B
; IL12, IL10 to IL6 ← 0
; IMF ← 1
EI
Example 2 :Reads interrupt latchess
WA, (ILL)
; W ← ILH, A ← ILL
TEST
(ILL). 7
; if IL7 = 1 then jump
JR
F, SSET
LD
Example 3 :Tests interrupt latches
3.2 Interrupt enable register (EIR)
The interrupt enable register (EIR) enables and disables the acceptance of interrupts, except for the non-maskable
interrupts (Software interrupt, undefined instruction interrupt, address trap interrupt and watchdog interrupt). Nonmaskable interrupt is accepted regardless of the contents of the EIR.
The EIR consists of an interrupt master enable flag (IMF) and the individual interrupt enable flags (EF). These
registers are located on address 002CH, 002DH, 003AH and 003BH 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).
3.2.1
Interrupt master enable flag (IMF)
The interrupt enable register (IMF) enables and disables the acceptance of the whole maskable interrupt.
While IMF = “0”, all maskable interrupts are not accepted regardless of the status on each individual interrupt
enable flag (EF). By setting IMF to “1”, the interrupt becomes acceptable if the individuals are enabled. 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. By executing return interrupt instruction [RETI/RETN], the stacked data,
which was the status before interrupt acceptance, is loaded on IMF again.
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”.
Page 36
TMP86FS28FG
3.2.2
Individual interrupt enable flags (EF29 to EF4)
Each of these flags enables and disables the acceptance of its maskable interrupt. Setting the corresponding
bit of an individual interrupt enable flag to “1” enables acceptance of its interrupt, and setting the bit to “0” disables acceptance. During reset, all the individual interrupt enable flags (EF29 to EF4) are initialized to “0” and
all maskable interrupts are not accepted until they are set to “1”.
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".
Example 1 :Enables interrupts individually and sets IMF
; IMF ← 0
DI
LDW
:
(EIRL), 1110100010100000B
; EF15 to EF13, EF11, EF7, EF5 ← 1
Note: IMF should not be set.
:
; IMF ← 1
EI
Example 2 :C compiler description example
unsigned int _io (3AH) EIRL;
/* 3AH shows EIRL address */
_DI();
EIRL = 10100000B;
:
_EI();
Page 37
3. Interrupt Control Circuit
3.2 Interrupt enable register (EIR)
TMP86FS28FG
Interrupt Latches
(Initial value: 00000000 000000**)
ILH,ILL
(003DH, 003CH)
15
14
13
12
11
10
9
8
7
6
5
4
3
2
IL15
IL14
IL13
IL12
IL11
IL10
IL9
IL8
IL7
IL6
IL5
IL4
IL3
IL2
ILH (003DH)
1
0
ILL (003CH)
(Initial value: 00000000 00000000)
ILD,ILE
(002FH, 002EH)
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
IL31
IL30
IL29
IL28
IL27
IL26
IL25
IL24
IL23
IL22
IL21
IL20
IL19
IL18
IL17
IL16
ILD (002FH)
IL29 to IL2
ILE (002EH)
at RD
0: No interrupt request
Interrupt latches
at WR
0: Clears the interrupt request
1: (Interrupt latch is not set.)
1: Interrupt request
R/W
Note 1: To clear any one of bits IL7 to IL4, be sure to write "1" into IL2 and IL3.
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".
Note 3: Do not clear IL with read-modify-write instructions such as bit operations.
Interrupt Enable Registers
(Initial value: 00000000 0000***0)
EIRH,EIRL
(003BH, 003AH)
15
14
13
EF15
EF14
EF13
12
11
10
9
8
7
6
5
EF12
EF11
EF10
EF9
EF8
EF7
EF6
EF5
EIRH (003BH)
4
3
2
1
EF4
0
IMF
EIRL (003AH)
(Initial value: 00000000 00000000)
EIRD,EIRE
(002DH, 002CH)
15
14
13
EF31
EF30
EF29
12
11
10
9
8
7
6
5
EF28
EF27
EF26
EF25
EF24
EF23
EF22
EF21
EIRD (002DH)
EF29 to EF4
IMF
4
3
2
1
0
EF20
EF19
EF18
EF17
EF16
EIRE (002CH)
Individual-interrupt enable flag
(Specified for each bit)
0:
1:
Disables the acceptance of each maskable interrupt.
Enables the acceptance of each maskable interrupt.
Interrupt master enable flag
0:
1:
Disables the acceptance of all maskable interrupts
Enables the acceptance of all maskable interrupts
R/W
Note 1: *: Don’t care
Note 2: Do not set IMF and the interrupt enable flag (EF15 to EF4) to “1” at the same time.
Note 3: 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 38
TMP86FS28FG
3.3 Interrupt Sequence
An interrupt request, which raised interrupt latch, is held, until interrupt is accepted or interrupt latch is cleared to
“0” by resetting or an instruction. Interrupt acceptance sequence requires 8 machine cycles (2 µs @16 MHz) after the
completion of the current instruction. The interrupt service task terminates upon execution of an interrupt return
instruction [RETI] (for maskable interrupts) or [RETN] (for non-maskable interrupts). Figure 3-1 shows the timing
chart of interrupt acceptance processing.
3.3.1
Interrupt acceptance processing is packaged as follows.
a. The interrupt master enable flag (IMF) is cleared to “0” in order to disable the acceptance of any following interrupt.
b. The interrupt latch (IL) for the interrupt source accepted is cleared to “0”.
c. The contents of the program counter (PC) and the program status word, including the interrupt master
enable flag (IMF), are saved (Pushed) on the stack in sequence of PSW + IMF, PCH, PCL. Meanwhile, the stack pointer (SP) is decremented by 3.
d. The entry address (Interrupt vector) of the corresponding interrupt service program, loaded on the vector table, is transferred to the program counter.
e. The instruction stored at the entry address of the interrupt service program is executed.
Note:When the contents of PSW are saved on the stack, the contents of IMF are also saved.
Interrupt service task
1-machine cycle
Interrupt
request
Interrupt
latch (IL)
IMF
Execute
instruction
PC
SP
Execute
instruction
a−1
a
Execute
instruction
Interrupt acceptance
a+1
b
a
b+1 b+2 b + 3
n−1 n−2
n
Execute RETI instruction
c+2
c+1
a
n−2 n−1
n-3
a+1 a+2
n
Note 1: a: Return address entry address, b: Entry address, c: Address which RETI instruction is stored
Note 2: On condition that interrupt is enabled, it takes 38/fc [s] or 38/fs [s] at maximum (If the interrupt latch is set at the first
machine cycle on 10 cycle instruction) to start interrupt acceptance processing since its interrupt latch is set.
Figure 3-1 Timing Chart of Interrupt Acceptance/Return Interrupt Instruction
Example: Correspondence between vector table address for INTTBT and the entry address of the interrupt
service program
Vector table address
FFF2H
03H
FFF3H
D2H
Entry address
Vector
D203H
0FH
D204H
06H
Figure 3-2 Vector table address,Entry address
Page 39
Interrupt
service
program
3. Interrupt Control Circuit
3.3 Interrupt Sequence
TMP86FS28FG
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.
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.
3.3.2
Saving/restoring general-purpose registers
During interrupt acceptance processing, the program counter (PC) and the program status word (PSW,
includes IMF) are automatically saved on the stack, but the accumulator and others are not. These registers are
saved by software if necessary. When multiple interrupt services are nested, it is also necessary to avoid using
the same data memory area for saving registers. The following methods are used to save/restore the generalpurpose registers.
3.3.2.1
Using PUSH and POP instructions
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.
Example :Save/store register using PUSH and POP instructions
PINTxx:
PUSH
WA
; Save WA register
(interrupt processing)
POP
WA
; Restore WA register
RETI
; RETURN
Address
(Example)
SP
b-5
A
SP
b-4
SP
b-3
PCL
W
PCL
PCH
PCH
PCH
PSW
PSW
PSW
At acceptance of
an interrupt
At execution of
PUSH instruction
PCL
At execution of
POP instruction
b-2
b-1
SP
b
At execution of
RETI instruction
Figure 3-3 Save/store register using PUSH and POP instructions
3.3.2.2
Using data transfer instructions
To save only a specific register without nested interrupts, data transfer instructions are available.
Page 40
TMP86FS28FG
Example :Save/store register using data transfer instructions
PINTxx:
LD
(GSAVA), A
; Save A register
(interrupt processing)
LD
A, (GSAVA)
; Restore A register
RETI
; RETURN
Main task
Interrupt
service task
Interrupt
acceptance
Saving
registers
Restoring
registers
Interrupt return
Saving/Restoring general-purpose registers using PUSH/POP data transfer instruction
Figure 3-4 Saving/Restoring General-purpose Registers under Interrupt Processing
3.3.3
Interrupt return
Interrupt return instructions [RETI]/[RETN] perform as follows.
[RETI]/[RETN] Interrupt Return
1. Program counter (PC) and program status word
(PSW, includes IMF) are restored from the stack.
2. Stack pointer (SP) is incremented by 3.
As for address trap interrupt (INTATRAP), it is required to alter stacked data for program counter (PC) to
restarting address, during interrupt service program.
Note:If [RETN] is executed with the above data unaltered, the program returns to the address trap area and
INTATRAP occurs again.When interrupt acceptance processing has completed, stacked data for PCL and
PCH are located on address (SP + 1) and (SP + 2) respectively.
Example 1 :Returning from address trap interrupt (INTATRAP) service program
PINTxx:
POP
WA
; Recover SP by 2
LD
WA, Return Address
;
PUSH
WA
; Alter stacked data
(interrupt processing)
RETN
; RETURN
Page 41
3. Interrupt Control Circuit
3.4 Software Interrupt (INTSW)
TMP86FS28FG
Example 2 :Restarting without returning interrupt
(In this case, PSW (Includes IMF) before interrupt acceptance is discarded.)
PINTxx:
INC
SP
; Recover SP by 3
INC
SP
;
INC
SP
;
(interrupt processing)
LD
EIRL, data
; Set IMF to “1” or clear it to “0”
JP
Restart Address
; Jump into restarting address
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 1: It is recommended that stack pointer be return to rate before INTATRAP (Increment 3 times), if return interrupt instruction [RETN] is not utilized during interrupt service program under INTATRAP (such as Example
2).
Note 2: When the interrupt processing time is longer than the interrupt request generation time, the interrupt service
task is performed but not the main task.
3.4 Software Interrupt (INTSW)
Executing the SWI instruction generates a software interrupt and immediately starts interrupt processing (INTSW
is highest prioritized interrupt).
Use the SWI instruction only for detection of the address error or for debugging.
3.4.1
Address error detection
FFH is read if for some cause such as noise the CPU attempts to fetch an instruction from a non-existent
memory address during single chip mode. Code FFH is the SWI instruction, so a software interrupt is generated and an address error is detected. The address error detection range can be further expanded by writing
FFH to unused areas of the program memory. Address trap reset is generated in case that an instruction is
fetched from RAM, DBR or SFR areas.
3.4.2
Debugging
Debugging efficiency can be increased by placing the SWI instruction at the software break point setting
address.
3.5 Undefined Instruction Interrupt (INTUNDEF)
Taking code which is not defined as authorized instruction for instruction causes INTUNDEF. INTUNDEF is generated when the CPU fetches such a code and tries to execute it. INTUNDEF is accepted even if non-maskable interrupt is in process. Contemporary process is broken and INTUNDEF interrupt process starts, soon after it is
requested.
Note: The undefined instruction interrupt (INTUNDEF) forces CPU to jump into vector address, as software interrupt
(SWI) does.
3.6 Address Trap Interrupt (INTATRAP)
Fetching instruction from unauthorized area for instructions (Address trapped area) causes reset output or address
trap interrupt (INTATRAP). INTATRAP is accepted even if non-maskable interrupt is in process. Contemporary process is broken and INTATRAP interrupt process starts, soon after it is requested.
Note: The operating mode under address trapped, whether to be reset output or interrupt processing, is selected on
watchdog timer control register (WDTCR).
Page 42
TMP86FS28FG
3.7 External Interrupts
The TMP86FS28FG has 6 external interrupt inputs. These inputs are equipped with digital noise reject circuits
(Pulse inputs of less than a certain time are eliminated as noise).
Edge selection is also possible with INT1 to INT4. The INT0/P30 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, noise reject control and INT0/P30 pin function selection are performed by the external interrupt
control register (EINTCR).
Source
INT0
INT1
INT2
INT3
INT4
INT5
Pin
INT0
INT1
INT2
INT3
INT4
INT5
Enable Conditions
Release Edge (level)
Digital Noise Reject
IMF Œ EF4 Œ INT0EN=1
Falling edge
Pulses of less than 2/fc [s] are eliminated as
noise. Pulses of 7/fc [s] or more are considered
to be signals. In the SLOW or the SLEEP mode,
pulses of less than 1/fs [s] are eliminated as
noise. Pulses of 3.5/fs [s] or more are considered to be signals.
IMF Œ EF5 = 1
Falling edge
or
Rising edge
Pulses of less than 15/fc or 63/fc [s] are eliminated as noise. Pulses of 49/fc or 193/fc [s] or
more are considered to be signals. In the SLOW
or the SLEEP mode, pulses of less than 1/fs [s]
are eliminated as noise. Pulses of 3.5/fs [s] or
more are considered to be signals.
IMF Œ EF11 = 1
Falling edge
or
Rising edge
Pulses of less than 7/fc [s] are eliminated as
noise. Pulses of 25/fc [s] or more are considered
to be signals. In the SLOW or the SLEEP mode,
pulses of less than 1/fs [s] are eliminated as
noise. Pulses of 3.5/fs [s] or more are considered to be signals.
IMF Œ EF22 = 1
Falling edge
or
Rising edge
Pulses of less than 7/fc [s] are eliminated as
noise. Pulses of 25/fc [s] or more are considered
to be signals. In the SLOW or the SLEEP mode,
pulses of less than 1/fs [s] are eliminated as
noise. Pulses of 3.5/fs [s] or more are considered to be signals.
IMF Œ EF25 = 1
Falling edge,
Rising edge,
Falling and Rising edge
or
H level
Pulses of less than 7/fc [s] are eliminated as
noise. Pulses of 25/fc [s] or more are considered
to be signals. In the SLOW or the SLEEP mode,
pulses of less than 1/fs [s] are eliminated as
noise. Pulses of 3.5/fs [s] or more are considered to be signals.
Falling edge
Pulses of less than 2/fc [s] are eliminated as
noise. Pulses of 7/fc [s] or more are considered
to be signals. In the SLOW or the SLEEP mode,
pulses of less than 1/fs [s] are eliminated as
noise. Pulses of 3.5/fs [s] or more are considered to be signals.
IMF Œ EF26 = 1
Note 1: In NORMAL1/2 or IDLE1/2 mode, if a signal with no noise is input on an external interrupt pin, it takes a maximum of "signal establishment time + 6/fs[s]" from the input signal's edge to set the interrupt latch.
Note 2: When INT0EN = "0", IL4 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.
Page 43
3. Interrupt Control Circuit
3.7 External Interrupts
TMP86FS28FG
External Interrupt Control Register
EINTCR
7
6
(0037H)
INT1NC
INT0EN
5
4
INT4ES
3
2
1
INT3ES
INT2ES
INT1ES
0
(Initial value: 0000 000*)
INT1NC
Noise reject time select
0: Pulses of less than 63/fc [s] are eliminated as noise
1: Pulses of less than 15/fc [s] are eliminated as noise
R/W
INT0EN
P30/INT0 pin configuration
0: P30 input/output port
1: INT0 pin (Port P30 should be set to an input mode)
R/W
INT4 ES
INT4 edge select
00: Rising edge
01: Falling edge
10: Rising edge and Falling edge
11: H level
R/W
INT3 ES
INT3 edge select
0: Rising edge
1: Falling edge
R/W
INT2 ES
INT2 edge select
0: Rising edge
1: Falling edge
R/W
INT1 ES
INT1 edge select
0: Rising edge
1: Falling edge
R/W
Note 1: fc: High-frequency clock [Hz], *: Don’t care
Note 2: When the system clock frequency is switched between high and low or when the external interrupt control register
(EINTCR) is overwritten, the noise canceller may not operate normally. It is recommended that external interrupts are disabled using the interrupt enable register (EIR).
Note 3: The maximum time from modifying INT1NC until a noise reject time is changed is 26/fc.
Note 4: In case RESET pin is released while the state of INT4 pin keeps "H" level, the external interrupt 4 request is not generated
even if the INT4 edge select is specified as "H" level. The rising edge is needed after RESET pin is released.
Page 44
TMP86FS28FG
4. Special Function Register (SFR)
The TMP86FS28FG adopts the memory mapped I/O system, and all peripheral control and data transfers are performed through the special function register (SFR) or the data buffer register (DBR). The SFR is mapped on address
0000H to 003FH, DBR is mapped on address 0F00H to 0FFFH.
This chapter shows the arrangement of the special function register (SFR) and data buffer register (DBR) for
TMP86FS28FG.
4.1 SFR
Address
Read
Write
0000H
P0DR
0001H
P1DR
0002H
P2DR
0003H
P3DR
0004H
P4DR
0005H
P5DR
0006H
P6DR
0007H
P7DR
0008H
P8DR
0009H
TC3CR
000AH
TC4CR
000BH
TC5CR
000CH
TC6CR
000DH
Reserved
000EH
Reserved
000FH
Reserved
0010H
TC10DRAL
0011H
TC10DRAH
0012H
TC10DRBL
0013H
TC10DRBH
0014H
TC10CR
0015H
TTREG3
0016H
TTREG4
0017H
TTREG5
0018H
TTREG6
0019H
PWREG3
001AH
PWREG4
001BH
PWREG5
001CH
PWREG6
001DH
Reserved
001EH
Reserved
001FH
Reserved
0020H
TC11DRAL
0021H
TC11DRAH
0022H
TC11DRBL
0023H
TC11DRBH
0024H
TC11CR
0025H
Reserved
Page 45
4. Special Function Register (SFR)
4.1 SFR
TMP86FS28FG
Address
Read
Write
0026H
Reserved
0027H
Reserved
0028H
Reserved
0029H
Reserved
002AH
Reserved
002BH
P3OUTCR
002CH
EIRE
002DH
EIRD
002EH
ILE
002FH
ILD
0030H
0031H
Reserved
-
STOPCR
0032H
P0OUTCR
0033H
Reserved
0034H
-
WDTCR1
0035H
-
WDTCR2
0036H
TBTCR
0037H
EINTCR
0038H
SYSCR1
0039H
SYSCR2
003AH
EIRL
003BH
EIRH
003CH
ILL
003DH
ILH
003EH
Reserved
003FH
PSW
Note 1: Do not access reserved areas by the program.
Note 2: − ; Cannot be accessed.
Note 3: Write-only registers and interrupt latches cannot use the read-modify-write instructions (Bit manipulation instructions such
as SET, CLR, etc. and logical operation instructions such as AND, OR, etc.).
Page 46
TMP86FS28FG
4.2 DBR
Address
Read
Write
0F00H
Reserved
: :
: :
0F5FH
Reserved
Address
Read
Write
0F60H
SIOBR0
0F61H
SIOBR1
0F62H
SIOBR2
0F63H
SIOBR3
0F64H
SIOBR4
0F65H
SIOBR5
0F66H
SIOBR6
0F67H
SIOBR7
0F68H
-
SIOCR1
0F69H
SIOSR
SIOCR2
Address
Read
0F70H
Write
Reserved
: :
: :
0F7FH
Reserved
Page 47
4. Special Function Register (SFR)
4.2 DBR
TMP86FS28FG
Address
Read
Write
0F80H
Reserved
: :
: :
0F9FH
Reserved
Address
Read
Write
0FA0H
Reserved
0FA1H
Reserved
0FA2H
Reserved
0FA3H
Reserved
0FA4H
Reserved
0FA5H
Reserved
0FA6H
Reserved
0FA7H
Reserved
0FA8H
Reserved
0FA9H
Reserved
0FAAH
Reserved
0FABH
Reserved
0FACH
0FADH
Reserved
Reserved
FLSSTB
0FAEH
Reserved
0FAFH
FLSCR
0FB0H
Reserved
0FB1H
Reserved
0FB2H
Reserved
0FB3H
Reserved
0FB4H
Reserved
0FB5H
Reserved
0FB6H
Reserved
0FB7H
Reserved
0FB8H
Reserved
0FB9H
Reserved
0FBAH
Reserved
0FBBH
Reserved
0FBCH
Reserved
0FBDH
Reserved
0FBEH
Reserved
0FBFH
Reserved
Page 48
TMP86FS28FG
Address
Read
Write
0FC0H
SEG1/0
0FC1H
SEG3/2
0FC2H
SEG5/4
0FC3H
SEG7/6
0FC4H
SEG9/8
0FC5H
SEG11/10
0FC6H
SEG13/12
0FC7H
SEG15/14
0FC8H
SEG17/16
0FC9H
SEG19/18
0FCAH
SEG21/20
0FCBH
SEG23/22
0FCCH
SEG25/24
0FCDH
SEG27/26
0FCEH
SEG29/28
0FCFH
SEG31/30
0FD0H
SEG33/32
0FD1H
SEG35/34
0FD2H
SEG37/36
0FD3H
SEG39/38
0FD4H
P4LCR
0FD5H
P5LCR
0FD6H
P6LCR
0FD7H
P7LCR
0FD8H
P8LCR
0FD9H
LCDCR
0FDAH
Reserved
0FDBH
Reserved
0FDCH
Reserved
0FDDH
Reserved
0FDEH
Reserved
0FDFH
Reserved
Page 49
4. Special Function Register (SFR)
4.2 DBR
TMP86FS28FG
Address
Read
Write
0FE0H
ADCDR2
-
0FE1H
ADCDR1
-
0FE2H
ADCCR1
0FE3H
ADCCR2
0FE4H
0FE5H
Reserved
UART0SR
UART0CR1
0FE6H
-
UART0CR2
0FE7H
RD0BUF
TD0BUF
0FE8H
UART1SR
UART1CR1
0FE9H
-
UART1CR2
0FEAH
RD1BUF
TD1BUF
0FEBH
Reserved
0FECH
Reserved
0FEDH
Reserved
0FEEH
Reserved
0FEFH
Reserved
0FF0H
P0PRD
0FF1H
Reserved
0FF2H
P2PRD
-
0FF3H
P3PRD
-
0FF4H
P4PRD
-
0FF5H
P5PRD
-
0FF6H
P6PRD
-
0FF7H
P7PRD
-
0FF8H
P8PRD
0FF9H
P1CR1
0FFAH
P1CR2
0FFBH
P4OUTCR
0FFCH
P5OUTCR
0FFDH
P6OUTCR
0FFEH
P7OUTCR
0FFFH
P8OUTCR
Note 1: Do not access reserved areas by the program.
Note 2: − ; Cannot be accessed.
Note 3: Write-only registers and interrupt latches cannot use the read-modify-write instructions (Bit manipulation instructions such
as SET, CLR, etc. and logical operation instructions such as AND, OR, etc.).
Page 50
TMP86FS28FG
5. I/O Ports
The TMP86FS28FG has 9 input/output ports (62 pins) as shown below.
Table 5-1
Port Functions
Primary Function
Table 5-2
Port
P0
Secondary Functions
Port P0
3-bit input/output port
External interrupt input, PPG output
Port P1
8-bit input/output port
Analog input, STOP mode release signal input
Port P2
3-bit input/output port
External interrupt input, low-frequency resonator connection, STOP mode
release signal input
Port P3
8-bit input/output port
External interrupt input, timer/counter input, serial interface input/output, UART
input/output, divider output
Port P4
8-bit input/output port
External interrupt input, timer/counter input, LCD segment output, PPG output
Port P5
8-bit input/output port
Timer/counter input/output, LCD segment output, UART input/output
Port P6
8-bit input/output port
LCD segment output
Port P7
8-bit input/output port
LCD segment output
Port P8
8-bit input/output port
LCD segment output
Register List
Latch
P0DR (0000H)
Read
Pch Control
CR1
CR2
LCD Control
P0PRD (0FF0H)
P0OUTCR (0032H)
−
−
−
P1
P1DR (0001H)
−
−
P1CR1 (0FF9H)
P1CR2 (0FFAH)
−
P2
P2DR (0002H)
P2PRD (0FF2H)
−
−
−
−
P3
P3DR (0003H)
P3PRD (0FF3H)
P3OUTCR (002BH)
−
−
−
P4
P4DR (0004H)
P4PRD (0FF4H)
P4OUTCR (0FFBH)
−
−
P4LCR (0FD4H)
P5
P5DR (0005H)
P5PRD (0FF5H)
P5OUTCR (0FFCH)
−
−
P5LCR (0FD5H)
P6
P6DR (0006H)
P6PRD (0FF6H)
P6OUTCR (0FFDH)
−
−
P6LCR (0FD6H)
P7
P7DR (0007H)
P7PRD (0FF7H)
P7OUTCR (0FFEH)
−
−
P7LCR (0FD7H)
P8
P8DR (0008H)
P8PRD (0FF8H)
P8OUTCR (0FFFH)
−
−
P8LCR (0FD8H)
Page 51
5. I/O Ports
TMP86FS28FG
Each output port contains a latch for holding output data. All input ports do not have latches, making it necessary
to externally hold input data until it is read externally or to read input data multiple times before it is processed. Figure 5-1 shows input/output timings.
External data is read from an input/output port in the S1 state of the read cycle in instruction execution. Since this
timing cannot be recognized externally, transient input such as chattering must be processed by software. Data is output to an input/output port in the S2 state of the write cycle in instruction execution.
Fetch cycle
Fetch cycle
Read cycle
S0 S1 S2 S3 S0 S1 S2 S3 S0 S1 S2 S3
Instruction
execution cycle
Ex: LD A, (x)
Input strobe
Data input
(a) Input timing
Fetch cycle
Fetch cycle
Write cycle
S0 S1 S2 S3 S0 S1 S2 S3 S0 S1 S2 S3
Instruction
execution cycle
Ex: LD (x), A
Output latch pulse
Data output
(b) Output timing
Note: The positions of the read and write cycles may vary depending on the instruction.
Figure 5-1 Input/Output Timings (Example)
Page 52
TMP86FS28FG
5.1 Port P0 (P00 to P02)
Port P0 is a 3-bit input/output port that can also be used for external interrupt input or PPG output.
A reset initializes the output latch (P0DR) to “1” and the Pch control (P0OUTCR) to “0”.
To use a pin in Port P0 as an input port or external interrupt input, set P0DR to “1” and then set the corresponding
bit in P0OUTCR to “0”.
To use a pin in Port P0 as a PPG output, set P0DR to “1”.
The output circuit of Port P0 can be set either as sink open-drain output (“0”) or CMOS output (“1”) individually
for each bit in P0OUTCR.
Port P0 has a separate data input register. The output latch state can be read from the P0DR register, and the pin
state can be read from the P0PRD register.
Table 5-3 Register Programming for Port P0 (P00 to P02)
Programmed Value
Function
P0DR
P0OUTCR
Port input, external interrupt input
“1”
“0”
Port "0" output
“0”
Port "1" output, PPG output
“1”
Set as
appropriate.
STOP
OUTEN
P0OUTCRi
D
Q
D
Q
P0OUTCRi input
Data input (P0PRD)
Output latch read (P0DR)
Data output (P0DR)
P0i
Note) i = 2~0
Output latch
Control output
Control input
Figure 5-2 Port P0
Page 53
5. I/O Ports
5.1 Port P0 (P00 to P02)
P0DR
(0000H)
R/W
P0OUTCR
(0032H)
R/W
TMP86FS28FG
7
5
4
3
2
1
0
P02
P01
P00
(Initial value: **** *111)
PPG1
INT3
7
6
5
4
3
2
1
0
(Initial value: **** *000)
P0OUTCR
P0PRD
(0FF0H)
6
7
Port P0 input/output control
(set for each bit individually)
0: Sink open-drain output
1: CMOS output
6
3
5
4
R/W
2
1
0
P02
P01
P00
Read only
Page 54
(Initial value: **** *000)
TMP86FS28FG
5.2 Port P1 (P10 to P17)
Port P1 is an 8-bit input/output port that can be configured as an input or an output on a bit basis. Port P1 is also
used for analog input or key-on wake-up input.
The Port P1 input/output control register (P1CR1) and Port P1 input control register (P1CR2) are used to specify
the function of each pin.
A reset initializes P1CR1 to “0”, P1CR2 to “1”, and the output latch (P1DR) to “0” so that Port P1 becomes an
input port.
To use a pin in Port P1 as an input port, set P1CR1 to “0” and then set P1CR2 to “1”. To use a pin in Port P1 as an
analog input or key-on wake-up input, set P1CR1 to “0” and then set P1CR2 to “0”.
To use a pin in Port P1 as an output port, set the corresponding bit in P1CR1 to “1”.
To read the output latch data, set P1CR1 to “1”and read P1DR. To read the pin state, set P1CR1 to “0” and P1CR2
to “1” and then read P1DR. When P1CR1 = “0” and P1CR2 = “0”, P1DR is read as “0”.
Bits not used as analog inputs are used as input/output pins. During AD conversion, however, output instructions
must not be executed to ensure the accuracy of conversion results. Also, during AD conversion, do not input signals
that fluctuate widely to pins near analog input pins.
Table 5-4 Register Programming for Port P1 (P10 to P17)
Programmed Value
Function
P1DR
P1CR1
P1CR2
Port input
*
“0”
“1”
Analog input, key-on wake-up input
*
“0”
“0”
Port “0” output
“0”
“1”
*
Port "1" output
“1”
“1”
*
Note: An asterisk (*) indicates that either “1” or “0” can be set.
Table 5-5 Values Read from P1DR according to Register Programming
Conditions
Values Read from P1DR
P1CR1
P1CR2
“0”
“0”
“0”
“0”
“1”
Pin state
“0”
“1”
Output latch state
“1”
Page 55
5. I/O Ports
5.2 Port P1 (P10 to P17)
TMP86FS28FG
Analog input
AINDS
SAIN
PCR2i
D
Q
D
Q
D
Q
D
Q
D
Q
D
Q
P1CR2i input
P1CR1i
P1CR1i input
Data input (P1DR)
Data output (P1DR)
P1i
Note 1) i = 0, 1, 6, 7 : j = 2~5 : k = 2~5
Note 2) STOP = bit 7 in SYSCR1
Note 3) SAIN = AD input select signal
Note 4) STOPk = input select signal for
key-on wake-up
STOP
OUTEN
STOPk
Key-on wake-up
Analog input
AINDS
SAIN
P1CR2j
P1CR2j input
P1CR1j
P1CR1j input
Data input (P1DR)
Data output (P1DR)
P1j
STOP
OUTEN
Figure 5-3 Port P1
Note 1: Pins set to input mode read the pin input data. Therefore, when both input and output modes are used in Port P1,
the contents of the output latch of a pin set to input mode may be overwritten by a bit manipulation instruction.
Note 2: For a pin used as an analog input, be sure to clear the corresponding bit in P1CR2 to "0" to prevent flow-through
current.
Note 3: For a pin used as an analog input, do not set P1CR1 to "1" (port output) to prevent the pin from becoming shorted
with an external signal.
Note 4: Pins not used as analog inputs can be used as input/output pins. During AD conversion, however, output instructions must not be executed to ensure the accuracy of conversion results. Also, during AD conversion, do not input
signals that fluctuate widely to pins near analog input pins.
Page 56
TMP86FS28FG
P1DR
(0001H)
R/W
P1CR1
(0FF9H)
7
6
5
4
3
2
1
0
P17
AIN7
P16
AIN6
P15
AIN5
STOP5
P14
AIN4
STOP4
P13
AIN3
STOP3
P12
AIN2
STOP2
P11
AIN1
P10
AIN0
7
6
5
4
3
2
1
0
(Initial value: 0000 0000)
P1CR1
P1CR2
(0FFAH)
(Initial value: 0000 0000)
7
Port P1 input/output control
(set for each bit individually)
0: Port input, key-on wake-up input, analog input
1: Port output
6
3
5
4
2
1
R/W
0
(Initial value: 1111 1111)
P1CR2
Port P1 input control
(set for each bit individually)
0: Analog input, key-on wake-up input
1: Port input
Page 57
R/W
5. I/O Ports
5.3 Port P2 (P20 to P22)
TMP86FS28FG
5.3 Port P2 (P20 to P22)
Port P2 is a 3-bit input/output port that can also be used for external interrupt input, STOP mode release signal
input, or low-frequency resonator connection.
To use Port P2 as an input port or function pins, set the output latch (P2DR) to “1”. A reset initializes P2DR to “1”.
In the dual clock mode, pins P21 (XTIN) and P22 (XOUT) are connected with a low-frequency resonator (32.768
kHz). In the single clock mode, pins P21 and P22 can be used as normal input/output port pins.
It is recommended that pin P20 be used as an external interrupt input, STOP release signal input, or input port.
(When P20 is used as an output port, the interrupt latch is set on the falling edge of the output pulse.)
Port P2 has a separate data input register. The output latch state can be read from the P2DR register, and the pin
state can be read from the P2PRD register.
When a read instruction is executed on P2DR or P2PRD, bits 7 to 3 are read as undefined.
Data input (P20PRD)
Data input (P20)
D
Data output (P20)
Q
P20 (INT5, STOP)
Output latch
Control input
Data input (P21PRD)
Osc. enable
Output latch read (P21)
Data output (P21)
D
Q
P21 (XTIN)
Output latch
Data input (P22PRD)
Output latch read (P22)
Data output (P22)
D
Q
P22 (XTOUT)
Output latch
STOP
OUTEN
XTEN
fs
Figure 5-4 Port P2
P2DR
(0002H)
R/W
7
6
5
4
3
2
1
0
P22
XTOUT
P21
XTIN
INT5
P20
(Initial value: **** *111)
STOP
P2PRD
(0FF2H)
Read only
7
6
5
4
3
2
1
0
P22
P21
P20
Note: Since pin P20 is also used as a STOP pin, the output of P20 becomes high-impedance in STOP mode regardless of the
OUTEN state.
Page 58
TMP86FS28FG
5.4 Port P3 (P30 to P37)
Port P3 is an 8-bit input/output port that can also be used for external interrupt input, divider output, timer/counter
input, serial interface input/output, or UART input/output.
A reset initializes the output latch (P3DR) to “1” and the Pch control (P3OUTCR) to “0”.
To use a pin in Port P3 as an external interrupt input, timer/counter input, serial interface input, or UART input, set
P3DR to “1” and then set the corresponding bit in P3OUTCR to “0”.
To use a pin in Port P3 as a divider output, serial interface output, or UART output, set P3DR to “1”.
Port 3 can be used for either SIO or UART, so be sure not to enable both of these functions at the same time.
The output circuit of Port P3 can be set either as sink open-drain output (“0”) or CMOS output (“1”) individually
for each bit in P3OUTCR.
Port P3 has a separate data input register. The output latch state can be read from the P3DR register, and the pin
state can be read from the P3PRD register.
Table 5-6 Register Programming for Port P3 (P30 to P37)
Programmed Value
Function
P3DR
P3OUTCR
Port input, external interrupt input, timer/counter
input, serial interface input, UART input
“1”
“0”
Port “0” output
“0”
Port “1” output, serial interface output, UART
output, divider output
“1”
Set as
appropriate.
STOP
OUTEN
P3OUTCRi
D
Q
D
Q
P3OUTCRi input
Data input (P3PRD)
Output latch read (P3DR)
Data output (P3DR)
P3i
Note) i = 7~0
Output latch
Control output
Control input
Figure 5-5 Port P3
Page 59
5. I/O Ports
5.4 Port P3 (P30 to P37)
P3DR
(0003H)
R/W
P3OUTCR
(002BH)
TMP86FS28FG
7
6
5
4
3
2
P37
TC10
INT4
P36
P35
SI
TXD1
P34
SO
RXD1
P33
P32
SCK
7
6
5
4
3
0
P31
P30
DVO
INT0
1
0
(Initial value: 1111 1111)
(Initial value: 0000 0000)
Port P3 output circuit control
(set for each bit individually)
0: Sink open-drain output
1: CMOS output
7
6
5
4
3
2
1
0
P37
P36
P35
P34
P33
P32
P31
P30
P3OUTCR
P3PRD
(0FF3H)
Read only
2
1
Page 60
R/W
TMP86FS28FG
5.5 Port P4 (P40 to P47)
Port P4 is an 8-bit input/output port that can also be used for external interrupt input, PPG output, timer/counter
input, or LCD segment output.
A reset initializes the output latch (P4DR) to “1”, the Pch control (P4OUTCR) to “0”, and the LCD output control
register (P4LCR) to “0”.
To use a pin in Port P4 as an input port, external interrupt input, or timer/counter input, set P4DR to “1” and then
set the corresponding bit in P4LCR and P4OUTCR to “0”.
To use a pin in Port P4 as an LCD segment output, set the corresponding bit in P4LCR to “1”.
To use a pin in Port P4 as a PPG output, set P4DR to “1” and then set the corresponding bit in P4LCR to “0”.
The output circuit of Port P4 can be set either as sink open-drain outut (“0”) or CMOS output (“1”) individually for
each bit in P4OUTCR.
Port P4 has a separate data input register. The output latch state can be read from the P4DR register, and the pin
state can be read from the P4PRD register.
Table 5-7 Register Programming for Port P4 (P40 to P47)
Programmed Value
Function
P4DR
P4OUTCR
P4LCR
Port input, external interrupt input,
timer/counter input
“1”
“0”
“0”
Port "0" output
“0”
Port “1” output
“1”
PPG output
“1”
LCD segment output
*
“0”
Set as
appropriate.
“0”
“0”
*
“1”
Note: An asterisk (*) indicates that either “1” or “0” can be set.
STOP
OUTEN
P4OUTCRi
D
Q
D
Q
D
Q
P4OUTCRi input
P4LCRi input
P4LCRi
Data input (P4PRD)
Output latch read (P4DR)
Data output (P4DR)
P4i
Note) i = 7~0
Output latch
Control output
Control input
LCD data output
Figure 5-6 Port P4
Page 61
5. I/O Ports
5.5 Port P4 (P40 to P47)
TMP86FS28FG
7
6
5
4
3
2
1
0
P4DR
(0004H)
R/W
P47
SEG32
P46
SEG31
P45
SEG30
P44
SEG29
P43
SEG28
TC11
P42
SEG27
PPG1
P41
SEG26
INT2
P40
SEG25
INT1
P4LCR
(0FD4H)
7
3
2
1
0
7
4
Port P4 segment output control
(Set for each bit individually)
0: Input/output port
1: LCD segment output
6
3
5
4
2
1
R/W
0
(Initial value: 0000 0000)
P4 output circuit control
(Set for each bit individually)
0: Sink open-drain output
1: CMOS output
7
6
5
4
3
2
1
0
P47
P46
P45
P44
P43
P42
P41
P40
P4OUTCR
P4PRD
(0FF4H)
Read only
5
(Initial value: 0000 0000)
P4LCR
P4OUTCR
(0FFBH)
6
(Initial value: 0000 0000)
Page 62
R/W
TMP86FS28FG
5.6 Port P5 (P50 to P57)
Port P5 is an 8-bit input/output port that can also be used for timer/counter input/output, LCD segment output, or
UART input/output.
A reset initializes the output latch (P5DR) to “1”, the Pch control (P5OUTCR) to “0”, and the LCD output control
register (P5LCR) to “0”.
To use a pin in Port P5 as an input port, timer/counter input, or UART input, set P5DR to “1” and then set the corresponding bit in P5LCR and P5OUTCR to “0”.
To use a pin in Port P5 as an LCD segment output, set the corresponding bit in P5LCR to “1”.
To use a pin in Port P5 as a UART output or timer/counter output, set P5DR to "1" and then set the corresponding
bit in P5LCR to “0”.
The output circuit of Port P5 can be set either as sink open-drain output (“0”) or CMOS otuput (“1”) individually
for each bit in P5OUTCR.
Port P5 has a separate data input register. The output latch state can be read from the P5DR register, and the pin
state can be read from the P5PRD register.
Table 5-8 Register Programming for Port P5 (P50 to P57)
Programmed Value
Function
P5DR
P5OUTCR
P5LCR
Port input, UART input, timer/counter input
“1”
“0”
“0”
Port “0” output
“0”
“0”
Port “1” output, UART output
“1”
Set as
appropriate.
“0”
*
*
“1”
LCD segment output
Note: An asterisk (*) indicates that either “1” or “0” can be set.
STOP
OUTEN
P5OUTCRi
D
Q
D
Q
D
Q
P5OUTCRi input
P5LCRi input
P5LCRi
Data input (P5PRD)
Output latch read (P5DR)
Data output (P5DR)
P5i
Note) i = 7~0
Output latch
Control output
Control input
LCD data output
Figure 5-7 Port P5
Page 63
5. I/O Ports
5.6 Port P5 (P50 to P57)
P5DR
(0005H)
R/W
P5LCR
(0FD5H)
TMP86FS28FG
7
6
5
4
3
2
1
0
P57
SEG24
P56
SEG25
P55
SEG26
TC6
P54
SEG27
TC5
P53
SEG28
TC4
P52
SEG29
TC3
P51
SEG30
RXD0
P50
SEG31
TXD0
PWM6
PWM5
PWM4
PWM3
PDO6
PDO5
PDO4
PDO3
5
4
3
2
1
0
7
(Initial value: 0000 0000)
P5LCR
P5OUTCR
(0FFCH)
7
Port P5 segment output control
(Set for each bit individually)
0: Input/output port
1: LCD segment output
6
3
5
4
2
1
R/W
0
(Initial value: 0000 0000)
P5OUTCR
P5PRD
(0FF5H)
6
(Initial value: 0000 0000)
Port P5 input/output control
(Set for each bit individually)
0: Sink open-drain output
1: CMOS output
R/W
7
6
5
4
3
2
1
0
P57
P56
P55
P54
P53
P52
P51
P50
Read only
Page 64
TMP86FS28FG
5.7 Port P6 (P60 to P67)
Port P6 is an 8-bit input/output port that can also be used for LCD segment output.
A reset initializes the output latch (P6DR) to “1”, the Pch control (P6OUTCR) to “0”, and the LCD output control
register (P6LCR) to “0”.
To use a pin in Port P6 as an input port, set P6DR to “1” and then set the corresponding bit in P6LCR and
P6OUTCR to “0”.
To use a pin in Port P6 as an LCD segment output, set the corresponding bit in P6LCR to “1”.
The output circuit of Port P6 can be set either as sink open-drain output (“0”) or CMOS output (“1”) individually
for each bit in P6OUTCR.
Port P6 has a separate data input register. The outut latch state can be read from the P6DR register, and the pin
state can be read from the P6PRD register.
Table 5-9 Register Programming for Port P6 (P60 to P67)
Programmed Value
Function
P6DR
P6OUTCR
P6LCR
Port input
“1”
“0”
“0”
Port "0" output
“0”
“0”
Port “1” output
“1”
Set as
appropriate.
“0”
*
*
“1”
LCD segment output
Note: An asterisk (*) indicates that either “1” or “0” can be set.
STOP
OUTEN
P6OUTCRi
D
Q
D
Q
D
Q
P6OUTCRi input
P6LCRi input
P6LCRi
Data input (P6PRD)
Output latch read (P6DR)
Data output (P6DR)
P6i
Note) i = 7~0
Output latch
LCD data output
Figure 5-8 Port P6
Page 65
5. I/O Ports
5.7 Port P6 (P60 to P67)
P6DR
(0006H)
R/W
P6LCR
(0FD6H)
TMP86FS28FG
7
6
5
4
3
2
1
0
P67
SEG16
P66
SEG17
P65
SEG18
P64
SEG19
P63
SEG20
P62
SEG21
P61
SEG22
P60
SEG23
7
6
5
4
3
2
1
0
(Initial value: 0000 0000)
P6LCR
P6OUTCR
(0FFDH)
7
Port P6 segment output control
(Set for each bit individually)
0: Input/output port
1: Segment output
6
3
5
4
2
R/W
1
0
(Initial value: 1111 1111)
P6CR2
P6PRD
(0FF6H)
(Initial value: 0000 0000)
Port P6 input/output control
(Set for each bit individually)
0: Sink open-drain output
1: CMOS output
R/W
7
6
5
4
3
2
1
0
P67
P66
P65
P64
P63
P62
P61
P60
Read only
Page 66
TMP86FS28FG
5.8 Port P7 (P70 to P77)
Port P7 is an 8-bit input/output port that can also be used for LCD segment output.
A reset initializes the output latch (P7DR) to “1”, the Pch control (P7OUTCR) to “0”, and the LCD output control
register (P7LCR) to “0”.
To use a pin in Port P7 as an input port, set P7DR to “1” and then set the corresponding bit in P7LCR and
P7OUTCR to “0”.
To use a pin in Port P7 as an LCD segment output, set the corresponding bit in P7LCR to “1”.
The output circuit of Port P7 can be set either as sink open-drain output (“0”) or CMOS output (“1”) individually
for each bit in P7OUTCR.
Port P7 has a separate data input register. The output latch state can be read from the P7DR register, and the pin
state can be read from the P7PRD register.
Table 5-10 Register Programming for Port P7 (P70 to P77)
Programmed Value
Function
P7DR
P7OUTCR
P7LCR
Port input
“1”
“0”
“0”
Port “0” output
“0”
“0”
Port “1” output
“1”
Set as
appropriate.
“0”
*
*
“1”
LCD segment output
Note: An asterisk (*) indicates that either “1” or “0” can be set.
STOP
OUTEN
P7OUTCRi
D
Q
D
Q
D
Q
P7OUTCRi input
P7LCRi input
P7LCRi
Data input (P7PRD)
Output latch read (P7DR)
Data output (P7DR)
P7i
Note) i = 7~0
Output latch
LCD data output
Figure 5-9 Port P7
Page 67
5. I/O Ports
5.8 Port P7 (P70 to P77)
P7DR
(0007H)
R/W
P7LCR
(0FD7H)
TMP86FS28FG
7
6
5
4
3
2
1
0
P77
SEG8
P76
SEG9
P75
SEG10
P74
SEG11
P73
SEG12
P72
SEG13
P71
SEG14
P70
SEG15
7
6
5
4
3
2
1
0
(Initial value: 0000 0000)
P7LCR
P7OUTCR
(0FFEH)
7
Port P7 segment output control
(set for each bit individually)
0: Input/output port
1: Segment output
6
3
5
4
2
R/W
1
0
(Initial value: 0000 0000)
P7OUTCR
P7PRD
(0FF7H)
(Initial value: 0000 0000)
Port P7 input/output control
(set for each bit individually)
0: Sink open-drain output
1: CMOS output
R/W
7
6
5
4
3
2
1
0
P77
P76
P75
P74
P73
P72
P71
P70
Read only
Page 68
TMP86FS28FG
5.9 Port P8 (P80 to P87)
Port P8 is an 8-bit input/output port that can also be used for LCD segment output.
A reset initializes the output latch (P8DR) to “1”, the Pch control (P8OUTCR) to “0”, and the LCD output control
register (P8LCR) to “0”.
To use a pin in Port P8 as an input port, set P8DR to “1” and then set the corresponding bit in P8LCR and
P8OUTCR to “0”.
To use a pin in Port P8 as an LCD segment output, set the corresponding bit in P8LCR to “1”.
The output circuit of Port P8 can be set either as sink open-drain output (“0”) or CMOS output (“1”) individually
for each bit in P8OUTCR.
Port P8 has a separate data input register. The output latch state can be read from the P8DR register, and the pin
state can be read from the P8PRD register.
Table 5-11 Register Programming for Port P8 (P80 to P87)
Port Input
Function
P8DR
P8OUTCR
P8LCR
Port input
“1”
“0”
“0”
Port “0” output
“0”
“0”
Port “1” output
“1”
Set as
appropriate.
“0”
*
*
“1”
LCD segment output
Note: An asterisk (*) indicates that either “1” or “0” can be set.
STOP
OUTEN
P8OUTCRi
D
Q
D
Q
D
Q
P8OUTCRi input
P8LCRi input
P8LCRi
Data input (P8PRD)
Output latch read (P8DR)
Data output (P8DR)
P8i
Note) i = 7~0
Output latch
LCD data output
Figure 5-10 Port P8
Page 69
5. I/O Ports
5.9 Port P8 (P80 to P87)
P8DR
(0008H)
R/W
P8LCR
(0FD8H)
TMP86FS28FG
7
6
5
4
3
2
1
0
P87
SEG0
P86
SEG1
P85
SEG2
P84
SEG3
P83
SEG4
P82
SEG5
P81
SEG6
P80
SEG7
7
6
5
4
3
2
1
0
(Initial value: 0000 0000)
P8LCR
P8OUTCR
(0FFFH)
7
Port P8 segment output control
(Set for each bit individually)
0: Input/output port
1: LCD segment output
6
3
5
4
2
1
R/W
0
(Initial value: 0000 0000)
P8OUTCR
P8PRD
(0FF8H)
(Initial value: 0000 0000)
Port P8 input/output control
(Set for each bit individually)
0: Sink open-drain output
1: CMOS output
R/W
7
6
5
4
3
2
1
0
P87
P86
P85
P84
P83
P82
P81
P80
Read only
Page 70
TMP86FS28FG
6. Watchdog Timer (WDT)
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 “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.
6.1 Watchdog Timer Configuration
Reset release
23
15
Binary counters
Selector
fc/2 or fs/2
fc/221 or fs/213
fc/219 or fs/211
fc/217 or fs/29
Clock
Clear
R
Overflow
1
WDT output
2
S
2
Q
Interrupt request
Internal reset
Q
S R
WDTEN
WDTT
Writing
disable code
Writing
clear code
WDTOUT
Controller
0034H
WDTCR1
0035H
WDTCR2
Watchdog timer control registers
Figure 6-1 Watchdog Timer Configuration
Page 71
Reset
request
INTWDT
interrupt
request
6. Watchdog Timer (WDT)
6.2 Watchdog Timer Control
TMP86FS28FG
6.2 Watchdog Timer Control
The watchdog timer is controlled by the watchdog timer control registers (WDTCR1 and WDTCR2). The watchdog timer is automatically enabled after the reset release.
6.2.1
Malfunction Detection Methods Using the Watchdog Timer
The CPU malfunction is detected, as shown below.
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/SLEEP
mode, and automatically restarts (continues counting) when the STOP/IDLE/SLEEP 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
Within 3/4 of WDT
detection time
LD
(WDTCR2), 4EH
: Clears the binary counters.
LD
(WDTCR1), 00001101B
: WDTT ← 10, WDTOUT ← 1
LD
(WDTCR2), 4EH
: Clears the binary counters (always clears immediately before and
after changing WDTT).
(WDTCR2), 4EH
: Clears the binary counters.
(WDTCR2), 4EH
: Clears the binary counters.
:
:
LD
Within 3/4 of WDT
detection time
:
:
LD
Page 72
TMP86FS28FG
Watchdog Timer Control Register 1
WDTCR1
(0034H)
7
WDTEN
6
5
4
3
(ATAS)
(ATOUT)
WDTEN
Watchdog timer enable/disable
2
1
0
WDTT
WDTOUT
(Initial value: **11 1001)
0: Disable (Writing the disable code to WDTCR2 is required.)
1: Enable
NORMAL1/2 mode
WDTT
WDTOUT
Watchdog timer detection time
[s]
Watchdog timer output select
DV7CK = 0
DV7CK = 1
SLOW1/2
mode
00
225/fc
217/fs
217/fs
01
223/fc
215/fs
215fs
10
221fc
213/fs
213fs
11
219/fc
211/fs
211/fs
0: Interrupt request
1: Reset request
Write
only
Write
only
Write
only
Note 1: After clearing WDTOUT to “0”, the program cannot set it to “1”.
Note 2: fc: High-frequency clock [Hz], fs: Low-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
don’t care 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 WDTEN, set the register in accordance with the procedures shown in “6.2.3 Watchdog Timer Disable”.
Watchdog Timer Control Register 2
WDTCR2
(0035H)
7
6
5
4
3
2
1
0
(Initial value: **** ****)
WDTCR2
Write
Watchdog timer control code
4EH: Clear the watchdog timer binary counter (Clear code)
B1H: Disable the watchdog timer (Disable code)
D2H: Enable assigning address trap area
Others: Invalid
Write
only
Note 1: The disable code is valid only when WDTCR1<WDTEN> = 0.
Note 2: *: Don’t care
Note 3: The binary counter of the watchdog timer must not be cleared by the interrupt task.
Note 4: Write the clear code 4EH using a cycle shorter than 3/4 of the time set in WDTCR1<WDTT>.
6.2.2
Watchdog Timer Enable
Setting WDTCR1<WDTEN> to “1” enables the watchdog timer. Since WDTCR1<WDTEN> is initialized
to “1” during reset, the watchdog timer is enabled automatically after the reset release.
Page 73
6. Watchdog Timer (WDT)
6.2 Watchdog Timer Control
6.2.3
TMP86FS28FG
Watchdog Timer Disable
To disable the watchdog timer, set the register in accordance with the following procedures. Setting the register in other procedures causes a malfunction of the microcontroller.
1. Set the interrupt master flag (IMF) to “0”.
2. Set WDTCR2 to the clear code (4EH).
3. Set WDTCR1<WDTEN> to “0”.
4. Set WDTCR2 to the disable code (B1H).
Note:While the watchdog timer is disabled, the binary counters of the watchdog timer are cleared.
Example :Disabling the watchdog timer
: IMF ← 0
DI
LD
(WDTCR2), 04EH
: Clears the binary counter
LDW
(WDTCR1), 0B101H
: WDTEN ← 0, WDTCR2 ← Disable code
Table 6-1 Watchdog Timer Detection Time (Example: fc = 16.0 MHz, fs = 32.768 kHz)
Watchdog Timer Detection Time[s]
WDTT
6.2.4
NORMAL1/2 mode
DV7CK = 0
DV7CK = 1
SLOW
mode
00
2.097
4
4
01
524.288 m
1
1
10
131.072 m
250 m
250 m
11
32.768 m
62.5 m
62.5 m
Watchdog Timer Interrupt (INTWDT)
When WDTCR1<WDTOUT> is cleared to “0”, a watchdog timer interrupt request (INTWDT) is generated
by the binary-counter overflow.
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>.
Example :Setting watchdog timer interrupt
LD
SP, 083FH
: Sets the stack pointer
LD
(WDTCR1), 00001000B
: WDTOUT ← 0
Page 74
TMP86FS28FG
6.2.5
Watchdog Timer Reset
When a binary-counter overflow occurs while WDTCR1<WDTOUT> is set to “1”, a watchdog timer reset
request is generated. When a watchdog timer reset request is generated, the internal hardware is reset. The reset
time is maximum 24/fc [s] (1.5 µs @ fc = 16.0 MHz).
Note:When a watchdog timer reset is generated in the SLOW1 mode, the reset time is maximum 24/fc (high-frequency clock) since the high-frequency clock oscillator is restarted. However, when crystals have inaccuracies upon start of the high-frequency clock oscillator, the reset time should be considered as an approximate
value because it has slight errors.
219/fc [s]
217/fc
Clock
Binary counter
(WDTT=11)
1
2
3
0
1
2
3
0
Overflow
INTWDT interrupt request
(WDTCR1<WDTOUT>= "0")
Internal reset
A reset occurs
(WDTCR1<WDTOUT>= "1")
Write 4EH to WDTCR2
Figure 6-2 Watchdog Timer Interrupt
Page 75
6. Watchdog Timer (WDT)
6.3 Address Trap
TMP86FS28FG
6.3 Address Trap
The Watchdog Timer Control Register 1 and 2 share the addresses with the control registers to generate address
traps.
Watchdog Timer Control Register 1
7
WDTCR1
(0034H)
6
5
4
3
ATAS
ATOUT
(WDTEN)
2
1
(WDTT)
0
(WDTOUT)
(Initial value: **11 1001)
ATAS
Select address trap generation in
the internal RAM area
0: Generate no address trap
1: Generate address traps (After setting ATAS to “1”, writing the control code
D2H to WDTCR2 is required)
ATOUT
Select operation at address trap
0: Interrupt request
1: Reset request
Write
only
Watchdog Timer Control Register 2
WDTCR2
(0035H)
7
5
4
3
2
1
0
(Initial value: **** ****)
WDTCR2
6.3.1
6
Write
Watchdog timer control code
and address trap area control
code
D2H: Enable address trap area selection (ATRAP control code)
4EH: Clear the watchdog timer binary counter (WDT clear code)
B1H: Disable the watchdog timer (WDT disable code)
Others: Invalid
Write
only
Selection of Address Trap in Internal RAM (ATAS)
WDTCR1<ATAS> specifies whether or not to generate address traps in the internal RAM area. To execute
an instruction in the internal RAM area, clear WDTCR1<ATAS> to “0”. To enable the WDTCR1<ATAS> setting, set WDTCR1<ATAS> and then write D2H to WDTCR2.
Executing an instruction in the SFR or DBR area generates an address trap unconditionally regardless of the
setting in WDTCR1<ATAS>.
6.3.2
Selection of Operation at Address Trap (ATOUT)
When an address trap is generated, either the interrupt request or the reset request can be selected by
WDTCR1<ATOUT>.
6.3.3
Address Trap Interrupt (INTATRAP)
While WDTCR1<ATOUT> is “0”, if the CPU should start looping for some cause such as noise and an
attempt be made to fetch an instruction from the on-chip RAM (while WDTCR1<ATAS> is “1”), DBR or the
SFR area, address trap interrupt (INTATRAP) will be generated.
An address trap interrupt is a non-maskable interrupt which can be accepted regardless of the interrupt master flag (IMF).
When an address trap interrupt is generated while the other interrupt including an address trap interrupt is
already accepted, the new address trap is processed immediately and the previous interrupt is held pending.
Therefore, if address trap interrupts are generated continuously without execution of the RETN instruction, too
many levels of nesting may cause a malfunction of the microcontroller.
To generate address trap interrupts, set the stack pointer beforehand.
Page 76
TMP86FS28FG
6.3.4
Address Trap Reset
While WDTCR1<ATOUT> is “1”, if the CPU should start looping for some cause such as noise and an
attempt be made to fetch an instruction from the on-chip RAM (while WDTCR1<ATAS> is “1”), DBR or the
SFR area, address trap reset will be generated.
When an address trap reset request is generated, the internal hardware is reset. The reset time is maximum
24/fc [s] (1.5 µs @ fc = 16.0 MHz).
Note:When an address trap reset is generated in the SLOW1 mode, the reset time is maximum 24/fc (high-frequency clock) since the high-frequency clock oscillator is restarted. However, when crystals have inaccuracies upon start of the high-frequency clock oscillator, the reset time should be considered as an approximate
value because it has slight errors.
Page 77
6. Watchdog Timer (WDT)
6.3 Address Trap
TMP86FS28FG
Page 78
TMP86FS28FG
7. Time Base Timer (TBT)
The time base timer generates time base for key scanning, dynamic displaying, etc. It also provides a time base
timer interrupt (INTTBT).
7.1 Time Base Timer
7.1.1
Configuration
MPX
fc/223 or fs/215
fc/221 or fs/213
fc/216 or fs/28
fc/214 or fs/26
fc/213 or fs/25
fc/212 or fs/24
fc/211 or fs/23
fc/29 or fs/2
Source clock
IDLE0, SLEEP0
release request
Falling edge
detector
INTTBT
interrupt request
3
TBTCK
TBTEN
TBTCR
Time base timer control register
Figure 7-1 Time Base Timer configuration
7.1.2
Control
Time Base Timer is controlled by Time Base Timer control register (TBTCR).
Time Base Timer Control Register
7
TBTCR
(0036H)
6
(DVOEN)
TBTEN
5
(DVOCK)
Time Base Timer
enable / disable
4
3
(DV7CK)
TBTEN
2
1
0
TBTCK
(Initial Value: 0000 0000)
0: Disable
1: Enable
NORMAL1/2, IDLE1/2 Mode
TBTCK
Time Base Timer interrupt
Frequency select : [Hz]
DV7CK = 0
DV7CK = 1
SLOW1/2
SLEEP1/2
Mode
000
fc/223
fs/215
fs/215
001
fc/221
fs/213
fs/213
010
fc/216
fs/28
–
011
fc/2
14
6
–
100
fc/213
fs/25
–
101
fc/2
12
4
–
110
fc/211
fs/23
–
111
9
fs/2
–
fc/2
Note 1: fc; High-frequency clock [Hz], fs; Low-frequency clock [Hz], *; Don't care
Page 79
fs/2
fs/2
R/W
7. Time Base Timer (TBT)
7.1 Time Base Timer
TMP86FS28FG
Note 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.
Example :Set the time base timer frequency to fc/216 [Hz] and enable an INTTBT interrupt.
LD
(TBTCR) , 00000010B
; TBTCK ← 010
LD
(TBTCR) , 00001010B
; TBTEN ← 1
; IMF ← 0
DI
SET
(EIRL) . 6
Table 7-1 Time Base Timer Interrupt Frequency ( Example : fc = 16.0 MHz, fs = 32.768 kHz )
Time Base Timer Interrupt Frequency [Hz]
TBTCK
7.1.3
NORMAL1/2, IDLE1/2 Mode
NORMAL1/2, IDLE1/2 Mode
SLOW1/2, SLEEP1/2 Mode
DV7CK = 0
DV7CK = 1
000
1.91
1
1
001
7.63
4
4
010
244.14
128
–
011
976.56
512
–
100
1953.13
1024
–
101
3906.25
2048
–
110
7812.5
4096
–
111
31250
16384
–
Function
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 7-2 ).
Source clock
TBTCR<TBTEN>
INTTBT
Interrupt period
Enable TBT
Figure 7-2 Time Base Timer Interrupt
Page 80
TMP86FS28FG
7.2 Divider Output (DVO)
Approximately 50% duty pulse can be output using the divider output circuit, which is useful for piezoelectric
buzzer drive. Divider output is from DVO pin.
7.2.1
Configuration
Output latch
D
Data output
Q
DVO pin
MPX
A
B
C Y
D
S
2
fc/213 or fs/25
fc/212 or fs/24
fc/211 or fs/23
fc/210 or fs/22
Port output latch
TBTCR<DVOEN>
DVOCK
DVOEN
TBTCR
DVO pin output
Divider output control register
(a) configuration
(b) Timing chart
Figure 7-3 Divider Output
7.2.2
Control
The Divider Output is controlled by the Time Base Timer Control Register.
Time Base Timer Control Register
7
TBTCR
(0036H)
DVOEN
DVOEN
6
5
DVOCK
4
3
(DV7CK)
(TBTEN)
Divider output
enable / disable
2
1
0
(TBTCK)
(Initial value: 0000 0000)
0: Disable
1: Enable
R/W
DV7CK = 0
DV7CK = 1
SLOW1/2
SLEEP1/2
Mode
00
fc/213
fs/25
fs/25
01
fc/212
fs/24
fs/24
10
fc/211
fs/23
fs/23
11
fc/210
fs/22
fs/22
NORMAL1/2, IDLE1/2 Mode
DVOCK
Divider Output (DVO)
frequency selection: [Hz]
R/W
Note: 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.
Page 81
7. Time Base Timer (TBT)
7.2 Divider Output (DVO)
TMP86FS28FG
Example :1.95 kHz pulse output (fc = 16.0 MHz)
LD
(TBTCR) , 00000000B
; DVOCK ← "00"
LD
(TBTCR) , 10000000B
; DVOEN ← "1"
Table 7-2 Divider Output Frequency ( Example : fc = 16.0 MHz, fs = 32.768 kHz )
Divider Output Frequency [Hz]
DVOCK
NORMAL1/2, IDLE1/2 Mode
DV7CK = 0
DV7CK = 1
SLOW1/2, SLEEP1/2
Mode
00
1.953 k
1.024 k
1.024 k
01
3.906 k
2.048 k
2.048 k
10
7.813 k
4.096 k
4.096 k
11
15.625 k
8.192 k
8.192 k
Page 82
B
A
TC1㪇㩷㫇㫀㫅
Falling
Decoder
Page 83
C
fc/23
Figure 8-1 TimerCounter 10 (TC10)
S
Y
S
A
B
Start
Source㩷
㩷clock
Selector
S
TC10DRA
CMP
PPG output
mode
16-bit timer register A, B
TC10DRB
16-bit up-counter
Clear
MPPG10
INTTC10 interript
Match
Q
Enable
Toggle
Set
Clear
Pulse width
measurement
mode
TC10S clear
TFF10
PPG output
mode
Internal
reset
Write to TC10CR
Note: Function I/O may not operate depending on I/O port setting. For more details, see the chapter "I/O Port".
Capture
Window mode
ACAP10
TC10CR
Y
TC10 control register
TC10CK
2
B
fc/27
D
Clear
Set Q
Command start
METT10
External
trigger start
A
Port
(Note)
Edge detector
Rising
External
trigger
TC10S
2
fc/211, fs/23
Pulse width
measurement
mode
Y
Clear
Set
Toggle
Q
Port
(Note)
㪧㪧㪞㩷
㩷pin
8.1.1
S
8.1
MCAP10
TMP86FS28FG
8. 16-Bit TimerCounter (TC10,TC11)
16-Bit TimerCounter 10
Configuration
8. 16-Bit TimerCounter (TC10,TC11)
8.1 16-Bit TimerCounter 10
8.1.2
TMP86FS28FG
TimerCounter Control
The TimerCounter 10 is controlled by the TimerCounter 10 control register (TC10CR) and two 16-bit timer
registers (TC10DRA and TC10DRB).
Timer Register
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
TC10DRA
(0011H, 0010H)
TC10DRAH (0011H)
TC10DRAL (0010H)
(Initial value: 1111 1111 1111 1111)
Read/Write
TC10DRB
(0013H, 0012H)
TC10DRBH (0013H)
TC10DRBL (0012H)
(Initial value: 1111 1111 1111 1111)
Read/Write (Write enabled only in the PPG output mode)
TimerCounter 10 Control Register
TC10CR
(0014H)
TFF10
7
6
TFF10
ACAP10
MCAP10
METT10
MPPG10
5
4
3
TC10S
2
1
TC10CK
0
Read/Write
(Initial value: 0000 0000)
TC10M
Timer F/F10 control
0: Clear
1: Set
ACAP10
Auto capture control
0:Auto-capture disable
1:Auto-capture enable
MCAP10
Pulse width measurement mode control
0:Double edge capture
1:Single edge capture
METT10
External trigger timer
mode control
0:Trigger start
1:Trigger start and stop
MPPG10
PPG output control
0:Continuous pulse generation
1:One-shot
TC10S
TC10 start control
R/W
R/W
Timer
Extrigger
Event
Window
Pulse
00: Stop and counter clear
O
O
O
O
O
O
01: Command start
O
–
–
–
–
O
10: Rising edge start
(Ex-trigger/Pulse/PPG)
Rising edge count (Event)
Positive logic count (Window)
–
O
O
O
O
O
11: Falling edge start
(Ex-trigger/Pulse/PPG)
Falling edge count (Event)
Negative logic count (Window)
–
O
O
O
O
O
Divider
SLOW,
SLEEP
mode
NORMAL1/2, IDLE1/2 mode
TC10CK
TC10 source clock select
[Hz]
DV7CK = 0
DV7CK = 1
00
fc/211
fs/23
DV9
fs/23
01
fc/27
fc/27
DV5
–
10
fc/23
fc/23
DV1
–
11
TC10M
TC10 operating mode
select
PPG
R/W
R/W
External clock (TC10 pin input)
00: Timer/external trigger timer/event counter mode
01: Window mode
10: Pulse width measurement mode
11: PPG (Programmable pulse generate) output mode
R/W
Note 1: fc: High-frequency clock [Hz], fs: Low-frequency clock [Hz]
Note 2: The timer register consists of two shift registers. A value set in the timer register becomes valid at the rising edge of the
first source clock pulse that occurs after the upper byte (TC10DRAH and TC10DRBH) is written. Therefore, write the
lower byte and the upper byte in this order (it is recommended to write the register with a 16-bit access instruction). Writing
only the lower byte (TC10DRAL and TC10DRBL) does not enable the setting of the timer register.
Note 3: To set the mode, source clock, PPG output control and timer F/F control, write to TC10CR1 during TC10S=00. Set the
timer F/F10 control until the first timer start after setting the PPG mode.
Page 84
TMP86FS28FG
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.
TC10DRA > TC10DRB > 1 (PPG output mode), TC10DRA > 1 (other modes)
Note 6: Set TFF10 to “0” in the mode except PPG output mode.
Note 7: Set TC10DRB after setting TC10M to the PPG output mode.
Note 8: When the STOP mode is entered, the start control (TC10S) is cleared to “00” automatically, and the timer stops. After the
STOP mode is exited, set the TC10S to use the timer counter again.
Note 9: Use the auto-capture function in the operative condition of TC10. 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 TC10DRB by the source clock of up-counter after setting TC10CR<ACAP10>
to "1". Therefore, to read the captured value, wait at least one cycle of the internal source clock before reading TC10DRB
for the first time.
8.1.3
Function
TimerCounter 10 has six types of operating modes: timer, external trigger timer, event counter, window,
pulse width measurement, programmable pulse generator output modes.
8.1.3.1
Timer mode
In the timer mode, the up-counter counts up using the internal clock. When a match between the up-counter and the timer
register 1A (TC10DRA) value is detected, an INTTC10 interrupt is generated and the up-counter is cleared. After being
cleared, the up-counter restarts counting. Setting TC10CR<ACAP10> to “1” captures the up-counter value into the timer
register 1B (TC10DRB) with the auto-capture function. Use the auto-capture function in the operative condition of TC10.
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 TC10DRB by the source clock of upcounter after setting TC10CR<ACAP10> to "1". Therefore, to read the captured value, wait at least one cycle of the internal
source clock before reading TC10DRB for the first time.
Table 8-1 Internal Source Clock for TimerCounter 10 (Example: fc = 16 MHz, fs = 32.768 kHz)
NORMAL1/2, IDLE1/2 mode
TC10CK
SLOW, SLEEP mode
DV7CK = 0
DV7CK = 1
Resolution
[µs]
Maximum Time Setting
[s]
Resolution
[µs]
Maximum Time Setting
[s]
Resolution
[µs]
Maximum
Time Setting [s]
00
128
8.39
244.14
16.0
244.14
16.0
01
8.0
0.524
8.0
0.524
–
–
10
0.5
32.77 m
0.5
32.77 m
–
–
Example 1 :Setting the timer mode with source clock fc/211 [Hz] and generating an interrupt 1 second later
(fc = 16 MHz, TBTCR<DV7CK> = “0”)
LDW
; Sets the timer register (1 s ÷ 211/fc = 1E84H)
(TC10DRA), 1E84H
DI
SET
; IMF= “0”
(EIRL). 7
; Enables INTTC10
EI
; IMF= “1”
LD
(TC10CR), 00000000B
; Selects the source clock and mode
LD
(TC10CR), 00010000B
; Starts TC10
Page 85
8. 16-Bit TimerCounter (TC10,TC11)
8.1 16-Bit TimerCounter 10
TMP86FS28FG
Example 2 :Auto-capture
LD
(TC10CR), 01010000B
:
:
LD
WA, (TC10DRB)
; ACAP10 ← 1
; Reads the capture value
Note: Since the up-counter value is captured into TC10DRB by the source clock of up-counter after setting TC10CR<ACAP10> to
"1". Therefore, to read the captured value, wait at least one cycle of the internal source clock before reading TC10DRB for the
first time.
Timer start
Source clock
Counter
0
TC10DRA
?
1
2
3
n-1
4
n
0
1
2
3
4
5
6
n
Match detect
INTTC10 interruput request
Counter clear
(a) Timer mode
Source clock
m-2
Counter
m-1
m
m+1
m+2
n-1
n
Capture
TC10DRB
?
m-1
m
n+1
Capture
m+1
m+2
ACAP10
(b) Auto-capture
Figure 8-2 Timer Mode Timing Chart
Page 86
n-1
n
n+1
7
TMP86FS28FG
8.1.3.2
External Trigger Timer Mode
In the external trigger timer mode, the up-counter starts counting by the input pulse triggering of the
TC10 pin, and counts up at the edge of the internal clock. For the trigger edge used to start counting, either
the rising or falling edge is defined in TC10CR<TC10S>.
• When TC10CR<METT10> is set to “1” (trigger start and stop)
When a match between the up-counter and the TC10DRA value is detected after the timer
starts, the up-counter is cleared and halted and an INTTC10 interrupt request is generated.
If the edge opposite to trigger edge is detected before detecting a match between the upcounter and the TC10DRA, the up-counter is cleared and halted without generating an interrupt
request. Therefore, this mode can be used to detect exceeding the specified pulse by interrupt.
After being halted, the up-counter restarts counting when the trigger edge is detected.
• When TC10CR<METT10> is set to “0” (trigger start)
When a match between the up-counter and the TC10DRA value is detected after the timer
starts, the up-counter is cleared and halted and an INTTC10 interrupt request is generated.
The edge opposite to the trigger edge has no effect in count up. The trigger edge for the next
counting is ignored if detecting it before detecting a match between the up-counter and the
TC10DRA.
Since the TC10 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. The rejection circuit is turned off in the
SLOW1/2 or SLEEP1/2 mode, but a pulse width of one machine cycle or more is required.
Example 1 :Generating an interrupt 1 ms after the rising edge of the input pulse to the TC10 pin
(fc =16 MHz)
LDW
; 1ms ÷ 27/fc = 7DH
(TC10DRA), 007DH
DI
SET
; IMF= “0”
(EIRL). 7
; Enables INTTC10 interrupt
EI
; IMF= “1”
LD
(TC10CR), 00000100B
; Selects the source clock and mode
LD
(TC10CR), 00100100B
; Starts TC10 external trigger, METT10 = 0
Example 2 :Generating an interrupt when the low-level pulse with 4 ms or more width is input to the TC10 pin
(fc =16 MHz)
LDW
; 4 ms ÷ 27/fc = 1F4H
(TC10DRA), 01F4H
DI
SET
; IMF= “0”
(EIRL). 7
; Enables INTTC10 interrupt
EI
; IMF= “1”
LD
(TC10CR), 00000100B
; Selects the source clock and mode
LD
(TC10CR), 01110100B
; Starts TC10 external trigger, METT10 = 0
Page 87
8. 16-Bit TimerCounter (TC10,TC11)
8.1 16-Bit TimerCounter 10
TMP86FS28FG
At the rising
edge (TC10S = 10)
Count start
Count start
TC10 pin input
Source clock
Up-counter
0
1
2
TC10DRA
3
n-1
4
n
Match detect
0
n
2
1
3
Count clear
INTTC10
interrupt request
(a) Trigger start (METT10 = 0)
Count clear
Count start
At the rising
edge (TC10S = 10)
Count start
TC10 pin input
Source clock
Up-counter
TC10DRA
0
1
2
m-1
3
m
0
1
2
n
n
3
Match detect
0
Count clear
INTTC10
interrupt request
Note: m < n
(b) Trigger start and stop (METT10 = 1)
Figure 8-3 External Trigger Timer Mode Timing Chart
Page 88
TMP86FS28FG
8.1.3.3
Event Counter Mode
In the event counter mode, the up-counter counts up at the edge of the input pulse to the TC10 pin.
Either the rising or falling edge of the input pulse is selected as the count up edge in TC10CR<TC10S>.
When a match between the up-counter and the TC10DRA value is detected, an INTTC10 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 TC10 pin. Since a match between the up-counter and the value set to TC10DRA
is detected at the edge opposite to the selected edge, an INTTC10 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 TC10 pin.
Setting TC10CR<ACAP10> to “1” captures the up-counter value into TC10DRB with the auto capture
function. Use the auto-capture function in the operative condition of TC10. 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 TC10DRB by the source clock of
up-counter after setting TC10CR<ACAP10> to "1". Therefore, to read the captured value, wait at least
one cycle of the internal source clock before reading TC10DRB for the first time.
Timer start
TC10 pin Input
Up-counter
TC10DRA
0
?
1
n-1
2
n
0
1
n
Match detect
INTTC10
interrput request
Counter clear
Figure 8-4 Event Counter Mode Timing Chart
Table 8-2 Input Pulse Width to TC10 Pin
Minimum Pulse Width [s]
NORMAL1/2, IDLE1/2 Mode
SLOW1/2, SLEEP1/2 Mode
High-going
23/fc
23/fs
Low-going
23/fc
23/fs
Page 89
2
At the
rising edge
(TC10S = 10)
8. 16-Bit TimerCounter (TC10,TC11)
8.1 16-Bit TimerCounter 10
8.1.3.4
TMP86FS28FG
Window Mode
In the window mode, the up-counter counts up at the rising edge of the pulse that is logical ANDed
product of the input pulse to the TC10 pin (window pulse) and the internal source clock. Either the positive logic (count up during high-going pulse) or negative logic (count up during low-going pulse) can be
selected.
When a match between the up-counter and the TC10DRA value is detected, an INTTC10 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 TC10CR<TC10CK>.
Count start
Count stop
Count start
Timer start
TC10 pin input
Internal clock
Counter
TC10DRA
0
?
1
2
3
4
5
6
7
0
1
2
3
7
Match detect
INTTC10
interrput request
Counter clear
(a) Positive logic (TC10S = 10)
Timer start
Count start
Count stop
Count start
TC10 pin input
Internal clock
0
Counter
TC10DRA
?
1
2
3
4
5
6
7
8
9 0
1
9
Match detect
INTTC10
interrput request
(b) Negative logic (TC10S = 11)
Figure 8-5 Window Mode Timing Chart
Page 90
Counter
clear
TMP86FS28FG
8.1.3.5
Pulse Width Measurement Mode
In the pulse width measurement mode, the up-counter starts counting by the input pulse triggering of the
TC10 pin, and counts up at the edge of the internal clock. Either the rising or falling edge of the internal
clock is selected as the trigger edge in TC10CR<TC10S>. Either the single- or double-edge capture is
selected as the trigger edge in TC10CR<MCAP10>.
• When TC10CR<MCAP10> is set to “1” (single-edge capture)
Either high- or low-level input pulse width can be measured. To measure the high-level input
pulse width, set the rising edge to TC10CR<TC10S>. To measure the low-level input pulse
width, set the falling edge to TC10CR<TC10S>.
When detecting the edge opposite to the trigger edge used to start counting after the timer
starts, the up-counter captures the up-counter value into TC10DRB and generates an INTTC10
interrupt request. The up-counter is cleared at this time, and then restarts counting when detecting the trigger edge used to start counting.
• When TC10CR<MCAP10> is set to “0” (double-edge capture)
The cycle starting with either the high- or low-going input pulse can be measured. To measure the cycle starting with the high-going pulse, set the rising edge to TC10CR<TC10S>. To
measure the cycle starting with the low-going pulse, set the falling edge to TC10CR<TC10S>.
When detecting the edge opposite to the trigger edge used to start counting after the timer
starts, the up-counter captures the up-counter value into TC10DRB and generates an INTTC10
interrupt request. The up-counter continues counting up, and captures the up-counter value into
TC10DRB and generates an INTTC10 interrupt request when detecting the trigger edge used to
start counting. The up-counter is cleared at this time, and then continues counting.
Note 1: The captured value must be read from TC10DRB 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 TC10DRB.
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 91
8. 16-Bit TimerCounter (TC10,TC11)
8.1 16-Bit TimerCounter 10
TMP86FS28FG
Example :Duty measurement (resolution fc/27 [Hz])
CLR
(INTTC10SW). 0
; INTTC10 service switch initial setting
Address set to convert INTTC10SW at each INTTC10
LD
(TC10CR), 00000110B
; Sets the TC10 mode and source clock
DI
SET
; IMF= “0”
(EIRL). 7
; Enables INTTC10
EI
LD
; IMF= “1”
(TC10CR), 00100110B
; Starts TC10 with an external trigger at MCAP10 = 0
CPL
(INTTC10SW). 0
; INTTC10 interrupt, inverts and tests INTTC10 service switch
JRS
F, SINTTC10
LD
A, (TC10DRBL)
LD
W,(TC10DRBH)
LD
(HPULSE), WA
; Stores high-level pulse width in RAM
A, (TC10DRBL)
; Reads TC10DRB (Cycle)
:
PINTTC10:
; Reads TC10DRB (High-level pulse width)
RETI
SINTTC10:
LD
LD
W,(TC10DRBH)
LD
(WIDTH), WA
; Stores cycle in RAM
:
RETI
; Duty calculation
:
VINTTC10:
DW
PINTTC10
; INTTC10 Interrupt vector
WIDTH
HPULSE
TC10 pin
INTTC10 interrupt request
INTTC10SW
Page 92
TMP86FS28FG
Count start
TC10 pin input
Count start
Trigger
(TC10S = "10")
Internal clock
Counter
0
1
2
3
4
1
Capture
n
n-1 n
TC10DRB
INTTC10
interrupt request
2
0
3
[Application] High-or low-level pulse width measurement
(a) Single-edge capture (MCAP10 = "1")
Count start
Count start
TC10 pin input
(TC10S = "10")
Internal clock
Counter
0
1
2
3
4
n+1
TC10DRB
n
n+1 n+2 n+3
Capture
n
m-2 m-1 m 0
1
Capture
m
INTTC10
interrupt request
[Application] (1) Cycle/frequency measurement
(2) Duty measurement
(b) Double-edge capture (MCAP10 = "0")
Figure 8-6 Pulse Width Measurement Mode
Page 93
2
8. 16-Bit TimerCounter (TC10,TC11)
8.1 16-Bit TimerCounter 10
8.1.3.6
TMP86FS28FG
Programmable Pulse Generate (PPG) Output Mode
In the programmable pulse generation (PPG) mode, an arbitrary duty pulse is generated by counting
performed in the internal clock. To start the timer, TC10CR<TC10S> specifies either the edge of the input
pulse to the TC10 pin or the command start. TC10CR<MPPG10> specifies whether a duty pulse is produced continuously or not (one-shot pulse).
• When TC10CR<MPPG10> is set to “0” (Continuous pulse generation)
When a match between the up-counter and the TC10DRB value is detected after the timer
starts, the level of the PPG pin is inverted and an INTTC10 interrupt request is generated. The
up-counter continues counting. When a match between the up-counter and the TC10DRA value
is detected, the level of the PPG pin is inverted and an INTTC10 interrupt request is generated.
The up-counter is cleared at this time, and then continues counting and pulse generation.
When TC10S is cleared to “00” during PPG output, the PPG pin retains the level immediately
before the counter stops.
• When TC10CR<MPPG10> is set to “1” (One-shot pulse generation)
When a match between the up-counter and the TC10DRB value is detected after the timer
starts, the level of the PPG pin is inverted and an INTTC10 interrupt request is generated. The
up-counter continues counting. When a match between the up-counter and the TC10DRA value
is detected, the level of the PPG pin is inverted and an INTTC10 interrupt request is generated.
TC10CR<TC10S> is cleared to “00” automatically at this time, and the timer stops. The pulse
generated by PPG retains the same level as that when the timer stops.
Since the output level of the PPG pin can be set with TC10CR<TFF10> 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 TC10CR<TFF10> 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 TC10DRA or TC10DRB 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 TC10CR<TFF10> during a run of the timer. TC10CR<TFF10> can be set correctly
only at initialization (after reset). When the timer stops during PPG, TC10CR<TFF10> 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 TC10CR<TFF10> 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 TC10CR<TC10M> to the timer mode (it is not
required to start the timer mode), and then set the PPG mode. Set TC10CR<TFF10> at this time.
Note 3: In the PPG mode, the following relationship must be satisfied.
TC10DRA > TC10DRB
Note 4: Set TC10DRB after changing the mode of TC10M to the PPG mode.
Page 94
TMP86FS28FG
Example :Generating a pulse which is high-going for 800 µs and low-going for 200 µs
(fc = 16 MHz)
Setting port
LD
(TC10CR), 10000111B
; Sets the PPG mode, selects the source clock
LDW
(TC10DRA), 007DH
; Sets the cycle (1 ms ÷ 27/fc ms = 007DH)
LDW
(TC10DRB), 0019H
; Sets the low-level pulse width (200 µs ÷ 27/fc = 0019H)
LD
(TC10CR), 10010111B
; Starts the timer
Example :After stopping PPG, setting the PPG pin to a high-level to restart PPG
(fc = 16 MHz)
Setting port
LD
(TC10CR), 10000111B
; Sets the PPG mode, selects the source clock
LDW
(TC10DRA), 007DH
; Sets the cycle (1 ms ÷ 27/fc µs = 007DH)
LDW
(TC10DRB), 0019H
; Sets the low-level pulse width (200 µs ÷ 27/fc = 0019H)
LD
(TC10CR), 10010111B
; Starts the timer
:
:
LD
(TC10CR), 10000111B
; Stops the timer
LD
(TC10CR), 10000100B
; Sets the timer mode
LD
(TC10CR), 00000111B
; Sets the PPG mode, TFF10 = 0
LD
(TC10CR), 00010111B
; Starts the timer
I/O port output latch
shared with PPG output
Data output
Port output
enable
Q
D
PPG pin
R
Function output
TC10CR<TFF10>
Set
Write to TC10CR
Internal reset
Clear
Match to TC10DRB
Match to TC10DRA
Q
Toggle
Timer F/F10
INTTC10 interrupt request
㪫㪚㪈㪇㪚㪩㪓㪤㪧㪧㪞㪈㪇㪕
TC10CR<TC10S> clear
Figure 8-7 PPG Output
Page 95
8. 16-Bit TimerCounter (TC10,TC11)
8.1 16-Bit TimerCounter 10
TMP86FS28FG
Timer start
Internal clock
Counter
0
1
TC10DRB
n
TC10DRA
m
2
n
n+1
m 0
1
2
n
n+1
m 0
1
2
Match detect
PPG pin output
INTTC10
interrupt request
Note: m > n
(a) Continuous pulse generation (TC10S = 01)
Count start
TC10 pin input
Trigger
Internal clock
Counter
0
TC10DRB
n
TC10DRA
m
1
n
n+1
m
0
PPG pin output
INTTC10
interrupt request
[Application] One-shot pulse output
(b) One-shot pulse generation (TC10S = 10)
Figure 8-8 PPG Mode Timing Chart
Page 96
Note: m > n
S
Falling
External
trigger
Page 97
7
fc/23
fc/2
fs/2
3
Port
(Note)
Figure 8-9 TimerCounter 11 (TC11)
TC11S
2
C
B
A
D
ACAP11
TC11CR
Y
S
A
Start
Source㩷
㩷clock
Clear
Selector
TC11DRA
CMP
PPG output
mode
16-bit timer register A, B
TC11DRB
16-bit up-counter
MPPG11
INTTC11 interript
S
Match
Q
Enable
Toggle
Set
Clear
Pulse width
measurement
mode
TC11S clear
TFF11
PPG output
mode
Internal
reset
Write to TC11CR
Note: Function I/O may not operate depending on I/O port setting. For more details, see the chapter "I/O Port".
Capture
Window mode
TC11 control register
S
Y
B
Clear
Set Q
Command start
METT11
External
trigger start
Decoder
2
TC11CK
Edge detector
Rising
11,
fc/2
TC1㪈㩷㫇㫀㫅
Pulse width
measurement
mode
B
A
Clear
Set
Toggle
Q
Port
(Note)
㪧㪧㪞㩷
㩷pin
8.2.1
Y
8.2
MCAP11
TMP86FS28FG
16-Bit TimerCounter 11
Configuration
8. 16-Bit TimerCounter (TC10,TC11)
8.2 16-Bit TimerCounter 11
8.2.2
TMP86FS28FG
TimerCounter Control
The TimerCounter 11 is controlled by the TimerCounter 11 control register (TC11CR) and two 16-bit timer
registers (TC11DRA and TC11DRB).
Timer Register
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
TC11DRA
(0021H, 0020H)
TC11DRAH (0021H)
TC11DRAL (0020H)
(Initial value: 1111 1111 1111 1111)
Read/Write
TC11DRB
(0023H, 0022H)
TC11DRBH (0023H)
TC11DRBL (0022H)
(Initial value: 1111 1111 1111 1111)
Read/Write (Write enabled only in the PPG output mode)
TimerCounter 11 Control Register
TC11CR
(0024H)
7
6
TFF11
ACAP11
MCAP11
METT11
MPPG11
5
4
3
TC11S
2
1
TC11CK
0
Read/Write
(Initial value: 0000 0000)
TC11M
TFF11
Timer F/F11 control
0: Clear
1: Set
ACAP11
Auto capture control
0:Auto-capture disable
1:Auto-capture enable
MCAP11
Pulse width measurement mode control
0:Double edge capture
1:Single edge capture
METT11
External trigger timer
mode control
0:Trigger start
1:Trigger start and stop
MPPG11
PPG output control
0:Continuous pulse generation
1:One-shot
TC11S
TC11 start control
R/W
R/W
Timer
Extrigger
Event
Window
Pulse
00: Stop and counter clear
O
O
O
O
O
O
01: Command start
O
–
–
–
–
O
10: Rising edge start
(Ex-trigger/Pulse/PPG)
Rising edge count (Event)
Positive logic count (Window)
–
O
O
O
O
O
11: Falling edge start
(Ex-trigger/Pulse/PPG)
Falling edge count (Event)
Negative logic count (Window)
–
O
O
O
O
O
Divider
SLOW,
SLEEP
mode
NORMAL1/2, IDLE1/2 mode
TC11CK
TC11 source clock select
[Hz]
DV7CK = 0
DV7CK = 1
00
fc/211
fs/23
DV9
fs/23
01
fc/27
fc/27
DV5
–
10
fc/23
fc/23
DV1
–
11
TC11M
TC11 operating mode
select
PPG
R/W
R/W
External clock (TC11 pin input)
00: Timer/external trigger timer/event counter mode
01: Window mode
10: Pulse width measurement mode
11: PPG (Programmable pulse generate) output mode
R/W
Note 1: fc: High-frequency clock [Hz], fs: Low-frequency clock [Hz]
Note 2: The timer register consists of two shift registers. A value set in the timer register becomes valid at the rising edge of the
first source clock pulse that occurs after the upper byte (TC11DRAH and TC11DRBH) is written. Therefore, write the lower
Page 98
TMP86FS28FG
byte and the upper byte in this order (it is recommended to write the register with a 16-bit access instruction). Writing only
the lower byte (TC11DRAL and TC11DRBL) does not enable the setting of the timer register.
Note 3: To set the mode, source clock, PPG output control and timer F/F control, write to TC11CR1 during TC11S=00. Set the
timer F/F10 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.
TC11DRA > TC11DRB > 1 (PPG output mode), TC11DRA > 1 (other modes)
Note 6: Set TFF11 to “0” in the mode except PPG output mode.
Note 7: Set TC11DRB after setting TC11M to the PPG output mode.
Note 8: When the STOP mode is entered, the start control (TC11S) is cleared to “00” automatically, and the timer stops. After the
STOP mode is exited, set the TC11S to use the timer counter again.
Note 9: Use the auto-capture function in the operative condition of TC11. 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 TC11DRB by the source clock of up-counter after setting TC11CR<ACAP11>
to "1". Therefore, to read the captured value, wait at least one cycle of the internal source clock before reading TC11DRB
for the first time.
8.2.3
Function
TimerCounter 11 has six types of operating modes: timer, external trigger timer, event counter, window,
pulse width measurement, programmable pulse generator output modes.
8.2.3.1
Timer mode
In the timer mode, the up-counter counts up using the internal clock. When a match between the up-counter and the timer
register 1A (TC11DRA) value is detected, an INTTC11 interrupt is generated and the up-counter is cleared. After being
cleared, the up-counter restarts counting. Setting TC11CR<ACAP11> to “1” captures the up-counter value into the timer
register 1B (TC11DRB) with the auto-capture function. Use the auto-capture function in the operative condition of TC11.
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 TC11DRB by the source clock of upcounter after setting TC11CR<ACAP11> to "1". Therefore, to read the captured value, wait at least one cycle of the internal
source clock before reading TC11DRB for the first time.
Table 8-3 Internal Source Clock for TimerCounter 11 (Example: fc = 16 MHz, fs = 32.768 kHz)
NORMAL1/2, IDLE1/2 mode
TC11CK
SLOW, SLEEP mode
DV7CK = 0
DV7CK = 1
Resolution
[µs]
Maximum Time Setting
[s]
Resolution
[µs]
Maximum Time Setting
[s]
Resolution
[µs]
Maximum
Time Setting [s]
00
128
8.39
244.14
16.0
244.14
16.0
01
8.0
0.524
8.0
0.524
–
–
10
0.5
32.77 m
0.5
32.77 m
–
–
Page 99
8. 16-Bit TimerCounter (TC10,TC11)
8.2 16-Bit TimerCounter 11
TMP86FS28FG
Example 1 :Setting the timer mode with source clock fc/211 [Hz] and generating an interrupt 1 second later
(fc = 16 MHz, TBTCR<DV7CK> = “0”)
LDW
; Sets the timer register (1 s ÷ 211/fc = 1E84H)
(TC11DRA), 1E84H
DI
; IMF= “0”
SET
(EIRL). 2
; Enables INTTC11
EI
; IMF= “1”
LD
(TC11CR), 00000000B
; Selects the source clock and mode
LD
(TC11CR), 00010000B
; Starts TC11
LD
(TC11CR), 01010000B
; ACAP11 ← 1
:
:
LD
WA, (TC11DRB)
Example 2 :Auto-capture
; Reads the capture value
Note: Since the up-counter value is captured into TC11DRB by the source clock of up-counter after setting TC11CR<ACAP11> to
"1". Therefore, to read the captured value, wait at least one cycle of the internal source clock before reading TC11DRB for the
first time.
Timer start
Source clock
Counter
0
TC11DRA
?
1
2
3
n-1
4
n
0
1
3
2
4
5
6
n
Match detect
INTTC11 interruput request
Counter clear
(a) Timer mode
Source clock
m-2
Counter
m-1
m
m+1
m+2
n-1
n
Capture
TC11DRB
?
m-1
m
n+1
Capture
m+1
m+2
n-1
ACAP11
(b) Auto-capture
Figure 8-10 Timer Mode Timing Chart
Page 100
n
n+1
7
TMP86FS28FG
8.2.3.2
External Trigger Timer Mode
In the external trigger timer mode, the up-counter starts counting by the input pulse triggering of the
TC11 pin, and counts up at the edge of the internal clock. For the trigger edge used to start counting, either
the rising or falling edge is defined in TC11CR<TC11S>.
• When TC11CR<METT11> is set to “1” (trigger start and stop)
When a match between the up-counter and the TC11DRA value is detected after the timer
starts, the up-counter is cleared and halted and an INTTC11 interrupt request is generated.
If the edge opposite to trigger edge is detected before detecting a match between the upcounter and the TC11DRA, the up-counter is cleared and halted without generating an interrupt
request. Therefore, this mode can be used to detect exceeding the specified pulse by interrupt.
After being halted, the up-counter restarts counting when the trigger edge is detected.
• When TC11CR<METT11> is set to “0” (trigger start)
When a match between the up-counter and the TC11DRA value is detected after the timer
starts, the up-counter is cleared and halted and an INTTC11 interrupt request is generated.
The edge opposite to the trigger edge has no effect in count up. The trigger edge for the next
counting is ignored if detecting it before detecting a match between the up-counter and the
TC11DRA.
Since the TC11 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. The rejection circuit is turned off in the
SLOW1/2 or SLEEP1/2 mode, but a pulse width of one machine cycle or more is required.
Example 1 :Generating an interrupt 1 ms after the rising edge of the input pulse to the TC11 pin
(fc =16 MHz)
LDW
; 1ms ÷ 27/fc = 7DH
(TC11DRA), 007DH
DI
SET
; IMF= “0”
(EIRL). 2
; Enables INTTC11 interrupt
EI
; IMF= “1”
LD
(TC11CR), 00000100B
; Selects the source clock and mode
LD
(TC11CR), 00100100B
; Starts TC11 external trigger, METT11 = 0
Example 2 :Generating an interrupt when the low-level pulse with 4 ms or more width is input to the TC11 pin
(fc =16 MHz)
LDW
; 4 ms ÷ 27/fc = 1F4H
(TC11DRA), 01F4H
DI
SET
; IMF= “0”
(EIRL). 2
; Enables INTTC11 interrupt
EI
; IMF= “1”
LD
(TC11CR), 00000100B
; Selects the source clock and mode
LD
(TC11CR), 01110100B
; Starts TC11 external trigger, METT11 = 0
Page 101
8. 16-Bit TimerCounter (TC10,TC11)
8.2 16-Bit TimerCounter 11
TMP86FS28FG
At the rising
edge (TC11S = 10)
Count start
Count start
TC11 pin input
Source clock
Up-counter
0
1
2
TC11DRA
3
n-1
4
n
n
Match detect
1
0
2
3
Count clear
INTTC11
interrupt request
(a) Trigger start (METT11 = 0)
Count clear
Count start
At the rising
edge (TC11S = 10)
Count start
TC11 pin input
Source clock
Up-counter
TC11DRA
0
1
2
m-1
3
m
0
1
2
n
n
3
Match detect
0
Count clear
INTTC11
interrupt request
Note: m < n
(b) Trigger start and stop (METT11 = 1)
Figure 8-11 External Trigger Timer Mode Timing Chart
Page 102
TMP86FS28FG
8.2.3.3
Event Counter Mode
In the event counter mode, the up-counter counts up at the edge of the input pulse to the TC11 pin.
Either the rising or falling edge of the input pulse is selected as the count up edge in TC11CR<TC11S>.
When a match between the up-counter and the TC11DRA value is detected, an INTTC11 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 TC11 pin. Since a match between the up-counter and the value set to TC11DRA
is detected at the edge opposite to the selected edge, an INTTC11 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 TC11 pin.
Setting TC11CR<ACAP11> to “1” captures the up-counter value into TC11DRB with the auto capture
function. Use the auto-capture function in the operative condition of TC11. 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 TC11DRB by the source clock of
up-counter after setting TC11CR<ACAP11> to "1". Therefore, to read the captured value, wait at least
one cycle of the internal source clock before reading TC11DRB for the first time.
Timer start
TC11 pin Input
Up-counter
TC11DRA
0
?
1
n-1
2
n
0
1
n
Match detect
INTTC11
interrput request
Counter clear
Figure 8-12 Event Counter Mode Timing Chart
Table 8-4 Input Pulse Width to TC11 Pin
Minimum Pulse Width [s]
NORMAL1/2, IDLE1/2 Mode
SLOW1/2, SLEEP1/2 Mode
High-going
23/fc
23/fs
Low-going
23/fc
23/fs
Page 103
2
At the
rising edge
(TC11S = 10)
8. 16-Bit TimerCounter (TC10,TC11)
8.2 16-Bit TimerCounter 11
8.2.3.4
TMP86FS28FG
Window Mode
In the window mode, the up-counter counts up at the rising edge of the pulse that is logical ANDed
product of the input pulse to the TC11 pin (window pulse) and the internal source clock. Either the positive logic (count up during high-going pulse) or negative logic (count up during low-going pulse) can be
selected.
When a match between the up-counter and the TC11DRA value is detected, an INTTC11 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 TC11CR<TC11CK>.
Count start
Count stop
Count start
Timer start
TC11 pin input
Internal clock
Counter
TC11DRA
0
?
1
2
3
4
5
6
7
0
1
2
3
7
Match detect
INTTC11
interrput request
Counter clear
(a) Positive logic (TC11S = 10)
Timer start
Count start
Count stop
Count start
TC11 pin input
Internal clock
0
Counter
TC11DRA
?
1
2
3
4
5
6
7
8
9 0
1
9
Match detect
INTTC11
interrput request
(b) Negative logic (TC11S = 11)
Figure 8-13 Window Mode Timing Chart
Page 104
Counter
clear
TMP86FS28FG
8.2.3.5
Pulse Width Measurement Mode
In the pulse width measurement mode, the up-counter starts counting by the input pulse triggering of the
TC11 pin, and counts up at the edge of the internal clock. Either the rising or falling edge of the internal
clock is selected as the trigger edge in TC11CR<TC11S>. Either the single- or double-edge capture is
selected as the trigger edge in TC11CR<MCAP11>.
• When TC11CR<MCAP11> is set to “1” (single-edge capture)
Either high- or low-level input pulse width can be measured. To measure the high-level input
pulse width, set the rising edge to TC11CR<TC11S>. To measure the low-level input pulse
width, set the falling edge to TC11CR<TC11S>.
When detecting the edge opposite to the trigger edge used to start counting after the timer
starts, the up-counter captures the up-counter value into TC11DRB and generates an INTTC11
interrupt request. The up-counter is cleared at this time, and then restarts counting when detecting the trigger edge used to start counting.
• When TC11CR<MCAP11> is set to “0” (double-edge capture)
The cycle starting with either the high- or low-going input pulse can be measured. To measure the cycle starting with the high-going pulse, set the rising edge to TC11CR<TC11S>. To
measure the cycle starting with the low-going pulse, set the falling edge to TC11CR<TC11S>.
When detecting the edge opposite to the trigger edge used to start counting after the timer
starts, the up-counter captures the up-counter value into TC11DRB and generates an INTTC11
interrupt request. The up-counter continues counting up, and captures the up-counter value into
TC11DRB and generates an INTTC11 interrupt request when detecting the trigger edge used to
start counting. The up-counter is cleared at this time, and then continues counting.
Note 1: The captured value must be read from TC11DRB 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 TC11DRB.
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 105
8. 16-Bit TimerCounter (TC10,TC11)
8.2 16-Bit TimerCounter 11
TMP86FS28FG
Example :Duty measurement (resolution fc/27 [Hz])
CLR
(INTTC11SW). 0
; INTTC11 service switch initial setting
Address set to convert INTTC11SW at each INTTC11
LD
(TC11CR), 00000110B
; Sets the TC11 mode and source clock
(EIRH). 7
; Enables INTTC11
DI
SET
; IMF= “0”
EI
LD
; IMF= “1”
(TC11CR), 00100110B
; Starts TC11 with an external trigger at MCAP11 = 0
CPL
(INTTC11SW). 0
; INTTC11 interrupt, inverts and tests INTTC11 service switch
JRS
F, SINTTC11
LD
A, (TC11DRBL)
LD
W,(TC11DRBH)
LD
(HPULSE), WA
; Stores high-level pulse width in RAM
A, (TC11DRBL)
; Reads TC11DRB (Cycle)
:
PINTTC11:
; Reads TC11DRB (High-level pulse width)
RETI
SINTTC11:
LD
LD
W,(TC11DRBH)
LD
(WIDTH), WA
; Stores cycle in RAM
:
RETI
; Duty calculation
:
VINTTC11:
DW
PINTTC11
; INTTC11 Interrupt vector
WIDTH
HPULSE
TC11 pin
INTTC11 interrupt request
INTTC11SW
Page 106
TMP86FS28FG
Count start
TC11 pin input
Count start
Trigger
(TC11S = "10")
Internal clock
Counter
0
1
2
3
4
1
Capture
n
n-1 n 0
TC11DRB
INTTC11
interrupt request
2
3
[Application] High-or low-level pulse width measurement
(a) Single-edge capture (MCAP11 = "1")
Count start
Count start
TC11 pin input
(TC11S = "10")
Internal clock
Counter
0
1
2
3
4
n+1
TC11DRB
n
n+1 n+2 n+3
Capture
n
m-2 m-1 m 0
1
Capture
m
INTTC11
interrupt request
[Application] (1) Cycle/frequency measurement
(2) Duty measurement
(b) Double-edge capture (MCAP11 = "0")
Figure 8-14 Pulse Width Measurement Mode
Page 107
2
8. 16-Bit TimerCounter (TC10,TC11)
8.2 16-Bit TimerCounter 11
8.2.3.6
TMP86FS28FG
Programmable Pulse Generate (PPG) Output Mode
In the programmable pulse generation (PPG) mode, an arbitrary duty pulse is generated by counting
performed in the internal clock. To start the timer, TC11CR<TC11S> specifies either the edge of the input
pulse to the TC11 pin or the command start. TC11CR<MPPG11> specifies whether a duty pulse is produced continuously or not (one-shot pulse).
• When TC11CR<MPPG11> is set to “0” (Continuous pulse generation)
When a match between the up-counter and the TC11DRB value is detected after the timer
starts, the level of the PPG pin is inverted and an INTTC11 interrupt request is generated. The
up-counter continues counting. When a match between the up-counter and the TC11DRA value
is detected, the level of the PPG pin is inverted and an INTTC11 interrupt request is generated.
The up-counter is cleared at this time, and then continues counting and pulse generation.
When TC11S is cleared to “00” during PPG output, the PPG pin retains the level immediately
before the counter stops.
• When TC11CR<MPPG11> is set to “1” (One-shot pulse generation)
When a match between the up-counter and the TC11DRB value is detected after the timer
starts, the level of the PPG pin is inverted and an INTTC11 interrupt request is generated. The
up-counter continues counting. When a match between the up-counter and the TC11DRA value
is detected, the level of the PPG pin is inverted and an INTTC11 interrupt request is generated.
TC11CR<TC11S> is cleared to “00” automatically at this time, and the timer stops. The pulse
generated by PPG retains the same level as that when the timer stops.
Since the output level of the PPG pin can be set with TC11CR<TFF11> 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 TC11CR<TFF11> 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 TC11DRA or TC11DRB 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 TC11CR<TFF11> during a run of the timer. TC11CR<TFF11> can be set correctly only
at initialization (after reset). When the timer stops during PPG, TC11CR<TFF11> 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 TC11CR<TFF11> 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 TC11CR<TC11M> to the timer mode (it is not
required to start the timer mode), and then set the PPG mode. Set TC11CR<TFF11> at this time.
Note 3: In the PPG mode, the following relationship must be satisfied.
TC11DRA > TC11DRB
Note 4: Set TC11DRB after changing the mode of TC11M to the PPG mode.
Page 108
TMP86FS28FG
Example :Generating a pulse which is high-going for 800 µs and low-going for 200 µs
(fc = 16 MHz)
Setting port
LD
(TC11CR), 10000111B
; Sets the PPG mode, selects the source clock
LDW
(TC11DRA), 007DH
; Sets the cycle (1 ms ÷ 27/fc ms = 007DH)
LDW
(TC11DRB), 0019H
; Sets the low-level pulse width (200 µs ÷ 27/fc = 0019H)
LD
(TC11CR), 10010111B
; Starts the timer
Example :After stopping PPG, setting the PPG pin to a high-level to restart PPG
(fc = 16 MHz)
Setting port
LD
(TC11CR), 10000111B
; Sets the PPG mode, selects the source clock
LDW
(TC11DRA), 007DH
; Sets the cycle (1 ms ÷ 27/fc µs = 007DH)
LDW
(TC11DRB), 0019H
; Sets the low-level pulse width (200 µs ÷ 27/fc = 0019H)
LD
(TC11CR), 10010111B
; Starts the timer
:
:
LD
(TC11CR), 10000111B
; Stops the timer
LD
(TC11CR), 10000100B
; Sets the timer mode
LD
(TC11CR), 00000111B
; Sets the PPG mode, TFF11 = 0
LD
(TC11CR), 00010111B
; Starts the timer
I/O port output latch
shared with PPG output
Data output
Port output
enable
Q
D
PPG pin
R
Function output
TC11CR<TFF11>
Set
Write to TC11CR
Internal reset
Clear
Match to TC11DRB
Match to TC11DRA
Q
Toggle
Timer F/F11
INTTC11 interrupt request
㪫㪚㪈㪈㪚㪩㪓㪤㪧㪧㪞㪈㪈㪕
TC11CR<TC11S> clear
Figure 8-15 PPG Output
Page 109
8. 16-Bit TimerCounter (TC10,TC11)
8.2 16-Bit TimerCounter 11
TMP86FS28FG
Timer start
Internal clock
Counter
TC11DRB
0
1
2
n
n+1
m 0
1
2
n
n+1
m 0
1
2
n
Match detect
TC11DRA
m
PPG pin output
INTTC11
interrupt request
Note: m > n
(a) Continuous pulse generation (TC11S = 01)
Count start
TC11 pin input
Trigger
Internal clock
Counter
0
TC11DRB
n
TC11DRA
m
1
n
n+1
m
0
PPG pin output
INTTC11
interrupt request
[Application] One-shot pulse output
(b) One-shot pulse generation (TC11S = 10)
Figure 8-16 PPG Mode Timing Chart
Page 110
Note: m > n
TMP86FS28FG
9. 8-Bit TimerCounter (TC3, TC4)
9.1 Configuration
PWM mode
Overflow
fc/211 or fs/23
7
fc/2
5
fc/2
fc/23
fs
fc/2
fc
TC4 pin
A
B
C
D
E
F
G
H
Y
A
B
INTTC4
interrupt request
Clear
Y
8-bit up-counter
TC4S
S
PDO, PPG mode
A
B
S
16-bit
mode
S
TC4M
TC4S
TFF4
Toggle
Q
Set
Clear
Y
16-bit mode
Timer, Event
Counter mode
S
TC4CK
PDO4/PWM4/
PPG4 pin
Timer F/F4
A
Y
TC4CR
B
TTREG4
PWREG4
PWM, PPG mode
DecodeEN
PDO, PWM,
PPG mode
TFF4
16-bit
mode
TC3S
PWM mode
fc/211 or fs/23
fc/27
5
fc/2
3
fc/2
fs
fc/2
fc
TC3 pin
Y
8-bit up-counter
Overflow
16-bit mode
PDO mode
16-bit mode
Timer,
Event Couter mode
S
TC3M
TC3S
TFF3
INTTC3
interrupt request
Clear
A
B
C
D
E
F
G
H
Toggle
Q
Set
Clear
PDO3/PWM3/
pin
Timer F/F3
TC3CK
TC3CR
PWM mode
TTREG3
PWREG3
DecodeEN
TFF3
Figure 9-1 8-Bit TimerCounter 3, 4
Page 111
PDO, PWM mode
16-bit mode
9. 8-Bit TimerCounter (TC3, TC4)
9.1 Configuration
TMP86FS28FG
9.2 TimerCounter Control
The TimerCounter 3 is controlled by the TimerCounter 3 control register (TC3CR) and two 8-bit timer registers
(TTREG3, PWREG3).
TimerCounter 3 Timer Register
TTREG3
(0015H)
R/W
7
PWREG3
(0019H)
R/W
7
6
5
4
3
2
1
0
(Initial value: 1111 1111)
6
5
4
3
2
1
0
(Initial value: 1111 1111)
Note 1: Do not change the timer register (TTREG3) setting while the timer is running.
Note 2: Do not change the timer register (PWREG3) setting in the operating mode except the 8-bit and 16-bit PWM modes while
the timer is running.
TimerCounter 3 Control Register
TC3CR
(0009H)
TFF3
7
TFF3
6
5
4
TC3CK
Time F/F3 control
3
2
TC3S
0:
1:
1
0
TC3M
(Initial value: 0000 0000)
Clear
Set
R/W
NORMAL1/2, IDLE1/2 mode
TC3CK
Operating clock selection [Hz]
DV7CK = 0
DV7CK = 1
SLOW1/2
SLEEP1/2
mode
000
fc/211
fs/23
fs/23
001
fc/27
fc/27
–
010
fc/25
fc/25
–
011
fc/23
fc/23
–
100
fs
fs
fs
101
fc/2
fc/2
–
110
fc
fc
fc (Note 8)
111
TC3S
TC3 start control
0:
1:
000:
001:
TC3M
TC3M operating mode select
010:
011:
1**:
R/W
TC3 pin input
Operation stop and counter clear
Operation start
R/W
8-bit timer/event counter mode
8-bit programmable divider output (PDO) mode
8-bit pulse width modulation (PWM) output mode
16-bit mode
(Each mode is selectable with TC4M.)
Reserved
R/W
Note 1: fc: High-frequency clock [Hz] fs: Low-frequency clock[Hz]
Note 2: Do not change the TC3M, TC3CK and TFF3 settings while the timer is running.
Note 3: To stop the timer operation (TC3S= 1 → 0), do not change the TC3M, TC3CK and TFF3 settings. To start the timer operation (TC3S= 0 → 1), TC3M, TC3CK and TFF3 can be programmed.
Note 4: To use the TimerCounter in the 16-bit mode, set the operating mode by programming TC4CR<TC4M>, where TC3M must
be fixed to 011.
Note 5: To use the TimerCounter in the 16-bit mode, select the source clock by programming TC3CK. Set the timer start control
and timer F/F control by programming TC4CR<TC4S> and TC4CR<TFF4>, respectively.
Note 6: The operating clock settings are limited depending on the timer operating mode. For the detailed descriptions, see Table
9-1 and Table 9-2.
Page 112
TMP86FS28FG
Note 7: The timer register settings are limited depending on the timer operating mode. For the detailed descriptions, see Table 93.
Note 8: The operating clock fc in the SLOW or SLEEP mode can be used only as the high-frequency warm-up mode.
Page 113
9. 8-Bit TimerCounter (TC3, TC4)
9.1 Configuration
TMP86FS28FG
The TimerCounter 4 is controlled by the TimerCounter 4 control register (TC4CR) and two 8-bit timer registers
(TTREG4 and PWREG4).
TimerCounter 4 Timer Register
TTREG4
(0016H)
R/W
7
PWREG4
(001AH)
R/W
7
6
5
4
3
2
1
0
(Initial value: 1111 1111)
6
5
4
3
2
1
0
(Initial value: 1111 1111)
Note 1: Do not change the timer register (TTREG4) setting while the timer is running.
Note 2: Do not change the timer register (PWREG4) setting in the operating mode except the 8-bit and 16-bit PWM modes while
the timer is running.
TimerCounter 4 Control Register
TC4CR
(000AH)
TFF4
7
TFF4
6
5
4
TC4CK
Timer F/F4 control
3
2
TC4S
0:
1:
1
0
TC4M
(Initial value: 0000 0000)
Clear
Set
R/W
NORMAL1/2, IDLE1/2 mode
TC4CK
Operating clock selection [Hz]
DV7CK = 0
DV7CK = 1
SLOW1/2
SLEEP1/2
mode
000
fc/211
fs/23
fs/23
001
fc/27
fc/27
–
010
fc/25
fc/25
–
011
fc/2
3
3
–
100
fs
fs
fs
101
fc/2
fc/2
–
110
fc
fc
–
111
TC4S
TC4 start control
0:
1:
000:
001:
010:
TC4M
TC4M operating mode select
011:
100:
101:
110:
111:
fc/2
R/W
TC4 pin input
Operation stop and counter clear
Operation start
R/W
8-bit timer/event counter mode
8-bit programmable divider output (PDO) mode
8-bit pulse width modulation (PWM) output mode
Reserved
16-bit timer/event counter mode
Warm-up counter mode
16-bit pulse width modulation (PWM) output mode
16-bit PPG mode
R/W
Note 1: fc: High-frequency clock [Hz] fs: Low-frequency clock [Hz]
Note 2: Do not change the TC4M, TC4CK and TFF4 settings while the timer is running.
Note 3: To stop the timer operation (TC4S= 1 → 0), do not change the TC4M, TC4CK and TFF4 settings.
To start the timer operation (TC4S= 0 → 1), TC4M, TC4CK and TFF4 can be programmed.
Note 4: When TC4M= 1** (upper byte in the 16-bit mode), the source clock becomes the TC3 overflow signal regardless of the
TC4CK setting.
Note 5: To use the TimerCounter in the 16-bit mode, select the operating mode by programming TC4M, where TC3CR<TC3M>
must be set to 011.
Page 114
TMP86FS28FG
Note 6: To the TimerCounter in the 16-bit mode, select the source clock by programming TC3CR<TC3CK>. Set the timer start
control and timer F/F control by programming TC4S and TFF4, respectively.
Note 7: The operating clock settings are limited depending on the timer operating mode. For the detailed descriptions, see Table
9-1 and Table 9-2.
Note 8: The timer register settings are limited depending on the timer operating mode. For the detailed descriptions, see Table 93.
Table 9-1 Operating Mode and Selectable Source Clock (NORMAL1/2 and IDLE1/2 Modes)
Operating mode
fc/211
or
fc/27
fc/25
fc/23
fs
fc/2
fc
TC3
pin input
TC4
pin input
fs/23
8-bit timer
Ο
Ο
Ο
Ο
–
–
–
–
–
8-bit event counter
–
–
–
–
–
–
–
Ο
Ο
8-bit PDO
Ο
Ο
Ο
Ο
–
–
–
–
–
8-bit PWM
Ο
Ο
Ο
Ο
Ο
Ο
Ο
–
–
16-bit timer
Ο
Ο
Ο
Ο
–
–
–
–
–
16-bit event counter
–
–
–
–
–
–
–
Ο
–
Warm-up counter
–
–
–
–
Ο
–
–
–
–
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 (TC3CK).
Note 2: Ο : Available source clock
Table 9-2 Operating Mode and Selectable Source Clock (SLOW1/2 and SLEEP1/2 Modes)
Operating mode
fc/211
or
fc/27
fc/25
fc/23
fs
fc/2
fc
TC3
pin input
TC4
pin input
fs/23
8-bit timer
Ο
–
–
–
–
–
–
–
–
8-bit event counter
–
–
–
–
–
–
–
Ο
Ο
8-bit PDO
Ο
–
–
–
–
–
–
–
–
8-bit PWM
Ο
–
–
–
Ο
–
–
–
–
16-bit timer
Ο
–
–
–
–
–
–
–
–
16-bit event counter
–
–
–
–
–
–
–
Ο
–
Warm-up counter
–
–
–
–
–
–
Ο
–
–
16-bit PWM
Ο
–
–
–
Ο
–
–
Ο
–
16-bit PPG
Ο
–
–
–
–
–
–
Ο
–
Note1: 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 (TC3CK).
Note2: Ο : Available source clock
Page 115
9. 8-Bit TimerCounter (TC3, TC4)
9.1 Configuration
TMP86FS28FG
Table 9-3 Constraints on Register Values Being Compared
Operating mode
Register Value
8-bit timer/event counter
1≤ (TTREGn) ≤255
8-bit PDO
1≤ (TTREGn) ≤255
8-bit PWM
2≤ (PWREGn) ≤254
16-bit timer/event counter
1≤ (TTREG4, 3) ≤65535
Warm-up counter
256≤ (TTREG4, 3) ≤65535
16-bit PWM
2≤ (PWREG4, 3) ≤65534
16-bit PPG
and
(PWREG4, 3) + 1 < (TTREG4, 3)
1≤ (PWREG4, 3) < (TTREG4, 3) ≤65535
Note: n = 3 to 4
Page 116
TMP86FS28FG
9.3 Function
The TimerCounter 3 and 4 have the 8-bit timer, 8-bit event counter, 8-bit programmable divider output (PDO), 8bit pulse width modulation (PWM) output modes. The TimerCounter 3 and 4 (TC3, 4) are cascadable to form a 16bit timer. The 16-bit timer has the operating modes such as the 16-bit timer, 16-bit event counter, warm-up counter,
16-bit pulse width modulation (PWM) output and 16-bit programmable pulse generation (PPG) modes.
9.3.1
8-Bit Timer Mode (TC3 and 4)
In the timer mode, the up-counter counts up using the internal clock. When a match between the up-counter
and the timer register j (TTREGj) value is detected, an INTTCj interrupt is generated and the up-counter is
cleared. After being cleared, the up-counter restarts counting.
Note 1: In the timer mode, fix TCjCR<TFFj> to 0. If not fixed, the PDOj, PWMj and PPGj pins may output pulses.
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 the programming. Therefore, if TTREGi is changed while the timer is running, an expected operation
may not be obtained.
Note 3: j = 3, 4
Table 9-4 Source Clock for TimerCounter 3, 4 (Internal Clock)
Source Clock
NORMAL1/2, IDLE1/2 mode
Resolution
Maximum Time Setting
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211 [Hz]
fs/23 [Hz]
fs/23 [Hz]
128 µs
244.14 µs
32.6 ms
62.3 ms
fc/27
fc/27
–
8 µs
–
2.0 ms
–
fc/25
fc/25
–
2 µs
–
510 µs
–
fc/23
fc/23
–
500 ns
–
127.5 µs
–
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
Example :Setting the timer mode with source clock fc/27 Hz and generating an interrupt 80 µs later
(TimerCounter4, fc = 16.0 MHz)
(TTREG4), 0AH
: Sets the timer register (80 µs÷27/fc = 0AH).
(EIRE). 5
: Enables INTTC4 interrupt.
LD
(TC4CR), 00010000B
: Sets the operating clock to fc/27, and 8-bit timer mode.
LD
(TC4CR), 00011000B
: Starts TC4.
LD
DI
SET
EI
Page 117
9. 8-Bit TimerCounter (TC3, TC4)
9.1 Configuration
TMP86FS28FG
TC4CR<TC4S>
Internal
Source Clock
1
Counter
TTREG4
?
2
3
n-1
n 0
1
2
n-1
n 0
1
2
0
n
Match detect
Counter clear
INTTC4 interrupt request
Counter clear
Match detect
Figure 9-2 8-Bit Timer Mode Timing Chart (TC4)
9.3.2
8-Bit Event Counter Mode (TC3, 4)
In the 8-bit event counter mode, the up-counter counts up at the falling edge of the input pulse to the TCj pin.
When a match between the up-counter and the TTREGj value is detected, an INTTCj 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 TCj pin. Two machine cycles are required for the low- or high-level pulse input to the TCj pin.
Therefore, a maximum frequency to be supplied is fc/24 Hz in the NORMAL1/2 or IDLE1/2 mode, and fs/24
Hz in the SLOW1/2 or SLEEP1/2 mode.
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 TTREGi is changed while the timer is running, an
expected operation may not be obtained.
Note 3: j = 3, 4
TC4CR<TC4S>
TC4 pin input
0
Counter
TTREG4
?
1
2
n-1
n 0
1
2
n-1
n 0
1
2
0
n
Match detect
INTTC4 interrupt request
Counter
clear
Match detect
Counter
clear
Figure 9-3 8-Bit Event Counter Mode Timing Chart (TC4)
9.3.3
8-Bit Programmable Divider Output (PDO) Mode (TC3, 4)
This mode is used to generate a pulse with a 50% duty cycle from the PDOj pin.
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 118
TMP86FS28FG
Example :Generating 1024 Hz pulse using TC4 (fc = 16.0 MHz)
Setting port
LD
(TTREG4), 3DH
: 1/1024÷27/fc÷2 = 3DH
LD
(TC4CR), 00010001B
: Sets the operating clock to fc/27, and 8-bit PDO mode.
LD
(TC4CR), 00011001B
: Starts TC4.
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 = 3, 4
Page 119
Page 120
?
INTTC4 interrupt request
PDO4 pin
Timer F/F4
TTREG4
Counter
Internal
source clock
TC4CR<TFF4>
TC4CR<TC4S>
0
n
1
Match detect
2
n 0
1
Match detect
2
n 0
1
Match detect
2
n 0
1
Match detect
2
n 0
1
2
3
Set F/F
Held at the level when the timer
is stopped
0
Write of "1"
9.1 Configuration
9. 8-Bit TimerCounter (TC3, TC4)
TMP86FS28FG
Figure 9-4 8-Bit PDO Mode Timing Chart (TC4)
TMP86FS28FG
9.3.4
8-Bit Pulse Width Modulation (PWM) Output Mode (TC3, 4)
This mode is used to generate a pulse-width modulated (PWM) signals with up to 8 bits of resolution. The
up-counter counts up using the internal clock.
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, fc/2 or fs 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 = 3, 4
Table 9-5 PWM Output Mode
Source Clock
NORMAL1/2, IDLE1/2 mode
Resolution
Repeated Cycle
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211 [Hz]
fs/23 [Hz]
fs/23 [Hz]
128 µs
244.14 µs
32.8 ms
62.5 ms
fc/2
7
–
8 µs
–
2.05 ms
–
fc/2
5
–
2 µs
–
512 µs
–
fc/2
7
fc/2
5
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
fc/23
fc/23
–
500 ns
–
128 µs
–
fs
fs
fs
30.5 µs
30.5 µs
7.81 ms
7.81 ms
fc/2
fc/2
–
125 ns
–
32 µs
–
fc
fc
–
62.5 ns
–
16 µs
–
Page 121
Page 122
?
Shift registar
0
Shift
INTTC4 interrupt request
PWM4 pin
Timer F/F4
?
PWREG4
Counter
Internal
source clock
TC4CR<TFF4>
TC4CR<TC4S>
n
n
n
Match detect
1
n
n+1
Shift
FF
0
n
n
n+1
m
One cycle period
Write to PWREG4
Match detect
1
Shift
FF
0
m
m
m+1
Write to PWREG4
p
Match detect
m
1
Shift
FF
0
p
p
Match detect
1
p
9.1 Configuration
9. 8-Bit TimerCounter (TC3, TC4)
TMP86FS28FG
Figure 9-5 8-Bit PWM Mode Timing Chart (TC4)
TMP86FS28FG
9.3.5
16-Bit Timer Mode (TC3 and 4)
In the timer mode, the up-counter counts up using the internal clock. The TimerCounter 3 and 4 are cascadable to form a 16-bit timer.
When a match between the up-counter and the timer register (TTREG3, TTREG4) value is detected after the
timer is started by setting TC4CR<TC4S> to 1, an INTTC4 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 = 3, 4
Table 9-6 Source Clock for 16-Bit Timer Mode
Source Clock
Resolution
NORMAL1/2, IDLE1/2 mode
Maximum Time Setting
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211
fs/23
fs/23
128 µs
244.14 µs
8.39 s
16 s
fc/27
fc/27
–
8 µs
–
524.3 ms
–
fc/25
fc/25
–
2 µs
–
131.1 ms
–
fc/23
fc/23
–
500 ns
–
32.8 ms
–
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
Example :Setting the timer mode with source clock fc/27 Hz, and generating an interrupt 300 ms later
(fc = 16.0 MHz)
(TTREG3), 927CH
: Sets the timer register (300 ms÷27/fc = 927CH).
(EIRE). 5
: Enables INTTC4 interrupt.
LD
(TC3CR), 13H
:Sets the operating clock to fc/27, and 16-bit timer mode
(lower byte).
LD
(TC4CR), 04H
: Sets the 16-bit timer mode (upper byte).
LD
(TC4CR), 0CH
: Starts the timer.
LDW
DI
SET
EI
TC4CR<TC4S>
Internal
source clock
0
Counter
TTREG3
(Lower byte)
TTREG4
(Upper byte)
?
?
INTTC4 interrupt request
1
2
3
mn-1 mn 0
1
2
mn-1 mn 0
1
n
m
Match
detect
Counter
clear
Match
detect
Counter
clear
Figure 9-6 16-Bit Timer Mode Timing Chart (TC3 and TC4)
Page 123
2
0
9. 8-Bit TimerCounter (TC3, TC4)
9.1 Configuration
9.3.6
TMP86FS28FG
16-Bit Event Counter Mode (TC3 and 4)
In the event counter mode, the up-counter counts up at the falling edge to the TC3 pin. The TimerCounter 3
and 4 are cascadable to form a 16-bit event counter.
When a match between the up-counter and the timer register (TTREG3, TTREG4) value is detected after
the timer is started by setting TC4CR<TC4S> to 1, an INTTC4 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 TC3 pin.
Two machine cycles are required for the low- or high-level pulse input to the TC3 pin.
Therefore, a maximum frequency to be supplied is fc/24 Hz in the NORMAL1/2 or IDLE1/2 mode, and fs/
2 in the SLOW1/2 or SLEEP1/2 mode. Program the lower byte (TTREG3), and upper byte (TTREG4) in this
order in the timer register. (Programming only the upper or lower byte should not be attempted.)
4
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 = 3, 4
9.3.7
16-Bit Pulse Width Modulation (PWM) Output Mode (TC3 and 4)
This mode is used to generate a pulse-width modulated (PWM) signals with up to 16 bits of resolution. The
TimerCounter 3 and 4 are cascadable to form the 16-bit PWM signal generator.
The counter counts up using the internal clock or external clock.
When a match between the up-counter and the timer register (PWREG3, PWREG4) value is detected, the
logic level output from the timer F/F4 is switched to the opposite state. The counter continues counting. The
logic level output from the timer F/F4 is switched to the opposite state again by the counter overflow, and the
counter is cleared. The INTTC4 interrupt is generated at this time.
Two machine cycles are required for the high- or low-level pulse input to the TC3 pin. Therefore, a maximum frequency to be supplied is fc/24 Hz in the NORMAL1/2 or IDLE1/2 mode, and fs/24 to in the SLOW1/2
or SLEEP1/2 mode.
Since the initial value can be set to the timer F/F4 by TC4CR<TFF4>, positive and negative pulses can be
generated. Upon reset, the timer F/F4 is cleared to 0.
(The logic level output from the PWM4 pin is the opposite to the timer F/F4 logic level.)
Since PWREG4 and 3 in the PWM mode are serially connected to the shift register, the values set to
PWREG4 and 3 can be changed while the timer is running. The values set to PWREG4 and 3 during a run of
the timer are shifted by the INTTCj interrupt request and loaded into PWREG4 and 3. While the timer is
stopped, the values are shifted immediately after the programming of PWREG4 and 3. Set the lower byte
(PWREG3) and upper byte (PWREG4) in this order to program PWREG4 and 3. (Programming only the lower
or upper byte of the register should not be attempted.)
If executing the read instruction to PWREG4 and 3 during PWM output, the values set in the shift register is
read, but not the values set in PWREG4 and 3. Therefore, after writing to the PWREG4 and 3, reading data of
PWREG4 and 3 is previous value until INTTC4 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 PWREG4 and 3 immediately after the INTTC4 interrupt
request is generated (normally in the INTTC4 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 INTTC4 interrupt request is generated.
Note 2: When the timer is stopped during PWM output, the PWM4 pin holds the output status when the timer is
stopped. To change the output status, program TC4CR<TFF4> after the timer is stopped. Do not program
TC4CR<TFF4> upon stopping of the timer.
Example: Fixing the PWM4 pin to the high level when the TimerCounter is stopped
Page 124
TMP86FS28FG
CLR (TC4CR).3: Stops the timer.
CLR (TC4CR).7 : Sets the PWM4 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, fc/2 or fs is selected as the source clock, a pulse is output from the PWM4
pin during the warm-up period time after exiting the STOP mode.
Table 9-7 16-Bit PWM Output Mode
Source Clock
NORMAL1/2, IDLE1/2 mode
Resolution
Repeated Cycle
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211
fs/23 [Hz]
fs/23 [Hz]
128 µs
244.14 µs
8.39 s
16 s
fc/27
fc/27
–
8 µs
–
524.3 ms
–
fc/25
fc/25
–
2 µs
–
131.1 ms
–
fc/23
fc/23
–
500 ns
–
32.8 ms
–
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
fs
fs
fs
30.5 µs
30.5 µs
2s
2s
fc/2
fc/2
–
125 ns
–
8.2 ms
–
fc
fc
–
62.5 ns
–
4.1 ms
–
Example :Generating a pulse with 1-ms high-level width and a period of 32.768 ms (fc = 16.0 MHz)
Setting ports
LDW
(PWREG3), 07D0H
: Sets the pulse width.
LD
(TC3CR), 33H
: Sets the operating clock to fc/23, and 16-bit PWM output
mode (lower byte).
LD
(TC4CR), 056H
: Sets TFF4 to the initial value 0, and 16-bit PWM signal
generation mode (upper byte).
LD
(TC4CR), 05EH
: Starts the timer.
Page 125
Page 126
?
?
PWREG4
(Upper byte)
16-bit
shift register
0
a
Shift
INTTC4 interrupt request
PWM4 pin
Timer F/F4
?
PWREG3
(Lower byte)
Counter
Internal
source clock
TC4CR<TFF4>
TC4CR<TC4S>
an
n
an
Match detect
1
an
an+1
Shift
FFFF
0
an
an
an+1
m
b
One cycle period
Write to PWREG4
Write to PWREG3
Match detect
1
Shift
FFFF
0
bm
bm bm+1
p
c
Write to PWREG4
Write to PWREG3
Match detect
bm
1
Shift
FFFF
0
cp
Match detect
cp
1
cp
9.1 Configuration
9. 8-Bit TimerCounter (TC3, TC4)
TMP86FS28FG
Figure 9-7 16-Bit PWM Mode Timing Chart (TC3 and TC4)
TMP86FS28FG
9.3.8
16-Bit Programmable Pulse Generate (PPG) Output Mode (TC3 and 4)
This mode is used to generate pulses with up to 16-bits of resolution. The timer counter 3 and 4 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 (PWREG3, PWREG4) value is detected, the logic level output from the timer F/F4 is
switched to the opposite state. The counter continues counting. The logic level output from the timer F/F4 is
switched to the opposite state again when a match between the up-counter and the timer register (TTREG3,
TTREG4) value is detected, and the counter is cleared. The INTTC4 interrupt is generated at this time.
Two machine cycles are required for the high- or low-level pulse input to the TC3 pin. Therefore, a maximum frequency to be supplied is fc/24 Hz in the NORMAL1/2 or IDLE1/2 mode, and fs/24 to in the SLOW1/
2 or SLEEP1/2 mode.
Since the initial value can be set to the timer F/F4 by TC4CR<TFF4>, positive and negative pulses can be
generated. Upon reset, the timer F/F4 is cleared to 0.
(The logic level output from the PPG4 pin is the opposite to the timer F/F4.)
Set the lower byte and upper byte in this order to program the timer register. (TTREG3 → TTREG4,
PWREG3 → PWREG4) (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 = 16.0 MHz)
Setting ports
LDW
(PWREG3), 07D0H
: Sets the pulse width.
LDW
(TTREG3), 8002H
: Sets the cycle period.
LD
(TC3CR), 33H
: Sets the operating clock to fc/23, and16-bit PPG mode
(lower byte).
LD
(TC4CR), 057H
: Sets TFF4 to the initial value 0, and 16-bit
PPG mode (upper byte).
LD
(TC4CR), 05FH
: Starts the timer.
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 PPG4 pin holds the output status when the timer is
stopped. To change the output status, program TC4CR<TFF4> after the timer is stopped. Do not change
TC4CR<TFF4> upon stopping of the timer.
Example: Fixing the PPG4 pin to the high level when the TimerCounter is stopped
CLR (TC4CR).3: Stops the timer
CLR (TC4CR).7: Sets the PPG4 pin to the high level
Note 3: i = 3, 4
Page 127
Page 128
?
TTREG4
(Upper byte)
INTTC4 interrupt request
PPG4 pin
Timer F/F4
?
?
TTREG3
(Lower byte)
PWREG4
(Upper byte)
n
PWREG3
(Lower byte)
?
0
Counter
Internal
source clock
TC4CR<TFF4>
TC4CR<TC4S>
m
r
q
mn
Match detect
1
mn mn+1
Match detect
qr-1 qr 0
mn
Match detect
1
mn mn+1
Match detect
qr-1 qr 0
mn
Match detect
1
F/F clear
0
Held at the level when the timer
stops
mn mn+1
Write of "0"
9.1 Configuration
9. 8-Bit TimerCounter (TC3, TC4)
TMP86FS28FG
Figure 9-8 16-Bit PPG Mode Timing Chart (TC3 and TC4)
TMP86FS28FG
9.3.9
Warm-Up Counter Mode
In this mode, the warm-up period time is obtained to assure oscillation stability when the system clocking is
switched between the high-frequency and low-frequency. The timer counter 3 and 4 are cascadable to form a
16-bit TimerCounter. The warm-up counter mode has two types of mode; switching from the high-frequency to
low-frequency, and vice-versa.
Note 1: In the warm-up counter mode, fix TCiCR<TFFi> to 0. If not fixed, the PDOi, PWMi and PPGi pins may output
pulses.
Note 2: In the warm-up counter mode, only upper 8 bits of the timer register TTREG4 and 3 are used for match
detection and lower 8 bits are not used.
Note 3: i = 3, 4
9.3.9.1
Low-Frequency Warm-up Counter Mode
(NORMAL1 → NORMAL2 → SLOW2 → SLOW1)
In this mode, the warm-up period time from a stop of the low-frequency clock fs to oscillation stability
is obtained. Before starting the timer, set SYSCR2<XTEN> to 1 to oscillate the low-frequency clock.
When a match between the up-counter and the timer register (TTREG4, 3) value is detected after the timer
is started by setting TC4CR<TC4S> to 1, the counter is cleared by generating the INTTC4 interrupt
request. After stopping the timer in the INTTC4 interrupt service routine, set SYSCR2<SYSCK> to 1 to
switch the system clock from the high-frequency to low-frequency, and then clear of SYSCR2<XEN> to
0 to stop the high-frequency clock.
Table 9-8 Setting Time of Low-Frequency Warm-Up Counter Mode (fs = 32.768 kHz)
Minimum Time Setting
(TTREG4, 3 = 0100H)
Maximum Time Setting
(TTREG4, 3 = FF00H)
7.81 ms
1.99 s
Example :After checking low-frequency clock oscillation stability with TC4 and 3, switching to the SLOW1 mode
SET
(SYSCR2).6
: SYSCR2<XTEN> ← 1
LD
(TC3CR), 43H
: Sets TFF3=0, source clock fs, and 16-bit mode.
LD
(TC4CR), 05H
: Sets TFF4=0, and warm-up counter mode.
LD
(TTREG3), 8000H
: Sets the warm-up time.
(The warm-up time depends on the oscillator characteristic.)
: IMF ← 0
DI
SET
(EIRE). 5
: IMF ← 1
EI
SET
:
PINTTC4:
: Enables the INTTC4.
(TC4CR).3
: Starts TC4 and 3.
:
CLR
(TC4CR).3
: Stops TC4 and 3.
SET
(SYSCR2).5
: SYSCR2<SYSCK> ← 1
(Switches the system clock to the low-frequency clock.)
CLR
(SYSCR2).7
: SYSCR2<XEN> ← 0 (Stops the high-frequency clock.)
RETI
:
VINTTC4:
DW
:
PINTTC4
: INTTC4 vector table
Page 129
9. 8-Bit TimerCounter (TC3, TC4)
9.1 Configuration
TMP86FS28FG
9.3.9.2
High-Frequency Warm-Up Counter Mode
(SLOW1 → SLOW2 → NORMAL2 → NORMAL1)
In this mode, the warm-up period time from a stop of the high-frequency clock fc to the oscillation stability is obtained. Before starting the timer, set SYSCR2<XEN> to 1 to oscillate the high-frequency clock.
When a match between the up-counter and the timer register (TTREG4, 3) value is detected after the timer
is started by setting TC4CR<TC4S> to 1, the counter is cleared by generating the INTTC4 interrupt
request. After stopping the timer in the INTTC4 interrupt service routine, clear SYSCR2<SYSCK> to 0 to
switch the system clock from the low-frequency to high-frequency, and then SYSCR2<XTEN> to 0 to
stop the low-frequency clock.
Table 9-9 Setting Time in High-Frequency Warm-Up Counter Mode
Minimum time Setting
(TTREG4, 3 = 0100H)
Maximum time Setting
(TTREG4, 3 = FF00H)
16 µs
4.08 ms
Example :After checking high-frequency clock oscillation stability with TC4 and 3, switching to the NORMAL1 mode
SET
(SYSCR2).7
: SYSCR2<XEN> ← 1
LD
(TC3CR), 63H
: Sets TFF3=0, source clock fc, and 16-bit mode.
LD
(TC4CR), 05H
: Sets TFF4=0, and warm-up counter mode.
LD
(TTREG3), 0F800H
: Sets the warm-up time.
(The warm-up time depends on the oscillator characteristic.)
: IMF ← 0
DI
SET
(EIRE). 5
: IMF ← 1
EI
SET
:
PINTTC4:
: Enables the INTTC4.
(TC4CR).3
: Starts the TC4 and 3.
:
CLR
(TC4CR).3
: Stops the TC4 and 3.
CLR
(SYSCR2).5
: SYSCR2<SYSCK> ← 0
(Switches the system clock to the high-frequency clock.)
CLR
(SYSCR2).6
: SYSCR2<XTEN> ← 0
(Stops the low-frequency clock.)
RETI
VINTTC4:
:
:
DW
PINTTC4
: INTTC4 vector table
Page 130
TMP86FS28FG
10. 8-Bit TimerCounter (TC5, TC6)
10.1 Configuration
PWM mode
Overflow
fc/211 or fs/23
7
fc/2
5
fc/2
fc/23
fs
fc/2
fc
TC6 pin
A
B
C
D
E
F
G
H
Y
A
B
INTTC6
interrupt request
Clear
Y
8-bit up-counter
TC6S
S
PDO, PPG mode
A
B
S
16-bit
mode
S
TC6M
TC6S
TFF6
Toggle
Q
Set
Clear
Y
16-bit mode
Timer, Event
Counter mode
S
TC6CK
PDO6/PWM6/
PPG6 pin
Timer F/F6
A
Y
TC6CR
B
TTREG6
PWREG6
PWM, PPG mode
DecodeEN
PDO, PWM,
PPG mode
TFF6
16-bit
mode
TC5S
PWM mode
fc/211 or fs/23
fc/27
5
fc/2
3
fc/2
fs
fc/2
fc
TC5 pin
Y
8-bit up-counter
Overflow
16-bit mode
PDO mode
16-bit mode
Timer,
Event Couter mode
S
TC5M
TC5S
TFF5
INTTC5
interrupt request
Clear
A
B
C
D
E
F
G
H
Toggle
Q
Set
Clear
PDO5/PWM5/
pin
Timer F/F5
TC5CK
TC5CR
PWM mode
TTREG5
PWREG5
DecodeEN
TFF5
Figure 10-1 8-Bit TimerCounter 5, 6
Page 131
PDO, PWM mode
16-bit mode
10. 8-Bit TimerCounter (TC5, TC6)
10.1 Configuration
TMP86FS28FG
10.2 TimerCounter Control
The TimerCounter 5 is controlled by the TimerCounter 5 control register (TC5CR) and two 8-bit timer registers
(TTREG5, PWREG5).
TimerCounter 5 Timer Register
TTREG5
(0017H)
R/W
7
PWREG5
(001BH)
R/W
7
6
5
4
3
2
1
0
(Initial value: 1111 1111)
6
5
4
3
2
1
0
(Initial value: 1111 1111)
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.
TimerCounter 5 Control Register
TC5CR
(000BH)
TFF5
7
TFF5
6
5
4
TC5CK
Time F/F5 control
3
2
TC5S
0:
1:
1
0
TC5M
(Initial value: 0000 0000)
Clear
Set
R/W
NORMAL1/2, IDLE1/2 mode
TC5CK
Operating clock selection [Hz]
DV7CK = 0
DV7CK = 1
SLOW1/2
SLEEP1/2
mode
000
fc/211
fs/23
fs/23
001
fc/27
fc/27
–
010
fc/25
fc/25
–
011
fc/23
fc/23
–
100
fs
fs
fs
101
fc/2
fc/2
–
110
fc
fc
fc (Note 8)
111
TC5S
TC5 start control
0:
1:
000:
001:
TC5M
TC5M operating mode select
010:
011:
1**:
R/W
TC5 pin input
Operation stop and counter clear
Operation start
R/W
8-bit timer/event counter mode
8-bit programmable divider output (PDO) mode
8-bit pulse width modulation (PWM) output mode
16-bit mode
(Each mode is selectable with TC6M.)
Reserved
R/W
Note 1: fc: High-frequency clock [Hz] fs: Low-frequency clock[Hz]
Note 2: Do not change the TC5M, TC5CK and TFF5 settings while the timer is running.
Note 3: To stop the timer operation (TC5S= 1 → 0), do not change the TC5M, TC5CK and TFF5 settings. To start the timer operation (TC5S= 0 → 1), TC5M, TC5CK and TFF5 can be programmed.
Note 4: To use the TimerCounter in the 16-bit mode, set the operating mode by programming TC6CR<TC6M>, where TC5M must
be fixed to 011.
Note 5: To use the TimerCounter in the 16-bit mode, select the source clock by programming TC5CK. Set the timer start control
and timer F/F control by programming TC6CR<TC6S> and TC6CR<TFF6>, respectively.
Note 6: The operating clock settings are limited depending on the timer operating mode. For the detailed descriptions, see Table
10-1 and Table 10-2.
Page 132
TMP86FS28FG
Note 7: The timer register settings are limited depending on the timer operating mode. For the detailed descriptions, see Table 103.
Note 8: The operating clock fc in the SLOW or SLEEP mode can be used only as the high-frequency warm-up mode.
Page 133
10. 8-Bit TimerCounter (TC5, TC6)
10.1 Configuration
TMP86FS28FG
The TimerCounter 6 is controlled by the TimerCounter 6 control register (TC6CR) and two 8-bit timer registers
(TTREG6 and PWREG6).
TimerCounter 6 Timer Register
TTREG6
(0018H)
R/W
7
PWREG6
(001CH)
R/W
7
6
5
4
3
2
1
0
(Initial value: 1111 1111)
6
5
4
3
2
1
0
(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.
TimerCounter 6 Control Register
TC6CR
(000CH)
TFF6
7
TFF6
6
5
4
TC6CK
Timer F/F6 control
3
2
TC6S
0:
1:
1
0
TC6M
(Initial value: 0000 0000)
Clear
Set
R/W
NORMAL1/2, IDLE1/2 mode
TC6CK
Operating clock selection [Hz]
DV7CK = 0
DV7CK = 1
SLOW1/2
SLEEP1/2
mode
000
fc/211
fs/23
fs/23
001
fc/27
fc/27
–
010
fc/25
fc/25
–
011
fc/2
3
3
–
100
fs
fs
fs
101
fc/2
fc/2
–
110
fc
fc
–
111
TC6S
TC6 start control
0:
1:
000:
001:
010:
TC6M
TC6M operating mode select
011:
100:
101:
110:
111:
fc/2
R/W
TC6 pin input
Operation stop and counter clear
Operation start
R/W
8-bit timer/event counter mode
8-bit programmable divider output (PDO) mode
8-bit pulse width modulation (PWM) output mode
Reserved
16-bit timer/event counter mode
Warm-up counter mode
16-bit pulse width modulation (PWM) output mode
16-bit PPG mode
R/W
Note 1: fc: High-frequency clock [Hz] fs: Low-frequency clock [Hz]
Note 2: Do not change the TC6M, TC6CK and TFF6 settings while the timer is running.
Note 3: To stop the timer operation (TC6S= 1 → 0), do not change the TC6M, TC6CK and TFF6 settings.
To start the timer operation (TC6S= 0 → 1), TC6M, TC6CK and TFF6 can be programmed.
Note 4: When TC6M= 1** (upper byte in the 16-bit mode), the source clock becomes the TC5 overflow signal regardless of the
TC6CK setting.
Note 5: To use the TimerCounter in the 16-bit mode, select the operating mode by programming TC6M, where TC5CR<TC5M>
must be set to 011.
Page 134
TMP86FS28FG
Note 6: To the TimerCounter in the 16-bit mode, select the source clock by programming TC5CR<TC5CK>. Set the timer start
control and timer F/F control by programming TC6S and TFF6, respectively.
Note 7: The operating clock settings are limited depending on the timer operating mode. For the detailed descriptions, see Table
10-1 and Table 10-2.
Note 8: The timer register settings are limited depending on the timer operating mode. For the detailed descriptions, see Table 103.
Table 10-1 Operating Mode and Selectable Source Clock (NORMAL1/2 and IDLE1/2 Modes)
Operating mode
fc/211
or
fc/27
fc/25
fc/23
fs
fc/2
fc
TC5
pin input
TC6
pin input
fs/23
8-bit timer
Ο
Ο
Ο
Ο
–
–
–
–
–
8-bit event counter
–
–
–
–
–
–
–
Ο
Ο
8-bit PDO
Ο
Ο
Ο
Ο
–
–
–
–
–
8-bit PWM
Ο
Ο
Ο
Ο
Ο
Ο
Ο
–
–
16-bit timer
Ο
Ο
Ο
Ο
–
–
–
–
–
16-bit event counter
–
–
–
–
–
–
–
Ο
–
Warm-up counter
–
–
–
–
Ο
–
–
–
–
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
Table 10-2 Operating Mode and Selectable Source Clock (SLOW1/2 and SLEEP1/2 Modes)
Operating mode
fc/211
or
fc/27
fc/25
fc/23
fs
fc/2
fc
TC5
pin input
TC6
pin input
fs/23
8-bit timer
Ο
–
–
–
–
–
–
–
–
8-bit event counter
–
–
–
–
–
–
–
Ο
Ο
8-bit PDO
Ο
–
–
–
–
–
–
–
–
8-bit PWM
Ο
–
–
–
Ο
–
–
–
–
16-bit timer
Ο
–
–
–
–
–
–
–
–
16-bit event counter
–
–
–
–
–
–
–
Ο
–
Warm-up counter
–
–
–
–
–
–
Ο
–
–
16-bit PWM
Ο
–
–
–
Ο
–
–
Ο
–
16-bit PPG
Ο
–
–
–
–
–
–
Ο
–
Note1: 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).
Note2: Ο : Available source clock
Page 135
10. 8-Bit TimerCounter (TC5, TC6)
10.1 Configuration
TMP86FS28FG
Table 10-3 Constraints on Register Values Being Compared
Operating mode
Register Value
8-bit timer/event counter
1≤ (TTREGn) ≤255
8-bit PDO
1≤ (TTREGn) ≤255
8-bit PWM
2≤ (PWREGn) ≤254
16-bit timer/event counter
1≤ (TTREG6, 5) ≤65535
Warm-up counter
256≤ (TTREG6, 5) ≤65535
16-bit PWM
2≤ (PWREG6, 5) ≤65534
16-bit PPG
and
(PWREG6, 5) + 1 < (TTREG6, 5)
1≤ (PWREG6, 5) < (TTREG6, 5) ≤65535
Note: n = 5 to 6
Page 136
TMP86FS28FG
10.3 Function
The TimerCounter 5 and 6 have the 8-bit timer, 8-bit event counter, 8-bit programmable divider output (PDO), 8bit pulse width modulation (PWM) output modes. The TimerCounter 5 and 6 (TC5, 6) are cascadable to form a 16bit timer. The 16-bit timer has the operating modes such as the 16-bit timer, 16-bit event counter, warm-up counter,
16-bit pulse width modulation (PWM) output and 16-bit programmable pulse generation (PPG) modes.
10.3.1 8-Bit Timer Mode (TC5 and 6)
In the timer mode, the up-counter counts up using the internal clock. When a match between the up-counter
and the timer register j (TTREGj) value is detected, an INTTCj interrupt is generated and the up-counter is
cleared. After being cleared, the up-counter restarts counting.
Note 1: In the timer mode, fix TCjCR<TFFj> to 0. If not fixed, the PDOj, PWMj and PPGj pins may output pulses.
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 the programming. Therefore, if TTREGi is changed while the timer is running, an expected operation
may not be obtained.
Note 3: j = 5, 6
Table 10-4 Source Clock for TimerCounter 5, 6 (Internal Clock)
Source Clock
NORMAL1/2, IDLE1/2 mode
Resolution
Maximum Time Setting
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211 [Hz]
fs/23 [Hz]
fs/23 [Hz]
128 µs
244.14 µs
32.6 ms
62.3 ms
fc/27
fc/27
–
8 µs
–
2.0 ms
–
fc/25
fc/25
–
2 µs
–
510 µs
–
fc/23
fc/23
–
500 ns
–
127.5 µs
–
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
Example :Setting the timer mode with source clock fc/27 Hz and generating an interrupt 80 µs later
(TimerCounter6, fc = 16.0 MHz)
(TTREG6), 0AH
: Sets the timer register (80 µs÷27/fc = 0AH).
(EIRD). 0
: Enables INTTC6 interrupt.
LD
(TC6CR), 00010000B
: Sets the operating clock to fc/27, and 8-bit timer mode.
LD
(TC6CR), 00011000B
: Starts TC6.
LD
DI
SET
EI
Page 137
10. 8-Bit TimerCounter (TC5, TC6)
10.1 Configuration
TMP86FS28FG
TC6CR<TC6S>
Internal
Source Clock
1
Counter
TTREG6
?
2
3
n-1
n 0
1
2
n-1
n 0
1
2
0
n
Match detect
Counter clear
INTTC6 interrupt request
Counter clear
Match detect
Figure 10-2 8-Bit Timer Mode Timing Chart (TC6)
10.3.2 8-Bit Event Counter Mode (TC5, 6)
In the 8-bit event counter mode, the up-counter counts up at the falling edge of the input pulse to the TCj pin.
When a match between the up-counter and the TTREGj value is detected, an INTTCj 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 TCj pin. Two machine cycles are required for the low- or high-level pulse input to the TCj pin.
Therefore, a maximum frequency to be supplied is fc/24 Hz in the NORMAL1/2 or IDLE1/2 mode, and fs/24
Hz in the SLOW1/2 or SLEEP1/2 mode.
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 TTREGi is changed while the timer is running, an
expected operation may not be obtained.
Note 3: j = 5, 6
TC6CR<TC6S>
TC6 pin input
0
Counter
TTREG6
?
1
2
n-1
n 0
1
2
n-1
n 0
1
2
0
n
Match detect
INTTC6 interrupt request
Counter
clear
Match detect
Counter
clear
Figure 10-3 8-Bit Event Counter Mode Timing Chart (TC6)
10.3.3 8-Bit Programmable Divider Output (PDO) Mode (TC5, 6)
This mode is used to generate a pulse with a 50% duty cycle from the PDOj pin.
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 138
TMP86FS28FG
Example :Generating 1024 Hz pulse using TC6 (fc = 16.0 MHz)
Setting port
LD
(TTREG6), 3DH
: 1/1024÷27/fc÷2 = 3DH
LD
(TC6CR), 00010001B
: Sets the operating clock to fc/27, and 8-bit PDO mode.
LD
(TC6CR), 00011001B
: Starts TC6.
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 139
Page 140
?
INTTC6 interrupt request
PDO6 pin
Timer F/F6
TTREG6
Counter
Internal
source clock
TC6CR<TFF6>
TC6CR<TC6S>
0
n
1
Match detect
2
n 0
1
Match detect
2
n 0
1
Match detect
2
n 0
1
Match detect
2
n 0
1
2
3
Set F/F
Held at the level when the timer
is stopped
0
Write of "1"
10.1 Configuration
10. 8-Bit TimerCounter (TC5, TC6)
TMP86FS28FG
Figure 10-4 8-Bit PDO Mode Timing Chart (TC6)
TMP86FS28FG
10.3.4 8-Bit Pulse Width Modulation (PWM) Output Mode (TC5, 6)
This mode is used to generate a pulse-width modulated (PWM) signals with up to 8 bits of resolution. The
up-counter counts up using the internal clock.
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, fc/2 or fs 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
Table 10-5 PWM Output Mode
Source Clock
NORMAL1/2, IDLE1/2 mode
Resolution
Repeated Cycle
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211 [Hz]
fs/23 [Hz]
fs/23 [Hz]
128 µs
244.14 µs
32.8 ms
62.5 ms
fc/2
7
–
8 µs
–
2.05 ms
–
fc/2
5
–
2 µs
–
512 µs
–
fc/2
7
fc/2
5
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
fc/23
fc/23
–
500 ns
–
128 µs
–
fs
fs
fs
30.5 µs
30.5 µs
7.81 ms
7.81 ms
fc/2
fc/2
–
125 ns
–
32 µs
–
fc
fc
–
62.5 ns
–
16 µs
–
Page 141
Page 142
?
Shift registar
0
Shift
INTTC6 interrupt request
PWM6 pin
Timer F/F6
?
PWREG6
Counter
Internal
source clock
TC6CR<TFF6>
TC6CR<TC6S>
n
n
n
Match detect
1
n
n+1
Shift
FF
0
n
n
n+1
m
One cycle period
Write to PWREG6
Match detect
1
Shift
FF
0
m
m
m+1
Write to PWREG6
p
Match detect
m
1
Shift
FF
0
p
p
Match detect
1
p
10.1 Configuration
10. 8-Bit TimerCounter (TC5, TC6)
TMP86FS28FG
Figure 10-5 8-Bit PWM Mode Timing Chart (TC6)
TMP86FS28FG
10.3.5 16-Bit Timer Mode (TC5 and 6)
In the timer mode, the up-counter counts up using the internal clock. The TimerCounter 5 and 6 are cascadable to form a 16-bit timer.
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
Table 10-6 Source Clock for 16-Bit Timer Mode
Source Clock
Resolution
NORMAL1/2, IDLE1/2 mode
Maximum Time Setting
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211
fs/23
fs/23
128 µs
244.14 µs
8.39 s
16 s
fc/27
fc/27
–
8 µs
–
524.3 ms
–
fc/25
fc/25
–
2 µs
–
131.1 ms
–
fc/23
fc/23
–
500 ns
–
32.8 ms
–
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
Example :Setting the timer mode with source clock fc/27 Hz, and generating an interrupt 300 ms later
(fc = 16.0 MHz)
(TTREG5), 927CH
: Sets the timer register (300 ms÷27/fc = 927CH).
(EIRD). 0
: Enables INTTC6 interrupt.
LD
(TC5CR), 13H
:Sets the operating clock to fc/27, and 16-bit timer mode
(lower byte).
LD
(TC6CR), 04H
: Sets the 16-bit timer mode (upper byte).
LD
(TC6CR), 0CH
: Starts the timer.
LDW
DI
SET
EI
TC6CR<TC6S>
Internal
source clock
0
Counter
TTREG5
(Lower byte)
TTREG6
(Upper byte)
?
?
INTTC6 interrupt request
1
2
3
mn-1 mn 0
1
2
mn-1 mn 0
1
n
m
Match
detect
Counter
clear
Match
detect
Counter
clear
Figure 10-6 16-Bit Timer Mode Timing Chart (TC5 and TC6)
Page 143
2
0
10. 8-Bit TimerCounter (TC5, TC6)
10.1 Configuration
TMP86FS28FG
10.3.6 16-Bit Event Counter Mode (TC5 and 6)
In the event counter mode, the up-counter counts up at the falling edge to the TC5 pin. The TimerCounter 5
and 6 are cascadable to form a 16-bit event counter.
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 NORMAL1/2 or IDLE1/2 mode, and fs/
2 in the SLOW1/2 or SLEEP1/2 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.)
4
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
10.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.
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 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/2 or IDLE1/2 mode, and fs/24 to in the SLOW1/2
or SLEEP1/2 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 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 (PWREG6) 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 the PWM6 pin to the high level when the TimerCounter is stopped
Page 144
TMP86FS28FG
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, fc/2 or fs 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.
Table 10-7 16-Bit PWM Output Mode
Source Clock
NORMAL1/2, IDLE1/2 mode
Resolution
Repeated Cycle
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP1/2
mode
fc/211
fs/23 [Hz]
fs/23 [Hz]
128 µs
244.14 µs
8.39 s
16 s
fc/27
fc/27
–
8 µs
–
524.3 ms
–
fc/25
fc/25
–
2 µs
–
131.1 ms
–
fc/23
fc/23
–
500 ns
–
32.8 ms
–
fc = 16 MHz
fs = 32.768 kHz
fc = 16 MHz
fs = 32.768 kHz
fs
fs
fs
30.5 µs
30.5 µs
2s
2s
fc/2
fc/2
–
125 ns
–
8.2 ms
–
fc
fc
–
62.5 ns
–
4.1 ms
–
Example :Generating a pulse with 1-ms high-level width and a period of 32.768 ms (fc = 16.0 MHz)
Setting ports
LDW
(PWREG5), 07D0H
: Sets the pulse width.
LD
(TC5CR), 33H
: Sets the operating clock to fc/23, and 16-bit PWM output
mode (lower byte).
LD
(TC6CR), 056H
: Sets TFF6 to the initial value 0, and 16-bit PWM signal
generation mode (upper byte).
LD
(TC6CR), 05EH
: Starts the timer.
Page 145
Page 146
?
?
PWREG6
(Upper byte)
16-bit
shift register
0
a
Shift
INTTC6 interrupt request
PWM6 pin
Timer F/F6
?
PWREG5
(Lower byte)
Counter
Internal
source clock
TC6CR<TFF6>
TC6CR<TC6S>
an
n
an
Match detect
1
an
an+1
Shift
FFFF
0
an
an
an+1
m
b
One cycle period
Write to PWREG6
Write to PWREG5
Match detect
1
Shift
FFFF
0
bm
bm bm+1
p
c
Write to PWREG6
Write to PWREG5
Match detect
bm
1
Shift
FFFF
0
cp
Match detect
cp
1
cp
10.1 Configuration
10. 8-Bit TimerCounter (TC5, TC6)
TMP86FS28FG
Figure 10-7 16-Bit PWM Mode Timing Chart (TC5 and TC6)
TMP86FS28FG
10.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.
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/2 or IDLE1/2 mode, and fs/24 to in the SLOW1/
2 or SLEEP1/2 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 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 = 16.0 MHz)
Setting ports
LDW
(PWREG5), 07D0H
: Sets the pulse width.
LDW
(TTREG5), 8002H
: Sets the cycle period.
LD
(TC5CR), 33H
: Sets the operating clock to fc/23, and16-bit PPG mode
(lower byte).
LD
(TC6CR), 057H
: Sets TFF6 to the initial value 0, and 16-bit
PPG mode (upper byte).
LD
(TC6CR), 05FH
: Starts the timer.
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 147
Page 148
?
TTREG6
(Upper byte)
INTTC6 interrupt request
PPG6 pin
Timer F/F6
?
?
TTREG5
(Lower byte)
PWREG6
(Upper byte)
n
PWREG5
(Lower byte)
?
0
Counter
Internal
source clock
TC6CR<TFF6>
TC6CR<TC6S>
m
r
q
mn
Match detect
1
mn mn+1
Match detect
qr-1 qr 0
mn
Match detect
1
mn mn+1
Match detect
qr-1 qr 0
mn
Match detect
1
F/F clear
0
Held at the level when the timer
stops
mn mn+1
Write of "0"
10.1 Configuration
10. 8-Bit TimerCounter (TC5, TC6)
TMP86FS28FG
Figure 10-8 16-Bit PPG Mode Timing Chart (TC5 and TC6)
TMP86FS28FG
10.3.9 Warm-Up Counter Mode
In this mode, the warm-up period time is obtained to assure oscillation stability when the system clocking is
switched between the high-frequency and low-frequency. The timer counter 5 and 6 are cascadable to form a
16-bit TimerCounter. The warm-up counter mode has two types of mode; switching from the high-frequency to
low-frequency, and vice-versa.
Note 1: In the warm-up counter mode, fix TCiCR<TFFi> to 0. If not fixed, the PDOi, PWMi and PPGi pins may output
pulses.
Note 2: In the warm-up counter mode, only upper 8 bits of the timer register TTREG6 and 5 are used for match
detection and lower 8 bits are not used.
Note 3: i = 5, 6
10.3.9.1 Low-Frequency Warm-up Counter Mode
(NORMAL1 → NORMAL2 → SLOW2 → SLOW1)
In this mode, the warm-up period time from a stop of the low-frequency clock fs to oscillation stability
is obtained. Before starting the timer, set SYSCR2<XTEN> to 1 to oscillate the low-frequency clock.
When a match between the up-counter and the timer register (TTREG6, 5) value is detected after the timer
is started by setting TC6CR<TC6S> to 1, the counter is cleared by generating the INTTC6 interrupt
request. After stopping the timer in the INTTC6 interrupt service routine, set SYSCR2<SYSCK> to 1 to
switch the system clock from the high-frequency to low-frequency, and then clear of SYSCR2<XEN> to
0 to stop the high-frequency clock.
Table 10-8 Setting Time of Low-Frequency Warm-Up Counter Mode (fs = 32.768 kHz)
Minimum Time Setting
(TTREG6, 5 = 0100H)
Maximum Time Setting
(TTREG6, 5 = FF00H)
7.81 ms
1.99 s
Example :After checking low-frequency clock oscillation stability with TC6 and 5, switching to the SLOW1 mode
SET
(SYSCR2).6
: SYSCR2<XTEN> ← 1
LD
(TC5CR), 43H
: Sets TFF5=0, source clock fs, and 16-bit mode.
LD
(TC6CR), 05H
: Sets TFF6=0, and warm-up counter mode.
LD
(TTREG5), 8000H
: Sets the warm-up time.
(The warm-up time depends on the oscillator characteristic.)
: IMF ← 0
DI
SET
(EIRD). 0
: IMF ← 1
EI
SET
:
PINTTC6:
: Enables the INTTC6.
(TC6CR).3
: Starts TC6 and 5.
:
CLR
(TC6CR).3
: Stops TC6 and 5.
SET
(SYSCR2).5
: SYSCR2<SYSCK> ← 1
(Switches the system clock to the low-frequency clock.)
CLR
(SYSCR2).7
: SYSCR2<XEN> ← 0 (Stops the high-frequency clock.)
RETI
:
VINTTC6:
DW
:
PINTTC6
: INTTC6 vector table
Page 149
10. 8-Bit TimerCounter (TC5, TC6)
10.1 Configuration
TMP86FS28FG
10.3.9.2 High-Frequency Warm-Up Counter Mode
(SLOW1 → SLOW2 → NORMAL2 → NORMAL1)
In this mode, the warm-up period time from a stop of the high-frequency clock fc to the oscillation stability is obtained. Before starting the timer, set SYSCR2<XEN> to 1 to oscillate the high-frequency clock.
When a match between the up-counter and the timer register (TTREG6, 5) value is detected after the timer
is started by setting TC6CR<TC6S> to 1, the counter is cleared by generating the INTTC6 interrupt
request. After stopping the timer in the INTTC6 interrupt service routine, clear SYSCR2<SYSCK> to 0 to
switch the system clock from the low-frequency to high-frequency, and then SYSCR2<XTEN> to 0 to
stop the low-frequency clock.
Table 10-9 Setting Time in High-Frequency Warm-Up Counter Mode
Minimum time Setting
(TTREG6, 5 = 0100H)
Maximum time Setting
(TTREG6, 5 = FF00H)
16 µs
4.08 ms
Example :After checking high-frequency clock oscillation stability with TC6 and 5, switching to the NORMAL1 mode
SET
(SYSCR2).7
: SYSCR2<XEN> ← 1
LD
(TC5CR), 63H
: Sets TFF5=0, source clock fc, and 16-bit mode.
LD
(TC6CR), 05H
: Sets TFF6=0, and warm-up counter mode.
LD
(TTREG5), 0F800H
: Sets the warm-up time.
(The warm-up time depends on the oscillator characteristic.)
: IMF ← 0
DI
SET
(EIRD). 0
: IMF ← 1
EI
SET
:
PINTTC6:
: Enables the INTTC6.
(TC6CR).3
: Starts the TC6 and 5.
:
CLR
(TC6CR).3
: Stops the TC6 and 5.
CLR
(SYSCR2).5
: SYSCR2<SYSCK> ← 0
(Switches the system clock to the high-frequency clock.)
CLR
(SYSCR2).6
: SYSCR2<XTEN> ← 0
(Stops the low-frequency clock.)
RETI
VINTTC6:
:
:
DW
PINTTC6
: INTTC6 vector table
Page 150
TMP86FS28FG
11. Synchronous Serial Interface (SIO)
The TMP86FS28FG 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 peripherl devices via SO, SI, SCK port.
11.1 Configuration
SIO control / status register
SIOSR
SIOCR1
SIOCR2
CPU
Transmit and
receive data buffer
(8 bytes in DBR)
Buffer control
circuit
Control circuit
Shift register
Shift
clock
7
6
5
4
3
2
1
0
SO
Serial data output
8-bit transfer
4-bit transfer
SI
Serial data input
INTSIO interrupt request
Serial clock
SCK
Serial clock I/O
Figure 11-1 Serial Interface
Page 151
11. Synchronous Serial Interface (SIO)
11.2 Control
TMP86FS28FG
11.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
0F60H to 0F67H 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>.
SIO Control Register 1
SIOCR1
7
6
(0F68H)
SIOS
SIOINH
SIOS
5
4
Continue / abort transfer
SIOM
2
1
SIOM
Indicate transfer start / stop
SIOINH
3
Transfer mode select
0
SCK
0:
Stop
1:
Start
(Initial value: 0000 0000)
0:
Continuously transfer
1:
Abort transfer (Automatically cleared after abort)
000:
8-bit transmit mode
010:
4-bit transmit mode
100:
8-bit transmit / receive mode
101:
8-bit receive mode
110:
4-bit receive mode
Write
only
Except the above: Reserved
NORMAL1/2, IDLE1/2 mode
SCK
Serial clock select
DV7CK = 0
DV7CK = 1
SLOW1/2
SLEEP1/2
mode
000
fc/213
fs/25
fs/25
001
fc/28
fc/28
-
010
fc/27
fc/27
-
011
fc/26
fc/26
-
100
fc/25
fc/25
-
101
fc/24
fc/24
-
110
Reserved
111
External clock ( Input from SCK pin )
Note 1: fc; High-frequency clock [Hz], fs; Low-frequency clock [Hz]
Note 2: Set SIOS to "0" and SIOINH to "1" when setting the transfer mode or serial clock.
Note 3: SIOCR1 is write-only register, which cannot access any of in read-modify-write instruction such as bit operate, etc.
SIO Control Register 2
SIOCR2
(0F69H)
7
6
5
4
3
WAIT
Page 152
2
1
BUF
0
(Initial value: ***0 0000)
Write
only
TMP86FS28FG
Always sets "00" except 8-bit transmit / receive mode.
WAIT
Wait control
Number of transfer words
(Buffer address in use)
BUF
00:
Tf = TD(Non wait)
01:
Tf = 2TD(Wait)
10:
Tf = 4TD(Wait)
11:
Tf = 8TD (Wait)
000:
1 word transfer
0F60H
001:
2 words transfer
0F60H ~ 0F61H
010:
3 words transfer
0F60H ~ 0F62H
011:
4 words transfer
0F60H ~ 0F63H
100:
5 words transfer
0F60H ~ 0F64 H
101:
6 words transfer
0F60H ~ 0F65H
110:
7 words transfer
0F60H ~ 0F66 H
111:
8 words transfer
0F60H ~ 0F67H
Write
only
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 0F60H ).
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.
SIO Status Register
SIOSR
7
6
(0F69H)
SIOF
SEF
SIOF
SEF
5
4
3
2
1
Serial transfer operating status monitor
0:
1:
Transfer terminated
Transfer in process
Shift operating status monitor
0:
1:
Shift operation terminated
Shift operation in process
0
Note 1: Tf; Frame time, TD; Data transfer time
Note 2: After SIOS is cleared to "0", SIOF is cleared to "0" at the termination of transfer or the setting of SIOINH to "1".
(output)
SCK output
TD
Tf
Figure 11-2 Frame time (Tf) and Data transfer time (TD)
11.3 Serial clock
11.3.1 Clock source
Internal clock or external clock for the source clock is selected by SIOCR1<SCK>.
Page 153
Read
only
11. Synchronous Serial Interface (SIO)
11.3 Serial clock
TMP86FS28FG
11.3.1.1 Internal clock
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.
Table 11-1 Serial Clock Rate
NORMAL1/2, IDLE1/2 mode
DV7CK = 0
SLOW1/2,
SLEEP1/2 mode
DV7CK = 1
SCK
Clock
Baud Rate
Clock
Baud Rate
Clock
Baud Rate
000
fc/213
1.91 Kbps
fs/25
1024 bps
fs/25
1024 bps
001
fc/28
61.04 Kbps
fc/28
61.04 Kbps
-
-
010
fc/27
122.07 Kbps
fc/27
122.07 Kbps
-
-
011
fc/26
244.14 Kbps
fc/26
244.14 Kbps
-
-
100
fc/25
488.28 Kbps
fc/25
488.28 Kbps
-
-
101
fc/24
976.56 Kbps
fc/24
976.56 Kbps
-
-
110
-
-
-
-
-
-
111
External
External
External
External
External
External
Note: 1 Kbit = 1024 bit (fc = 16 MHz, fs = 32.768 kHz)
Automatically
wait function
SCK
pin (output)
SO
a0
pin (output)
Written transmit
data
a1
a2
a3
a
b0
b
b1
b2
b3
c0
c1
c
Figure 11-3 Automatic Wait Function (at 4-bit transmit mode)
11.3.1.2 External clock
An external clock connected to the SCK pin is used as the serial clock. In this case, output latch of this
port should be set to "1". To ensure shifting, a pulse width of at least 4 machine cycles 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. Therfore, maximum transfer frequency will be 488.3K bit/sec (at fc=16MHz).
SCK
pin (Output)
tcyc = 4/fc (In the NORMAL1/2, IDLE1/2 modes)
4/fs (In the SLOW1/2, SLEEP1/2 modes)
tSCKL, tSCKH > 4tcyc
tSCKL tSCKH
Figure 11-4 External clock pulse width
Page 154
TMP86FS28FG
11.3.2 Shift edge
The leading edge is used to transmit, and the trailing edge is used to receive.
11.3.2.1 Leading edge
Transmitted data are shifted on the leading edge of the serial clock (falling edge of the SCK pin input/
output).
11.3.2.2 Trailing edge
Received data are shifted on the trailing edge of the serial clock (rising edge of the SCK pin input/output).
SCK pin
SO pin
Bit 0
Bit 1
Bit 2
Bit 3
Shift register
3210
*321
**32
***3
Bit 2
Bit 3
(a) Leading edge
SCK pin
SI pin
Shift register
Bit 0
Bit 1
0***
****
10**
210*
3210
*; Don’t care
(b) Trailing edge
Figure 11-5 Shift edge
11.4 Number of bits to transfer
Either 4-bit or 8-bit serial transfer can be selected. When 4-bit serial transfer is selected, only the lower 4 bits of
the transmit/receive data buffer register are used. The upper 4 bits are cleared to “0” when receiving.
The data is transferred in sequence starting at the least significant bit (LSB).
11.5 Number of words to transfer
Up to 8 words consisting of 4 bits of data (4-bit serial transfer) or 8 bits (8-bit serial transfer) of data can be transferred continuously. The number of words to be transferred can be selected by SIOCR2<BUF>.
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.
Page 155
11. Synchronous Serial Interface (SIO)
11.6 Transfer Mode
TMP86FS28FG
SCK pin
SO pin
a0
a1
a2
a3
INTSIO interrupt
(a) 1 word transmit
SCK pin
SO pin
a0
a1
a2
a3
b0
b1
b2
b3
c0
c1
c2
c3
b3
c0
c1
c2
c3
INTSIO interrupt
(b) 3 words transmit
SCK pin
SI pin
a0
a1
a2
a3
b0
b1
b2
INTSIO interrupt
(c) 3 words receive
Figure 11-6 Number of words to transfer (Example: 1word = 4bit)
11.6 Transfer Mode
SIOCR1<SIOM> is used to select the transmit, receive, or transmit/receive mode.
11.6.1 4-bit and 8-bit transfer modes
In these modes, firstly set the SIO control register to the transmit mode, and then write first transmit data
(number of transfer words to be transferred) to the data buffer registers (DBR).
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 transmitted, do
not use the DBR of the remained 5 words.
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.
Page 156
TMP86FS28FG
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
a
DBR
b
Write Write
(a)
(b)
Figure 11-7 Transfer Mode (Example: 8bit, 1word transfer, Internal clock)
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 11-8 Transfer Mode (Example: 8bit, 1word transfer, External clock)
Page 157
11. Synchronous Serial Interface (SIO)
11.6 Transfer Mode
TMP86FS28FG
SCK pin
SIOSR<SIOF>
SO pin
MSB of last word
tSODH = min 3.5/fc [s] ( In the NORMAL1/2, IDLE1/2 modes)
tSODH = min 3.5/fs [s] (In the SLOW1/2, SLEEP1/2 modes)
Figure 11-9 Transmiiied Data Hold Time at End of Transfer
11.6.2 4-bit and 8-bit receive modes
After setting the control registers to the receive mode, set SIOCR1<SIOS> to “1” to enable receiving. The
data are then transferred to the shift register via the SI pin in synchronous with the serial clock. When one word
of data has been received, it is transferred from the shift register to the data buffer register (DBR). When the
number of words specified with the SIOCR2<BUF> has been received, an INTSIO (Buffer full) interrupt is
generated to request that these data be read out. The data are then read from the data buffer registers by the
interrupt service program.
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.
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.
Page 158
TMP86FS28FG
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
Read out
Read out
Figure 11-10 Receive Mode (Example: 8bit, 1word transfer, Internal clock)
11.6.3 8-bit transfer / receive mode
After setting the SIO control register to the 8-bit transmit/receive mode, write the data to be transmitted first
to the data buffer registers (DBR). After that, enable the transmit/receive by setting SIOCR1<SIOS> to “1”.
When transmitting, the data are output from the SO pin at leading edges of the serial clock. When receiving,
the data are input to the SI pin at the trailing edges of the serial clock. When the all receive is enabled, 8-bit
data are transferred from the shift register to the data buffer register. An INTSIO interrupt is generated when
the number of data words specified with the SIOCR2<BUF> has been transferred. Usually, read the receive
data from the buffer register in the interrupt service. The data buffer register is used for both transmitting and
receiving; therefore, always write the data to be transmitted after reading the all received data.
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.
The transmit/receive operation is ended by clearing SIOCR1<SIOS> to “0” or setting SIOCR1<SIOINH> to
“1” in INTSIO interrupt service program.
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.
Page 159
11. Synchronous Serial Interface (SIO)
11.6 Transfer Mode
TMP86FS28FG
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
c
a
DBR
Write (a)
Read out (c)
b
Write (b)
d
Read out (d)
Figure 11-11 Transfer / Receive Mode (Example: 8bit, 1word transfer, Internal clock)
SCK pin
SIOSR<SIOF>
SO pin
Bit 6
Bit 7 of last word
tSODH = min 4/fc [s] ( In the NORMAL1/2, IDLE1/2 modes)
tSODH = min 4/fs [s] (In the SLOW1/2, SLEEP1/2 modes)
Figure 11-12 Transmitted Data Hold Time at End of Transfer / Receive
Page 160
TMP86FS28FG
12. Asynchronous Serial interface (UART1 )
12.1 Configuration
UART control register 1
Transmit data buffer
UART1CR1
TD1BUF
3
Receive data buffer
RD1BUF
2
INTTXD1
Receive control circuit
Transmit control circuit
2
Shift register
Shift register
Parity bit
Stop bit
Noise rejection
circuit
RXD1
TXD1
INTRXD1
Transmit/receive clock
Y
M
P
X
S
fc/13
fc/26
fc/52
fc/104
fc/208
fc/416
INTTC5
fc/96
A
B
C
D
E
F
G
H
A
B
C
6
fc/2
fc/27
8
fc/2
S
2
Y
4
2
Counter
UART1SR
UART1CR2
UART status register
UART control register 2
MPX: Multiplexer
Baud rate generator
Figure 12-1 UART1 (Asynchronous Serial Interface)
Page 161
12. Asynchronous Serial interface (UART1 )
12.2 Control
TMP86FS28FG
12.2 Control
UART1 is controlled by the UART1 Control Registers (UART1CR1, UART1CR2). The operating status can be
monitored using the UART status register (UART1SR).
UART1 Control Register1
UART1CR1
(0FE8H)
7
6
5
4
3
TXE
RXE
STBT
EVEN
PE
2
1
0
BRG
(Initial value: 0000 0000)
TXE
Transfer operation
0:
1:
Disable
Enable
RXE
Receive operation
0:
1:
Disable
Enable
STBT
Transmit stop bit length
0:
1:
1 bit
2 bits
EVEN
Even-numbered parity
0:
1:
Odd-numbered parity
Even-numbered parity
Parity addition
0:
1:
No parity
Parity
PE
BRG
000:
001:
010:
011:
100:
101:
110:
111:
Transmit clock select
Write
only
fc/13 [Hz]
fc/26
fc/52
fc/104
fc/208
fc/416
TC5 ( Input INTTC5)
fc/96
Note 1: When operations are disabled by setting TXE and RXE bit 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: UART1CR1<RXE> and UART1CR1<TXE> should be set to “0” before UART1CR1<BRG> is changed.
UART1 Control Register2
UART1CR2
(0FE9H)
7
6
5
4
3
2
1
0
RXDNC
RXDNC
Selection of RXD input noise
rejection time
STOPBR
Receive stop bit length
00:
01:
10:
11:
0:
1:
STOPBR
(Initial value: **** *000)
No noise rejection (Hysteresis input)
Rejects pulses shorter than 31/fc [s] as noise
Rejects pulses shorter than 63/fc [s] as noise
Rejects pulses shorter than 127/fc [s] as noise
Write
only
1 bit
2 bits
Note: When UART1CR2<RXDNC> = “01”, pulses longer than 96/fc [s] are always regarded as signals; when
UART1CR2<RXDNC> = “10”, longer than 192/fc [s]; and when UART1CR2<RXDNC> = “11”, longer than 384/fc [s].
Page 162
TMP86FS28FG
UART1 Status Register
UART1SR
(0FE8H)
7
6
5
4
3
2
1
PERR
FERR
OERR
RBFL
TEND
TBEP
0
(Initial value: 0000 11**)
PERR
Parity error flag
0:
1:
No parity error
Parity error
FERR
Framing error flag
0:
1:
No framing error
Framing error
OERR
Overrun error flag
0:
1:
No overrun error
Overrun error
RBFL
Receive data buffer full flag
0:
1:
Receive data buffer empty
Receive data buffer full
TEND
Transmit end flag
0:
1:
On transmitting
Transmit end
TBEP
Transmit data buffer empty flag
0:
1:
Transmit data buffer full (Transmit data writing is finished)
Transmit data buffer empty
Note: When an INTTXD is generated, TBEP flag is set to "1" automatically.
UART1 Receive Data Buffer
RD1BUF
(0FEAH)
7
6
5
4
3
2
1
0
Read only
(Initial value: 0000 0000)
UART1 Transmit Data Buffer
TD1BUF
(0FEAH)
7
6
5
4
3
2
1
0
Write only
(Initial value: 0000 0000)
Page 163
Read
only
12. Asynchronous Serial interface (UART1 )
12.3 Transfer Data Format
TMP86FS28FG
12.3 Transfer Data Format
In UART1, an one-bit start bit (Low level), stop bit (Bit length selectable at high level, by UART1CR1<STBT>),
and parity (Select parity in UART1CR1<PE>; even- or odd-numbered parity by UART1CR1<EVEN>) are added to
the transfer data. The transfer data formats are shown as follows.
PE
STBT
0
Frame Length
8
1
2
3
9
10
0
Start
Bit 0
Bit 1
0
1
Start
Bit 0
1
0
Start
1
1
Start
11
Bit 6
Bit 7
Stop 1
Bit 1
Bit 6
Bit 7
Stop 1
Stop 2
Bit 0
Bit 1
Bit 6
Bit 7
Parity
Stop 1
Bit 0
Bit 1
Bit 6
Bit 7
Parity
Stop 1
12
Stop 2
Figure 12-2 Transfer Data Format
Without parity / 1 STOP bit
With parity / 1 STOP bit
Without parity / 2 STOP bit
With parity / 2 STOP bit
Figure 12-3 Caution on Changing Transfer Data Format
Note: In order to switch the transfer data format, perform transmit operations in the above Figure 12-3 sequence except
for the initial setting.
Page 164
TMP86FS28FG
12.4 Transfer Rate
The baud rate of UART1 is set of UART1CR1<BRG>. The example of the baud rate are shown as follows.
Table 12-1 Transfer Rate (Example)
Source Clock
BRG
16 MHz
8 MHz
4 MHz
000
76800 [baud]
38400 [baud]
19200 [baud]
001
38400
19200
9600
010
19200
9600
4800
011
9600
4800
2400
100
4800
2400
1200
101
2400
1200
600
When TC5 is used as the UART1 transfer rate (when UART1CR1<BRG> = “110”), the transfer clock and transfer
rate are determined as follows:
Transfer clock [Hz] = TC5 source clock [Hz] / TTREG5 setting value
Transfer Rate [baud] = Transfer clock [Hz] / 16
12.5 Data Sampling Method
The UART1 receiver keeps sampling input using the clock selected by UART1CR1<BRG> until a start bit is
detected in RXD1 pin input. RT clock starts detecting “L” level of the RXD1 pin. Once a start bit is detected, the
start bit, data bits, stop bit(s), and parity bit are sampled at three times of RT7, RT8, and RT9 during one receiver
clock interval (RT clock). (RT0 is the position where the bit supposedly starts.) Bit is determined according to majority rule (The data are the same twice or more out of three samplings).
RXD1 pin
Start bit
RT0
1
2
3
Bit 0
4
5
6
7
8
9 10 11 12 13 14 15 0
1
2
3
4
5
6
7
8
9 10 11
2
3
4
5
6
7
8
9 10 11
RT clock
Start bit
Internal receive data
Bit 0
(a) Without noise rejection circuit
RXD1 pin
Start bit
RT0
1
2
3
Bit 0
4
5
6
7
8
9 10 11 12 13 14 15 0
1
RT clock
Internal receive data
Start bit
Bit 0
(b) With noise rejection circuit
Figure 12-4 Data Sampling Method
Page 165
12. Asynchronous Serial interface (UART1 )
12.6 STOP Bit Length
TMP86FS28FG
12.6 STOP Bit Length
Select a transmit stop bit length (1 bit or 2 bits) by UART1CR1<STBT>.
12.7 Parity
Set parity / no parity by UART1CR1<PE> and set parity type (Odd- or Even-numbered) by
UART1CR1<EVEN>.
12.8 Transmit/Receive Operation
12.8.1 Data Transmit Operation
Set UART1CR1<TXE> to “1”. Read UART1SR to check UART1SR<TBEP> = “1”, then write data in
TD1BUF (Transmit data buffer). Writing data in TD1BUF zero-clears UART1SR<TBEP>, transfers the data
to the transmit shift register and the data are sequentially output from the TXD1 pin. The data output include a
one-bit start bit, stop bits whose number is specified in UART1CR1<STBT> and a parity bit if parity addition
is specified. Select the data transfer baud rate using UART1CR1<BRG>. When data transmit starts, transmit
buffer empty flag UART1SR<TBEP> is set to “1” and an INTTXD1 interrupt is generated.
While UART1CR1<TXE> = “0” and from when “1” is written to UART1CR1<TXE> to when send data are
written to TD1BUF, the TXD1 pin is fixed at high level.
When transmitting data, first read UART1SR, then write data in TD1BUF. Otherwise, UART1SR<TBEP> is
not zero-cleared and transmit does not start.
12.8.2 Data Receive Operation
Set UART1CR1<RXE> to “1”. When data are received via the RXD1 pin, the receive data are transferred to
RD1BUF (Receive data buffer). At this time, the data transmitted includes a start bit and stop bit(s) and a parity
bit if parity addition is specified. When stop bit(s) are received, data only are extracted and transferred to
RD1BUF (Receive data buffer). Then the receive buffer full flag UART1SR<RBFL> is set and an INTRXD1
interrupt is generated. Select the data transfer baud rate using UART1CR1<BRG>.
If an overrun error (OERR) occurs when data are received, the data are not transferred to RD1BUF (Receive
data buffer) but discarded; data in the RD1BUF are not affected.
Note:When a receive operation is disabled by setting UART1CR1<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 166
TMP86FS28FG
12.9 Status Flag
12.9.1 Parity Error
When parity determined using the receive data bits differs from the received parity bit, the parity error flag
UART1SR<PERR> is set to “1”. The UART1SR<PERR> is cleared to “0” when the RD1BUF is read after
reading the UART1SR.
RXD1 pin
Shift register
Parity
Stop
pxxxx0*
xxxx0**
1pxxxx0
UART1SR<PERR>
After reading UART1SR then
RD1BUF clears PERR.
INTRXD1 interrupt
Figure 12-5 Generation of Parity Error
12.9.2 Framing Error
When “0” is sampled as the stop bit in the receive data, framing error flag UART1SR<FERR> is set to “1”.
The UART1SR<FERR> is cleared to “0” when the RD1BUF is read after reading the UART1SR.
RXD1 pin
Shift register
Stop
Final bit
xxxx0*
xxx0**
0xxxx0
After reading UART1SR then
RD1BUF clears FERR.
UART1SR<FERR>
INTRXD1 interrupt
Figure 12-6 Generation of Framing Error
12.9.3 Overrun Error
When all bits in the next data are received while unread data are still in RD1BUF, overrun error flag
UART1SR<OERR> is set to “1”. In this case, the receive data is discarded; data in RD1BUF are not affected.
The UART1SR<OERR> is cleared to “0” when the RD1BUF is read after reading the UART1SR.
Page 167
12. Asynchronous Serial interface (UART1 )
12.9 Status Flag
TMP86FS28FG
UART1SR<RBFL>
RXD1 pin
Stop
Final bit
Shift register
xxx0**
RD1BUF
yyyy
xxxx0*
1xxxx0
UART1SR<OERR>
After reading UART1SR then
RD1BUF clears OERR.
INTRXD1 interrupt
Figure 12-7 Generation of Overrun Error
Note:Receive operations are disabled until the overrun error flag UART1SR<OERR> is cleared.
12.9.4 Receive Data Buffer Full
Loading the received data in RD1BUF sets receive data buffer full flag UART1SR<RBFL> to "1". The
UART1SR<RBFL> is cleared to “0” when the RD1BUF is read after reading the UART1SR.
RXD1 pin
Stop
Final bit
Shift register
xxx0**
RD1BUF
yyyy
xxxx0*
1xxxx0
xxxx
After reading UART1SR then
RD1BUF clears RBFL.
UART1SR<RBFL>
INTRXD1 interrupt
Figure 12-8 Generation of Receive Data Buffer Full
Note:If the overrun error flag UART1SR<OERR> is set during the period between reading the UART1SR and reading the RD1BUF, it cannot be cleared by only reading the RD1BUF. Therefore, after reading the RD1BUF,
read the UART1SR again to check whether or not the overrun error flag which should have been cleared still
remains set.
12.9.5 Transmit Data Buffer Empty
When no data is in the transmit buffer TD1BUF, that is, when data in TD1BUF are transferred to the transmit
shift register and data transmit starts, transmit data buffer empty flag UART1SR<TBEP> is set to “1”. The
UART1SR<TBEP> is cleared to “0” when the TD1BUF is written after reading the UART1SR.
Page 168
TMP86FS28FG
Data write
TD1BUF
xxxx
*****1
Shift register
TXD1 pin
Data write
zzzz
yyyy
1xxxx0
*1xxxx
****1x
*****1
Start
Bit 0
Final bit
Stop
1yyyy0
UART1SR<TBEP>
After reading UART1SR writing
TD1BUF clears TBEP.
INTTXD1 interrupt
Figure 12-9 Generation of Transmit Data Buffer Empty
12.9.6 Transmit End Flag
When data are transmitted and no data is in TD1BUF (UART1SR<TBEP> = “1”), transmit end flag
UART1SR<TEND> is set to “1”. The UART1SR<TEND> is cleared to “0” when the data transmit is started
after writing the TD1BUF.
Shift register
TXD1 pin
***1xx
****1x
*****1
1yyyy0
Stop
Start
*1yyyy
Bit 0
Data write for TD1BUF
UART1SR<TBEP>
UART1SR<TEND>
INTTXD1 interrupt
Figure 12-10 Generation of Transmit End Flag and Transmit Data Buffer Empty
Page 169
12. Asynchronous Serial interface (UART1 )
12.9 Status Flag
TMP86FS28FG
Page 170
TMP86FS28FG
13. Asynchronous Serial interface (UART0 )
13.1 Configuration
UART control register 1
Transmit data buffer
UART0CR1
TD0BUF
3
Receive data buffer
RD0BUF
2
INTTXD0
Receive control circuit
Transmit control circuit
2
Shift register
Shift register
Parity bit
Stop bit
Noise rejection
circuit
RXD0
TXD0
INTRXD0
Transmit/receive clock
Y
M
P
X
S
fc/13
fc/26
fc/52
fc/104
fc/208
fc/416
INTTC3
fc/96
A
B
C
D
E
F
G
H
A
B
C
6
fc/2
fc/27
8
fc/2
S
2
Y
4
2
Counter
UART0SR
UART0CR2
UART status register
UART control register 2
MPX: Multiplexer
Baud rate generator
Figure 13-1 UART0 (Asynchronous Serial Interface)
Page 171
13. Asynchronous Serial interface (UART0 )
13.2 Control
TMP86FS28FG
13.2 Control
UART0 is controlled by the UART0 Control Registers (UART0CR1, UART0CR2). The operating status can be
monitored using the UART status register (UART0SR).
UART0 Control Register1
UART0CR1
(0FE5H)
7
6
5
4
3
TXE
RXE
STBT
EVEN
PE
2
1
0
BRG
(Initial value: 0000 0000)
TXE
Transfer operation
0:
1:
Disable
Enable
RXE
Receive operation
0:
1:
Disable
Enable
STBT
Transmit stop bit length
0:
1:
1 bit
2 bits
EVEN
Even-numbered parity
0:
1:
Odd-numbered parity
Even-numbered parity
Parity addition
0:
1:
No parity
Parity
PE
BRG
000:
001:
010:
011:
100:
101:
110:
111:
Transmit clock select
Write
only
fc/13 [Hz]
fc/26
fc/52
fc/104
fc/208
fc/416
TC3 ( Input INTTC3)
fc/96
Note 1: When operations are disabled by setting TXE and RXE bit 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: UART0CR1<RXE> and UART0CR1<TXE> should be set to “0” before UART0CR1<BRG> is changed.
UART0 Control Register2
UART0CR2
(0FE6H)
7
6
5
4
3
2
1
0
RXDNC
RXDNC
Selection of RXD input noise
rejection time
STOPBR
Receive stop bit length
00:
01:
10:
11:
0:
1:
STOPBR
(Initial value: **** *000)
No noise rejection (Hysteresis input)
Rejects pulses shorter than 31/fc [s] as noise
Rejects pulses shorter than 63/fc [s] as noise
Rejects pulses shorter than 127/fc [s] as noise
Write
only
1 bit
2 bits
Note: When UART0CR2<RXDNC> = “01”, pulses longer than 96/fc [s] are always regarded as signals; when
UART0CR2<RXDNC> = “10”, longer than 192/fc [s]; and when UART0CR2<RXDNC> = “11”, longer than 384/fc [s].
Page 172
TMP86FS28FG
UART0 Status Register
UART0SR
(0FE5H)
7
6
5
4
3
2
1
PERR
FERR
OERR
RBFL
TEND
TBEP
0
(Initial value: 0000 11**)
PERR
Parity error flag
0:
1:
No parity error
Parity error
FERR
Framing error flag
0:
1:
No framing error
Framing error
OERR
Overrun error flag
0:
1:
No overrun error
Overrun error
RBFL
Receive data buffer full flag
0:
1:
Receive data buffer empty
Receive data buffer full
TEND
Transmit end flag
0:
1:
On transmitting
Transmit end
TBEP
Transmit data buffer empty flag
0:
1:
Transmit data buffer full (Transmit data writing is finished)
Transmit data buffer empty
Note: When an INTTXD is generated, TBEP flag is set to "1" automatically.
UART0 Receive Data Buffer
RD0BUF
(0FE7H)
7
6
5
4
3
2
1
0
Read only
(Initial value: 0000 0000)
UART0 Transmit Data Buffer
TD0BUF
(0FE7H)
7
6
5
4
3
2
1
0
Write only
(Initial value: 0000 0000)
Page 173
Read
only
13. Asynchronous Serial interface (UART0 )
13.3 Transfer Data Format
TMP86FS28FG
13.3 Transfer Data Format
In UART0, an one-bit start bit (Low level), stop bit (Bit length selectable at high level, by UART0CR1<STBT>),
and parity (Select parity in UART0CR1<PE>; even- or odd-numbered parity by UART0CR1<EVEN>) are added to
the transfer data. The transfer data formats are shown as follows.
PE
STBT
0
Frame Length
8
1
2
3
9
10
0
Start
Bit 0
Bit 1
0
1
Start
Bit 0
1
0
Start
1
1
Start
11
Bit 6
Bit 7
Stop 1
Bit 1
Bit 6
Bit 7
Stop 1
Stop 2
Bit 0
Bit 1
Bit 6
Bit 7
Parity
Stop 1
Bit 0
Bit 1
Bit 6
Bit 7
Parity
Stop 1
12
Stop 2
Figure 13-2 Transfer Data Format
Without parity / 1 STOP bit
With parity / 1 STOP bit
Without parity / 2 STOP bit
With parity / 2 STOP bit
Figure 13-3 Caution on Changing Transfer Data Format
Note: In order to switch the transfer data format, perform transmit operations in the above Figure 13-3 sequence except
for the initial setting.
Page 174
TMP86FS28FG
13.4 Transfer Rate
The baud rate of UART0 is set of UART0CR1<BRG>. The example of the baud rate are shown as follows.
Table 13-1 Transfer Rate (Example)
Source Clock
BRG
16 MHz
8 MHz
4 MHz
000
76800 [baud]
38400 [baud]
19200 [baud]
001
38400
19200
9600
010
19200
9600
4800
011
9600
4800
2400
100
4800
2400
1200
101
2400
1200
600
When TC3 is used as the UART0 transfer rate (when UART0CR1<BRG> = “110”), the transfer clock and transfer
rate are determined as follows:
Transfer clock [Hz] = TC3 source clock [Hz] / TTREG3 setting value
Transfer Rate [baud] = Transfer clock [Hz] / 16
13.5 Data Sampling Method
The UART0 receiver keeps sampling input using the clock selected by UART0CR1<BRG> until a start bit is
detected in RXD0 pin input. RT clock starts detecting “L” level of the RXD0 pin. Once a start bit is detected, the
start bit, data bits, stop bit(s), and parity bit are sampled at three times of RT7, RT8, and RT9 during one receiver
clock interval (RT clock). (RT0 is the position where the bit supposedly starts.) Bit is determined according to majority rule (The data are the same twice or more out of three samplings).
RXD0 pin
Start bit
RT0
1
2
3
Bit 0
4
5
6
7
8
9 10 11 12 13 14 15 0
1
2
3
4
5
6
7
8
9 10 11
2
3
4
5
6
7
8
9 10 11
RT clock
Start bit
Internal receive data
Bit 0
(a) Without noise rejection circuit
RXD0 pin
Start bit
RT0
1
2
3
Bit 0
4
5
6
7
8
9 10 11 12 13 14 15 0
1
RT clock
Internal receive data
Start bit
Bit 0
(b) With noise rejection circuit
Figure 13-4 Data Sampling Method
Page 175
13. Asynchronous Serial interface (UART0 )
13.6 STOP Bit Length
TMP86FS28FG
13.6 STOP Bit Length
Select a transmit stop bit length (1 bit or 2 bits) by UART0CR1<STBT>.
13.7 Parity
Set parity / no parity by UART0CR1<PE> and set parity type (Odd- or Even-numbered) by
UART0CR1<EVEN>.
13.8 Transmit/Receive Operation
13.8.1 Data Transmit Operation
Set UART0CR1<TXE> to “1”. Read UART0SR to check UART0SR<TBEP> = “1”, then write data in
TD0BUF (Transmit data buffer). Writing data in TD0BUF zero-clears UART0SR<TBEP>, transfers the data
to the transmit shift register and the data are sequentially output from the TXD0 pin. The data output include a
one-bit start bit, stop bits whose number is specified in UART0CR1<STBT> and a parity bit if parity addition
is specified. Select the data transfer baud rate using UART0CR1<BRG>. When data transmit starts, transmit
buffer empty flag UART0SR<TBEP> is set to “1” and an INTTXD0 interrupt is generated.
While UART0CR1<TXE> = “0” and from when “1” is written to UART0CR1<TXE> to when send data are
written to TD0BUF, the TXD0 pin is fixed at high level.
When transmitting data, first read UART0SR, then write data in TD0BUF. Otherwise, UART0SR<TBEP> is
not zero-cleared and transmit does not start.
13.8.2 Data Receive Operation
Set UART0CR1<RXE> to “1”. When data are received via the RXD0 pin, the receive data are transferred to
RD0BUF (Receive data buffer). At this time, the data transmitted includes a start bit and stop bit(s) and a parity
bit if parity addition is specified. When stop bit(s) are received, data only are extracted and transferred to
RD0BUF (Receive data buffer). Then the receive buffer full flag UART0SR<RBFL> is set and an INTRXD0
interrupt is generated. Select the data transfer baud rate using UART0CR1<BRG>.
If an overrun error (OERR) occurs when data are received, the data are not transferred to RD0BUF (Receive
data buffer) but discarded; data in the RD0BUF are not affected.
Note:When a receive operation is disabled by setting UART0CR1<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 176
TMP86FS28FG
13.9 Status Flag
13.9.1 Parity Error
When parity determined using the receive data bits differs from the received parity bit, the parity error flag
UART0SR<PERR> is set to “1”. The UART0SR<PERR> is cleared to “0” when the RD0BUF is read after
reading the UART0SR.
RXD0 pin
Shift register
Parity
Stop
pxxxx0*
xxxx0**
1pxxxx0
UART0SR<PERR>
After reading UART0SR then
RD0BUF clears PERR.
INTRXD0 interrupt
Figure 13-5 Generation of Parity Error
13.9.2 Framing Error
When “0” is sampled as the stop bit in the receive data, framing error flag UART0SR<FERR> is set to “1”.
The UART0SR<FERR> is cleared to “0” when the RD0BUF is read after reading the UART0SR.
RXD0 pin
Shift register
Stop
Final bit
xxxx0*
xxx0**
0xxxx0
After reading UART0SR then
RD0BUF clears FERR.
UART0SR<FERR>
INTRXD0 interrupt
Figure 13-6 Generation of Framing Error
13.9.3 Overrun Error
When all bits in the next data are received while unread data are still in RD0BUF, overrun error flag
UART0SR<OERR> is set to “1”. In this case, the receive data is discarded; data in RD0BUF are not affected.
The UART0SR<OERR> is cleared to “0” when the RD0BUF is read after reading the UART0SR.
Page 177
13. Asynchronous Serial interface (UART0 )
13.9 Status Flag
TMP86FS28FG
UART0SR<RBFL>
RXD0 pin
Stop
Final bit
Shift register
xxx0**
RD0BUF
yyyy
xxxx0*
1xxxx0
UART0SR<OERR>
After reading UART0SR then
RD0BUF clears OERR.
INTRXD0 interrupt
Figure 13-7 Generation of Overrun Error
Note:Receive operations are disabled until the overrun error flag UART0SR<OERR> is cleared.
13.9.4 Receive Data Buffer Full
Loading the received data in RD0BUF sets receive data buffer full flag UART0SR<RBFL> to "1". The
UART0SR<RBFL> is cleared to “0” when the RD0BUF is read after reading the UART0SR.
RXD0 pin
Stop
Final bit
Shift register
xxx0**
RD0BUF
yyyy
xxxx0*
1xxxx0
xxxx
After reading UART0SR then
RD0BUF clears RBFL.
UART0SR<RBFL>
INTRXD0 interrupt
Figure 13-8 Generation of Receive Data Buffer Full
Note:If the overrun error flag UART0SR<OERR> is set during the period between reading the UART0SR and reading the RD0BUF, it cannot be cleared by only reading the RD0BUF. Therefore, after reading the RD0BUF,
read the UART0SR again to check whether or not the overrun error flag which should have been cleared still
remains set.
13.9.5 Transmit Data Buffer Empty
When no data is in the transmit buffer TD0BUF, that is, when data in TD0BUF are transferred to the transmit
shift register and data transmit starts, transmit data buffer empty flag UART0SR<TBEP> is set to “1”. The
UART0SR<TBEP> is cleared to “0” when the TD0BUF is written after reading the UART0SR.
Page 178
TMP86FS28FG
Data write
TD0BUF
xxxx
*****1
Shift register
TXD0 pin
Data write
zzzz
yyyy
1xxxx0
*1xxxx
****1x
*****1
Start
Bit 0
Final bit
Stop
1yyyy0
UART0SR<TBEP>
After reading UART0SR writing
TD0BUF clears TBEP.
INTTXD0 interrupt
Figure 13-9 Generation of Transmit Data Buffer Empty
13.9.6 Transmit End Flag
When data are transmitted and no data is in TD0BUF (UART0SR<TBEP> = “1”), transmit end flag
UART0SR<TEND> is set to “1”. The UART0SR<TEND> is cleared to “0” when the data transmit is started
after writing the TD0BUF.
Shift register
TXD0 pin
***1xx
****1x
*****1
1yyyy0
Stop
Start
*1yyyy
Bit 0
Data write for TD0BUF
UART0SR<TBEP>
UART0SR<TEND>
INTTXD0 interrupt
Figure 13-10 Generation of Transmit End Flag and Transmit Data Buffer Empty
Page 179
13. Asynchronous Serial interface (UART0 )
13.9 Status Flag
TMP86FS28FG
Page 180
TMP86FS28FG
14. 10-bit AD Converter (ADC)
The TMP86FS28FG have a 10-bit successive approximation type AD converter.
14.1 Configuration
The circuit configuration of the 10-bit AD converter is shown in Figure 14-1.
It consists of control register ADCCR1 and ADCCR2, converted value register ADCDR1 and ADCDR2, a DA
converter, a sample-hold circuit, a comparator, and a successive comparison circuit.
DA converter
VAREF
AVSS
R/2
R
R/2
AVDD
Analog input
multiplexer
AIN0
A
Sample hold
circuit
Reference
voltage
Y
10
Analog
comparator
n
S EN
Successive approximate circuit
Shift clock
AINDS
ADRS
SAIN
INTADC
Control circuit
4
ADCCR1
2
AMD
IREFON
AIN7
3
ACK
ADCCR2
AD converter control register 1, 2
8
ADCDR1
2
EOCF ADBF
ADCDR2
AD conversion result register 1, 2
Note: Before using AD converter, set appropriate value to I/O port register conbining a analog input port. For details, see the section on "I/O ports".
Figure 14-1 10-bit AD Converter
Page 181
14. 10-bit AD Converter (ADC)
14.2 Register configuration
TMP86FS28FG
14.2 Register configuration
The AD converter consists of the following four registers:
1. AD converter control register 1 (ADCCR1)
This register selects the analog channels and operation mode (Software start or repeat) in which to perform AD conversion and controls the AD converter as it starts operating.
2. AD converter control register 2 (ADCCR2)
This register selects the AD conversion time and controls the connection of the DA converter (Ladder
resistor network).
3. AD converted value register 1 (ADCDR1)
This register used to store the digital value fter being converted by the AD converter.
4. AD converted value register 2 (ADCDR2)
This register monitors the operating status of the AD converter.
AD Converter Control Register 1
ADCCR1
(0FE2H)
7
ADRS
6
5
AMD
4
3
2
AINDS
1
SAIN
AD conversion start
0:
1:
AD conversion start
AMD
AD operating mode
00:
01:
10:
11:
AD operation disable
Software start mode
Reserved
Repeat mode
AINDS
Analog input control
0:
1:
Analog input enable
Analog input disable
Analog input channel select
0000:
0001:
0010:
0011:
0100:
0101:
0110:
0111:
1000:
1001:
1010:
1011:
1100:
1101:
1110:
1111:
AIN0
AIN1
AIN2
AIN3
AIN4
AIN5
AIN6
AIN7
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
ADRS
SAIN
0
(Initial value: 0001 0000)
R/W
Note 1: Select analog input channel during AD converter stops (ADCDR2<ADBF> = "0").
Note 2: When the analog input channel is all use disabling, the ADCCR1<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 ADCCR1<ADRS> is automatically cleared to "0" after starting conversion.
Note 5: Do not set ADCCR1<ADRS> newly again during AD conversion. Before setting ADCCR1<ADRS> newly again, check
ADCDR2<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 or SLOW/SLEEP mode are started, AD converter control register1 (ADCCR1) is all initialized and no data can
be written in this register. Therfore, to use AD converter again, set the ADCCR1 newly after returning to NORMAL1 or
NORMAL2 mode.
Page 182
TMP86FS28FG
AD Converter Control Register 2
7
ADCCR2
(0FE3H)
6
IREFON
ACK
5
4
3
IREFON
"1"
2
1
ACK
0
"0"
(Initial value: **0* 000*)
DA converter (Ladder resistor) connection
control
0:
1:
Connected only during AD conversion
Always connected
AD conversion time select
(Refer to the following table about the conversion time)
000:
001:
010:
011:
100:
101:
110:
111:
39/fc
Reserved
78/fc
156/fc
312/fc
624/fc
1248/fc
Reserved
R/W
Note 1: Always set bit0 in ADCCR2 to "0" and set bit4 in ADCCR2 to "1".
Note 2: When a read instruction for ADCCR2, bit6 to 7 in ADCCR2 read in as undefined data.
Note 3: After STOP or SLOW/SLEEP mode are started, AD converter control register2 (ADCCR2) is all initialized and no data can
be written in this register. Therfore, to use AD converter again, set the ADCCR2 newly after returning to NORMAL1 or
NORMAL2 mode.
Table 14-1 ACK setting and Conversion time
Condition
ACK
000
Conversion
time
16 MHz
8 MHz
4 MHz
2 MHz
10 MHz
5 MHz
2.5 MHz
39/fc
-
-
-
19.5 µs
-
-
15.6 µs
001
Reserved
010
78/fc
-
-
19.5 µs
39.0 µs
-
15.6 µs
31.2 µs
011
156/fc
-
19.5 µs
39.0 µs
78.0 µs
15.6 µs
31.2 µs
62.4 µs
100
312/fc
19.5 µs
39.0 µs
78.0 µs
156.0 µs
31.2 µs
62.4 µs
124.8 µs
101
624/fc
39.0 µs
78.0 µs
156.0 µs
-
62.4 µs
124.8 µs
-
110
1248/fc
78.0 µs
156.0 µs
-
-
124.8 µs
-
-
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) .
-
VAREF = 4.5 to 5.5 V
15.6 µs and more
-
VAREF = 2.7 to 5.5 V
31.2 µs and more
AD Converted value Register 1
ADCDR1
(0FE1H)
7
6
5
4
3
2
1
0
AD09
AD08
AD07
AD06
AD05
AD04
AD03
AD02
3
2
1
0
(Initial value: 0000 0000)
AD Converted value Register 2
ADCDR2
(0FE0H)
7
6
5
4
AD01
AD00
EOCF
ADBF
(Initial value: 0000 ****)
Page 183
14. 10-bit AD Converter (ADC)
14.2 Register configuration
TMP86FS28FG
EOCF
ADBF
AD conversion end flag
0:
1:
Before or during conversion
Conversion completed
AD conversion BUSY flag
0:
1:
During stop of AD conversion
During AD conversion
Read
only
Note 1: The ADCDR2<EOCF> is cleared to "0" when reading the ADCDR1. Therfore, the AD conversion result should be read to
ADCDR2 more first than ADCDR1.
Note 2: The ADCDR2<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 or SLOW mode .
Note 3: If a read instruction is executed for ADCDR2, read data of bit3 to bit0 are unstable.
Page 184
TMP86FS28FG
14.3 Function
14.3.1 Software Start Mode
After setting ADCCR1<AMD> to “01” (software start mode), set ADCCR1<ADRS> to “1”. AD conversion of the voltage at the analog input pin specified by ADCCR1<SAIN> is thereby started.
After completion of the AD conversion, the conversion result is stored in AD converted value registers
(ADCDR1, ADCDR2) and at the same time ADCDR2<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 ADCCR1<ADRS> newly again
(Restart) during AD conversion. Before setting ADRS newly again, check ADCDR2<EOCF> to see that the
conversion is completed or wait until the interrupt signal (INTADC) is generated (e.g., interrupt handling routine).
AD conversion start
AD conversion start
ADCCR1<ADRS>
ADCDR2<ADBF>
ADCDR1 status
Indeterminate
1st conversion result
2nd conversion result
EOCF cleared by reading
conversion result
ADCDR2<EOCF>
INTADC interrupt request
ADCDR1
ADCDR2
Conversion result
read
Conversion result
read
Conversion result
read
Conversion result
read
Figure 14-2 Software Start Mode
14.3.2 Repeat Mode
AD conversion of the voltage at the analog input pin specified by ADCCR1<SAIN> is performed repeatedly.
In this mode, AD conversion is started by setting ADCCR1<ADRS> to “1” after setting ADCCR1<AMD> to
“11” (Repeat mode).
After completion of the AD conversion, the conversion result is stored in AD converted value registers
(ADCDR1, ADCDR2) and at the same time ADCDR2<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 ADCCR1<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 185
14. 10-bit AD Converter (ADC)
14.3 Function
TMP86FS28FG
ADCCR1<AMD>
“11”
“00”
AD conversion start
ADCCR1<ADRS>
1st conversion
result
Conversion operation
Indeterminate
ADCDR1,ADCDR2
2nd conversion result
3rd conversion result
1st conversion result
2nd conversion result
AD convert operation suspended.
Conversion result is not stored.
3rd conversion result
ADCDR2<EOCF>
EOCF cleared by reading
conversion result
INTADC interrupt request
ADCDR1
Conversion
result read
ADCDR2
Conversion
result read
Conversion
result read
Conversion
result read
Conversion
result read
Conversion
result read
Figure 14-3 Repeat Mode
14.3.3
Register Setting
1. Set up the AD converter control register 1 (ADCCR1) as follows:
• Choose the channel to AD convert using AD input channel select (SAIN).
• Specify analog input enable for analog input control (AINDS).
• Specify AMD for the AD converter control operation mode (software or repeat mode).
2. Set up the AD converter control register 2 (ADCCR2) as follows:
• Set the AD conversion time using AD conversion time (ACK). For details on how to set the conversion time, refer to Figure 14-1 and AD converter control register 2.
• Choose IREFON for DA converter control.
3. After setting up (1) and (2) above, set AD conversion start (ADRS) of AD converter control register 1
(ADCCR1) to “1”. If software start mode has been selected, AD conversion starts immediately.
4. After an elapse of the specified AD conversion time, the AD converted value is stored in AD converted value register 1 (ADCDR1) and the AD conversion finished flag (EOCF) of AD converted
value register 2 (ADCDR2) is set to “1”, upon which time AD conversion interrupt INTADC is generated.
5. EOCF is cleared to “0” by a read of the conversion result. However, if reconverted before a register
read, although EOCF is cleared the previous conversion result is retained until the next conversion is
completed.
Page 186
TMP86FS28FG
Example :After selecting the conversion time 19.5 µs at 16 MHz and the analog input channel AIN3 pin, perform AD conversion once. After checking EOCF, read the converted value, store the lower 2 bits in address 0009EH nd store
the upper 8 bits in address 0009FH in RAM. The operation mode is software start mode.
SLOOP :
: (port setting)
:
;Set port register approrriately before setting AD
converter registers.
:
:
(Refer to section I/O port in details)
LD
(ADCCR1) , 00100011B
; Select AIN3
LD
(ADCCR2) , 11011000B
;Select conversion time(312/fc) and operation
mode
SET
(ADCCR1) . 7
; ADRS = 1(AD conversion start)
TEST
(ADCDR2) . 5
; EOCF= 1 ?
JRS
T, SLOOP
LD
A , (ADCDR2)
LD
(9EH) , A
LD
A , (ADCDR1)
LD
(9FH), A
; Read result data
; Read result data
14.4 STOP/SLOW Modes during AD Conversion
When standby mode (STOP or SLOW mode) is entered forcibly during AD conversion, the AD convert operation
is suspended and the AD converter is initialized (ADCCR1 and ADCCR2 are initialized to initial value). Also, the
conversion result is indeterminate. (Conversion results up to the previous operation are cleared, so be sure to read
the conversion results before entering standby mode (STOP or SLOW mode).) When restored from standby mode
(STOP or SLOW mode), AD conversion is not automatically restarted, so it is necessary to restart AD conversion.
Note that since the analog reference voltage is automatically disconnected, there is no possibility of current flowing
into the analog reference voltage.
Page 187
14. 10-bit AD Converter (ADC)
14.5 Analog Input Voltage and AD Conversion Result
TMP86FS28FG
14.5 Analog Input Voltage and AD Conversion Result
The analog input voltage is corresponded to the 10-bit digital value converted by the AD as shown in Figure 14-4.
3FFH
3FEH
3FDH
AD
conversion
result
03H
02H
01H
VAREF
0
1
2
3
1021 1022 1023 1024
Analog input voltage
AVSS
1024
Figure 14-4 Analog Input Voltage and AD Conversion Result (Typ.)
Page 188
TMP86FS28FG
14.6 Precautions about AD Converter
14.6.1 Analog input pin voltage range
Make sure the analog input pins (AIN0 to AIN7) are used at voltages within VAREF to AVSS. If any voltage
outside this range is applied to one of the analog input pins, the converted value on that pin becomes uncertain.
The other analog input pins also are affected by that.
14.6.2 Analog input shared pins
The analog input pins (AIN0 to AIN7) are shared with input/output ports. When using any of the analog
inputs to execute AD conversion, do not execute input/output instructions for all other ports. This is necessary
to prevent the accuracy of AD conversion from degrading. Not only these analog input shared pins, some other
pins may also be affected by noise arising from input/output to and from adjacent pins.
14.6.3 Noise Countermeasure
The internal equivalent circuit of the analog input pins is shown in Figure 14-5. The higher the output
impedance of the analog input source, more easily they are susceptible to noise. Therefore, make sure the output impedance of the signal source in your design is 5 kΩ or less. Toshiba also recommends attaching a capacitor external to the chip.
Internal resistance
AINi
Permissible signal
source impedance
5 kΩ (typ)
Analog comparator
Internal capacitance
C = 22 pF (typ.)
5 kΩ (max)
DA converter
Note) i = 7 to 0
Figure 14-5
Analog Input Equivalent Circuit and Example of Input Pin Processing
Page 189
14. 10-bit AD Converter (ADC)
14.6 Precautions about AD Converter
TMP86FS28FG
Page 190
TMP86FS28FG
15. Key-on Wakeup (KWU)
In the TMP86FS28FG, the STOP mode is released by not only P20(INT5/STOP) pin but also four (STOP2 to
STOP5) pins.
When the STOP mode is released by STOP2 to STOP5 pins, the STOP pin needs to be used.
In details, refer to the following section " 15.2 Control ".
15.1 Configuration
INT5
STOP
STOP mode
release signal
(1: Release)
STOP2
STOP3
STOP4
STOPCR
(0031H)
STOP5
STOP4
STOP3
STOP2
STOP5
Figure 15-1 Key-on Wakeup Circuit
15.2 Control
STOP2 to STOP5 pins can controlled by Key-on Wakeup Control Register (STOPCR). It can be configured as
enable/disable in 1-bit unit. When those pins are used for STOP mode release, configure corresponding I/O pins to
input mode by I/O port register beforehand.
Key-on Wakeup Control Register
STOPCR
7
6
5
4
(0031H)
STOP5
STOP4
STOP3
STOP2
3
2
1
0
(Initial value: 0000 ****)
STOP5
STOP mode released by STOP5
0:Disable
1:Enable
Write
only
STOP4
STOP mode released by STOP4
0:Disable
1:Enable
Write
only
STOP3
STOP mode released by STOP3
0:Disable
1:Enable
Write
only
STOP2
STOP mode released by STOP2
0:Disable
1:Enable
Write
only
15.3 Function
Stop mode can be entered by setting up the System Control Register (SYSCR1), and can be exited by detecting the
"L" level on STOP2 to STOP5 pins, which are enabled by STOPCR, for releasing STOP mode (Note1).
Page 191
15. Key-on Wakeup (KWU)
15.3 Function
TMP86FS28FG
Also, each level of the STOP2 to STOP5 pins can be confirmed by reading corresponding I/O port data register,
check all STOP2 to STOP5 pins "H" that is enabled by STOPCR before the STOP mode is started (Note2,3).
Note 1: When the STOP mode released by the edge release mode (SYSCR1<RELM> = “0”), inhibit input from STOP2 to
STOP5 pins by Key-on Wakeup Control Register (STOPCR) or must be set "H" level into STOP2 to STOP5 pins
that are available input during STOP mode.
Note 2: When the STOP pin input is high or STOP2 to STOP5 pins input which is enabled by STOPCR is low, executing an
instruction which starts STOP mode will not place in STOP mode but instead will immediately start the release
sequence (Warm up).
Note 3: The input circuit of Key-on Wakeup input and Port input is separated, so each input voltage threshold value is different. Therefore, a value comes from port input before STOP mode start may be different from a value which is
detected by Key-on Wakeup input (Figure 15-2).
Note 4: STOP pin doesn’t have the control register such as STOPCR, so when STOP mode is released by STOP2 to
STOP5 pins, STOP pin also should be used as STOP mode release function.
Note 5: In STOP mode, Key-on Wakeup pin which is enabled as input mode (for releasing STOP mode) by Key-on
Wakeup Control Register (STOPCR) may generate the penetration current, so the said pin must be disabled AD
conversion input (analog voltage input).
Note 6: When the STOP mode is released by STOP2 to STOP5 pins, the level of STOP pin should hold "L" level (Figure
15-3).
External pin
Port input
Key-on wakeup
input
Figure 15-2 Key-on Wakeup Input and Port Input
b) In case of STOP2 to STOP5
a) STOP
STOP pin
STOP pin "L"
STOP mode
Release
STOP mode
STOP2 pin
STOP mode
Release
STOP mode
Figure 15-3 Priority of STOP pin and STOP2 to STOP5 pins
Table 15-1 Release level (edge) of STOP mode
Release level (edge)
Pin name
SYSCR1<RELM>="1"
(Note2)
SYSCR1<RELM>="0"
STOP
"H" level
Rising edge
STOP2
"L" level
Don’t use (Note1)
STOP3
"L" level
Don’t use (Note1)
STOP4
"L" level
Don’t use (Note1)
STOP5
"L" level
Don’t use (Note1)
Page 192
TMP86FS28FG
16. LCD Driver
The TMP86FS28FG has a driver and control circuit to directly drive the liquid crystal device (LCD). The pins to
be connected to LCD are as follows:
1. Segment output port 40 pins (SEG39 to SEG0)
2. Common output port4 pins (COM3 to COM0)
In addition, C0, C1, V1, V2, V3 pin are provided for the LCD driver’s booster circuit.
The devices that can be directly driven is selectable from LCD of the following drive methods:
1. 1/4 Duty (1/3 Bias) LCD
Max 160 Segments(8 segments × 20 digits)
2. 1/3 Duty (1/3 Bias) LCD
Max 120 Segments(8 segments × 15 digits)
3. 1/2 Duty (1/2 Bias) LCD
Max 80 Segments(8 segments × 10 digits)
4. Static LCD
Max 40 Segments(8 segments × 5 digits)
16.1 Configuration
LCDCR
7
6
EDSP BRES
5
4
VFSEL
3
2
1
DUTY
0
SLF
DBR
fc/217, fs/29
display data area
fc/216, fs/28
fc/215
fc/213
Timing
control
Duty
control
Display data select control
fc/213, fs/25
fc/211, fs/23
Blanking
control
fc/210, fs/22
fc/29
Constant voltage
booster circuit
C0 C1
V1 V2 V3
Display data buffer register
Common driver
COM0
to
Segment driver
COM3
SEG0
SEG39
Figure 16-1 LCD Driver
Note: The LCD driver incorporates a dedicated divider circuit. Therefore, the break function of a debugger (development
tool) will not stop LCD driver output.
Page 193
16. LCD Driver
16.2 Control
TMP86FS28FG
16.2 Control
The LCD driver is controlled using the LCD control register (LCDCR). The LCD driver’s display is enabled using
the EDSP.
LCD Driver Control Register
LCDCR
(0FD9H)
7
6
EDSP
BRES
5
4
3
VFSEL
2
1
DUTY
0
SLF
(Initial value: 0000 0000)
EDSP
LCD Display Control
0: Blanking
1: Enables LCD display (Blanking is released)
BRES
Booster circuit control
0: Disable (use divider resistance)
1: Enable
NORMAL1/2, IDLE/1/2 mode
VFSEL
DUTY
Selection of boost frequency
Selection of driving methods
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP0/1/2 mode
00
fc/213
fs/25
fs/25
01
fc/211
fs/23
fs/23
10
fc/210
fs/22
fs/22
11
fc/29
fc/29
–
NORMAL1/2, IDLE/1/2 mode
SLF
R/W
00: 1/4 Duty (1/3 Bias)
01: 1/3 Duty (1/3 Bias)
10: 1/2 Duty (1/2 Bias)
11: Static
Selection of LCD frame frequency
DV7CK = 0
DV7CK = 1
SLOW1/2,
SLEEP0/1/2 mode
00
fc/217
fs/29
fs/29
01
fc/216
fs/28
fs/28
10
fc/215
fc/215
–
11
fc/213
fc/213
–
Note 1: When <BRES>(Booster circuit control) is set to “0”, VDD ≥ V3 ≥ V2 ≥ V1 ≥ VSS should be satisfied.
When <BRES> is set to “1”, 5.5 [V] ≥ V3 ≥ VDD should be satisfied.
If these conditions are not satisfied, it not only affects the quality of LCD display but also may damage the device due to
over voltage of the port.
Note 2: When used as the booster circuit, bias should be composed to 1/3. Therefore, do not set LCDCR<DUTY> to "10" or "11"
when the booster circuit is enable.
Note 3: Do not set SLF to “10” or “11” in SLOW1/2 modes.
Note 4: Do not set VFSEL to “11” SLOW1/2 modes.
Page 194
TMP86FS28FG
16.2.1 LCD driving methods
As for LCD driving method, 4 types can be selected by LCDCR<DUTY>. The driving method is initialized
in the initial program according to the LCD used.
VLCD3
VLCD3
1/fF
1/fF
0
0
−VLCD3
Data "1"
Data "0"
−VLCD3
(a) 1/4 Duty (1/3 Bias)
VLCD3
Data "0"
(b) 1/3 Duty (1/3 Bias)
VLCD3
1/fF
Data "1"
1/fF
0
0
−VLCD3
−VLCD3
Data "1"
Data "0"
Data "1"
(d) Static
(c) 1/2 Duty (1/2 Bias)
Note 1: fF: Frame frequency
Note 2: VLCD3: LCD drive voltage
Figure 16-2 LCD Drive Waveform (COM-SEG pins)
Page 195
Data "0"
16. LCD Driver
16.2 Control
TMP86FS28FG
16.2.2 Frame frequency
Frame frequency (fF) is set according to driving method and base frequency as shown in the following Table
16-1. The base frequency is selected by LCDCR<SLF> according to the frequency fc and fs of the basic clock
to be used.
Table 16-1 Setting of LCD Frame Frequency
(a) At the single clock mode. At the dual clock mode (DV7CK = 0).
Frame frequency [Hz]
SLF
Base frequency [Hz]
1/4 Duty
1/3 Duty
4 fc
--- • -------3 2 17
1/2 Duty
Static
4 fc
--- • -------2 2 17
fc
-------17
2
fc
-------17
2
fc
-------17
2
(fc = 16 MHz)
122
163
244
122
(fc = 8 MHz)
61
81
122
61
fc
-------16
2
fc
-------16
2
4 fc
--- • -------2 2 16
fc
-------16
2
(fc = 8 MHz)
122
163
244
122
(fc = 4 MHz)
61
81
122
61
fc
-------15
2
fc
-------15
2
4 fc
--- • -------2 2 15
fc
-------15
2
(fc = 4 MHz)
122
163
244
122
(fc = 2 MHz)
61
81
122
61
fc
-------13
2
fc
-------13
2
4 fc
--- • -------2 2 13
fc
-------13
2
(fc = 1 MHz)
122
244
122
00
4 fc
--- • -------3 2 16
01
4 fc
--- • -------3 2 15
10
11
4 fc
--- • -------3 2 13
163
Note: fc: High-frequency clock [Hz]
Table 16-2
(b) At the dual clock mode (DV7CK = 1 or SYSCK = 1)
Frame frequency [Hz]
SLF
00
01
Base frequency [Hz]
1/4 Duty
1/3 Duty
1/2 Duty
Static
fs
-----9
2
fs
-----9
2
4 fs
--- • -----3 29
4 fs
--- • -----2 29
fs
-----9
2
(fs = 32.768 kHz)
64
85
128
64
fs
-----8
2
fs
-----8
2
4 fs
--- • -----3 28
4 fs
--- • -----2 28
fs
-----8
2
(fs = 32.768 kHz)
128
171
256
128
Note: fs: Low-frequency clock [Hz]
Page 196
TMP86FS28FG
16.2.3 Driving method for LCD driver
In the TMP86FS28FG, LCD driving voltages can be generated using either an internal booster circuit or an
external resistor divider. This selection is made in LCDCR<BRES>.
16.2.3.1 When using the booster circuit (LCDCR<BRES>="1")
When the reference voltage is connected to the V1 pin, the booster circuit boosts the reference voltage
twofold (V2) or threefold (V3) to generate the output voltages for segment/common signals. When the
reference voltage is connected to the V2 pin, it is reduced to 1/2 (V1) or boosted to 3/2 (V3). When the
reference voltage is connected to the V3 pin, it is reduced to 1/3 (V1) or 2/3 (V2).
LCDCR<VFSEL> is used to select the reference frequency in the booster circuit. The faster the boosting frequency, the higher the segment/common drive capability, but power consumption is increased.
Conversely, the slower the boosting frequency, the lower the segment/common drive capability, but power
consumption is reduced. If the drive capability is insufficient, the LCD may not be displayed clearly.
Therefore, select an optimum boosting frequency for the LCD panel to be used.
Table 16-3 shows the V3 pin current capacity and boosting frequency.
Note: When used as the booster circuit, bias should be composed to 1/3. Therefore, do not set
LCDCR<DUTY> to "10" or "11" when the booster circuit is enable (LCDCR<BRES>="1").
Keep the following
condition.
VDD
V3
V2
V3
V1 = 1/3 x V3
C = 0.1 to 0.47 µF
V1
C
C
Reference voltage
C1
C0
C
VSS
a) Reference pin = V1
Keep the following
condition.
VDD
V3
V2
V3
V2 = 2/3 x V3
C = 0.1 to 0.47 µF
V1
C
C
C
Reference voltage
C1
C0
VSS
b) Reference pin = V2
Page 197
C
16. LCD Driver
16.2 Control
TMP86FS28FG
Keep the following
condition.
VDD
V3
V2
V3
V1
C
C
Reference voltage
C
C
= 0.1 to 0.47 µF
C1
C0
C
VSS
c) Reference pin = V3
Keep the following
condition.
VDD
V3
V2
V3 =
V1
C
C
C
C
= 0.1 to 0.47 µF
C1
C0
C
VSS
d) Reference pin = V3
Note 1: When the TMP86FS28FG uses the booster circuit to drive the LCD, the power supply and capacitor for the booster circuit
should be connected as shown above.
Note 2: When the reference voltage is connected to a pin other than V1, add a capacitor between V1 and GND.
Note 3: The connection examples shown above are different from those shown in the datasheets of the previous version. Since
the above connection method enhances the boosting characteristics, it is recommended that new boards be designed
using the above connection method. (Using the existing connection method does not affect LCD display.)
Figure 16-3 Connection Examples When Using the Booster Circuit (LCDCR<BRES> = “1”)
Table 16-3 V3 Pin Current Capacity and Boosting Frequency (typ.)
VFSEL
Boosting frequency
fc = 16 MHz
fc = 8 MHz
fc = 4 MHz
fc = 32.768 MHz
00
fc/213 or fs/25
−37 mV/ µA
−80 mV/ µA
−138 mV/ µA
−76 mV/ µA
01
fc/211 or fs/23
−19 mV/ µA
−24 mV/ µA
−37 mV/ µA
−23 mV/ µA
10
fc/210 or fs/22
−17 mV/ µA
−19 mV/ µA
−24 mV/ µA
−18 mV/ µA
11
fc/29
−16 mV/ µA
−17 mV/ µA
−19 mV/ µA
–
Note 1: The current capacity is the amount of voltage that falls per 1µA.
Note 2: The boosting frequency should be selected depending on your LCD panel.
Note 3: For the reference pin V1 or V2, a current capacity ten times larger than the above is recommended to ensure stable operation.
For example, when the boosting frequency is fc/29 (at fc = 8 MHz), −1.7 mV/ µA or more is recommended for the current
capacity of the reference pin V1.
16.2.3.2 When using an external resistor divider (LCDCR<BRES>="0")
When an external resistor divider is used, the voltage of an external power supply is divided and input
on V1, V2, and V3 to generate the output voltages for segment/common signals.
Page 198
TMP86FS28FG
The smaller the external resistor value, the higher the segment/common drive capability, but power consumption is increased. Conversely, the larger the external resistor value, the lower the segment/common
drive capability, but power consumption is reduced. If the drive capability is insufficient, the LCD may
not be displayed clearly. Therefore, select an optimum resistor value for the LCD panel to be used.
Adjustment of
contrast
VDD
Adjustment of
contrast
VDD
V3
Adjustment of
contrast
VDD
V3
V3
R1
R1
V2
V2
C0
Open
C1
Open
R2
V2
C0
Open
C0
Open
C1
Open
C1
Open
V1
V1
V1
R2
R3
VSS
VSS
R1
VSS
1/2 Bias (R1 = R2)
1/3 Bias (R1 = R2 = R3)
Keep the following conditon.
VDD V3 V2 V1
Static
VSS
Figure 16-4 Connection Examples When Using an External Resistor Divider
(LCDCR<BRES> = “0”)
16.3 LCD Display Operation
16.3.1 Display data setting
Display data is stored to the display data area (assigned to address 0FC0H to 0FD3H, 20bytes) in the DBR.
The display data which are stored in the display data area is automatically read out and sent to the LCD driver
by the hardware. The LCD driver generates the segment signal and common signal according to the display
data and driving method. Therefore, display patterns can be changed by only over writing the contents of display data area by the program. Table 16-5 shows the correspondence between the display data area and SEG/
COM pins.
LCD light when display data is “1” and turn off when “0”. According to the driving method of LCD, the
number of pixels which can be driven becomes different, and the number of bits in the display data area which
is used to store display data also becomes different.
Therefore, the bits which are not used to store display data as well as the data buffer which corresponds to the
addresses not connected to LCD can be used to store general user process data (see Table 16-4).
Note:The display data memory contents become unstable when the power supply is turned on; therefore, the display data memory should be initialized by an initiation routine.
Table 16-4 Driving Method and Bit for Display Data
Driving methods
Bit 7/3
Bit 6/2
Bit 5/1
Bit 4/0
1/4 Duty
COM3
COM2
COM1
COM0
1/3 Duty
–
COM2
COM1
COM0
1/2 Duty
–
–
COM1
COM0
Static
–
–
–
COM0
Page 199
16. LCD Driver
16.3 LCD Display Operation
TMP86FS28FG
Note: –: This bit is not used for display data
Table 16-5 LCD Display Data Area (DBR)
Address
Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
COM1
COM0
0FC0H
SEG1
SEG0
0FC1H
SEG3
SEG2
0FC2H
SEG5
SEG4
0FC3H
SEG7
SEG6
0FC4H
SEG9
SEG8
0FC5H
SEG11
SEG10
0FC6H
SEG13
SEG12
0FC7H
SEG15
SEG14
0FC8H
SEG17
SEG16
0FC9H
SEG19
SEG18
0FCAH
SEG21
SEG20
0FCBH
SEG23
SEG22
0FCCH
SEG25
SEG24
0FCDH
SEG27
SEG26
0FCEH
SEG29
SEG28
0FCFH
SEG31
SEG30
0FD0H
SEG33
SEG32
0FD1H
SEG35
SEG34
0FD2H
SEG37
SEG36
0FD3H
SEG39
COM3
COM2
COM1
SEG38
COM0
COM3
COM2
16.3.2 Blanking
Blanking is enabled when EDSP is cleared to “0”.
Blanking turns off LCD through outputting a GND level to SEG/COM pin.
When in STOP mode, EDSP is cleared to “0” and automatically blanked. To redisplay ICD after exiting
STOP mode, it is necessary to set EDSP back to “1”.
Note:During reset, the LCD common outputs are fixed “0” level. But the multiplex terminal of input/output port and
LCD segment output becomes high impedance. Therefore, when the reset input is long remarkably, ghost
problem may appear in LCD display.
Page 200
TMP86FS28FG
16.4 Control Method of LCD Driver
16.4.1 Initial setting
Figure 16-5 shows the flowchart of initialization.
Example : To operate a 1/4 duty LCD of 40 segments × 4 com-mons at frame frequency fc/216 [Hz], and booster frequency fc/213 [Hz]
LD
(LCDCR), 01000001B
; Sets LCD driving method and frame frequency. Boost frequency
LD
(P*LCR), 0FFH
; Sets segment output control register. (*; Port No.)
:
:
:
:
LD
; Sets the initial value of display data.
(LCDCR), 11000001B
; Display enable
Sets LCD driving method (DUTY).
Sets boost frequency (VFSEL).
Sets frame frequency (SLF).
Enables booster circuit (BRES)
Sets segment output control registers
(P*LCR (*; Port No.))
Initialization of display data area.
Display enable (EDSP)
(Releases from blanking.)
Figure 16-5 Initial Setting of LCD Driver
16.4.2 Store of display data
Generally, display data are prepared as fixed data in program memory (ROM) and stored in display data area
by load command.
Page 201
16. LCD Driver
16.4 Control Method of LCD Driver
TMP86FS28FG
Example :To display using 1/4 duty LCD a numerical value which corresponds to the LCD data stored in data memory at address 80H (when pins COM and SEG are connected to LCD as in Figure 16-6), display data
become as shown in Table 16-6.
LD
A, (80H)
ADD
A, TABLE-$-7
LD
HL, 0F80H
LD
W, (PC + A)
LD
(HL), W
RET
TABLE:
DB
11011111B, 00000110B,
11100011B, 10100111B,
00110110B, 10110101B,
11110101B, 00010111B,
11110111B, 10110111B
Note:DB is a byte data difinition instruction.
COM0
COM1
COM2
COM3
SEG0
SEG1
Figure 16-6 Example of COM, SEG Pin Connection (1/4 Duty)
Table 16-6 Example of Display Data (1/4 Duty)
No.
display
Display data
No.
0
11011111
5
10110101
1
00000110
6
11110101
2
11100011
7
00000111
3
10100111
8
11110111
4
00110110
9
10110111
Page 202
display
Display data
TMP86FS28FG
Example 2: Table 16-6 shows an example of display data which are displayed using 1/2 duty LCD in the
same way as Table 16-7. The connection between pins COM and SEG are the same as shown in Figure 16-7.
COM0
SEG3
SEG0
SEG2
COM1
SEG1
Figure 16-7 Example of COM, SEG Pin Connection
Table 16-7 Example of Display Data (1/2 Duty)
Display data
Display data
Number
Number
High order address
Low order address
High order address
Low order address
0
**01**11
**01**11
5
**11**10
**01**01
1
**00**10
**00**10
6
**11**11
**01**01
2
**10**01
**01**11
7
**01**10
**00**11
3
**10**10
**01**11
8
**11**11
**01**11
4
**11**10
**00**10
9
**11**10
**01**11
Note: *: Don’t care
Page 203
16. LCD Driver
16.4 Control Method of LCD Driver
TMP86FS28FG
16.4.3 Example of LCD drive output
COM0
COM1
COM2
COM3
SEG0
SEG1
EDSP
VLCD3
SEG0
0
VLCD3
SEG1
0
Display data area
VLCD3
COM0
0
Address
0FC0H 1011 0101
VLCD3
COM1
0
VLCD3
COM2
0
VLCD3
COM3
0
VLCD3
0
COM0-SEG0
(Selected)
−VLCD3
VLCD3
0
COM2-SEG1
(Non selected)
−VLCD3
Figure 16-8 1/4 Duty (1/3 bias) Drive
Page 204
TMP86FS28FG
SEG1
SEG0
SEG2
COM0
COM1
COM2
EDSP
VLCD3
SEG0
0
Display data area
Address
VLCD3
SEG1
0
VLCD3
SEG2
0FC0H
*111 *010
0FC1H
**** *001
0
VLCD3
COM0
0
VLCD3
*: Don’t care
COM1
0
VLCD3
COM2
0
VLCD3
COM0-SEG1
(Selected)
0
−VLCD3
VLCD3
COM1-SEG2
(Non selected)
0
−VLCD3
Figure 16-9 1/3 Duty (1/3 bias) Drive
Page 205
16. LCD Driver
16.4 Control Method of LCD Driver
TMP86FS28FG
COM0
SEG3
COM0
COM2
COM1
COM1
EDSP
VLCD3
SEG0
0
Display data area
Address
VLCD3
SEG1
0
VLCD3
SEG2
0FC0H **01 **01
0FC1H **11 **10
*: Don’t care
0
VLCD3
SEG3
0
VLCD3
COM0
0
VLCD3
COM1
0
VLCD3
0
COM0-SEG1
(Selected)
VLCD3
−VLCD3
0
−VLCD3
COM1-SEG2
(Non selected)
Figure 16-10 1/2 Duty (1/2 bias) Drive
Page 206
TMP86FS28FG
SEG0
SEG1
SEG5
SEG6
SEG4
SEG2
SEG3
SEG7
COM0
Display data area
EDSP
Address
0FC0H
***0 ***1
0FC1H
***1 ***1
0FC2H
***1 ***0
0FC3H
***0 ***1
*: Don’t care
VLCD3
SEG0
0
VLCD3
SEG4
0
VLCD3
SEG7
0
VLCD3
COM0
0
VLCD3
COM0-SEG0
(Selected)
0
−VLCD3
VLCD3
COM0-SEG4
0
(Non selected)
−VLCD3
Figure 16-11 Static Drive
Page 207
16. LCD Driver
16.4 Control Method of LCD Driver
TMP86FS28FG
Page 208
TMP86FS28FG
17. Flash Memory
TMP86FS28FG has 61440byte flash memory (address: 1000H 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.
- Serial PROM mode
The flash memory is accessed by the CPU control in the serial PROM mode. Use of the serial interface
(UART) enables the flash memory to be controlled by the small number of pins. TMP86FS28FG in the
serial PROM mode supports on-board programming which enables users to program flash memory after
the microcontroller is mounted on a user board.
- Parallel PROM mode
The parallel PROM mode allows the flash memory to be accessed as a stand-alone flash memory by the
program writer provided by the third party. High-speed access to the flash memory is available by controlling address and data signals directly. For the support of the program writer, please ask Toshiba sales representative.
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 209
17. Flash Memory
17.1 Flash Memory Control
TMP86FS28FG
17.1 Flash Memory Control
The flash memory is controlled via the flash memory control register (FLSCR) and flash memory stanby control
resister (FLSSTB).
Flash Memory Control Register
FLSCR
7
6
(0FAFH)
5
4
FLSMD
FLSMD
BANKSEL
3
2
1
0
BANKSEL
(Initial value : 1100 1***)
Flash memory command sequence execution control
1100: Disable command sequence execution
0011: Enable command sequence execution
Others: Reserved
R/W
Flash memory bank select control
(Serial PROM mode only)
0: Select BANK0
1: Select BANK1
R/W
Note 1: The command sequence of the flash memory can be executed only when FLSMD="0011B". In other cases, any attempts
to execute the command sequence are ineffective.
Note 2: FLSMD must be set to either "1100B" or "0011B".
Note 3: BANKSEL is effective only in the serial PROM mode. In the MCU mode, the flash memory is always accessed with actual
addresses (1000-FFFFH) regardless of BANKSEL.
Note 4: Bits 2 through 0 in FLSCR are always read as don’t care.
Flash Memory Standby Control Register
FLSSTB
7
6
5
4
3
2
1
(0FADH)
0
FSTB
FSTB
Flash memory standby control
(Initial value : **** ***0)
0: Disable the standby function.
1: Enable the standby function.
Write
only
Note 1: When FSTB is set to 1, do not execute the read/write instruction to the flash memory because there is a possibility that the
expected data is not read or the program is not operated correctly. If executing the read/write instruction, FSTB is initialized to 0 automatically.
Note 2: If an interrupt is issued when FSTB is set to 1, FSTB is initialized to 0 automatically and then the vector area of the flash
memory is read.
Note 3: If the IDLE0/1/2, SLEEP0/1/2 or STOP mode is activated when FSTB is set to 1, FSTB is initialized to 0 automatically. In
the IDLE0/1/2, SLEEP0/1/2 or STOP mode, the standby function operates regardless of FSTB setting.
17.1.1 Flash Memory Command Sequence Execution Control (FLSCR<FLSMD>)
The flash memory can be protected from inadvertent write due to program error or microcontroller misoperation. This write protection feature is realized by disabling flash memory command sequence execution via the
flash memory control register (write protect). To enable command sequence execution, set FLSCR<FLSMD>
to “0011B”. To disable command sequence execution, set FLSCR<FLSMD> to “1100B”. After reset,
FLSCR<FLSMD> is initialized to “1100B” to disable command sequence execution. Normally,
FLSCR<FLSMD> should be set to “1100B” except when the flash memory needs to be written or erased.
17.1.2 Flash Memory Bank Select Control (FLSCR<BANKSEL>)
In the serial PROM mode, a 2-kbyte BOOTROM is mapped to addresses 7800H-7FFFH and the flash memory is mapped to 2 banks at 8000H-FFFFH. Flash memory addresses 1000H-7FFFH are mapped to 9000HFFFFH as BANK0, and flash memory addresses 8000H-FFFFH are mapped to 8000H-FFFFH as BANK1.
FLSCR<BANKSEL> is used to switch between these banks. For example, to access the flash memory address
7000H, set FLSCR<BANKSEL> to “0” and then access F000H. To access the flash memory address 9000H,
set FLSCR<BANKSEL> to “1" and then access 9000H.
In the MCU mode, the flash memory is accessed with actual addresses at 1000H-FFFFH. In this case,
FLSCR<BANKSEL> is ineffective (i.e., its value has no effect on other operations).
Page 210
TMP86FS28FG
Table 17-1 Flash Memory Access
Operating Mode
FLSCR
<BANKSEL>
MCU mode
Don’t care
0
(BANK0)
Access Area
Specified Address
1000H-FFFFH
1000H-7FFFH
9000H-FFFFH
Serial PROM mode
1
(BANK1)
8000H-FFFFH
17.1.3 Flash Memory Standby Control (FLSSTB<FSTB>)
Low power consumption is enabled by cutting off the steady-state current of the flash memory. In the
IDLE0/1/2, SLEEP0/1/2 or STOP mode, the steady-state current of the flash memory is cut off automatically.
When the program is executed in the RAM area (without accessing the flash memory) in the NORMAL 1/2
or SLOW1/2 mode, the current can be cut off by the control of the register. To cut off the steady-state current of
the flash memory, set FLSSTB<FSTB> to “1” by the control program in the RAM area. The procedures for
controlling the FLSSTB register are explained below.
(Steps1 and 2 are controlled by the program in the flash memory, and steps 3 through 8 are controlled by the
write control program executed in the RAM area.)
1. Transfer the control program of the FLSSTB register to the RAM area.
2. Jump to the RAM area.
3. Disable (DI) the interrupt master enable flag (IMF = “0”).
4. Set FLSSTB<FSTB> to “1”.
5. Execute the user program.
6. Repeat step 5 until the return request to the flash memory is detected.
7. Set FLSSTB<FSTB> to “0”.
8. Jump to the flash memory area.
Note 1: The standby function is not operated by setting FLSSTB<FSTB> with the program in the flash memory. You
must set FLSSTB<FSTB> by the program in the RAM area.
Note 2: To use the standby function by setting FLSSTB<FSTB> to “1” with the program in the RAM area,
FLSSTB<FSTB> must be set to “0” by the program in the RAM area before returning the program control to
the flash memory. If the program control is returned to the flash memory with FLSSTB<FSTB> set to “1”,
the program may misoperate and run out of control.
Page 211
17. Flash Memory
17.2 Command Sequence
TMP86FS28FG
17.2 Command Sequence
The command sequence in the MCU and the serial PROM modes consists of six commands (JEDEC compatible),
as shown in Table 17-2. Addresses specified in the command sequence are recognized with the lower 12 bits
(excluding BA, SA, and FF7FH used for read protection). The upper 4 bits are used to specify the flash memory
area, as shown in Table 17-3.
Table 17-2 Command Sequence
Command
Sequence
1st Bus Write
Cycle
2nd Bus Write
Cycle
3rd Bus Write
Cycle
4th Bus Write
Cycle
5th Bus Write
Cycle
6th Bus Write
Cycle
Address
Data
Address
Data
Address
Data
Address
Data
Address
Data
Address
Data
1
Byte program
555H
AAH
AAAH
55H
555H
A0H
BA
(Note 1)
Data
(Note 1)
-
-
-
-
2
Sector Erase
(4-kbyte Erase)
555H
AAH
AAAH
55H
555H
80H
555H
AAH
AAAH
55H
SA
(Note 2)
30H
3
Chip Erase
(All Erase)
555H
AAH
AAAH
55H
555H
80H
555H
AAH
AAAH
55H
555H
10H
4
Product ID Entry
555H
AAH
AAAH
55H
555H
90H
-
-
-
-
-
-
Product ID Exit
XXH
F0H
-
-
-
-
-
-
-
-
-
-
Product ID Exit
555H
AAH
AAAH
55H
555H
F0H
-
-
-
-
-
-
Read Protect
555H
AAH
AAAH
55H
555H
A5H
FF7FH
00H
-
-
-
-
5
6
Note 1: Set the address and data to be written.
Note 2: The area to be erased is specified with the upper 4 bits of the address.
Table 17-3 Address Specification in the Command Sequence
Operating Mode
FLSCR
<BANKSEL>
Specified Address
MCU mode
Don’t care
1***H-F***H
0
(BANK0)
9***H-F***H
1
(BANK1)
8***H-F***H
Serial PROM mode
17.2.1 Byte Program
This command writes the flash memory for each byte unit. The addresses and data to be written are specified
in the 4th bus write cycle. Each byte can be programmed in a maximum of 40 µs. The next command sequence
cannot be executed until the write operation is completed. To check the completion of the write operation, perform read operations repeatedly until the same data is read twice from the same address in the flash memory.
During the write operation, any consecutive attempts to read from the same address is reversed bit 6 of the data
(toggling between 0 and 1).
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.
17.2.2 Sector Erase (4-kbyte Erase)
This command erases the flash memory in units of 4 kbytes. The flash memory area to be erased is specified
by the upper 4 bits of the 6th bus write cycle address. For example, in the MCU mode, to erase 4 kbytes from
7000H to 7FFFH, specify one of the addresses in 7000H-7FFFH as the 6th bus write cycle. In the serial PROM
mode, to erase 4 kbytes from 7000H to 7FFFH, set FLSCR<BANKSEL> to "0" and then specify one of the
addresses in F000H-FFFFH as the 6th bus write cycle. The sector erase command is effective only in the MCU
and serial PROM modes, and it cannot be used in the parallel PROM mode.
Page 212
TMP86FS28FG
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).
17.2.3 Chip Erase (All Erase)
This command erases the entire flash memory in approximately 30 ms. 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). After the chip is erased, all bytes contain FFH.
17.2.4 Product ID Entry
This command activates the Product ID mode. In the Product ID mode, the vendor ID, the flash ID, and the
read protection status can be read from the flash memory.
Table 17-4 Values To Be Read in the Product ID Mode
Address
Meaning
F000H
Vendor ID
98H
F001H
Flash macro ID
41H
F002H
FF7FH
Read Value
Flash size
0EH:
60 kbytes
0BH:
48 kbytes
07H:
32 kbytes
05H:
24 kbytes
03H:
16 kbytes
01H:
8 kbytes
00H:
4 kbytes
FFH:
Read protection disabled
Read protection status
Other than FFH: Read protection enabled
Note: The value at address F002H (flash size) depends on the size of flash memory incorporated in each product. For example, if
the product has 60-kbyte flash memory, "0EH" is read from address F002H.
17.2.5 Product ID Exit
This command is used to exit the Product ID mode.
17.2.6 Read Protect
This command enables the read protection setting in the flash memory. When the read protection is enabled,
the flash memory cannot be read in the parallel PROM mode. In the serial PROM mode, the flash write command cannot be executed.
To enable the read protection setting in the serial PROM mode, set FLSCR<BANKSEL> to "1" before executing the read protect command sequence. To disable the read protection setting, it is necessary to execute the
chip erase command sequence. Whether or not the read protection is enabled can be checked by reading
FF7FH in the Product ID mode. For details, see Table 17-4.
Page 213
17. Flash Memory
17.3 Toggle Bit (D6)
TMP86FS28FG
It takes a maximum of 40 µs to set read protection in the flash memory. The next command sequence cannot
be executed until this operation is completed. To check the completion of the read protect 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 read protect operation, any attempts to read from the same address is reversed bit 6 of the
data (toggling between 0 and 1).
17.3 Toggle Bit (D6)
After the byte program, chip erase, and read protect command sequence is executed, any consecutive attempts to
read from the same address is reversed bit 6 (D6) of the data (toggling between 0 and 1) until the operation is completed. Therefore, this toggle bit provides a software mechanism to check the completion of each operation. Usually
perform read operations repeatedly for data polling until the same data is read twice from the same address in the
flash memory. After the byte program, chip erase, or read protect command sequence is executed, the initial read of
the toggle bit always produces a "1".
Page 214
TMP86FS28FG
17.4 Access to the Flash Memory Area
When the write, erase and read protections are set in the flash memory, read and fetch operations cannot be performed in the entire flash memory area. Therefore, to perform these operations in the entire flash memory area,
access to the flash memory area by the control program in the BOOTROM or RAM area. (The flash memory program cannot write to the flash memory.) The serial PROM or MCU mode is used to run the control program in the
BOOTROM or RAM area.
Note 1: The flash memory can be written or read for each byte unit. Erase operations can be performed either in the entire
area or in units of 4 kbytes, whereas read operations can be performed by an one transfer instruction. However,
the command sequence method is adopted for write and erase operations, requiring several-byte transfer instructions for each operation.
Note 2: 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.
17.4.1 Flash Memory Control in the Serial PROM Mode
The serial PROM mode is used to access to the flash memory by the control program provided in the
BOOTROM area. Since almost of all operations relating to access to the flash memory can be controlled simply by the communication data of the serial interface (UART), these functions are transparent to the user. For
the details of the serial PROM mode, see “Serial PROM Mode.”
Page 215
17. Flash Memory
17.4 Access to the Flash Memory Area
TMP86FS28FG
17.4.2 Flash Memory Control in the MCU mode
In the MCU mode, write operations are performed by executing the control program in the RAM area.
Before execution of the control program, copy the control program into the RAM area or obtain it from the
external using the communication pin. The procedures to execute the control program in the RAM area in the
MCU mode are described below.
17.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.)
1. Transfer the write control program to the RAM area.
2. Jump to the RAM area.
3. Disable (DI) the interrupt master enable flag (IMF←"0").
4. Disable the watchdog timer, if it is used.
5. Set FLSCR<FLSMD> to "0011B" (to enable command sequence execution).
6. Execute the erase command sequence.
7. Read the same flash memory address twice.
(Repeat step 7 until the same data is read by two consecutive read operations.)
8. Execute the write command sequence. (It is not required to specify the bank to be written.)
9. Read the same flash memory address twice.
(Repeat step 9 until the same data is read by two consecutive read operations.)
10. Set FLSCR<FLSMD> to "1100B" (to disable command sequence execution).
11. Jump to the flash memory area.
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.
Note 2: When writing to the flash memory, do not intentionally use non-maskable interrupts (the watchdog
timer must be disabled if it is used). If a non-maskable interrupt occurs while the flash memory is
being written, unexpected data is read from the flash memory (interrupt vector), resulting in malfunction of the microcontroller.
Page 216
TMP86FS28FG
Example :After sector erasure (E000H-EFFFH), the program in the RAM area writes data 3FH to address
E000H.
DI
: Disable interrupts (IMF←"0")
LD
(WDTCR2),4EH
: Clear the WDT binary counter.
LDW
(WDTCR1),0B101H
: Disable the WDT.
LD
(FLSCR),0011_1000B
: Enable command sequence execution.
LD
IX,0F555H
LD
IY,0FAAAH
LD
HL,0E000H
; #### Flash Memory Sector Erase Process ####
sLOOP1:
LD
(IX),0AAH
: 1st bus write cycle
LD
(IY),55H
: 2nd bus write cycle
LD
(IX),80H
: 3rd bus write cycle
LD
(IX),0AAH
: 4th bus write cycle
LD
(IY),55H
: 5th bus write cycle
LD
(HL),30H
: 6th bus write cycle
LD
W,(IX)
CMP
W,(IX)
JR
NZ,sLOOP1
: Loop until the same value is read.
; #### Flash Memory Write Process ####
sLOOP2:
LD
(IX),0AAH
: 1st bus write cycle
LD
(IY),55H
: 2nd bus write cycle
LD
(IX),0A0H
: 3rd bus write cycle
LD
(HL),3FH
: 4th bus write cycle, (1000H)=3FH
LD
W,(HL)
CMP
W,(HL)
JR
NZ,sLOOP2
: Loop until the same value is read.
LD
(FLSCR),1100_1000B
: Disable command sequence execution.
JP
XXXXH
: Jump to the flash memory area.
Example :This write control program reads data from address F000H and stores it to 98H in the RAM area.
LD
A,(0F000H)
: Read data from address F000H.
LD
(98H),A
: Store data to address 98H.
Page 217
17. Flash Memory
17.4 Access to the Flash Memory Area
TMP86FS28FG
Page 218
TMP86FS28FG
18. Serial PROM Mode
18.1 Outline
The TMP86FS28FG has a 2048 byte BOOTROM (Mask ROM) for programming to flash memory. The
BOOTROM is available in the serial PROM mode, and controlled by TEST, BOOT and RESET pins. Communication is performed via UART. The serial PROM mode has six types of operating mode: Flash memory writing, Flash
memory SUM output, Product ID code output, Flash memory status output, Flash memory erasing and Flash memory read protection setting. Memory address mapping in the serial PROM mode differs from that in the MCU mode.
Figure 18-1 shows memory address mapping in the serial PROM mode.
Note: TMP86FS28FG doesn’t support RAM loader mode. (The RAM loader mode can’t be used in TMP86FS28FG.)
Table 18-1 Operating Range in the Serial PROM Mode
Parameter
Power supply
High frequency (Note)
Min
Max
Unit
4.5
5.5
V
2
16
MHz
Note: Though included in above operating range, some of high frequencies are not supported in the serial PROM mode. For
details, refer to “Table 18-5”.
18.2 Memory Mapping
The Figure 18-1 shows memory mapping in the Serial PROM mode and MCU mode.
In the serial PROM mode, the BOOTROM (Mask ROM) is mapped in addresses from 7800H to 7FFFH. The flash
memory is divided into two banks for mapping. Figure 18-1
To use the Flash memory writing command (30H), specify the flash memory addresses from 1000H to FFFFH, that
is the same addresses in the MCU mode, because the BOOTROM changes the flash memory address.
0000H
SFR
003FH
0040H
RAM
0000H
64 bytes
SFR
2048 bytes
RAM
083FH
64 bytes
2048 bytes
083FH
0F00H
DBR
003FH
0040H
0F00H
DBR
256 bytes
0FFFH
256 bytes
0FFFH
1000H
7800H
BOOTROM
7FFFH
8000H
9000H
Flash memory
2048 bytes
Flash memory
28672 bytes
(BANK0)
7FFFH
8000H
61440 bytes
32768 bytes
(BANK1)
FFFFH
FFFFH
Serial PROM mode
MCU mode
Figure 18-1 Memory Address Maps
Page 219
18. Serial PROM Mode
18.3 Serial PROM Mode Setting
TMP86FS28FG
18.3 Serial PROM Mode Setting
18.3.1 Serial PROM Mode Control Pins
To execute on-board programming, activate the serial PROM mode. Table 18-2 shows pin setting to activate
the serial PROM mode.
Table 18-2 Serial PROM Mode Setting
Pin
Setting
TEST pin
High
BOOT/RXD1 pin
High
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
18.3.2 Pin Function
In the serial PROM mode, TXD1 (P35) and RXD1 (P34) are used as a serial interface pin.
Table 18-3 Pin Function in the Serial PROM Mode
Pin Name
(Serial PROM Mode)
Input/
Output
Pin Name
(MCU Mode)
Function
TXD1
Output
Serial data output
BOOT/RXD1
Input/Input
Serial PROM mode control/Serial data input
RESET
Input
Serial PROM mode control
RESET
TEST
Input
Fixed to high
TEST
VDD, AVDD
Power
supply
4.5 to 5.5 V
VSS, AVSS
Power
supply
0V
VAREF
Power
supply
Leave open or apply input reference voltage.
P35
(Note 1)
P34
I/O ports except
P35, P34
I/O
These ports are in the high-impedance state in the serial PROM mode. The input level is fixed to
the port inputs with a hardware feature to prevent overlap current. (The port inputs are invalid.)
COM3 to COM0
Output
Low output in the serial PROM mode
C0,C1,V3 to V1
-
Connect to a capacitor (resistance), or leave open.
XIN
Input
XOUT
Output
Self-oscillate with an oscillator.
(Note 2)
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 2 MHz to 16 MHz.
Page 220
TMP86FS28FG
TMP86FS28FG
VDD(4.5 V to 5.5 V)
VDD
Serial PROM mode
TEST
MCU mode
XIN
pull-up
BOOT / RXD1 (P34)
TXD1 (P35)
XOUT
External control
RESET
VSS
GND
Figure 18-2 Serial PROM Mode Pin Setting
Note 1: For connection of other pins, refer to " Table 18-3 Pin Function in the Serial PROM Mode ".
18.3.3 Example Connection for On-Board Writing
Figure 18-3 shows an example connection to perform on-board wring.
VDD(4.5 V to 5.5 V)
VDD
Serial PROM mode
TEST
Pull-up
MCU mode
BOOT / RXD1 (P34)
Level
converter
TXD1 (P35)
PC control
(Note 2)
Other
parts
RESET
control
(Note 1)
RC power-on
reset circuit
RESET
XIN
XOUT
VSS
GND
Application board
External control board
Figure 18-3 Example Connection for On-Board Writing
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 18-3 Pin Function in the Serial PROM Mode ".
Page 221
18. Serial PROM Mode
18.3 Serial PROM Mode Setting
TMP86FS28FG
18.3.4 Activating the Serial PROM Mode
The following is a procedure to activate the serial PROM mode. " Figure 18-4 Serial PROM Mode Timing "
shows a serial PROM mode timing.
1. Supply power to the VDD pin.
2. Set the RESET pin to low.
3. Set the TEST pin and BOOT/RXD1 pins to high.
4. Wait until the power supply and clock oscillation stabilize.
5. Set the RESET pin to high.
6. Input the matching data (5AH) to the BOOT/RXD1 pin after setup sequence. For details of the setup
timing, refer to " 18.15 UART Timing ".
VDD
TEST(Input)
RESET(Input)
PROGRAM
BOOT/RXD1 (Input)
don't care
Reset mode
High level setting
Serial PROM mode
Setup time for serial PROM mode (Rxsup)
Matching data
input
Figure 18-4 Serial PROM Mode Timing
Page 222
TMP86FS28FG
18.4 Interface Specifications for UART
The following shows the UART communication format used in the serial PROM mode.
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 1-4 to TMP86FS28FG. The Table 18-5
shows an operating frequency and baud rate. The frequencies which are not described in Table 18-5 can not be used.
- Baud rate (Default): 9600 bps
- Data length: 8 bits
- Parity addition: None
- Stop bit: 1 bit
Table 18-4 Baud Rate Modification Data
Baud rate modification data
04H
05H
06H
07H
0AH
18H
28H
Baud rate (bps)
76800
62500
57600
38400
31250
19200
9600
Page 223
18. Serial PROM Mode
18.4 Interface Specifications for UART
TMP86FS28FG
Table 18-5 Operating Frequency and Baud Rate in the Serial PROM Mode
(Note 3)
1
2
3
4
5
6
7
8
Reference Baud Rate
(bps)
76800
62500
57600
38400
31250
19200
9600
Baud Rate Modification
Data
04H
05H
06H
07H
0AH
18H
28H
Ref. Frequency
(MHz)
Rating
(MHz)
Baud
rate
(bps)
(%)
(bps)
(%)
(bps)
(%)
(bps)
(%)
2
1.91 to 2.10
-
-
-
-
-
-
-
-
-
-
-
-
9615
+0.16
4
3.82 to 4.19
-
-
-
-
-
-
-
-
31250
0.00
19231
+0.16
9615
+0.16
(bps)
(%)
(bps)
(%)
(bps)
(%)
4.19
3.82 to 4.19
-
-
-
-
-
-
-
-
32734
+4.75
20144
+4.92
10072
+4.92
4.9152
4.70 to 5.16
-
-
-
-
-
-
38400
0.00
-
-
19200
0.00
9600
0.00
5
4.70 to 5.16
-
-
-
-
-
-
39063
+1.73
-
-
19531
+1.73
9766
+1.73
6
5.87 to 6.45
-
-
-
-
-
-
-
-
-
-
-
-
9375
-2.34
-
6.144
5.87 to 6.45
-
-
7.3728
7.05 to 7.74
-
-
-
-
-
-
-
-
-
-
-
9600
0.00
-
57600
0.00
-
-
-
-
19200
0.00
9600
0.00
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
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
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
9
14.7456
14.10 to 15.48
-
-
-
-
57600
0.00
38400
0.00
-
-
19200
0.00
9600
0.00
10
16
15.27 to 16.77
76923
+0.16
62500
0.00
-
-
38462
+0.16
31250
0.00
19231
+0.16
9615
+0.16
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 224
TMP86FS28FG
18.5 Operation Command
The eight commands shown in Table 18-6 are used in the serial PROM mode. After reset release, the
TMP86FS28FG waits for the matching data (5AH).
Table 18-6 Operation Command in the Serial PROM Mode
Command Data
Operating Mode
Description
5AH
Setup
Matching data. Execute this command after releasing the reset.
F0H
Flash memory erasing
Erases the flash memory area (address 1000H to FFFFH).
30H
Flash memory writing
Writes to the flash memory area (address 1000H to FFFFH).
90H
Flash memory SUM output
Outputs the 2-byte checksum upper byte and lower byte in this order for the
entire area of the flash memory (address 1000H to FFFFH).
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 read protection condition.
FAH
Flash memory read protection setting
Enables the read protection.
Note 1: TMP86FS28FG doesn’t support RAM loader mode.
18.6 Operation Mode
The serial PROM mode has six types of modes, that are (1) Flash memory erasing, (2) Flash memory writing, (3)
Flash memory SUM output, (4) Product ID code output, (5) Flash memory status output and (6) Flash memory read
protection setting modes. Description of each mode is shown below.
1. Flash memory erasing mode
The flash memory is erased by the chip erase (erasing an entire flash area) or sector erase (erasing sectors in
4-kbyte units). The erased area is filled with FFH. When the read protection is enabled, the sector erase in
the flash erasing mode can not be performed. To disable the read protection, perform the chip erase. Before
erasing the flash memory, TMP86FS28FG checks the passwords except a blank product. If the password is
not matched, the flash memory erasing mode is not activated.
2. Flash memory writing mode
Data is written to the specified flash memory address for each byte unit. The external controller must transmit the write data in the Intel Hex format (Binary). If no error is encountered till the end record,
TMP86FS28FG calculates the checksum for the entire flash memory area (1000H to FFFFH), and returns
the obtained result to the external controller. When the read protection is enabled, the flash memory writing
mode is not activated. In this case, perform the chip erase command beforehand in the flash memory erasing mode. Before activating the flash memory writing mode, TMP86FS28FG checks the password except a
blank product. If the password is not matched, flash memory writing mode is not activated.
3. Flash memory SUM output mode
The checksum is calculated for the entire flash memory area (1000H to FFFFH), and the result is returned
to the external controller. Since the BOOTROM does not support the operation command to read the flash
memory, use this checksum to identify programs when managing revisions of application programs.
4. Product ID code output
The code used to identify the product is output. The code to be output consists of 13-byte data, which
includes the information indicating the area of the ROM incorporated in the product. The external controller reads this code, and recognizes the product to write.
(In the case of TMP86FS28FG, the addresses from 1000H to FFFFH become the ROM area.)
5. Flash memory status output mode
The status of the area from FFE0H to FFFFH, and the read protection condition are output as 7-byte code.
The external controller reads this code to recognize the flash memory status.
6. Flash memory read protection setting mode
This mode disables reading the flash memory data in parallel PROM mode. In the serial PROM mode, the
flash memory writing mode is disabled. To disable the flash memory read protection, perform the chip
erase in the flash memory erasing mode.
Page 225
18. Serial PROM Mode
18.6 Operation Mode
TMP86FS28FG
18.6.1 Flash Memory Erasing Mode (Operating command: F0H)
Table 18-7 shows the flash memory erasing mode.
Table 18-7 Flash Memory Erasing Mode
Transfer Data from the External
Controller to TMP86FS28FG
Transfer Byte
BOOT
ROM
Baud Rate
Transfer Data from TMP86FS28FG to the
External Controller
1st byte
2nd byte
Matching data (5AH)
-
9600 bps
9600 bps
- (Automatic baud rate adjustment)
OK: Echo back data (5AH)
Error: No data transmitted
3rd byte
4th byte
Baud rate change data (Table 18-4)
-
9600 bps
9600 bps
OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
5th byte
6th byte
Operation command data (F0H)
-
Modified baud rate
Modified baud rate
OK: Echo back data (F0H)
Error: A1H × 3, A3H × 3, 63H × 3 (Note 1)
7th byte
8th byte
Password count storage address bit
15 to 08 (Note 4, 5)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
9th byte
10th byte
Password count storage address bit
07 to 00 (Note 4, 5)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
11th byte
12th byte
Password comparison start address
bit 15 to 08 (Note 4, 5)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
13th byte
14th byte
Password comparison start address
bit 07 to 00 (Note 4, 5)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted)
15th byte
:
m’th byte
Password string (Note 4, 5)
Modified baud rate
-
-
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
n’th - 2 byte
Erase area specification (Note 2)
Modified baud rate
-
n’th - 1 byte
-
Modified baud rate
OK: Checksum (Upper byte) (Note 3)
Error: Nothing transmitted
n’th byte
-
Modified baud rate
OK: Checksum (Lower byte) (Note 3)
Error: Nothing transmitted
n’th + 1 byte
(Wait for the next operation command
data)
Modified baud rate
-
Note 1: “xxH × 3” indicates that the device enters the halt condition after transmitting 3 bytes of xxh.
Note 2: Refer to " 18.13 Specifying the Erasure Area ".
Note 3: Refer to " 18.8 Checksum (SUM) ".
Note 4: Refer to " 18.10 Passwords ".
Note 5: Do not transmit the password string for a blank product.
Note 6: When a password error occurs, TMP86FS28FG stops UART communication and enters the halt mode. Therefore, when a
password error occurs, initialize TMP86FS28FG 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, TMP86FS28FG stops UART communication and enters the halt condition. Therefore, when a password error occurs, initialize TMP86FS28FG by the RESET pin
and reactivate the serial PROM mode.
Description of the flash memory erasing mode
1. The 1st through 4th bytes of the transmitted and received data contain the same data as in the flash
memory writing mode.
Page 226
TMP86FS28FG
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 18-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
“1.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 “1.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 227
18. Serial PROM Mode
18.6 Operation Mode
TMP86FS28FG
18.6.2 Flash Memory Writing Mode (Operation command: 30H)
Table 18-8 shows flash memory writing mode process.
Table 18-8 Flash Memory Writing Mode Process
Transfer Byte
BOOT
ROM
Transfer Data from External Controller
to TMP86FS28FG
Transfer Data from TMP86FS28FG to
External Controller
Baud Rate
1st byte
2nd byte
Matching data (5Ah)
-
9600 bps
9600 bps
- (Automatic baud rate adjustment)
OK: Echo back data (5AH)
Error: Nothing transmitted
3rd byte
4th byte
Baud rate modification data
(See Table 18-4)
-
9600 bps
9600 bps
OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
5th byte
6th byte
Operation command data (30H)
-
Modified baud rate
Modified baud rate
OK: Echo back data (30H)
Error: A1H × 3, A3H × 3, 63H × 3 (Note 1)
7th byte
8th byte
Password count storage address bit
15 to 08 (Note 4)
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
9th byte
10th byte
Password count storage address bit
07 to 00 (Note 4)
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
11th byte
12th byte
Password comparison start address
bit 15 to 08 (Note 4)
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
13th byte
14th byte
Password comparison start address
bit 07 to 00 (Note 4)
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted)
15th byte
:
m’th byte
Password string (Note 5)
Modified baud rate
-
m’th + 1 byte
:
n’th - 2 byte
Intel Hex format (binary)
(Note 2)
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
n’th + 1 byte
(Wait state for the next operation command data)
Modified baud rate
-
-
OK: Nothing transmitted
Error: Nothing transmitted
Modified baud rate
-
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to " 18.7 Error
Code ".
Note 2: Refer to " 18.9 Intel Hex Format (Binary) ".
Note 3: Refer to " 18.8 Checksum (SUM) ".
Note 4: Refer to " 18.10 Passwords ".
Note 5: If addresses from FFE0H to FFFFH 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 from the
external controller. If a password error occurs due to incorrect password count storage address or password comparison
start address, TMP86FS28FG stops UART communication and enters the halt condition. Therefore, when a password
error occurs, initialize TMP86FS28FG by the RESET pin and reactivate the serial ROM mode.
Note 6: If the read protection is enabled or a password error occurs, TMP86FS28FG stops UART communication and enters the
halt confition. In this case, initialize TMP86FS28FG 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, TMP86FS28FG stops UART communication and enters the halt condition. In this case, initialize TMP86FS28FG by the RESET pin and reactivate the serial
PROM mode.
Page 228
TMP86FS28FG
Description of the flash memory writing mode
1. The 1st byte of the received data contains the matching data. When the serial PROM mode is activated, TMP86FS28FG (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. Therefore, 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 18-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 18-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 1-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 15 to 8 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 7 to 0 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 15 to 8 bits of the password comparison start 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 7 to 0 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 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 Nbyte 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
FFE0H to FFFFH are filled with “FFH”, the passwords are not conpared because the device is considered as a blank product.
12. 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.
13. 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 " 18.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
Page 229
18. Serial PROM Mode
18.6 Operation Mode
TMP86FS28FG
record, the external controller judges whether the transmission is completed correctly by receiving the
checksum sent by the device.
14. After transmitting the checksum, the device waits for the next operation command data.
Note 1: Do not write only the address from FFE0H to FFFFH 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 2: 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 230
TMP86FS28FG
18.6.3 Flash Memory SUM Output Mode (Operation Command: 90H)
Table 18-9 shows flash memory SUM output mode process.
Table 18-9 Flash Memory SUM Output Process
Transfer Bytes
BOOT
ROM
Transfer Data from External Controller to TMP86FS28FG
Transfer Data from TMP86FS28FG to
External Controller
Baud Rate
1st byte
2nd byte
Matching data (5AH)
-
9600 bps
9600 bps
- (Automatic baud rate adjustment)
OK: Echo back data (5AH)
Error: Nothing transmitted
3rd byte
9600 bps
-
4th byte
Baud rate modification data
(See Table 18-4)
-
9600 bps
OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
5th byte
6th byte
Operation command data (90H)
-
Modified baud rate
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
9th byte
(Wait for the next operation command data)
Modified baud rate
-
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to " 18.7 Error
Code ".
Note 2: Refer to " 18.8 Checksum (SUM) ".
Description of the flash memory SUM output mode
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 1-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 " 18.8 Checksum (SUM) ".
5. After sending the checksum, the device waits for the next operation command data.
Page 231
18. Serial PROM Mode
18.6 Operation Mode
TMP86FS28FG
18.6.4 Product ID Code Output Mode (Operation Command: C0H)
Table 18-10 shows product ID code output mode process.
Table 18-10 Product ID Code Output Process
Transfer Bytes
BOOT
ROM
Transfer Data from External Controller
to TMP86FS28FG
Transfer Data from TMP86FS28FG to
External Controller
Baud Rate
1st byte
2nd byte
Matching data (5AH)
-
9600 bps
9600 bps
- (Automatic baud rate adjustment)
OK: Echo back data (5AH)
Error: Nothing transmitted
3rd byte
9600 bps
-
4th byte
Baud rate modification data
(See Table 18-4)
-
9600 bps
OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
5th byte
6th byte
Operation command data (C0H)
-
Modified baud rate
Modified baud rate
OK: Echo back data (C0H)
Error: A1H × 3, A3H × 3, 63H × 3 (Note 1)
7th byte
Modified baud rate
3AH
Start mark
8th byte
Modified baud rate
0AH
The number of transfer data
(from 9th to 18th bytes)
9th byte
Modified baud rate
02H
Length of address (2 bytes)
10th byte
Modified baud rate
1DH
Reserved data
11th byte
Modified baud rate
00H
Reserved data
12th byte
Modified baud rate
00H
Reserved data
13th byte
Modified baud rate
00H
Reserved data
14th byte
Modified baud rate
01H
ROM block count (1 block)
15th byte
Modified baud rate
10H
First address of ROM
(Upper byte)
16th byte
Modified baud rate
00H
First address of ROM
(Lower byte)
17th byte
Modified baud rate
FFH
End address of ROM
(Upper byte)
18th byte
Modified baud rate
FFH
End address of ROM
(Lower byte)
19th byte
Modified baud rate
D2H
Checksum of transferred data
(9th through 18th byte)
Modified baud rate
-
20th byte
(Wait for the next operation command
data)
Note: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to " 18.7 Error
Code ".
Description of Product ID code output mode
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 18-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 19th bytes contain the product ID code. For details, refer to " 18.11 Product ID Code
".
Page 232
TMP86FS28FG
5. After sending the checksum, the device waits for the next operation command data.
Page 233
18. Serial PROM Mode
18.6 Operation Mode
TMP86FS28FG
18.6.5 Flash Memory Status Output Mode (Operation Command: C3H)
Table 18-11 shows Flash memory status output mode process.
Table 18-11 Flash Memory Status Output Mode Process
Transfer Bytes
BOOT
ROM
Transfer Data from External Controller to TMP86FS28FG
Baud Rate
Transfer Data from TMP86FS28FG to External Controller
1st byte
2nd byte
Matching data (5AH)
-
9600 bps
9600 bps
- (Automatic baud rate adjustment)
OK: Echo back data (5AH)
Error: Nothing transmitted
3rd byte
9600 bps
-
4th byte
Baud rate modification data
(See Table 18-4)
-
9600 bps
OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
5th byte
6th byte
Operation command data (C3H)
-
Modified baud rate
Modified baud rate
OK: Echo back data (C3H)
Error: A1H × 3, A3H × 3, 63H × 3 (Note 1)
7th byte
Modified baud rate
3AH
Start mark
8th byte
Modified baud rate
04H
Byte count
(from 9th to 12th byte)
9th byte
Modified baud rate
00H
to
03H
Status code 1
10th byte
Modified baud rate
00H
Reserved data
11th byte
Modified baud rate
00H
Reserved data
12th byte
Modified baud rate
00H
Reserved data
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
Modified baud rate
-
14th byte
(Wait for the next operation command data)
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to " 18.7 Error
Code ".
Note 2: For the details on status code 1, refer to " 18.12 Flash Memory Status Code ".
Description of Flash memory status output mode
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 18-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 " 18.12
Flash Memory Status Code ".
5. After sending the status code, the device waits for the next operation command data.
Page 234
TMP86FS28FG
18.6.6 Flash Memory Read Protection Setting Mode (Operation Command: FAH)
Table 18-12 shows Flash memory read protection setting mode process.
Table 18-12 Flash Memory Read Protection Setting Mode Process
Transfer Data from External Controller to TMP86FS28FG
Transfer Bytes
BOOT
ROM
Baud Rate
Transfer Data from TMP86FS28FG to External Controller
1st byte
2nd byte
Matching data (5AH)
-
9600 bps
9600 bps
- (Automatic baud rate adjustment)
OK: Echo back data (5AH)
Error: Nothing transmitted
3rd byte
9600 bps
-
4th byte
Baud rate modification data
(See Table 18-4)
-
9600 bps
OK: Echo back data
Error: A1H × 3, A3H × 3, 62H × 3 (Note 1)
5th byte
6th byte
Operation command data (FAH)
-
Modified baud rate
Modified baud rate
OK: Echo back data (FAH)
Error: A1H × 3, A3H × 3, 63H × 3 (Note 1)
7th byte
8th byte
Password count storage address
15 to 08 (Note 2)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
9th byte
10th byte
Password count storage address
07 to 00 (Note 2)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
11th byte
12th byte
Password comparison start
address 15 to 08 (Note 2)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
13th byte
14th byte
Password comparison start
address 07 to 00 (Note 2)
Modified baud rate
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
15th byte
:
m’th byte
Password string (Note 2)
Modified baud rate
-
-
Modified baud rate
OK: Nothing transmitted
Error: Nothing transmitted
n’th byte
-
Modified baud rate
OK: FBH (Note 3)
Error: Nothing transmitted
n’+1th byte
(Wait for the next operation command data)
Modified baud rate
-
Note 1: “xxH × 3” indicates that the device enters the halt condition after sending 3 bytes of xxH. For details, refer to " 18.7 Error
Code ".
Note 2: Refer to " 18.10 Passwords ".
Note 3: If the read protection is enabled for a blank product or a password error occurs for a non-blank product, TMP86FS28FG
stops UART communication and enters the halt mode. In this case, initialize TMP86FS28FG 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, TMP86FS28FG stops UART communication and enters the halt mode. In this case, initialize TMP86FS28FG by the RESET pin and reactivate the serial PROM
mode.
Description of the Flash memory read protection setting mode
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 1-6, the
device echoes back the value which is the same data in the 6th byte position of the received data (in
Page 235
18. Serial PROM Mode
18.6 Operation Mode
TMP86FS28FG
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 read protection.
Page 236
TMP86FS28FG
18.7 Error Code
When detecting an error, the device transmits the error code to the external controller, as shown in Table 18-13.
Table 18-13 Error Code
Transmit Data
Meaning of Error Data
62H, 62H, 62H
Baud rate modification error.
63H, 63H, 63H
Operation command error.
A1H, A1H, A1H
Framing error in the received data.
A3H, A3H, A3H
Overrun error in the received data.
Note: If a password error occurs, TMP86FS28FG does not transmit an error code.
18.8 Checksum (SUM)
18.8.1 Calculation Method
The checksum (SUM) is calculated with the sum of all bytes, and the obtained result is returned as a word.
The data is read for each byte unit and the calculated result is returned as a word.
Example:
A1H
B2H
C3H
D4H
If the data to be calculated consists of the four bytes,
the checksum of the data is as shown below.
A1H + B2H + C3H + D4H = 02EAH
SUM (HIGH)= 02H
SUM (LOW)= EAH
The checksum which is transmitted by executing the flash memory write command or flash memory SUM
output command is calculated in the manner, as shown above.
Page 237
18. Serial PROM Mode
18.8 Checksum (SUM)
TMP86FS28FG
18.8.2 Calculation data
The data used to calculate the checksum is listed in Table 18-14.
Table 18-14 Checksum Calculation Data
Operating Mode
Calculation Data
Description
Data in the entire area of the flash memory
Even when a part of the flash memory is written, the checksum
of the entire flash memory area (1000H to FFFH) is calculated.
The data length, address, record type and checksum in Intel
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 " 18.11 Product ID Code ".
Flash Memory Status Output mode
9th through 12th bytes of the transferred data
For details, refer to " 18.12 Flash Memory Status Code "
Flash Memory Erasing mode
All data in the erased area of the flash memory
(the whole or part of the flash memory)
When the sector erase is executed, only the erased area is
used to calculate the checksum. In the case of the chip erase,
an entire area of the flash memory is used.
Flash memory writing mode
Flash memory SUM output
mode
Page 238
TMP86FS28FG
18.9 Intel Hex Format (Binary)
1. After receiving the checksum of a data record, the device waits for the start mark (3AH “:”) of the next data
record. After receiving the checksum of a data record, the device ignores the data except 3AH transmitted
by the external controller.
2. After transmitting the checksum of end record, the external controller must transmit nothing, and wait for
the 2-byte receive data (upper and lower bytes of the checksum).
3. If a receiving error or Intel Hex format error occurs, the device enters the halt condition without returning
an error code to the external controller. The Intel Hex format error occurs in the following case:
When the record type is not 00H, 01H, or 02H
When a checksum error occurs
When the data length of an extended record (record type = 02H) is not 02H
When the device receives the data record after receiving an extended record (record type = 02H) with
extended address of 1000H or larger.
When the data length of the end record (record type = 01H) is not 00H
18.10Passwords
The consecutive eight or more-byte data in the flash memory area can be specified to the password.
TMP86FS28FG 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 1000H to FF9FH. The area
from FFA0H to FFFFH can not be specified as the passwords area.
If addresses from FFE0H through FFFFH 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 18-15 shows the password setting in the blank product and nonblank product.
Table 18-15 Password Setting in the Blank Product and Non-Blank Product
Password
Blank Product (Note 1)
Non-Blank Product
PNSA
(Password count storage address)
1000H ≤ PNSA ≤ FF9FH
1000H ≤ PNSA ≤ FF9FH
PCSA
(Password comparison start address)
1000H ≤ PCSA ≤ FF9FH
1000H ≤ PCSA ≤ FFA0 - N
N
(Password count)
*
8≤N
Password string setting
Not required (Note 5)
Required (Note 2)
Note 1: When addresses from FFE0H through FFFFH 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. TMP86FS28FG 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, 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 239
18. Serial PROM Mode
18.10 Passwords
TMP86FS28FG
UART
RXD pin
F0H 12H F1H 07H 01H 02H 03H 04H 05H 06H 07H
PNSA
08H
Password string
PCSA
Flash memory
F012H
08H
F107H
01H
F108H
02H
F109H
03H
F10AH
04H
F10BH
05H
Example
F10CH
06H
PNSA = F012H
PCSA = F107H
Password string = 01H,02H,03H,04H,05H
06H,07H,08H
F10DH
07H
F10EH
"08H" becomes
the umber of
Compare
passwords
8 bytes
08H
Figure 18-5 Password Comparison
18.10.1Password String
The password string transmitted from the external controller is compared with the specified data in the flash
memory. When the password string is not matched to the data in the flash memory, the device enters the halt
condition due to the password error.
18.10.2Handling of Password Error
If a password error occurs, the device enters the halt condition. In this case, reset the device to reactivate the
serial PROM mode.
18.10.3Password Management during Program Development
If a program is modified many times in the development stage, confusion may arise as to the password.
Therefore, it is recommended to use a fixed password in the program development stage.
Example :Specify PNSA to F000H, and the password string to 8 bytes from address F001H
(PCSA becomes F001H.)
Password Section code abs = 0F000H
DB
08H
: PNSA definition
DB
“CODE1234”
: Password string definition
Page 240
TMP86FS28FG
18.11Product ID Code
The product ID code is the 13-byte data containing the start address and the end address of ROM. Table 18-16
shows the product ID code format.
Table 18-16 Product ID Code Format
Data
Description
In the Case of TMP86FS28FG
1st
Start Mark (3AH)
3AH
2nd
The number of transfer data (10 bytes from 3rd to 12th byte)
0AH
3rd
Address length (2 bytes)
02H
4th
Reserved data
1DH
5th
Reserved data
00H
6th
Reserved data
00H
7th
Reserved data
00H
8th
ROM block count
01H
9th
The first address of ROM (Upper byte)
10H
10th
The first address of ROM (Lower byte)
00H
11th
The end address of ROM (Upper byte)
FFH
12th
The end address of ROM (Lower byte)
FFH
13th
Checksum of the transferred data (2’s compliment for the sum of
3rd through 12th bytes)
D2H
18.12Flash Memory Status Code
The flash memory status code is the 7-byte data including the read protection status and the status of the data from
FFE0H to FFFFH. Table 18-17 shows the flash memory status code.
Table 18-17 Flash Memory Status Code
Data
Description
In the Case of TMP86FS28FG
1st
Start mark
3AH
2nd
Transferred data count (3rd through 6th byte)
04H
3rd
Status code
00H to 03H
(See figure below)
4th
Reserved data
00H
5th
Reserved data
00H
6th
Reserved data
00H
7th
Checksum of the transferred data (2’s compliment
for the sum of 3rd through 6th data)
3rd byte
00H
01H
02H
03H
checksum
00H
FFH
FEH
FDH
Status Code 1
7
6
5
4
3
Page 241
2
1
0
RPENA
BLANK
(Initial Value: 0000 00**)
18. Serial PROM Mode
18.12 Flash Memory Status Code
TMP86FS28FG
RPENA
Flash memory read protection status
0:
1:
Read protection is disabled.
Read protection is enabled.
BLANK
The status from FFE0H
to FFFFH.
0:
1:
All data is FFH in the area from FFE0H to FFFFH.
The value except FFH is included in the area from FFE0H to FFFFH.
Some operation commands are limited by the flash memory status code 1. If the read protection is enabled, flash
memory writing mode command can not be executed. Erase all flash memory before executing these command.
Flash Memory
Erasing Mode
RPENA
BLANK
Flash Memory
Writing Mode
Flash memory
SUM
Output Mode
0
0
m
m
m
m
0
1
Pass
m
m
m
1
0
×
m
m
m
m
×
×
1
1
×
m
m
m
Pass
×
Pass
Product
ID Code Output
Mode
Flash Memory
Status Output
Mode
Sector
Erase
Chip
Erase
Read Protection Setting
Mode
×
m
Pass
Pass
Note: m:
The command can be executed.
Pass: The command can be executed with a password.
×:
The command can not be executed.
(After echoing the command back to the external controller, TMP86FS28FG stops UART communication and enters
the halt condition.)
Page 242
TMP86FS28FG
18.13Specifying the Erasure Area
In the flash memory erasing mode, the erasure area of the flash memory is specified by n−2 byte data.
The start address of an erasure area is specified by ERASTA, and the end address is specified by ERAEND.
If ERASTA is equal to or smaller than ERAEND, the sector erase (erasure in 4 kbyte units) is executed. Executing
the sector erase while the read protection is enabled results in an infinite loop.
If ERASTA is larger than ERAEND, the chip erase (erasure of an entire flash memory area) is executed and the
read protection is disabled. Therefore, execute the chip erase (not sector erase) to disable the read protection.
Erasure Area Specification Data (n−2 byte data)
7
6
5
4
3
2
ERASTA
ERASTA
ERAEND
1
0
ERAEND
The start address of the
erasure area
0000:
0001:
0010:
0011:
0100:
0101:
0110:
0111:
1000:
1001:
1010:
1011:
1100:
1101:
1110:
1111:
from 0000H
from 1000H
from 2000H
from 3000H
from 4000H
from 5000H
from 6000H
from 7000H
from 8000H
from 9000H
from A000H
from B000H
from C000H
from D000H
from E000H
from F000H
The end address of the
erasure area
0000:
0001:
0010:
0011:
0100:
0101:
0110:
0111:
1000:
1001:
1010:
1011:
1100:
1101:
1110:
1111:
to 0FFFH
to 1FFFH
to 2FFFH
to 3FFFH
to 4FFFH
to 5FFFH
to 6FFFH
to 7FFFH
to 8FFFH
to 9FFFH
to AFFFH
to BFFFH
to CFFFH
to DFFFH
to EFFFH
to FFFFH
Note: When the sector erase is executed for the area containing no flash cell, TMP86FS28FG stops the UART communication and enters the halt condition.
Page 243
Page 244
Transmit UART data
(Checksum of an entire area)
Transmit UART data
Infinite loop
(Checksum of an entire area)
Flash memory
write process
Receive UART data
(Intel Hex format)
OK
Transmit UART data
(Transmit data = FBH)
Read protection setting
OK
Verify the password
(Compare the receive
data and flash
memory data)
Transmit UART data
(Echo back the baud rate
modification data)
NG
Verify the password
(Compare the receive
data and flash
memory data)
Receive UART data
Transmit UART data
(Transmit data = FAH)
Receive data = FAH
(Read protection
setting mode)
Non-blank product
Transmit UART data
(Product ID code)
Transmit UART data
(Transmit data = C0H)
Receive data = C0H
(Product ID
code output mode)
Blank product check
Protection
Enable
Transmit UART data
(Transmit data = 90H)
Receive data = 90H
(Flash memory sum
output mode)
Blank product check
Protection disabled
Read protection
check
Transmit UART data
(Transmit data = 30H)
Receive data = 30H
(Flash memory
writing mode)
Receive UART data
Modify the baud rate
based on the receive data
Blank Non-blank product
product
Transmit UART data
(Transmit data = 5AH)
Yes
No
Adjust the baud rate
(Adjust the source
clock to 9600 bps)
Receive data =
5AH
Receive UART data
Setup
START
Transmit UART data
(Status of the read protection
and blank product)
Infinite loop
NG
Blank
product
Blank product check
Read protection check
Transmit UART data
(Transmit data = C3H)
Receive data = C3H
(Flash memory status
output mode)
Non-blank product
Transmit UART data
(Checksum of an entire area)
Disable read protection
Chip erase
(Erase on entire area)
Transmit UART data
(Checksum of
the erased area)
Sector erase (Block erase)
Upper 4 bits x 1000H
to
Lower 4 bits x 1000H
Protection disabled
Read protection
check
Upper 4 bits < Lower 4 bits
Infinite loop
NG
Upper 4 bits > Lower 4 bits
Receive data
Receive UART data
OK
Verify the password
(Compare the receive
data and flash
memory data)
Blank
product
Blank product check
Transmit UART data
(Transmit data = F0H)
Receive data = F0H
(Flash memory
erasing mode)
Infinite loop
Protection
enabled
18.14 Flowchart
18. Serial PROM Mode
TMP86FS28FG
18.14Flowchart
TMP86FS28FG
18.15UART Timing
Table 18-18 UART Timing-1 (VDD = 4.5 to 5.5 V, fc = 2 to 16 MHz, Topr = -10 to 40°C)
Minimum Required Time
Parameter
Symbol
Clock Frequency (fc)
At fc = 2 MHz
At fc = 16 MHz
Time from matching data reception to the echo back
CMeb1
Approx. 930
465 µs
58.1 µs
Time from baud rate modification data reception to the echo back
CMeb2
Approx. 980
490 µs
61.3 µs
Time from operation command reception to the echo back
CMeb3
Approx. 800
400 µs
50 µs
Checksum calculation time
CKsm
Approx. 7864500
3.93 s
491.5 µs
Erasure time of an entire flash memory
CEall
-
30 ms
30 ms
Erasure time for a sector of a flash memory (in 4-kbyte units)
CEsec
-
15 ms
15 ms
Table 18-19 UART Timing-2 (VDD = 4.5 to 5.5 V, fc = 2 to 16 MHz, Topr = -10 to 40°C)
Minimum Required Time
Parameter
Symbol
Clock Frequency (fc)
At fc = 2 MHz
At fc = 16 MHz
Time from the reset release to the acceptance of start bit of RXD pin
RXsup
2100
1.05 ms
131.3 ms
Matching data transmission interval
CMtr1
28500
14.2 ms
1.78 ms
Time from the echo back of matching data to the acceptance of baud rate
modification data
CMtr2
380
190 µs
23.8 µs
Time from the echo back of baud rate modification data to the acceptance
of an operation command
CMtr3
650
325 µs
40.6 µs
Time from the echo back of operation command to the acceptance of
password count storage addresses (Upper byte)
CMtr4
800
400 µs
50 µs
CMtr3
CMtr2
RXsup
CMtr4
RESET pin
(5AH)
(30H)
(28H)
RXD pin
(5AH)
(30H)
(28H)
TXD pin
CMeb1
(5AH)
CMeb2
(5AH)
RXD pin
TXD pin
CMtr1
Page 245
CMeb3
(5AH)
18. Serial PROM Mode
18.15 UART Timing
TMP86FS28FG
Page 246
TMP86FS28FG
20. Electrical Characteristics
20.1 Absolute Maximum Ratings
The absolute maximum ratings are rated values which must not be exceeded during operation, even for an instant.
Any one of the ratings must not be exceeded. If any absolute maximum rating is exceeded, a device may break down
or its performance may be degraded, causing it to catch fire or explode resulting in injury to the user. Thus, when
designing products which include this device, ensure that no absolute maximum rating value will ever be exceeded.
(VSS = 0 V)
Parameter
Symbol
Pins
Ratings
Supply voltage
VDD
−0.3 to 6.5
Input voltage
VIN
−0.3 to VDD + 0.3
VOUT
−0.3 to VDD + 0.3
Output voltage
Output current (Per 1 pin)
Output current (Total)
Power dissipation [Topr = 85°C]
IOL1
P0,P1,P2,P3,P4,P5,P6,P7,P8 ports
3.2
IOH1
P0,P1,P3,P4,P5,P6,P7,P8 ports
−1.8
Σ IOL1
P0,P1,P2,P3,P4,P5,P6,P7,P8 ports
80
Σ IOH1
P0,P1,P3,P4,P5,P6,P7,P8 ports
−30
PD
350
Soldering temperature (Time)
Tsld
260 (10 s)
Storage temperature
Tstg
−55 to 125
Operating temperature
Topr
−40 to 85
Page 249
Unit
V
mA
mW
°C
20. Electrical Characteristics
20.2 Operating Condition
TMP86FS28FG
20.2 Operating Condition
The Operating Conditions show the conditions under which the device be used in order for it to operate normally
while maintaining its quality. If the device is used outside the range of Operating Conditions (power supply voltage,
operating temperature range, or AC/DC rated values), it may operate erratically. Therefore, when designing your
application equipment, always make sure its intended working conditions will not exceed the range of Operating
Conditions.
20.2.1 MCU mode (Flash Programming or erasing)
(VSS = 0 V, Topr = -10 to 40°C)
Parameter
Symbol
Pins
VDD
Supply voltage
Input high level
Input low level
VIH1
Except hysteresis input
VIH2
Hysteresis input
VIL1
Except hysteresis input
VIL2
Clock frequency
fc
Ratings
NORMAL1, 2 modes
Hysteresis input
VDD ≥ 4.5 V
VDD ≥ 4.5 V
XIN, XOUT
Min
Max
4.5
5.5
VDD × 0.70
VDD
VDD × 0.75
Unit
V
VDD × 0.30
0
VDD × 0.25
1.0
16.0
MHz
20.2.2 MCU mode (Except Flash Programming or erasing)
(VSS = 0 V, Topr = −40 to 85°C)
Parameter
Symbol
Pins
Condition
fc = 16 MHz
fc = 8 MHz
VDD
Supply voltage
fs =
32.768 kHz
NORMAL1, 2 mode
IDLE0, 1, 2 mode
Min
Max
4.0
NORMAL1, 2 mode
IDLE0, 1, 2 mode
SLOW1, 2 mode
5.5
2.7(Note1)
SLEEP0, 1, 2 mode
STOP mode
Input high level
VIH1
Except hysteresis input
VIH2
Hysteresis input
Input low level
VIL1
Except hysteresis input
VIL2
Hysteresis input
LCD reference voltage
range
Capacity for LCD
booster circuit
fc
XIN, XOUT
fs
XTIN, XTOUT
V1
CLCD
VDD ≥ 4.5 V
V
VDD × 0.70
VDD × 0.75
VDD = 2.7 V to 5.5 V
VDD = 4.0 V to 5.5 V
VDD = 2.7 V to 5.5 V
LCD booster circuit enable
(V3 ≥ VDD)
VDD × 0.30
0
VDD × 0.25
VDD × 0.10
1.0
8.0
16.0
MHz
30.0
34.0
kHz
0.9
1.8
V
0.1
0.47
uF
Note 1: When the supply voltage is VDD < 3.0V, the operating tempreture is Topr= -20 to 85 °C.
Page 250
VDD
VDD × 0.90
VDD < 4.5 V
VIL3
Clock frequency
VDD ≥ 4.5 V
VDD < 4.5 V
VIH3
Unit
TMP86FS28FG
20.2.3 Serial PROM mode
(VSS = 0 V, Topr = -10 to 40 °C)
Parameter
Supply voltage
Input high voltage
Input low voltage
Clock frequency
Symbol
Pins
VDD
VIH1
NORMAL1, 2 modes
Except hysteresis input
VIH2
Hysteresis input
VIL1
Except hysteresis input
VIL2
Hysteresis input
fc
Condition
VDD ≥ 4.5 V
VDD ≥ 4.5 V
XIN, XOUT
Min
Max
4.5
5.5
VDD × 0.70
VDD × 0.75
0
2.0
Page 251
VDD
Unit
V
VDD × 0.30
VDD × 0.25
16.0
MHz
20. Electrical Characteristics
20.3 DC Characteristics
TMP86FS28FG
20.3 DC Characteristics
(VSS = 0 V, Topr = −40 to 85°C)
Parameter
Symbol
Pins
Condition
Hysteresis voltage
VHS
Hysteresis input
IIN1
TEST
Input current
IIN2
Sink open drain, Tri-state
IIN3
RESET, STOP
RIN2
RESET pull-up
VDD = 5.5 V, VIN = 0 V
Input resistance
VDD = 5.5 V, VIN = 5.5 V/0 V
Min
Typ.
Max
Unit
–
0.9
–
V
–
–
±2
µA
100
220
450
kΩ
–
–
±2
µA
Output leakage current
ILO
Sink open drain, Tri-state
VDD = 5.5 V, VOUT = 5.5 V/0 V
Output high voltage
VOH
C-MOS, Tri-st port
VDD = 4.5 V, IOH = −0.7 mA
4.1
–
–
Output low voltage
VOL
Except XOUT
VDD = 4.5 V, IOL = 1.6 mA
–
–
0.4
V2 terminal
V3 ≥ VDD
–
V1 x 2
–
V3 terminal
Reference supply terminal :V1
SEG/COM terminal no load
–
V1 x 3
–
–
15.5
16.5
LCD output voltage
use LCD driver’s
booste
V2-3OUT
Supply current in
NORMAL 1, 2 mode
VDD = 5.5 V
VIN = 5.3/0.2 V
fc = 16 MHz
fs = 32.768 kHz
Supply current in
IDLE 0, 1, 2 mode
Supply current in
SLOW 1 mode
When a program
operates on flash
memory (Note5,6)
VDD = 3.0 V
IDD
VIN = 2.8/0.2 V
fs = 32.768 kHz
LCD drive is not
enable.
Supply current in
SLEEP 1 mode
6
8.3
When a program
operates on flash
memory (Note5,6)
–
25
260
When a program
operates on RAM
–
20
24
–
9
21
–
8
18
–
0.5
10
VDD = 5.5 V
Supply current in
STOP mode
VIN = 5.3 V/0.2 V
V
mA
–
Supply current in
SLEEP 0 mode
V
µA
Note 1: Typical values show those at Topr = 25°C, VDD = 5 V
Note 2: Input current (IIN1, IIN2); The current through pull-up or pull-down resistor is not included.
Note 3: IDD does not include IREF current.
Note 4: The supply currents of SLOW 2 and SLEEP 2 modes are equivalent to IDLE 0, 1, 2.
Note 5: When a program is executing in the flash memory or when data is being read from the flash memory, the flash memory
operates in an intermittent manner, causing peak currents in the operation current, as shown in Figure 20-1.
In this case, the supply current IDD (in NORMAL1, NORMAL2 and SLOW1 modes) is defined as the sum of the average
peak current and MCU current.
Note 6: When designing the power supply, make sure that peak currents can be supplied. In SLOW1 mode, the difference
between the peak current and the average current becomes large.
1 machine cycle (4/fc or 4/fs)
n
Program coutner (PC)
n+1
n+2
n+3
Momentary flash current
I DDP-P
[mA]
Max. current
Typ. current
Sum of average
momentary flash current
and MCU current
MCU current
Figure 20-1 Intermittent Operation of Flash Memory
Page 252
TMP86FS28FG
20.4 AD Conversion Characteristics
(VSS = 0.0 V, 4.5 V ≤ VDD ≤ 5.5 V, Topr = −40 to 85°C)
Parameter
Symbol
Condition
Analog reference voltage
VAREF
Power supply voltage of analog control
circuit (Note6)
AVDD
VDD
AVSS
VSS
Analog reference voltage range (Note4)
∆VAREF
3.5
–
–
Analog input voltage
VAIN
AVSS
–
VAREF
Power supply current of analog
reference voltage
IREF
–
0.6
1.0
VDD = AVDD = VAREF = 5.5 V
VSS = AVSS = 0.0 V
Non linearity error
VDD = AVDD = 5.0 V
Zero point error
VSS = AVSS = 0.0 V
Full scale error
VAREF = 5.0 V
Total error
Min
Typ.
Max
AVDD − 1.0
–
AVDD
Unit
V
–
–
±2
–
–
±2
–
–
±2
–
–
±2
mA
LSB
(VSS = 0.0 V, 2.7 V ≤ VDD < 4.5 V, Topr = −40 to 85°C)
Parameter
Symbol
Analog reference voltage
VAREF
Power supply voltage of analog control
circuit (Note6)
AVDD
VDD
AVSS
VSS
Analog reference voltage range (Note4)
∆VAREF
2.5
–
–
VAIN
VSS
–
VAREF
–
0.5
0.8
Analog input voltage
Power supply current of analog
reference voltage
IREF
Condition
VDD = AVDD = VAREF = 4.5 V
VSS = AVSS = 0.0 V
Non linearity error
Zero point error
Full scale error
VDD = AVDD = 2.7 V
VSS = AVSS = 0.0 V
VAREF = 2.7 V
Total error
Min
Typ.
Max
AVDD − 1.0
–
AVDD
Unit
V
–
–
±2
–
–
±2
–
–
±2
–
–
±2
mA
LSB
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.
About conversion time, please refer to “Register Configuration”.
Note 3: Please use input voltage to AIN input Pin in limit of VAREF to VSS. When voltage of range outside is input, conversion value
becomes unsettled and gives affect to other channel conversion value.
Note 4: Analog reference voltage range: ∆VAREF = VAREF − VSS
Note 5: When AD is used with VDD < 2.7 V, the guaranteed temperature range varies with the operating voltage.
Note 6: The AVDD pin should be fixed on the VDD level even though AD converter is not used.
Page 253
20. Electrical Characteristics
20.5 AC Characteristics
TMP86FS28FG
20.5 AC Characteristics
(VSS = 0 V, VDD = 4.0 to 5.5 V, Topr = −40 to 85°C)
Parameter
Symbol
Condition
Min
Typ.
Max
0.25
–
4
117.6
–
133.3
For external clock operation
(XIN input)
fc = 16 MHz
–
31.25
–
ns
For external clock operation
(XTIN input)
fs = 32.768 kHz
–
15.26
–
µs
NORMAL1, 2 mode
Machine cycle time
tcy
IDLE1, 2 mode
µs
SLOW1, 2 mode
SLEEP1, 2 mode
High level clock pulse width
tWCH
Low level clock pulse width
tWCL
High level clock pulse width
tWCH
Low level clock pulse width
tWCL
Unit
(VSS = 0 V, VDD = 2.7 to 5.5 V, Topr = −40 to 85°C)
Parameter
Symbol
Condition
NORMAL1, 2 mode
Machine cycle time
tcy
IDLE1, 2 mode
tWCH
Low level clock pulse width
tWCL
High level clock pulse width
tWCH
Low level clock pulse width
tWCL
Typ.
Max
0.5
–
4
Unit
µs
SLOW1, 2 mode
117.6
–
133.3
For external clock operation
(XIN input)
fc = 8 MHz
–
62.5
–
ns
For external clock operation
(XTIN input)
fs = 32.768 kHz
–
15.26
–
µs
SLEEP1, 2 mode
High level clock pulse width
Min
Note 1: When the supply voltage is VDD < 3.0V, the operating tempreture is Topr= -20 to 85 °C.
20.6 Flash Characteristics
Parameter
Number of guaranteed writes to flash
memory
Condition
VSS = 0 V, Topr = -10 to 40 °C
Page 254
Min
Typ.
Max
Unit
–
–
100
Times
TMP86FS28FG
20.7 Recommended Oscillating Conditions
XIN
C1
XOUT
XTIN
C2
XTOUT
C1
(1) High-frequency Oscillation
C2
(2) Low-frequency Oscillation
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: For the resonators to be used with Toshiba microcontrollers, we recommend ceramic resonators manufactured by
Murata Manufacturing Co., Ltd.
For details, please visit the website of Murata at the following URL:
http://www.murata.com
20.8 Handling Precaution
- The solderability test conditions for lead-free products (indicated by the suffix G in product name) are shown
below.
1. When using the Sn-37Pb solder bath
Solder bath temperature = 230 °C
Dipping time = 5 seconds
Number of times = once
R-type flux used
2. When using the Sn-3.0Ag-0.5Cu solder bath
Solder bath temperature = 245 °C
Dipping time = 5 seconds
Number of times = once
R-type flux used
Note: The pass criteron of the above test is as follows:
Solderability rate until forming ≥ 95 %
- When using the device (oscillator) in places exposed to high electric fields such as cathode-ray tubes, we
recommend electrically shielding the package in order to maintain normal operating condition.
Page 255
20. Electrical Characteristics
20.8 Handling Precaution
TMP86FS28FG
Page 256
TMP86FS28FG
21. Package Dimensions
QFP80-P-1420-0.80B Rev 01
Unit: mm
Page 257
21. Package Dimensions
TMP86FS28FG
Page 258
This is a technical document that describes the operating functions and electrical specifications of the 8-bit
microcontroller series TLCS-870/C (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
systems 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
production 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.