![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
8 bit microcontroller tlcs-870/c series TMP86FS64FG
page 2 TMP86FS64FG the information contained herein is su bject to change without notice. 021023 _ d toshiba is continually working to improve the qual ity and reliability of its products. nevertheless, semiconductor devices in general can malfunction or fa il 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 to shiba products are used within specified operating ranges as set forth in the most re cent toshiba products specifications. also, please keep in mind the precautio ns 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 inte nded 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, tr ansportation instruments, traffic signal instruments, combustion control instruments, medical instrument s, 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 prohib ited under any applicable laws and regulations. 060106_q the information contained he rein is presented only as a guide for the applications of our products. no responsibility is assumed by tosh iba 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 patent or patent rights of toshiba or others. 021023_c the products described in this document may include products subject to the foreign exchange and foreign trade laws. 021023_f for a discussion of how the reliability of microcontro llers can be predicted, please refer to section 1.3 of the chapter entitled quality and reli ability assurance/hand ling precautions. 030619_s ? 2006 toshiba corporation all rights reserved revision history date revision 2005/12/27 1 first release 2006/2/6 2 contents revised 2006/6/29 3 periodical updating.no change in contents. 2006/8/22 4 contents revised i table of contents TMP86FS64FG 1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4 pin names and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2. operational descrip tions 2.1 cpu core function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.1.1 memory address map ............................................................................................................................. 1 1 2.1.2 program memory (flash) ........................................................................................................................ 12 2.1.3 data memory (ram) ............................................................................................................................... 12 2.2 system clock controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2.1 clock generator ............................................................................................................................... ....... 13 2.2.2 timing generator ............................................................................................................................... ..... 14 2.2.2.1 timing generator configuration 2.2.2.2 machine cycle 2.2.3 operating modes ............................................................................................................................... ..... 16 2.2.3.1 single-clock mode 2.2.3.2 dual-clock mode 2.2.3.3 stop mode 2.2.3.4 operation mode transition 2.2.4 operating mode control ......................................................................................................................... 21 2.2.4.1 stop mode 2.2.4.2 idle1/2 and sleep1/2 modes 2.2.4.3 idle0 and sleep0 modes 2.2.4.4 slow mode 2.3 reset circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 2.3.1 external reset input ............................................................................................................................... 36 2.3.2 address-trap-reset ............................................................................................................................... 37 2.3.3 watchdog timer reset ........................................................................................................................... 37 2.3.4 system clock reset ............................................................................................................................... 37 3. interrupt control circuit 3.1 interrupt latches (il15 to il2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.2 interrupt enable register (eir) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.2.1 interrupt master enable flag (imf) .......................................................................................................... 40 3.2.2 individual interrupt enable flags (ef15 to ef4) ...................................................................................... 41 3.3 interrupt source selector (intsel) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.4 interrupt sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.4.1 interrupt acceptance processing is packaged as follows. ....................................................................... 43 3.4.2 saving/restoring general-purpose registers ............................................................................................ 44 3.4.2.1 using push and pop instructions 3.4.2.2 using data transfer instructions 3.4.3 interrupt return ............................................................................................................................... ......... 46 3.5 software interrupt (intsw) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.5.1 address error detection .......................................................................................................................... 47 ii 3.5.2 debugging ............................................................................................................................... ............... 47 3.6 undefined instruction interrupt (intundef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.7 address trap interrupt (intatrap) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 3.8 external interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 4. special function r egister (sfr) 4.1 sfr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 4.2 dbr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 5. i/o ports 5.1 port p0 (p07 to p00) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 5.2 port p1 (p17 to p10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 5.3 port p2 (p22 to p20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 5.4 port p3 (p37 to p30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 5.5 port p4 (p47 to p40) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 5.6 port p5 (p57 to p50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 5.7 port p6 (p67to p60) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.8 port p7 (p77 to p70) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.9 port p8 (p87 to p80) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.10 port p9 (p97 to p90) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 5.11 port pa (pa7 to pa0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.12 port pb (pb7 to pb0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 6. watchdog timer (wdt) 6.1 watchdog timer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 6.2 watchdog timer control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 6.2.1 malfunction detection methods using the watchdog timer ................................................................... 74 6.2.2 watchdog timer enable ......................................................................................................................... 75 6.2.3 watchdog timer disable ........................................................................................................................ 76 6.2.4 watchdog timer interrupt (intwdt) ...................................................................................................... 76 6.2.5 watchdog timer reset ........................................................................................................................... 77 6.3 address trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 6.3.1 selection of address trap in internal ram (atas) ................................................................................ 78 6.3.2 selection of operation at address trap (atout) .................................................................................. 78 6.3.3 address trap interrupt (intatrap) ....................................................................................................... 78 6.3.4 address trap reset ............................................................................................................................... . 79 7. time base timer (tbt) 7.1 time base timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 7.1.1 configuration ............................................................................................................................... ........... 81 7.1.2 control ............................................................................................................................... ..................... 81 7.1.3 function ............................................................................................................................... ................... 82 7.2 divider output (dvo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 7.2.1 configuration ............................................................................................................................... ........... 83 7.2.2 control ............................................................................................................................... ..................... 83 iii 8. 16-bit timercounter 1 (tc1) 8.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 8.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 8.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 8.3.1 timer mode ............................................................................................................................... .............. 88 8.3.2 external trigger timer mode .................................................................................................................. 90 8.3.3 event counter mode ............................................................................................................................... 92 8.3.4 window mode ............................................................................................................................... .......... 93 8.3.5 pulse width measurement mode ............................................................................................................ 94 8.3.6 programmable pulse generate (ppg) output mode ............................................................................. 97 9. 16-bit timer/counter2 (tc2) 9.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 9.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 9.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 9.3.1 timer mode ............................................................................................................................... ............ 103 9.3.2 event counter mode .............................................................................................................................. 105 9.3.3 window mode ............................................................................................................................... ........ 105 10. 8-bit timercounter 3 (tc3) 10.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 10.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 10.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 10.3.1 timer mode ............................................................................................................................... .......... 109 figure 10-3 ................................................................................................................ .................................... 111 10.3.3 capture mode ............................................................................................................................... ...... 112 11. 8-bit timercounter 4 (tc4) 11.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 11.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 11.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 11.3.1 timer mode ............................................................................................................................... .......... 116 11.3.2 event counter mode ........................................................................................................................... 117 11.3.3 programmable divider output (pdo) mode ....................................................................................... 118 11.3.4 pulse width modulation (pwm) output mode .................................................................................... 119 12. 8-bit timercounter 5 (tc5) 12.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 12.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 12.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 12.3.1 timer mode ............................................................................................................................... .......... 124 12.3.2 event counter mode ........................................................................................................................... 125 12.3.3 programmable divider output (pdo) mode ....................................................................................... 126 12.3.4 pulse width modulation (pwm) output mode .................................................................................... 127 iv 13. 8-bit timercounter 6 (tc6) 13.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 13.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 13.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 13.3.1 timer mode ............................................................................................................................... .......... 132 13.3.2 event counter mode ........................................................................................................................... 133 13.3.3 programmable divider output (pdo) mode ....................................................................................... 134 13.3.4 pulse width modulation (pwm) output mode .................................................................................... 135 14. asynchronous serial interface (uart ) 14.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 14.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 14.3 transfer data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 14.4 infrared (irda) data format transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 14.5 transfer rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 14.6 data sampling method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 14.7 stop bit length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 14.8 parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 14.9 transmit/receive operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 14.9.1 data transmit operation .................................................................................................................... 143 14.9.2 data receive operation ..................................................................................................................... 143 14.10 status flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 14.10.1 parity error ............................................................................................................................... ......... 144 14.10.2 framing error ............................................................................................................................... ..... 144 14.10.3 overrun error ............................................................................................................................... ..... 144 14.10.4 receive data buffer full ................................................................................................................... 145 14.10.5 transmit data buffer empty ............................................................................................................. 145 14.10.6 transmit end flag ............................................................................................................................ 14 6 15. synchronous serial interface (sio1) 15.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 15.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 15.3 serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 15.3.1 clock source ............................................................................................................................... ........ 149 15.3.1.1 internal clock 15.3.1.2 external clock 15.3.2 shift edge ............................................................................................................................... ............. 151 15.3.2.1 leading edge 15.3.2.2 trailing edge 15.4 number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 15.5 number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 15.6 transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 15.6.1 4-bit and 8-bit transfer modes ............................................................................................................. 152 15.6.2 4-bit and 8-bit receive modes ............................................................................................................. 154 15.6.3 8-bit transfer / receive mode ............................................................................................................... 155 16. synchronous serial interface (sio2) 16.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 v 16.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 16.3 serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 16.3.1 clock source ............................................................................................................................... ........ 161 16.3.1.1 internal clock 16.3.1.2 external clock 16.3.2 shift edge ............................................................................................................................... ............. 163 16.3.2.1 leading edge 16.3.2.2 trailing edge 16.4 number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 16.5 number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 16.6 transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 16.6.1 4-bit and 8-bit transfer modes ............................................................................................................. 164 16.6.2 4-bit and 8-bit receive modes ............................................................................................................. 166 16.6.3 8-bit transfer / receive mode ............................................................................................................... 167 17. 10-bit ad converter (adc) 17.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 17.2 register configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 17.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 17.3.1 software start mode ........................................................................................................................... 175 17.3.2 repeat mode ............................................................................................................................... ....... 175 17.3.3 register setting ............................................................................................................................... . 176 17.4 stop/slow modes during ad conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.5 analog input voltage and ad conversion result . . . . . . . . . . . . . . . . . . . . . . . 178 17.6 precautions about ad converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 17.6.1 analog input pin voltage range ........................................................................................................... 179 17.6.2 analog input shared pins .................................................................................................................... 179 17.6.3 noise countermeasure ....................................................................................................................... 179 18. key-on wakeup (kwu) 18.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 18.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 18.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 19. flash memory 19.1 flash memory control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 19.1.1 flash memory command sequence execution control (flscr vi 20. serial prom mode 20.1 outline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 20.2 memory mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 20.3 serial prom mode setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 20.3.1 serial prom mode control pins ........................................................................................................ 194 20.3.2 pin function ............................................................................................................................... ......... 194 20.3.3 example connection for on-board writing ......................................................................................... 195 20.3.4 activating the serial prom mode ...................................................................................................... 196 20.4 interface specifications for uart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 20.5 operation command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 20.6 operation mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 20.6.1 flash memory erasing mode (operating command: f0h) ................................................................. 201 20.6.2 flash memory writing mode (operation command: 30h) .................................................................. 203 20.6.3 ram loader mode (operation command: 60h) ................................................................................ 206 20.6.4 flash memory sum output mode (operation command: 90h) ......................................................... 208 20.6.5 product id code output mode (operation command: c0h) .............................................................. 209 20.6.6 flash memory status output mode (operation command: c3h) ...................................................... 211 20.6.7 flash memory read protection setting mode (operation command: fah) ...................................... 212 20.7 error code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 20.8 checksum (sum) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 20.8.1 calculation method ............................................................................................................................. 2 14 20.8.2 calculation data ............................................................................................................................... ... 215 20.9 intel hex format (binary) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 20.10 passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 20.10.1 password string ............................................................................................................................... . 217 20.10.2 handling of password error .............................................................................................................. 217 20.10.3 password management during program development .................................................................... 217 20.11 product id code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 20.12 flash memory status code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 20.13 specifying the erasure area . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 20.14 port input control register . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 20.15 flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 20.16 uart timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 21. input/output circuitry 21.1 control pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225 21.2 input/output ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 22. electrical characteristics 22.1 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227 22.2 recommended operating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 22.2.1 mcu mode (flash programming or erasing) ..................................................................................... 228 22.2.2 mcu mode (except flash progra mming or erasing) ......................................................................... 228 22.2.3 serial prom mode ............................................................................................................................. 2 29 22.3 dc characteristics. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 230 22.4 ad characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232 22.5 ac characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 22.6 flash characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234 22.6.1 write/retention characteristics .......................................................................................................... 234 vii 22.7 recommended oscillating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 22.8 handling precaution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235 23. package dimension this is a technical docu ment that describes the operat ing functions and electrical specifications of the 8-bit microc ontroller series tlcs-870/c (lsi). viii page 1 060116ebp TMP86FS64FG cmos 8-bit microcontroller ? the information contained herein is subject to change without notice. 021023_d ? toshiba is continually working to improve the quality and reli ability of its products. neverthel ess, semiconductor devices in general can malfunction or fail due to their inherent el ectrical sensitivity and vul nerability to physical stre ss. it is the responsibility of the buyer, when utilizing toshiba products, to comply with the standards of sa fety 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, pleas e 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 gui de for semiconductor devices,? or ?toshiba se miconductor reliability handbook? etc. 021023_a ? the toshiba products listed in this document are intended for usage in general electronics applic ations (computer, personal eq uip- ment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). these toshiba products are neithe r intended nor warranted for usage in equipment that requires extr aordinarily high quality and/or re liability or a malfunctionor failure of which may cause loss of human life or bod ily injury (?unintended usage?). unintended us age include atomic energy control instru ments, airplane or spaceship instruments, transporta tion instruments, traffic signal instrume nts, combustion control instruments, medi cal instru- ments, all types of safety dev ices, etc. unintended usage of toshiba products li sted in this document shall be made at the cust omer'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 appl icable laws and regulations. 060106_q ? the information contained herein is present ed only as a guide for the applications of our products. no responsibility is assum ed by toshiba for any infringements of patents or other rights of the th ird parties which may result from its use. no license is gran ted by impli- cation or otherwise under any patent or patent rights of toshiba or others. 021023_c ? the products described in this document are subjec t to the foreign exchange and foreign trade laws. 021023_e ? for a discussion of how the reliability of microcontrollers c an be predicted, please refer to section 1.3 of the chapter entit led quality and reliability assurance/h andling precautions. 030619_s 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. TMP86FS64FG the TMP86FS64FG is a single-chip 8-bit high-speed a nd high-functionality microcomputer incorporating 61440 bytes of flash memory. it is pin-compatible with the tmp86cs64afg (mask rom version). the TMP86FS64FG can realize operations equivalent to those of the tmp86cs64afg by programming the on-chip flash memory. 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. 21interrupt sources (external : 6 internal : 15) 3. input / output ports (91 pins) large current output: 16pins (typ. 20ma), led direct drive 4. watchdog timer 5. prescaler - time base timer - divider output function 6. 16-bit timer counter: 1 ch - timer, external trigger, wi ndow, pulse width measurement, event counter, programmable pulse generate (ppg) modes 7. 16-bit timer counter: 1 ch - timer, event counter, window modes 8. 8-bit timer counter : 1 ch product no. rom (flash) ram package mask rom mcu emulation chip TMP86FS64FG 61440 bytes 2048 bytes p-qfp100-1420-0.65a tmp86cs64afg tmp86c964xb page 2 1.1 features TMP86FS64FG - timer, event counter, capture modes 9. 8-bit timer counter : 3 ch - timer, event counter, pulse width modulation (pwm) output, programmable divider output (pdo) modes 10. 8-bit uart : 1 ch 11. 8-bit sio: 2 ch 12. 10-bit successive approximation type ad converter - analog input: 16 ch 13. key-on wakeup : 4 ch 14. clock operation single clock mode dual clock mode 15. low power consumption operation stop mode: oscillation stops. (battery/capacitor back-up.) slow1 mode: low power consumption operation usin g low-frequency clock.(high-frequency clock stop.) slow2 mode: low power consumption operation usin g low-frequency clock.(high-frequency clock oscillate.) idle0 mode: cpu stops, and only the time-based-tim er(tbt) on peripherals operate using high fre- quency clock. release by falling edge of th e source clock which is set by tbtcr page 3 TMP86FS64FG 1.2 pin assignment figure 1-1 pin assignment 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 pa0 p83 p82 p81 p80 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 pa7 pa6 pa5 pa4 pa3 pa2 pa1 p07 p06 p05 p04 p03 p02 p01 p00 p17 p16 p84 p85 p86 p87 p90 p91 p92 p93 p94 p95 p96 p97 p50 p51 p52 p53 p54 p55 p56 p57 vss xin xout test vdd (xtin) p21 (xtout) p22 reset ( stop / int5 ) p20 ( pwm4/pdo4 /tc4) p30 ( pwm5/pdo5 /tc5) p31 ( pwm6/pdo6 /tc6) p32 (si1) p34 ( sck1 ) p33 (so1) p35 (si2) p36 (so2) p37 ( sck2 ) p40 (rxd1) p41 (txd1) p42 p43 (boot/rxd2) p44 (tc3/int3) p46 (txd2) p45 (int4) p47 (ain0) p60 (ain1) p61 (ain2) p62 (ain3) p63 (ain4) p64 p15 (tc2) p14 ( ppg ) p13 ( dvo ) p12 (int2/tc1) p11 (int1) p10 ( int0 ) avss avdd varef p77 (ain15/stop5) p76 (ain14/stop4) p75 (ain13/stop3) p74 (ain12/stop2) p73 (ain11) p72 (ain10) p71 (ain9) p70 (ain8) p67 (ain7) p66 (ain6) p65 (ain5) page 4 1.3 block diagram TMP86FS64FG 1.3 block diagram page 5 TMP86FS64FG figure 1-2 block diagram page 6 1.4 pin names and functions TMP86FS64FG 1.4 pin names and functions the TMP86FS64FG 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 p07 60 io port07 p06 59 io port06 p05 58 io port05 p04 57 io port04 p03 56 io port03 p02 55 io port02 p01 54 io port01 p00 53 io port00 p17 52 io port17 p16 51 io port16 p15 tc2 50 io i port15 tc2 input p14 ppg 49 io o port14 ppg output p13 dvo 48 io o port13 divider output p12 int2 tc1 47 io i i port12 external interrupt 2 input tc1 input p11 int1 46 io i port11 external interrupt 1 input p10 int0 45 io i port10 external interrupt 0 input p22 xtout 7 io o port22 low frequency osc output pin p21 xtin 6 io i port21 low frequency osc input pin p20 int5 stop 9 io i i port20 external interrupt 5 input stop mode release input p37 so2 17 io o port37 serial data output 2 p36 si2 16 io i port36 serial data input 2 p35 so1 15 io o port35 serial data output 1 p34 si1 14 io i port34 serial data input 1 p33 sck1 13 io io port33 serial clock i/o 1 page 7 TMP86FS64FG p32 tc6 pwm6/pdo6 12 io i o port32 tc6 input pwm6/pdo6 output p31 tc5 pwm5/pdo5 11 io i o port31 tc5 input pwm5/pdo5 output p30 tc4 pwm4/pdo4 10 io i o port30 tc4 input pwm4/pdo4 output p47 int4 25 io i port47 external interrupt 4 input p46 int3 tc3 24 io i i port46 external interrupt 3 input tc3 pin input p45 txd2 23 io o port45 uart data output 2 p44 rxd2 boot 22 io i i port44 uart data input 2 serial prom mode control input p43 21 io port43 p42 txd1 20 io o port42 uart data output 1 p41 rxd1 19 io i port41 uart data input 1 p40 sck2 18 io io port40 serial clock i/o 2 p57 100 io port57 p56 99 io port56 p55 98 io port55 p54 97 io port54 p53 96 io port53 p52 95 io port52 p51 94 io port51 p50 93 io port50 p67 ain7 33 io i port67 analog input7 p66 ain6 32 io i port66 analog input6 p65 ain5 31 io i port65 analog input5 p64 ain4 30 io i port64 analog input4 p63 ain3 29 io i port63 analog input3 p62 ain2 28 io i port62 analog input2 table 1-1 pin names and functions(2/4) pin name pin number input/output functions page 8 1.4 pin names and functions TMP86FS64FG p61 ain1 27 io i port61 analog input1 p60 ain0 26 io i port60 analog input0 p77 ain15 stop5 41 io i i port77 analog input15 stop5 input p76 ain14 stop4 40 io i i port76 analog input14 stop4 input p75 ain13 stop3 39 io i i port75 analog input13 stop3 input p74 ain12 stop2 38 io i i port74 analog input12 stop2 input p73 ain11 37 io i port73 analog input11 p72 ain10 36 io i port72 analog input10 p71 ain9 35 io i port71 analog input9 p70 ain8 34 io i port70 analog input8 p87 84 io port87 p86 83 io port86 p85 82 io port85 p84 81 io port84 p83 80 io port83 p82 79 io port82 p81 78 io port81 p80 77 io port80 p97 92 io port97 p96 91 io port96 p95 90 io port95 p94 89 io port94 p93 88 io port93 p92 87 io port92 p91 86 io port91 p90 85 io port90 pa7 68 io porta7 pa6 67 io porta6 table 1-1 pin names and functions(3/4) pin name pin number input/output functions page 9 TMP86FS64FG pa5 66 io porta5 pa4 65 io porta4 pa3 64 io porta3 pa2 63 io porta2 pa1 62 io porta1 pa0 61 io porta0 pb7 76 io portb7 pb6 75 io portb6 pb5 74 io portb5 pb4 73 io portb4 pb3 72 io portb3 pb2 71 io portb2 pb1 70 io portb1 pb0 69 io portb0 xin 2 i high frequency osc input pin xout 3 i high frequency osc output pin reset 8 i reset input test 4 i test pin (fix to low level) varef 42 i analog base voltage input pin for a/d conversion avdd 43 i analog power supply avss 44 i analog power supply vdd 5 i vdd pin vss 1 i gnd pin table 1-1 pin names and functions(4/4) pin name pin number input/output functions page 10 1.4 pin names and functions TMP86FS64FG page 11 TMP86FS64FG 2. operational descriptions 2.1 cpu core function the cpu core consists of a cpu, a system cl ock controller and an interrupt controller. this chapter provides descriptions of the cpu core, the program memory, th e data memory and the reset circuit. 2.1.1 memory address map TMP86FS64FG memory consists of ram and special function register (sfr), which are mapped to a 64 kbyte address space. the TMP86FS64FG memory consists of flash, ram, special function register (sfr) and data buffer resister (dbr), which are mapped to a 64 kbyte address space. figure 2-1 shows the TMP86FS64FG memory address map. figure 2-1 memory address map sfr 0000 h 64 bytes sfr: ram: special function register i/o port peripheral hardware control register peripheral hardware status register system control register program status word random access memory data memory stack 003f h ram 0040 h 2048 bytes 083f h dbr 0f80 h 128 bytes dbr: data buffer register peripheral hardware control register peripheral hardware status register 0fff h 1000 h flash: program memory flash 61440 bytes ffc0 h vector table for vector call instructions (32 bytes) ffdf h ffe0 h instruction vector table (32 bytes) ffff h page 12 2. operational descriptions 2.1 cpu core function TMP86FS64FG 2.1.2 program memory (flash) TMP86FS64FG incorporates the 61440-byte (addresses from 1000h through ffffh) program memory (flash). 2.1.3 data memory (ram) TMP86FS64FG incorporates the 2048-byte (addresses fr om 0040h through 083fh) ram. since the address space from 0040h through 00 ffh within the on-chip ram can be accessed directly, it can be accessed by instructions to shorten the processing time. perform initial setting through an initialize routine sin ce the contents of the data memory become don't cares at power-up. example :clearing ram of TMP86FS64FG ld hl, 0040h : sets the start address ld a, h : sets the initialization data (00h) ld bc,07ffh : sets the number of bytes (-1) sramclr: ld (hl), a inc hl dec bc jrs f, sramclr page 13 TMP86FS64FG 2.2 system clock controller the system clock controller consists of a clock generator, a timing generator and a operating mode controller. figure 2-2 system clock controller 2.2.1 clock generator the clock generator generates the basic clock which provides the system clocks to be supplied to the cpu core and peripheral hardware. the cl ock generator contains two oscillato rs used for the high- and low-fre- quency clocks. power consumption can be reduced by the low-speed operation with the low-frequency clock, which is switched by the operating mode controller. the high-frequency clock (fc) or low-frequency clock (fs) can be obtained easily by connecting a resonator between the xin and xout pins, or xtin and xtout pi ns, respectively. the clock can be supplied from an external oscillator. in this case, supply the clock via the xin or xtin pin, and leave the xout or xtout pins unconnected. figure 2-3 example resonator connection note:the hardware feature does not provide the function to monitor externally the basic clock directly. however, with disabling all interrupts and watchdog timers, the oscillation frequency can be adjusted by programming to output a fixed-frequency pulse (i.e., clock output) to a port and monitoring the pulse. for the system to require the adjustment of the oscillation frequency, the adjustment program must be created beforehand. timing generator operating mode controller high-frequency clock oscillator tbtcr syscr2 syscr1 xin xout xtin xtout clock generator fc 0036 h 0038 h 0039 h fs system clock timing generator control register cgcr 0030 h divider control register system control register oscillate/stop control low-frequency clock oscillator xin high-frequency clock xout (a) crystal or ceramic resonator xin xout (b) external oscillator ( unconnected ) xtin low-frequency clock xtout (c) crystal resonator xtin xtout (d) external oscillator ( unconnected ) page 14 2. operational descriptions 2.2 system clock controller TMP86FS64FG 2.2.2 timing generator the timing generator generates various types of system clocks which are supplied to the cpu core or periph- eral hardware from the basic cloc k (fc or fs). the timing generator provides the following functions. 1. generating the main system clock 2. generating the divider output ( dvo ) pulses 3. generating the source clocks for the time base timer 4. generating the source clocks for the watchdog timer 5. generating the internal source clocks for the timercounter 6. generating the warm-up clocks upon exit from the stop mode 2.2.2.1 timing generator configuration the timing generator consists of a 3-stage prescaler, a 21-stage divider, a main system clock generator and a machine cycle counter. either the clock fc/4 output from the 2nd stage or the clock fc/8 output from the 3rd stage can be selected as the clock input to th e 1st stage of the divider by cg cr page 15 TMP86FS64FG figure 2-4 timing gener ator configuration note 1: fc: high-frequency clock [hz], *: don't care note 2: the bit 4 and 3 are read as a don't care when the read instruction is executed to cgcr. table 2-3 division ratio of the divider dv7ck = 0 dv7ck = 1 dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 d v1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 dv1 fc/2 3 fc/2 4 fc/2 3 fc/2 4 dv12 fc/2 14 fc/2 15 fs/2 6 dv2 fc/2 4 fc/2 5 fc/2 4 fc/2 5 dv13 fc/2 15 fc/2 16 fs/2 7 dv3 fc/2 5 fc/2 6 fc/2 5 fc/2 6 dv14 fc/2 16 fc/2 17 fs/2 8 dv4 fc/2 6 fc/2 7 fc/2 6 fc/2 7 dv15 fc/2 17 fc/2 18 fs/2 9 dv5 fc/2 7 fc/2 8 fc/2 7 fc/2 8 dv16 fc/2 18 fc/2 19 fs/2 10 dv6 fc/2 8 fc/2 9 fc/2 8 fc/2 9 dv17 fc/2 19 fc/2 20 fs/2 11 dv7 fc/2 9 fc/2 10 fs/2 dv18 fc/2 20 fc/2 21 fs/2 12 dv8 fc/2 10 fc/2 11 fs/2 2 dv19 fc/2 21 fc/2 22 fs/2 13 dv9 fc/2 11 fc/2 12 fs/2 3 dv20 fc/2 22 fc/2 23 fs/2 14 dv10 fc/2 12 fc/2 13 fs/2 4 dv21 fc/2 23 fc/2 24 fs/2 15 dv11 fc/2 13 fc/2 14 fs/2 5 divider control register cgcr (0030h) 76543210 "0" "0" dv1ck "0" "0" "0" "0" "0" (initial value: **0* ****) dv1ck selection of the input clock to the 1st stage of the divider [hz] 0: 1: fc/4 fc/8 r/w syscr2 page 16 2. operational descriptions 2.2 system clock controller TMP86FS64FG note 3: 0 must be written to the bit 7, 6, 4 through 0 of cgcr. note 1: do not set dv7ck to 1 in the single-clock mode. note 2: do not set dv7ck to 1 until the lo w-frequency clock oscill ation is stabilized. note 3: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *: don't care note 4: in the slow 1/2 or sleep1/2 mode, fs is input to the 7th stage of the divider regardless of dv7ck setting. note 5: when the stop mode is entered from the normal1/2 mode, the output of the 6th stage of the divider is input to the 7th stage of the divider during warm up after exiting from the stop mode regardless of dv7ck setting. 2.2.2.2 machine cycle the instruction execution and peripheral hardware operation are synchronized with the system clock. the minimum instruction execution unit is called a "machine cycle". there ar e 10 types of instructions for tlcs-870/c series, which are 1-cycle instructions to be executed within 1-cycle through 10-cycle instructions to be executed within ten cycles. a machine cycle consists of 4 states (s0 to s3), and each state consists of one main system clock. figure 2-5 machine cycle 2.2.3 operating modes the operating mode contro ller starts and stops the oscillators fo r the high-frequency and low-frequency clocks, and switches the main system clock. the devi ce has the single-clock, du al-clock and stop modes, which can be controlled by the system control regist ers (syscr1 and syscr2). figure 2-6 shows the operat- ing mode transition. timing generator control resister tbtcr (0036h) 76543210 (dvoe n) (dvock) dv7ck (tbte n) (tbtck) (initial value: 0000 0000) dv7ck selection of the input clock to the 7th stage of the divider 0: fc/2 8 [hz] 1: fs r/w main system clock state s0 s1 s2 s3 s0 s1 s2 s3 machine cycle 1/fc or 1/fs [s] page 17 TMP86FS64FG 2.2.3.1 single-clock mode in the single-clock mode, only the oscillator for high-frequency clock is used. the p21(xtin) and p22 (xtout) pins for the low-frequency clock can be used as usual i/o ports. since the main system clock is generated from the high-frequency cl ock, the machine cycle time beco mes 4/fc [s] in the single-clock mode. (1) normal1 mode in the normal1 mode, the cpu core and on-chip peripherals operate using the high-frequency clock. after reset is released, nomal1 mode is entered. (2) idle1 mode in the idle1 mode, the cpu and watchdog timer ar e halted, and on-chip pe ripherals are clocked by the high-frequency clock. to enter the idle1 mode, set idel in the system control register 2 (syscr2) to 1. the idle1 mode is exited by the interrupt from the on-chip peripherals or external interrupts, and returned to the normal1 mode. when the imf (interrupt master enable flag) is set to 1 (interrupt enable), the normal operation is pe rformed after the interrupt processing is completed. when the imf is set to 0 (interrupt disable), program execution resumes with the instruction immedi- ately following the instruction that activated the idle1 mode. (3) idle0 mode in the idle0 mode, the cpu and on-chip peripherals are halted except oscillator and tbt. the idel0 mode is entered by setting the system control register syscr2 page 18 2. operational descriptions 2.2 system clock controller TMP86FS64FG (2) slow2 mode the cpu core operates with low-frequency clock. switching from normal2 to slow2, and vise-versa is programmed in syscr2 page 19 TMP86FS64FG 2.2.3.3 stop mode in the stop mode, all system operations including oscillators are halted, a nd the internal conditions immediately before the halt are retained with low-power dissipation. the stop mode is entered by setting the syst em control register 1, and exited with the stop pin input. after the warm-up period time has expired, the cpu returns to the mode it was before entering the stop mode, and program execution resumes with the instruction immediately following the instruction that activated the stop mode. 2.2.3.4 operation mode transition note 1: normal1 and normal2 modes are generically called normal mode: slow1 and slow2 are called slow mode: idle0 and idle1 and idle2 are called idle mode: sleep0, sleep1 and sleep2 are called sleep mode. note 2: this mode is exited at the falling edge of the source clock selected in tbtcr page 20 2. operational descriptions 2.2 system clock controller TMP86FS64FG table 2-4 operating mode and conditions operating mode oscillator cpu core tbt other periph- erals machine cycle time high-freq. low-freq. single- clock reset oscillation stop reset reset reset 4/fc [s] normal1 operate operate operate idle1 halt idle0 halt stop stop halt - dual-clock normal2 oscillation oscillation operate with high-freq. operate operate 4/fc [s] idle2 halt slow2 operate with low-freq. 4/fs [s] sleep2 halt slow1 stop operate with low-freq. sleep1 halt sleep0 halt stop stop halt - page 21 TMP86FS64FG 2.2.4 operating mode control note 1: to transit from the nomal mode to the stop mode, set re tm to 0. to transit from the stop mode to the nomal mode, set retm to 1. note 2: when exiting the stop mode with the reset pin input, the cpu returns to the normal1 mode regardless of the retm value. note 3: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *: don't care note 4: bit 1 and 0 in syscr1 are read as don't cares. note 5: when entering the stop mode with outen = 0, input value is fixed to 0. that may cause an external interrupt request to be set on falling edge. note 6: to use the key on wake-up is used, set relm to 1. note 7: the p20 pin is shared with the stop pin. when the st op mode is entered, output assumes the high-impedance state regardless of the outen state. note 8: select the warm-up period time depending on the feature of the resonator to be used. system control register 1 76543210 syscr1 (0038h) stop relm retm outen wut "0" (initial value: 0000 00**) stop stop mode enter 0: cpu core and peripherals operate 1: cpu core and peripherals halt (enter stop mode) r/w relm stop mode exit method 0: edge-sensitive (exit at the rising edge of stop pin) 1: level-sensitive (exit at the high level of stop pin) r/w retm operating mode after stop mode 0: return to normal 1/2 mode 1: return to slow1 mode r/w outen port output during stop mode 0: high impedance 1: output retained r/w wut warm-up time on exiting stop mode [ns] return to normal 1/2 mode return to slow1 mode r/w dv1ck=0 dv1ck=1 00 01 10 11 3 2 16 /fc 2 16 /fc 3 2 14 /fc 2 14 /fc 3 2 17 /fc 2 17 /fc 3 2 15 /fc 2 15 /fc 3 2 13 /fs 2 13 /fs 3 2 6 /fs 2 6 /fs page 22 2. operational descriptions 2.2 system clock controller TMP86FS64FG note 1: reset is performed when both xen and xten are cleared to 0, xen is cleared to 0 with sysck = 0, or xten is cleared to 0 with sysck = 1. note 2: wdt: watchdog timer, tg: timing generator, *: don?t care note 3: when the bit 3, 1 or 0 of syscr2 is read, a don't care is read. note 4: do not set idle and tghalt to 1 simultaneously. note 5: since the idle0/sleep0 mode is returned to the norm al1/slow1 mode by the asynchronous internal source clock specified in tbtcr page 23 TMP86FS64FG 2.2.4.1 stop mode the stop mode is controlled by the system control resister 1 (syscr1), stop pin input and stop5 to stop2. the stop pin is used as the p20 port and int5 pin (external interrupt input 5). the stop mode is entered by setting syscr1 page 24 2. operational descriptions 2.2 system clock controller TMP86FS64FG figure 2-7 level-s ensitive exit mode note 1: after a warm-up period starts, the stop mode is not reentered if the stop pin input becomes low or stop5 to stop2 becomes high again. note 2: to return to the level-sensitive exit mode af ter setting up the edge-sensitive exit mode, the exit mode is not switched until the rising edge of the stop pin input is detected. (2) edge-sensitive exit mode (relm = 0) in this mode, the stop mode is ex ited at the rising edge of the stop pin input. this mode is used in applications where a relatively short program is run repeatedly at periodic intervals. this periodic signal (i.e., a clock from a low-power cons umption oscillator) is input input to the stop pin. in the edge-sensitive exit mode, the stop mode is entered even if the stop pin input is high. disable the stop5 to stop2 pin input with the key-on wake-up control register (stopcr). figure 2-8 edge-s ensitive exit mode example 2 :entering the stop mode from the normal mode by the int5 interrupt pint5: test (p2prd) . 0 : to eliminate spurious noise, the stop mode is not entered if the p20 port input is set to high. jrs f, sint5 : sets the level-sensitive exit mode. ld (syscr1), 01010000b di : imf0 set (syscr1) . 7 : enters the stop mode. sint5: reti example :entering the stop mode from the normal mode di : imf0 ld (syscr1) , 10010000b : sets the edge-sensitive exit mode to enter the stop mode stop pin xout pin normal mode exit the stop mode by hardware. normal mode v ih warm-up stop mode detect the low level of the stop pin input by programming and enter the stop mode. whenever the stop pin input is set to high, the stop mode is exited. stop pin xout pin normal mode v ih warm-up stop mode stop mode enter the stop mode by programming. exit the stop mode by hardware at the rising edge of the stop pin input. normal mode page 25 TMP86FS64FG the stop mode is exited in the edge-sensi tive exit mode by the following sequence. 1. oscillations start. in the dual-clock mode, both high-frequency and low-frequency oscilla- tors start to return to the normal2 mode, and only the low-frequency oscillator starts to return to the slow mode. in the single-cl ock mode, only the high-frequency oscillator starts. 2. the warm-up period time is inserted to allow sufficient time for the oscillator to stabilize. during warm-up, internal operations remain ha lted. 4 types of warming-up period time can be selected in syscr1 page 26 2. operational descriptions 2.2 system clock controller TMP86FS64FG figure 2-9 entering and exiting the stop mode oscillated instruction execution divider (a) entering the stop mode (activated with set (syscr1).7 instruction located at address a) main system clock main system clock program counter instruction execution divider program counter stopped stopped a+2 a+3 n n+1 n+2 n+3 n+4 0 set (syscr1).7 oscillator oscillator warm-up (b) exiting the stop mode oscillated stopped stopped count up 0 0 1 2 3 a+3 a+4 a+5 a+6 instruction at a+4 address instruction at a+3 address instruction at a+2 address stop pin input page 27 TMP86FS64FG 2.2.4.2 idle1/2 and sleep1/2 modes the idle1/2 and sleep1/2 modes controlled by the system control re gister 2 (syscr2) and maskable interrupts. the following status is held during the idle1/2 or sleep1/2 mode. 1. the cpu and watchdog timer are halted. on-chip peripherals continue operation. 2. the data memory, registers, program status words, port output latches hold the status that acti- vated the idle1/2 or sleep1/2 mode. 3. the program counter holds the address of the instruction after next to the instruction to activate idle1/2 or sleep1/2 mode. figure 2-10 idle1/ 2 and sleep1/2 modes cpu and wdt halted interrupt processing reset ye s no no no no imf = "1" reset input ye s yes (interrupt service routine) (normal execution) interrupt request entering the idle1/2 or sleep1/2 mode (instruction) execution of the instruction immediately following the instruction that activated the idle1/2 or sleep1/2 mode page 28 2. operational descriptions 2.2 system clock controller TMP86FS64FG ? entering idle1/2 or sleep1/2 mode after clearing the interrupt master enable flag (imf) to 0, set the individual interrupt enable flag used to exit the idle1/2 or sleep1/2 mode to 1. to enter the edle1/2 or sleep1/2 mode, set syscr2 page 29 TMP86FS64FG figure 2-11 entering and exit ing the idle1/2 or sleep1/2 mode main system clock interrupt request instruction execution watchdog timer program counter stopped a+2 a+3 set(syscr2).4 operated 1. normal execution watchdog timer instruction execution program counter interrupt request main system clock stopped stopped a+3 a+4 instruction at a+2 address operated 2. interrupt service routine watchdog timer instruction execution program counter interrupt request main system clock stopped stopped a+3 interrupt accepted operated (a) entering the idle1/2 or sleep1/2 mode (activated with set(syscr1).4 instruction located at address a) (b) exiting the idle1/2 or sleep1/2 mode page 30 2. operational descriptions 2.2 system clock controller TMP86FS64FG 2.2.4.3 idle0 and sleep0 modes the idle0 mode is controlled by th e system control register 2 (syscr2) and time base timer. the fol- lowing status is held during the idle0 mode. ? the timing generator stops the clock distribution to the on-chip peripherals except the time base timer. ? the data memory, registers, program status words and port output latches hold the status that acti- vated the idle0 or sleep0 mode. ? the program counter holds the address of the instruction after next to the instruction to activate the idle0 or sleep0 mode. note: before entering the idle0 or sleep0 m ode, the on-chip peripherals must be disabled. figure 2-12 idle0 or sleep0 mode stopping operations of the on-chip functions (instruction) cpu and wdt halted interrupt processing reset ye s no no no "0" reset input ye s yes (interrupt service routine) (normal execution) tbtcr page 31 TMP86FS64FG ? entering idle0 or sleep0 mode disable on-chip peripherals such as a timer counter. to enter the idle0 or sleep0 mode, set syscr2 page 32 2. operational descriptions 2.2 system clock controller TMP86FS64FG figure 2-13 entering and exiting the idle 0 or sleep0 mode main system clock interrupt request instruction execution instruction execution instruction execution watchdog timer program counter stopped a+2 a+3 set(syscr2).2 operated 1. normal execution watchdog timer program counter tbt souce clock main system clock stopped stopped a+3 a+4 instruction at a+2 address operated 2. interrupt service routine watchdog timer program counter tbt souce clock main system clock stopped stopped a+3 interrupt accepted operated (a) entering the idle0 or sleep0 mode (activated with set(syscr2).4 instruction located at address a) (b) exiting the idle0 or sleep0 mode page 33 TMP86FS64FG 2.2.4.4 slow mode the slow mode is controlled by the system control register 2 (syscr2). (1) switching the normal2 mode to slow mode write 1 to syscr2 page 34 2. operational descriptions 2.2 system clock controller TMP86FS64FG (2) switching from the slow 1 mode to normal2 mode note: after sysck is cleared to 0, instructions are executed continuously by the low-frequency clock during synchronization period for hi gh-frequency and low-frequency clocks. first, set syscr2 page 35 TMP86FS64FG figure 2-14 switching bet ween slow and normal2 modes? sysck instruction execution xen (a) switching to the slow1 mode low- frequency clock main system clock oscillation stopped set (syscr2).5 clr (syscr2).7 high- frequency clock instruction execution low- frequency clock main system clock high- frequency clock slow mode normal2 mode slow2 mode sysck xen (b) switching to the normal2 mode slow1 mode set (syscr2).7 clr (syscr2).5 normal2 mode warm-up in slow2 mode page 36 2. operational descriptions 2.3 reset circuit TMP86FS64FG 2.3 reset circuit TMP86FS64FG has four types of reset, that are an external reset, addre ss trap reset, watchdog timer reset and sys- tem clock reset. an address trap reset, watchdog timer reset and system clock reset are internal factor resets. when detecting these reset requests, TMP86FS64FG is in the re set state during a maximum of 24/fc [s]. (during a flash reset, the reset pin is held high.) since the internal factor reset circuits that are watchdog timer re set, address trap reset a nd system clock reset are not initialized upon power-up, a maximum reset time may become 24/fc [s] (1.5 s @ 16.0 mhz). table 2-6 shows the on-chip hardware initialization by reset operation. 2.3.1 external reset input the reset pin is the hysteresis input wi th pull-up resistance. when the reset pin is held low for a mini- mum of 3 machine cycles (12/fc [s]) with the power supply voltage within the operating voltage range and sta- ble oscillation, a reset is triggere d and internal state is initialized. when the reset pin input goes high, the reset operation is released , and program execution starts at the vector address stored at addresses fffe to fffh. table 2-6 on-chip hardware in itialization by reset operation on-chip hardware initial value on-chip hardware initial value program counter (pc) (fffeh) prescaler and divider of the timing generator 0 stack pointer (sp) not initialized general-purpose register (w, a, b, c, d, e, h, l, ix, iy) not initialized jump status flag (jf) not initialized watchdog timer enabled zero flag (zf) not initialized output latch of i/o port refer to description of each i/o port carry flag (cf) not initialized half carry flag (hf) not initialized sign flag (sf) not initialized overflow flag (vf) not initialized interrupt master enable flag (imf) 0 interrupt individual enable flag (ef) 0 control register refer to description of each register interrupt latch (il) 0 ram not initialized page 37 TMP86FS64FG figure 2-15 reset circuit 2.3.2 address-trap-reset if the cpu runs away due to spurious noises and a ttempts to fetch an instruction form the on-chip ram (wdtcr1 page 38 2. operational descriptions 2.3 reset circuit TMP86FS64FG page 39 TMP86FS64FG 3. interrupt control circuit the TMP86FS64FG has a total of 21 interrupt sources excl uding reset, of which 5 source levels are multiplexed. interrupts can be nested with priorities. four of the internal interrupt sour ces 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 th e generation of its interrupt request wh ich requests the cpu to accept its inter- rupts. interrupts are enabled or disabled by software using the interrupt master enable fl ag (imf) and in terrupt enable flag (ef). if more than one interrupts are generated simultaneously, interrup ts are accepted in order which is domi- nated by hardware. however, there are no prioritized interrupt factors among non-maskable interrupts. note 1: the intsel register is used to select the interrupt source to be enabled for each multiplexed source level (see 3.3 inte r- rupt source selector (intsel)). note 2: to use the address trap interrupt (intatrap), clear wdtcr1 page 40 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86FS64FG the interrupt latches are located on address 003ch and 003d h in sfr area. each latch can be cleared to "0" indi- vidually 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-modify-write instructions such as bit manipulation or operation instructions are used, interrupt request would be cleared inadequately if inter- rupt 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 fo r 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 new ly 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 inte rrupt on interrupt service routine, manipulating ef or il should be executed before setting imf="1". 3.2 interrupt enab le register (eir) the interrupt enable register (eir) enables and disables the acceptance of interrupts, except fo r the non-maskable interrupts (software interrupt, undefined instruction interr upt, address trap interrupt and watchdog interrupt). non- maskable interrupt is accepted regardless of the contents of the eir. the eir consists of an interrupt mast er enable flag (imf) and the individua l interrupt enable flags (ef). these registers are located on address 003ah and 003bh in sfr ar ea, 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 ma ster 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 inter- rupts which follow are disabled. by executing return interrupt instruction [reti/retn], the stacked data, which was the status before interrup t 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 cl eared by [ei] and [di] instruction respectively. during reset, the imf is initial- ized to ?0?. example 1 :clears interrupt latches di ; imf 0 ldw (ill), 111010000011 1111b ; il12, il10 to il6 0 ei ; imf 1 example 2 :reads interrupt latchess ld wa, (ill) ; w ilh, a ill example 3 :tests interrupt latches test (ill). 7 ; if il7 = 1 then jump jr f, sset page 41 TMP86FS64FG 3.2.2 individual interrupt enable flags (ef15 to ef4) each of these flags enables and disables the acceptan ce of its maskable interrupt . setting the corresponding bit of an individual interrupt enable flag to ?1? enables acceptan ce of its interrupt, and setting the bit to ?0? dis- ables acceptance. during reset, all the i ndividual interrupt enable flags (ef15 to ef4) ar e 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 become s "0" automatically, clearing imf need not execute nor- mally on interrupt service routine. however, if using mult iple interrupt on interrupt service routine, manipulat- ing ef or il should be executed before setting imf="1". example 1 :enables interrupts individually and sets imf di ; imf 0 ldw : (eirl), 1110100010100000b ; ef15 to ef13, ef11, ef7, ef5 1 note: imf should not be set. : ei ; imf 1 example 2 :c compiler description example unsigned int _io (3ah) eirl; /* 3ah shows eirl address */ _di(); eirl = 10100000b; : _ei(); page 42 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86FS64FG 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 fl ag (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, clear ing imf need not execute normally on inter- rupt service routine. however, if using multiple interrupt on interrupt service routine, mani pulating ef or il should be exe- cuted before setting imf="1". note 3: do not clear il with read-modify-w rite instructions such as bit operations. 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 fl ag (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, clear ing imf need not execute normally on inter- rupt service routine. however, if using multiple interrupt on interrupt service routine, mani pulating ef or il should be exe- cuted before setting imf="1". interrupt latches (initial value: 00000000 000000**) ilh,ill (003dh, 003ch) 1514131211109876543210 il15 il14 il13 il12 il11 il10 il9 il8 il7 il6 il5 il4 il3 il2 ilh (003dh) ill (003ch) il15 to il2 interrupt latches at rd 0: no interrupt request 1: interrupt request at wr 0: clears the interrupt request 1: (interrupt latch is not set.) r/w interrupt enable registers (initial value: 00000000 0000***0) eirh,eirl (003bh, 003ah) 1514131211109876543210 ef15 ef14 ef13 ef12 ef11 ef10 ef9 ef8 ef7 ef6 ef5 ef4 imf eirh (003bh) eirl (003ah) ef15 to ef4 individual-interrupt enable flag (specified for each bit) 0: 1: disables the acceptance of each maskable interrupt. enables the acceptance of each maskable interrupt. r/w imf interrupt master enable flag 0: 1: disables the acceptance of all maskable interrupts enables the acceptance of all maskable interrupts page 43 TMP86FS64FG 3.3 interrupt sour ce selector (intsel) each interrupt source that shares the interrupt source level with another interrupt source is allowed to enable the interrupt latch only when it is selected in the intsel register. the interrupt controller does not hold interrupt requests corresponding to interrupt sour ces that are not selected in the intsel register. th erefore, the intsel reg- ister must be set appropriately befo re interrupt requests are generated. the following interrupt sources share their interrupt sour ce level; the source is selected onnthe register intsel. 1. inttbt and int2 share the interrupt source level whose priority is 9. 2. inttc1 and int3 share the interrupt source level whose priority is 10. 3. intsio1 and int4 share the interrupt source level whose priority is 14. 4. inttrx and int5 share the interrupt source level whose priority is 15. 5. intadc and intsio2 share the interrupt source level whose priority is 16. 3.4 interrupt sequence an interrupt request, which raised inte rrupt latch, is held, until interrupt is accepted or interrupt latch is cleared to ?0? by resetting or an instruct ion. 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.4.1 interrupt acceptance proc essing is packaged as follows. a. the interrupt master enab le flag (imf) is cleared to ?0? in or der to disable the acceptance of any fol- lowing interrupt. b. the interrupt latch (il) for the interrupt source accepted is cleared to ?0?. c. the contents of the program coun ter (pc) and the program status word, including the interrupt master enable flag (imf), are saved (pushed) on the st ack in sequence of psw + imf, pch, pcl. mean- while, the stack pointer (s p) is decremented by 3. d. the entry address (interrupt vect or) of the corresponding interrupt service program, loaded on the vec- tor table, is transferred to the program counter. e. the instruction stored at the entry address of the inte rrupt service program is executed. note:when the contents of psw are saved on the stack, the contents of imf are also saved. interrupt sour ce selector intsel (003eh) 76543210 il8er il9er - - - il13er il14er il15er (initial value: 00** *000) il8er selects inttbt or int2 0: inttbt 1: int2 r/w il9er selects inttc1 or int3 0: inttc1 1: int3 r/w il13er selects intsio1 or int4 0: intsio1 1: int4 r/w il14er selects inttrx or int5 0: inttrx 1: int5 r/w il15er selects intadc or intsio2 0: intadc 1: intsio2 r/w page 44 3. interrupt control circuit 3.4 interrupt sequence TMP86FS64FG 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 in terrupt instruction example: correspondence be tween vector table address for inttbt an d the entry address of the interrupt service program figure 3-2 vector table address,entry address a maskable interrupt is not accepted until the imf is set to ?1? even if th e 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 en abled 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 interr upt, keep interrupt service shorten compared with length between interrupt requests; otherwise the status cannot be recovered as non-maskable interrupt would simply nested. 3.4.2 saving/restoring general-purpose registers during interrupt acceptance processing , the program counter (pc) and the program status word (psw, includes imf) are automati cally saved on the stack, but the accumulato r and others are not. these registers are saved by software if necessary. when multiple interrupt se rvices are nested, it is also necessary to avoid using the same data memory area for saving registers. the fo llowing methods are used to save/restore the general- purpose registers. a b a c + 1 execute instruction sp pc execute instruction n n ? 2 n - 3 n ? 2n ? 1 n ? 1 n a + 2 a + 1 c + 2 b + 3 b + 2 b + 1 a + 1 a a ? 1 execute reti instruction interrupt acceptance execute instruction interrupt service task 1-machine cycle interrupt request interrupt latch (il) imf d2h 03h d203h d204h 06h vector table address entry address 0fh vector interrupt service program ffeeh ffefh page 45 TMP86FS64FG 3.4.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. figure 3-3 save/store register using push and pop instructions 3.4.2.2 using data transfer instructions to save only a specific register wi thout nested interrupts, data tran sfer instructions are available. example :save/store register us ing push and pop instructions pintxx: push wa ; save wa register (interrupt processing) pop wa ; restore wa register reti ; return example :save/store register us ing data transfer instructions pintxx: ld (gsava), a ; save a register (interrupt processing) ld a, (gsava) ; restore a register reti ; return pcl pch psw at acceptance of an interrupt at execution of push instruction at execution of reti instruction at execution of pop instruction b-4 b-3 b-2 b-1 b pcl pch psw pcl pch psw sp address (example) sp sp sp a w b-5 page 46 3. interrupt control circuit 3.4 interrupt sequence TMP86FS64FG figure 3-4 saving/restoring general-purpose r egisters under interrupt processing 3.4.3 interrupt return interrupt return instructions [reti]/[retn] perform as follows. as for address trap interrupt (intatrap), it is requir ed 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 pr ocessing has completed, stacked data for pcl and pch are located on address (sp + 1) and (sp + 2) respectively. interrupt requests are sampled during the final cycle of the instruction being executed. thus, the next inter- rupt can be accepted immediat ely after the interrupt retu rn instruction is executed. [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. 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 example 2 :restarting without returning interrupt (in this case, psw (includes imf) befo re 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 acceptance interrupt service task restoring registers saving registers interrupt return saving/restoring general-purpose registers using push/pop data transfer instruction main task page 47 TMP86FS64FG note 1: it is recommended that stack pointer be return to rate before intatrap (increment 3 times), if return inter- rupt instruction [retn] is not utilized during inte rrupt 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.5 software interrupt (intsw) executing the swi instruction generates a software interr upt 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.5.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 th e swi instruction, so a software interrupt is gener- ated and an address error is detect ed. 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.5.2 debugging debugging efficiency can be increased by placing the swi instruction at the software break point setting address. 3.6 undefined instruct ion interrupt (intundef) taking code which is not defined as authorized instru ction for instruction causes intundef. intundef is gen- erated when the cpu fetches such a co de and tries to execute it. intundef is accepted even if non-maskable inter- rupt 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.7 address trap interrupt (intatrap) fetching instruction from unauthorized area for instructio ns (address trapped area) cause s reset output or address trap interrupt (intatrap). intatrap is accepted even if non-maskable interrupt is in process. contemporary pro- cess is broken and intatrap interrupt pro cess starts, soon afte r 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). 3.8 external interrupts the TMP86FS64FG has 6 external interrupt inputs. these inputs are equipped with digital noise reject circuits (pulse inputs of less than a certa in time are elimin ated as noise). edge selection is also possible with int1 to int4. the int0 /p10 pin can be configured as either an external inter- rupt input pin or an input/output port, and is configured as an input port during reset. edge selection, noise reject control and int0 /p10 pin function selection are performed by the external interrupt control register (eintcr). page 48 3. interrupt control circuit 3.8 external interrupts TMP86FS64FG 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 "si g- nal 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 out put and a change occurs in data or input/output status, an inter - rupt request signal is generated in a pseudo manner. in this ca se, it is necessary to perform appropriate processing such as disabling the interrupt enable flag. source pin enable conditions release edge (level) digital noise reject int0 int0 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 consid- ered to be signals. int1 int1 imf ? ef5 = 1 falling edge or rising edge pulses of less than 15/fc or 63/fc [s] are elimi- nated as noise. pulses of 49/fc or 193/fc [s] or more are considered to be signals.(at cgcr page 49 TMP86FS64FG 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 operat e normally. it is recommended that external interrupts are dis- abled using the interrupt enable register (eir). note 3: the maximum time from modifying int1 nc until a noise reject time is changed is 2 6 /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. external interrupt control register eintcr76543210 (0037h) int1nc int0en int4es int3es int2es int1es (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 p10/ int0 pin configuration 0: p10 input/output port 1: int0 pin (port p10 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 page 50 3. interrupt control circuit 3.8 external interrupts TMP86FS64FG page 51 TMP86FS64FG 4. special function register (sfr) the TMP86FS64FG adopts the memory ma pped i/o system, and all peripheral control and data transfers are per- formed 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 0f80h to 0fffh. this chapter shows the arrangement of the special functi on register (sfr) and data buffer register (dbr) for TMP86FS64FG. 4.1 sfr address read write 0000h p0dr 0001h p1dr 0002h p2dr 0003h p3dr 0004h p4dr 0005h p5dr 0006h p6dr 0007h p7dr 0008h p0cr 0009h p1cr 000ah p4prd - 000bh p3cr 000ch p4cr 000dh p5cr 000eh adccr1 000fh adccr2 0010h tc3dra 0011h tc3drb - 0012h tc3cr 0013h tc2cr 0014h tc4cr 0015h tc5cr 0016h tc6cr 0017h tc6dr 0018h tc4dr 0019h tc5dr 001ah irdacr 001bh uartsr uartcr1 001ch - uartcr2 001dh rdbuf tdbuf 001eh reserved 001fh reserved 0020h tc1dral 0021h tc1drah 0022h tc1drbl 0023h tc1drbh 0024h tc2drl 0025h tc2drh page 52 4. special function register (sfr) 4.1 sfr TMP86FS64FG 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.). 0026h adcdr2 - 0027h adcdr1 - 0028h - sio1cr1 0029h sio1sr sio1cr2 002ah scisel 002bh reserved 002ch p2prd - 002dh p4oed 002eh p6cr 002fh p7cr 0030h cgcr 0031h - stopcr 0032h tc1cr 0033h reserved 0034h - wdtcr1 0035h - wdtcr2 0036h tbtcr 0037h eintcr 0038h syscr1 0039h syscr2 003ah eirl 003bh eirh 003ch ill 003dh ilh 003eh intsel 003fh psw address read write page 53 TMP86FS64FG 4.2 dbr address read write 0f80h reserved 0f81h reserved 0f82h reserved 0f83h reserved 0f84h reserved 0f85h reserved 0f86h reserved 0f87h reserved 0f88h reserved 0f89h reserved 0f8ah reserved 0f8bh reserved 0f8ch reserved 0f8dh reserved 0f8eh reserved 0f8fh reserved 0f90h sio1br0 0f91h sio1br1 0f92h sio1br2 0f93h sio1br3 0f94h sio1br4 0f95h sio1br5 0f96h sio1br6 0f97h sio1br7 0f98h sio2br0 0f99h sio2br1 0f9ah sio2br2 0f9bh sio2br3 0f9ch sio2br4 0f9dh sio2br5 0f9eh sio2br6 0f9fh sio2br7 page 54 4. special function register (sfr) 4.2 dbr TMP86FS64FG 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 reserved 0fadh reserved 0faeh reserved 0fafh reserved 0fb0h p8dr 0fb1h p9dr 0fb2h p8cr 0fb3h p9cr 0fb4h - sio2cr1 0fb5h sio2sr sio2cr2 0fb6h padr 0fb7h pbdr 0fb8h pacr 0fb9h pbcr 0fbah papu 0fbbh pbpu 0fbch p6pu 0fbdh p7pu 0fbeh reserved 0fbfh reserved address read write 0fc0h reserved : : : : 0fdfh reserved page 55 TMP86FS64FG 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.). address read write 0fe0h reserved 0fe1h reserved 0fe2h reserved 0fe3h reserved 0fe4h reserved 0fe5h reserved 0fe6h reserved 0fe7h reserved 0fe8h reserved 0fe9h reserved 0feah spcr 0febh reserved 0fech reserved 0fedh reserved 0feeh reserved 0fefh reserved 0ff0h reserved 0ff1h reserved 0ff2h reserved 0ff3h reserved 0ff4h reserved 0ff5h reserved 0ff6h reserved 0ff7h reserved 0ff8h reserved 0ff9h reserved 0ffah reserved 0ffbh reserved 0ffch reserved 0ffdh reserved 0ffeh reserved 0fffh flscr page 56 4. special function register (sfr) 4.2 dbr TMP86FS64FG page 57 TMP86FS64FG 5. i/o ports the TMP86FS64FG have 12 parallel input /output ports (91 pins) as follows. 1. port p0 (8-bit i/o port) 2. port p1 (8-bit i/o port) ? external interrupt input, timer/counter input, divider output. 3. port p2 (3-bit i/o port) ? external interrupt input, stop mode release signal input. 4. port p3 (8-bit i/o port) ? timer/counter input, seri al interface input/output. 5. port p4 (8-bit i/o port) ? timer/counter input, serial interface input/output, external interrupt input. 6. port p5 (8-bit i/o port) 7. port p6 (8-bit i/o port) ? analog input. 8. port p7 (8-bit i/o port) ? analog input, stop mode release signal input. 9. port p8 (8-bit i/o port) 10. port p9 (8-bit i/o port) 11. port pa (8-bit i/o port) 12. port pb (8-bit i/o port) each output port contains a latch, which holds the output data. all input ports do not have latches, so the external input data should be externally held until the input data is read from outside or reading should be performed several timer before processing. figure 5-1 shows input/output timing examples. external data is read from an i/o port in the s1 state of the read cycle during execution of the read instruction. this timing cannot be recognized from outside, so that transient input such as chattering must be processed by the pro- gram. output data changes in the s2 state of the write cycle du ring execution of the instruct ion which writes to an i/o port. note: the positions of the read and write c ycles may vary, depending on the instruction. figure 5-1 input/output timing (example) instruction execution cycle input strobe data input ex: ld a, (x) fetch cycle fetch cycle read cycle s0 s1 s2 s3 s0 s1 s2 s3 s0 s1 s2 s3 instruction execution cycle output strobe data output ex: ld (x), a fetch cycle fetch cycle write cycle s0 s1 s2 s3 s0 s1 s2 s3 s0 s1 s2 s3 (a) input timing (b) output timing page 58 5. i/o ports TMP86FS64FG 5.1 port p0 (p07 to p00) port p0 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port p0 input/output control register (p0cr). during reset, the p0cr is initialized to ? 0 ? , which configures port p0 as an input. the p0 output latches are also ini- tialized to ? 0 ? . note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-2 port p0 note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. p0dr (0000h) 76543210 p07 p06 p05 p04 p03 p02 p01 p00 (initial value: 0000 0000) p0cr (0008h) 76543210 p0cr7 p0cr6 p0cr5 p0cr4 p0cr3 p0cr2 p0cr1 p0cr0 (initial value: 0000 0000) p0cr i/o control for port p0 (specified for each bit) 0: input mode 1: output mode r/w output latch stop outen data input data output p0cri p0i d q page 59 TMP86FS64FG 5.2 port p1 (p17 to p10) port p1 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port p1 input/output control register (p1cr). during reset, the p1cr is initialized to ? 0 ? , which configures port p1 as an input mode. the p1 output latches are also initialized to ? 0 ? . it is also used as int0 , int1, int2/tc1, tc2, dvo and ppg . when used as secondary function pin, the input pins ( int0 , int1, int2, tc1,tc2) should be set to the input mode and the output pins ( dvo , ppg ) should be set to the output mode beforehand the output latch should be set to ? 1 ? . note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-3 port p1 note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. p1dr (0001h) 76543210 p17 p16 p15 tc2 p14 ppg p13 dvo p12 int2 tc1 p11 int1 p10 int0 (initial value: 0000 0000) p1cr (0009h) 76543210 p1cr7 p1cr6 p1cr5 p1cr4 p1cr3 p1cr2 p1cr1 p1cr0 (initial value: 0000 0000) p1cr i/o control for port p1 (specified for each bit) 0: input mode 1: output mode r/w output latch stop outen data input data output p1cri p1i d q control output control input page 60 5. i/o ports TMP86FS64FG 5.3 port p2 (p22 to p20) port p2 is a 3-bit input/output port. during reset, the p2dr is initialized to ? 1 ? . it is also used as int5 / stop1 . when used as secondary function pin or an input pin, the output latch should be set to ? 1 ? . in the dual-clock mode, the low-frequency oscillator (32.768 khz) is connected to p21 (xtin) and p22 (xtout) pins. p2 port output latch (p2dr) and p2 port terminal input (p2r) are located on their respective address. when a read instruction is executed for port p2, read data of bits 7 to 3 are unstable. note: stop: bit 7 in syscr1, outen: bit 4 in syscr1, xten: bit 6 in syscr2 figure 5-4 port p2 note 1: port p20 is used as stop1 pin. therefore, when stop mode is started, however syscr1 page 61 TMP86FS64FG 5.4 port p3 (p37 to p30) port p3 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port p3 input/output control register (p3cr). during reset, the p3cr is initialized to ? 0 ? , which configures port p3 as an input mode. the p3 output latches (p3dr) are also initialized to ? 1 ? . port p30, p31 and p32 are also used as tc4/ pwm4 / pdo4 , tc5/ pwm5 / pdo5 and tc6/ pwm6 / pdo6 . when used as secondary function pin, the input pins (tc4, tc5, tc6) should be set to the input mode and the output pins ( pwm4 / pdo4 , pwm5 / pdo5 , pwm6 / pdo6 ) should be set to the output. port p33, p34, p35, p36 and p37 are also used as sck1 , si1, so1, si2 and so2. when used as secondary function pin, sck1 should be set to the input or output mode, si1 and si2 should be set to the input mode, so1 and so2 should be set to the output mode. note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-5 port p3 note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. p3dr (0003h) 76543210 p37 so2 p36 si2 p35 so1 p34 si1 p33 sck1 p32 tc6 pwm6 pdo6 p31 tc5 pwm5 pdo5 p30 tc4 pwm4 pdo4 (initial value: 1111 1111) p3cr (000bh) 76543210 p3cr7 p3cr6 p3cr5 p3cr4 p3cr3 p3cr2 p3cr1 p3cr0 (initial value: 0000 0000) p3cr i/o control for port p3 (specified for each bit) 0: input mode 1: output mode r/w stop outen data input data output p3cri control output control input output latch p3i d q page 62 5. i/o ports TMP86FS64FG 5.5 port p4 (p47 to p40) port p4 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port p4 input/output control register (p4cr). during reset, the p4cr is initialized to ? 0 ? , which configures port p4 as an input mode. the p4 output latches are also initialized to ? 1 ? . it is also used as int0 , int1, int2/tc1, tc2, dvo and ppg . when used as secondary function pin, the input pins ( int0 , int1, int2, tc1, tc2) should be set to the input mode and the output pins ( dvo , ppg ) should be set to the output mode beforehand the output latch should be set to ? 1 ? . port p4 can be configured individually as a tri-state output or si nk open drain output under software control. it is specified by the corres ponding bit in the p4ode. during reset, the p4ode is initialized to ? 0 ? , and then p4cr is set to ? 1 ? , the tri-state output is configured. p4 port output latch (p4dr) and p4 port terminal input (p4r) are located on their respective address. when the input mode and output mode ar e configured simultaneous ly, even if the bit mani pulate instruction is exe- cuted, the data of the output latch of the terminal set as the input mode is not influenced of the terminal input. port p40, p41, p42, p44, p45, p46 and p47 are also used as sck2, rxd1, txd1, rxd2, txd2, int3/tc3 and int4. when used as secondary function pin, the sck1 pin should be set to the input or output mode, the input pins (rxd1, rxd2, int3/tc3, int4) should be set to the input mode and the output pins (txd1, txd2) should be set to the output. note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-6 port p4 output latch stop outen data input (p4r) data output data input (p4dr) control output control input p4odei p4cri p4i d q page 63 TMP86FS64FG note: regardless of p4ode setting, each terminal has a protect di ode. please refer to section ?input/output circuitry; (2) input / output ports?. p4dr (0004h) 76543210 p47 int4 p46 int3 tc3 p45 txd2 p44 rxd2 p43 p42 txd1 p41 rxd1 p40 sck2 (initial value: 1111 1111) p4r (000ah) 76543210 p47in p46in p45in p44in p43in p42in p41in p40in (initial value: **** ****) read only p4cr (000ch) 76543210 p4cr7 p4cr6 p4cr5 p4cr4 p4cr3 p4cr2 p4cr1 p4cr0 (initial value: 0000 0000) p4cr i/o control for port p4 (specified for each bit) 0: input mode 1: output mode r/w p4ode (002dh) 76543210 p4ode7 p4ode6 p4ode5 p4ode4 p4ode3 p4ode2 p4 ode1 p4ode0 (initial value: 0000 0000) p4ode p4 open drain control register (specified for each bit) 0: tri-state output 1: sink open drain output r/w page 64 5. i/o ports TMP86FS64FG 5.6 port p5 (p57 to p50) port p5 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port p5 input/output control register (p5cr). during reset, the p5cr is initialized to ? 0 ? , which configures port p5 as an input mode. the p5 output latches are also initialized to ? 0 ? . note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-7 port p5 note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. p5dr (0005h) 76543210 p57 p56 p55 p54 p53 p52 p51 p50 (initial value: 0000 0000) p5cr (000dh) 76543210 p5cr7 p5cr6 p5cr5 p5cr4 p5cr3 p5cr2 p5cr1 p5cr0 (initial value: 0000 0000) p5cr i/o control for port p5 (specified for each bit) 0: input mode 1: output mode r/w output latch stop outen data input data output p5cri p5i d q page 65 TMP86FS64FG 5.7 port p6 (p67to p60) port p6 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. port p6 is also used as an analog input. input/output mode is specified by the corresponding bit in the port p6 input/output control register (p6cr) , p6 output latch (p6dr) and adccr1 page 66 5. i/o ports TMP86FS64FG note 1: don't set output mode to pin, which is used for an analog input. note 2: when used for input mode (include analog input mode), read-modify-write instruction such as bit manipulate instructions cannot be used. read-modify-write instruction writes the all data of 8-bi t after data is read and modified. because a bit setting input mode read data of terminal, the output latch is changed by these instructions. so p6 port cannot input data. note: however the p6pu is set to ?1? (pull-up), the port configured output is not set up pull-up resistor. p6dr (0006h) 76543210 p67 ain7 p66 ain6 p65 ain5 p64 ain4 p63 ain3 p62 ain2 p61 ain1 p60 ain0 (initial value: 0000 0000) p6cr (002eh) 76543210 p6cr7 p6cr6 p6cr5 p6cr4 p6cr3 p6cr2 p6cr1 p6cr0 (initial value: 0000 0000) p6cr i/o control for port p6 (specified for each bit) ainds = 1 (ad unused) ainds = 0 (ad used) r/w p6dr = ?0? p6dr = ?1? p6dr = ?0? p6dr = ?1? 0 input "0" fixed #1 input mode ad input #2 input mode 1 output mode #1 input data to a pin whose input is fixed to ?0? is always ?0? regardless of the pin state and whether or not a programmable pull-up resistor is added. #2 when a read instruction for port p6 is executed, the bit of analog input mode becomes read data ?0?. p6pu (0fbch) 76543210 p6pu7 p6pu6 p6pu5 p6pu4 p6pu3 p6pu2 p6pu1 p6pu0 (initial value: 0000 0000) p6pu port p6 pull up control register (specified for each bit) 0: non pull-up 1: pull-up r/w page 67 TMP86FS64FG 5.8 port p7 (p77 to p70) port p7 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. port p7 is also used as an analog input and key on wake up input. input/output mode is specified by the cor- responding bit in the port p7 input/out put control register (p7cr), p7 out put latch (p7dr) and adccr1 page 68 5. i/o ports TMP86FS64FG note 1: don't set output mode to pin, which is used for an analog input. note 2: when used for input mode (include analog input mode), read-modify-write instruction such as bit manipulate instructions cannot be used. read-modify-write instruction writes the all data of 8-bi t after data is read and modified. because a bit setting input mode read data of terminal, the output latch is changed by these instructions. so p7 port cannot input data. note: however the p7pu is set to ?1? (pull-up), the port configured output is not set up pull-up resistor. p7dr (0007h) 76543210 p77 ain15 stop5 p76 ain14 stop4 p75 ain13 stop3 p74 ain12 stop2 p73 ain11 p72 ain10 p71 ain9 p70 ain8 (initial value: 0000 0000) p7cr (002fh) 76543210 p7cr7 p7cr6 p7cr5 p7cr4 p7cr3 p7cr2 p7cr1 p7cr0 (initial value: 0000 0000) p7cr i/o control for port p7 (specified for each bit) ainds = 1 (ad unused) ainds = 0 (ad used) r/w p7dr = ?0? p7dr = ?1? p7dr = ?0? p7dr = ?1? 0 input "0" fixed #1 input mode ad input #2 input mode 1 output mode #1 input data to a pin whose input is fixed to ?0? is always ?0? regardless of the pin state and whether or not a programmable pull-up resistor is added. #2 when a read instruction for port p7 is executed, the bit of analog input mode becomes read data ?0?. p7pu (0fbdh) 76543210 p7pu7 p7pu6 p7pu5 p7pu4 p7pu3 p7pu2 p7pu1 p7pu0 (initial value: 0000 0000) p7pu port p7 pull up control register (specified for each bit) 0: non pull-up 1: pull-up r/w page 69 TMP86FS64FG 5.9 port p8 (p87 to p80) port p8 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port p8 input/output control register (p8cr). during reset, the p8cr is initialized to ? 0 ? , which configures port p8 as an input. the p8 output latches are also ini- tialized to ? 0 ? . note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-10 port p8 note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. p8dr (0fb0h) 76543210 p87 p86 p85 p84 p83 p82 p81 p80 (initial value: 0000 0000) p8cr (0fb2h) 76543210 p8cr7 p8cr6 p8cr5 p8cr4 p8cr3 p8cr2 p8cr1 p8cr0 (initial value: 0000 0000) p8cr i/o control for port p8 (specified for each bit) 0: input mode 1: output mode r/w stop outen data input data output p8cri output latch p8i d q page 70 5. i/o ports TMP86FS64FG 5.10 port p9 (p97 to p90) port p9 is an 8-bit input/output port, which can be configured individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port p9 input/output control register (p9cr). during reset, the p9cr is initialized to ? 0 ? , which configures port p9 as an input. the p9 output latches are also ini- tialized to ? 0 ? . note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-11 port p9 note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. p9dr (0fb1h) 76543210 p97 p96 p95 p94 p93 p92 p91 p90 (initial value: 0000 0000) p9cr (0fb3h) 76543210 p9cr7 p9cr6 p9cr5 p9cr4 p9cr3 p9cr2 p9cr1 p9cr0 (initial value: 0000 0000) p9cr i/o control for port p9 (specified for each bit) 0: input mode 1: output mode r/w output latch stop outen data input data output p9cri p9i d q page 71 TMP86FS64FG 5.11 port pa (pa7 to pa0) port pa is an 8-bit input/output port, which can be config ured individually as an input or an output under software control. input/output mode is specified by the correspondin g bit in the port pa input/output control register (pacr). during reset, the pacr is initialized to ? 0 ? , which configures port pa as an input. the pa output latches are also ini- tialized to ? 0 ? . note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-12 port pa note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. note: however the papu is set to ?1? (pull-up), the port configured output is not set up pull-up resistor. padr (0fb6h) 76543210 pa7 pa6 pa5 pa4 pa3 pa2 pa1 pa0 (initial value: 0000 0000) pacr (0fb8h) 76543210 pacr7 pacr6 pacr5 pacr4 pacr3 pacr2 pacr1 pacr0 (initial value: 0000 0000) pacr i/o control for port pa (specified for each bit) 0: input mode 1: output mode r/w papu (0fbah) 76543210 papu7 papu6 papu5 papu4 papu3 papu2 papu1 papu0 (initial value: 0000 0000) papu port pa pull up control register (specified for each bit) 0: non pull-up 1: pull-up r/w output latch stop outen data input data output pacri pai vdd d q pull-up resistor (typ. 80 k ? ) papui page 72 5. i/o ports TMP86FS64FG 5.12 port pb (pb7 to pb0) port pb is an 8-bit input/output port, which can be configur ed individually as an input or an output under software control. input/output mode is specified by the corresponding bit in the port pb input/outpu t control register (pbcr). during reset, the p bcr is initialized to ? 0 ? which configures port pb as an input. the pb output latches are also ini- tialized to ? 0 ? . note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 figure 5-13 port pb and pbcr note: when used as an input mode, read-modify-w rite instructions such as bit manipu late instructions cannot be used. read- modify-write instruction writes the all data of 8-bit afte r read and modified. because a bi t setting input mode reads data of terminal, the output latch is changed by these instructions. note: however the pbpu is set to ?1? (pull-up), the por t configured output is not set up pull-up resistor. pbdr (0fb7h) 76543210 pb7 pb6 pb5 pb4 pb3 pb2 pb1 pb0 (initial value: 0000 0000) pbcr (0fb9h) 76543210 pbcr7 pbcr6 pbcr5 pbcr4 pbcr3 pbcr2 pbcr1 pbcr0 (initial value: 0000 0000) pbcr i/o control for port pb (specified for each bit) 0: input mode 1: output mode r/w pbpu (0fbbh) 76543210 pbpu7 pbpu6 pbpu5 pbpu4 pbpu3 pbpu2 pbpu1 pbpu0 (initial value: 0000 0000) pbpu port pb pull up control register (specified for each bit) 0: non pull-up 1: pull-up r/w output latch stop outen data input data output pbcri pbi vdd d q pull-up resistor (typ. 80 k ? ) pbpui page 73 TMP86FS64FG 6. watchdog timer (wdt) the watchdog timer is a fail-safe system to detect rapidl y the cpu malfunctions such as endless loops due to spu- rious noises or the deadlock conditions, and return the cpu to a sy stem recovery routine. the watchdog timer signal for detecting malfunctions can be programmed only once as ?reset request? or ?inter- rupt 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 inter- rupt. note: care must be taken in system des ign since the watchdog timer functions are not be operated completely due to effect of disturbing noise. 6.1 watchdog timer configuration figure 6-1 watchdog timer configuration 0034 h overflow wdt output internal reset binary counters wdtout writing clear code writing disable code wdten wdtt 2 0035 h watchdog timer control registers wdtcr1 wdtcr2 intwdt interrupt request interrupt request reset request reset release clock clear 1 2 controller q sr s r q selector fc/2 23 ,fc/2 24 or fs/2 15 fc/2 21 ,fc/2 22 or fs/2 13 fc/2 19 ,fc/2 20 or fs/2 11 fc/2 17 ,fc/2 18 or fs/2 9 page 74 6. watchdog timer (wdt) 6.2 watchdog timer control TMP86FS64FG 6.2 watchdog timer control the watchdog timer is controlled by the watchdog timer control registers (wdtcr1 and wdtcr2). the watch- dog timer is automatically enabled after the reset release. 6.2.1 malfunction detection me thods 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 en dless loops or the deadlock condition s occur for some reason, the watch- dog timer output is activated by the binary-counter overflow unless the binary counters are cleared. when wdtcr1 page 75 TMP86FS64FG 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 wi th the procedures shown in ?1.2.3 watchdog timer disable?. note 1: the disable code is valid only when wdtcr1 page 76 6. watchdog timer (wdt) 6.2 watchdog timer control TMP86FS64FG 6.2.3 watchdog timer disable to disable the watchdog timer, set the register in accordance with the fo llowing procedures . setting the reg- ister 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 page 77 TMP86FS64FG 6.2.5 watchdog timer reset when a binary-counter overflow occurs while wdt cr1 page 78 6. watchdog timer (wdt) 6.3 address trap TMP86FS64FG 6.3 address trap the watchdog timer control register 1 and 2 share the a ddresses with the control regi sters to generate address traps. 6.3.1 selection of address tr ap in internal ram (atas) wdtcr1 page 79 TMP86FS64FG 6.3.4 address trap reset while wdtcr1 page 80 6. watchdog timer (wdt) 6.3 address trap TMP86FS64FG page 81 TMP86FS64FG 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 figure 7-1 time base timer configuration 7.1.2 control time base timer is controled by time base timer control register (tbtcr). note 1: fc; high-frequency clock [hz], fs ; low-frequency clock [hz], *; don't care time base timer control register 7 6543210 tbtcr (0036h) (dvoen) (dvock) (dv7ck) tbten tbtck (initial value: 0000 0000) tbten time base timer enable / disable 0: disable 1: enable tbtck time base timer interrupt frequency select : [hz] normal1/2, idle1/2 mode slow1/2 sleep1/2 mode r/w dv7ck = 0 dv7ck = 1 dv1ck=0 dv1ck=1 dv1ck=0 dv1ck=1 000 fc/2 23 fc/2 24 fs/2 15 fs/2 15 fs/2 15 001 fc/2 21 fc/2 22 fs/2 13 fs/2 13 fs/2 13 010 fc/2 16 fc/2 17 fs/2 8 fs/2 8 ? 011 fc/2 14 fc/2 15 fs/2 6 fs/2 6 ? 100 fc/2 13 fc/2 14 fs/2 5 fs/2 5 ? 101 fc/2 12 fc/2 13 fs/2 4 fs/2 4 ? 110 fc/2 11 fc/2 12 fs/2 3 fs/2 3 ? 111 fc/2 9 fc/2 10 fs/2 fs/2 ? fc/2 23 ,fc/2 24 or fs/2 15 fc/2 21 ,fc/2 22 or fs/2 13 fc/2 16 ,fc/2 17 or fs/2 8 fc/2 14 ,fc/2 15 or fs/2 6 fc/2 13 ,fc/2 14 or fs/2 5 fc/2 12 ,fc/2 13 or fs/2 4 fc/2 11 ,fc/2 12 or fs/2 3 fc/2 9 ,fc/2 10 or fs/2 tbtcr tbten tbtck 3 mpx source clock falling edge detector time base timer control register inttbt interrupt request idle0, sleep0 release request page 82 7. time base timer (tbt) 7.1 time base timer TMP86FS64FG note 2: the interrupt frequency (tbtck) must be selected with t he time base timer disabled (tbten="0"). (the interrupt fre- quency must not be changed with the disable from the enable state.) both frequency selection and enabling can be per- formed simultaneously. 7.1.3 function an inttbt ( time base timer interrupt ) is generated on the first falling edge of source clock ( the divider output of the timing generato which is selected by tbtck. ) after time base timer has been enabled. the divider is not cleared by the progra m; therefore, only the first interrupt may be generated ahead of the set interrupt period ( figure 7-2 ). figure 7-2 time base timer interrupt example :set the time base timer frequency to fc/2 16 [hz] and enable an inttbt interrupt. ld (tbtcr) , 00000010b ; tbtck 010 ld (tbtcr) , 00001010b ; tbten 1 di ; imf 0 set (eirh) . 0 table 7-1 time base timer interrupt frequency ( example : fc = 16.0 mhz, fs = 32.768 khz ) tbtck time base timer interrupt frequency [hz] normal1/2, idle1/2 mode normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 000 1.91 0.95 1 1 1 001 7.63 3.81 4 4 4 010 244.14 122.07 128 128 ? 011 976.56 488.28 512 512 ? 100 1953.13 976.56 1024 1024 ? 101 3906.25 1953.13 2048 2048 ? 110 7812.5 3906.25 4096 4096 ? 111 31250 15625 16384 16384 ? source clock enable tbt interrupt period tbtcr page 83 TMP86FS64FG 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 figure 7-3 divider output 7.2.2 control the divider output is controlled by the time base timer control register. note: selection of divider output frequency (dvock) must be made whil e divider output is disabled (dvoen="0"). also, in other words, when changing the state of the divider output frequen cy from enabled (dvoen="1") to disable(dvoen="0"), do not change the setting of the divider output frequency. time base timer control register 7654 321 0 tbtcr (0036h) dvoen dvock (dv7ck) (tbten) (tbtck) (initial value: 0000 0000) dvoen divider output enable / disable 0: disable 1: enable r/w dvock divider output ( dvo ) frequency selection: [hz] normal1/2, idle1/2 mode slow1/2 sleep1/2 mode r/w dv7ck=0 dv7ck=1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 00 fc/2 13 fc/2 14 fs/2 5 fs/2 5 fs/2 5 01 fc/2 12 fc/2 13 fs/2 4 fs/2 4 fs/2 4 10 fc/2 11 fc/2 12 fs/2 3 fs/2 3 fs/2 3 11 fc/2 10 fc/2 11 fs/2 2 fs/2 2 fs/2 2 tbtcr output latch port output latch mpx dvoen tbtcr page 84 7. time base timer (tbt) 7.2 divider output (dvo) TMP86FS64FG 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 ( exam ple : fc = 16.0 mhz, fs = 32.768 khz ) dvock divider output frequency [hz] normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0 dv7ck = 1 dv1ck=0 dv1ck=1 dv1ck=0 dv1ck=1 00 1.953 k 976.6 1.024 k 1.024 k 1.024 k 01 3.906 k 1.953 k 2.048 k 2.048 k 2.048 k 10 7.813 k 3.906 k 4.096 k 4.096 k 4.096 k 11 15.625 k 7.813 k 8.192 k 8.192 k 8.192 k page 85 TMP86FS64FG 8. 16-bit timercounter 1 (tc1) 8.1 configuration figure 8-1 timercounter 1 (tc1) :::? pin tc1 :w:?::? mett1 start capture clear source clock ppg output mode write to tc1cr 16-bit up-counter clear tc1drb selector tc1dra tc1cr tc1 control register match inttc1 interript tff1 acap1 tc1ck window mode set toggle q 2 toggle set clear q y a d b c s b a y s tc1s clear mppg1 ppg output mode internal reset s enable mcap1 s y a b tc1s 2 set clear command start decoder external trigger start edge detector note: function i/o may not operate depending on i/o port setting. for more details, see the chapter "i/o port". port (note) q pulse width measurement mode falling rising trigger external cmp 16-bit timer register a, b pulse width measurement mode port (note) fc/2 11 , fc/2 12, fs/2 3 fc/2 7 , fc/2 6 fc/2 3 , fc/2 4 page 86 8. 16-bit timercounter 1 (tc1) 8.2 timercounter control TMP86FS64FG 8.2 timercounter control the timercounter 1 is controlled by the timercounter 1 control register (tc1cr) and two 16-bit timer registers (tc1dra and tc1drb). note 1: fc: high-frequency clock [hz], fs: low-frequency clock [hz] note 2: the timer register consists of two shift registers. a va lue set in the timer register becomes valid at the rising edge o f the first source clock pulse that occurs after the upper byte (t c1drah and tc1drbh) 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 acce ss instruction). writing only the lower byte (tc1dral and tc1drbl) does not enable the setting of the timer register. timer register 1514131211109876543210 tc1dra (0021h, 0020h) tc1drah (0021h) tc1dral (0020h) (initial value: 1111 1111 1111 1111) read/write tc1drb (0023h, 0022h) tc1drbh (0023h) tc1drbl (0022h) (initial value: 1111 1111 1111 1111) read/write (write e nabled only in the ppg output mode) timercounter 1 control register tc1cr (0032h) 76543210 tff1 acap1 mcap1 mett1 mppg1 tc1s tc1ck tc1m read/write (initial value: 0000 0000) tff1 timer f/f1 control 0: clear 1: set r/w acap1 auto capture control 0:auto-capture disable 1:auto-capture enable r/w mcap1 pulse width measure- ment mode control 0:double edge capture 1:single edge capture mett1 external trigger timer mode control 0:trigger start 1:trigger start and stop mppg1 ppg output control 0:continuous pulse generation 1:one-shot tc1s tc1 start control timer extrig- ger event win- dow pulse ppg r/w 00: stop and counter clear oooooo 01: command start o????o 10: rising edge start (ex-trigger/pulse/ppg) rising edge count (event) positive logic count (window) ? ooooo 11: falling edge start (ex-trigger/pulse/ppg) falling edge count (event) negative logic count (window) ? ooooo tc1ck tc1 source clock select [hz] normal1/2, idle1/2 mode divider slow, sleep mode r/w dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 00 fc/2 11 fc/2 12 fs/2 3 fs/2 3 dv9 fs/2 3 01 fc/2 7 fc/2 8 fc/2 7 fc/2 8 dv5 ? 10 fc/2 3 fc/2 4 fc/2 3 fc/2 4 dv1 ? 11 external clock (tc1 pin input) tc1m tc1 operating mode select 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 page 87 TMP86FS64FG note 3: to set the mode, source clock, ppg output control and time r f/f control, write to tc1cr1 during tc1s=00. set the timer f/f1 control until the first timer start after setting the ppg mode. note 4: auto-capture can be used only in t he timer, event counter, and window modes. note 5: to set the timer registers, the following relationship must be satisfied. tc1dra > tc1drb > 1 (ppg output mode), tc1dra > 1 (other modes) note 6: set tff1 to ?0? in the mode except ppg output mode. note 7: set tc1drb after setting tc1m to the ppg output mode. note 8: when the stop mode is entered, the start control (tc1s) is cleared to ?00? automatically, and the timer stops. after the stop mode is exited, set the tc1s to use the timer counter again. note 9: use the auto-capture function in the operative condition of tc1. a captured value may not be fixed if it's read after th e execution of the timer stop or auto-capture disable. read the capture value in a capture enabled condition. note 10:since the up-counter value is captured into tc1drb by the source clock of up-counter after setting tc1cr page 88 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86FS64FG 8.3 function timercounter 1 has six types of operating modes: timer, external trigger timer, event counter, window, pulse width measurement, programmable pulse generator output modes. 8.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 (tc1dra) value is detected, an inttc1 interr upt is generated and the up-counter is cleared. after being cleared, the up-counter restarts counting. setting tc1cr page 89 TMP86FS64FG figure 8-2 timer mode timing chart match detect acap1 tc1drb tc1dra inttc1 interruput request source clock counter source clock counter ? (a) timer mode (b) auto-capture ? 7 6 345 0 timer start 12 3 2 1 4 0 counter clear capture n + 1 n n n m + 2 m + 1 m m capture m + 2 m + 1 n + 1 n m ? 1 m ? 1 m ? 2 n ? 1 n ? 1 n ? 1 page 90 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86FS64FG 8.3.2 external trigger timer mode in the external trigger timer mode, the up-counter starts counting by the input pulse triggering of the tc1 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 tc1cr page 91 TMP86FS64FG figure 8-3 external tri gger timer mode timing chart inttc1 interrupt request source clock up-counter tc1dra tc1 pin input inttc1 interrupt request source clock up-counter tc1dra tc1 pin input 0 at the rising edge (tc1s = 10) at the rising edge (tc1s = 10) (a) trigger start (mett1 = 0) count start match detect count start 0 1 2 3 4 2 3 n (b) trigger start and stop (mett1 = 1) count start count start 0 1 2 3 m 0 n n 0 count clear note: m < n count clear 1 2 3 1 n m ? 1 n ? 1 match detect count clear page 92 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86FS64FG 8.3.3 event counter mode in the event counter mode, the up-counter counts up at the edge of the input pulse to the tc1 pin. either the rising or falling edge of the input pulse is se lected as the count up edge in tc1cr page 93 TMP86FS64FG 8.3.4 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 tc1 pin (window pulse) and the internal source clock. eith er 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 tc1dra va lue is detected, an inttc1 interrupt is generated and the up-counter is cleared. define the window pulse to the frequency which is sufficiently lower than the internal source clock pro- grammed with tc1cr page 94 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86FS64FG 8.3.5 pulse width measurement mode in the pulse width measurement mode, the up-counter starts counting by the input pulse triggering of the tc1 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 tc1cr< tc1s>. either the single- or double-e dge capture is selected as the trig- ger edge in tc1cr page 95 TMP86FS64FG example :duty measurem ent (resolution fc/2 7 [hz], cgcr page 96 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86FS64FG figure 8-6 pulse wi dth measurement mode tc1drb inttc1 interrupt request interrupt request tc1 pin input counter internal clock (mcap1 = "1") 23 n count start count start trigger (tc1s = "10") 1 3 2 1 4 0 n 0 capture n - 1 tc1drb inttc1 tc1 pin input counter internal clock (mcap1 = "0") 12 n count start count start (tc1s = "10") 3 2 1 4 0 n capture capture n + 1 m - 2 n + 3 n + 2 n + 1 m - 1 m0 m [application] high-or low-level pulse width measurement [application] (1) cycle/frequency measurement (2) duty measurement (a) single-edge capture (b) double-edge capture page 97 TMP86FS64FG 8.3.6 programmable pulse generate (ppg) output mode in the programmable pulse generation (ppg) mode, an arbitrary duty pulse is generated by counting per- formed in the internal clock. to start the timer, tc1c r page 98 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86FS64FG figure 8-7 ppg output example :generating a pulse which is high-going for 800 s and low-going for 200 s (fc = 16 mhz, cgcr page 99 TMP86FS64FG figure 8-8 pp g mode timing chart inttc1 tc1dra internal clock counter tc1drb tc1dra ppg pin output 0 inttc1 interrupt request interrupt request 12 m01 2 n m01 n 2 n n + 1 n + 1 m (a) continuous pulse generation (tc1s = 01) tc1drb trigger count start timer start counter internal clock tc1 pin input ppg pin output 0 1m n n n + 1 m 0 (b) one-shot pulse generation (tc1s = 10) match detect note: m > n note: m > n [application] one-shot pulse output page 100 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86FS64FG page 101 TMP86FS64FG 9. 16-bit timer/counter2 (tc2) 9.1 configuration note: when control input/output is used, i/o port setting should be set correctly. for det ails, refer to the section "i/o ports" . figure 9-1 time r/counter2 (tc2) c d f tc2 control register tc2 pin tc2cr 16-bit up counter tc2dr clear tc2s tc2ck source clock timer/ event counter window tc2s 16-bit timer register 2 3 h a b e s b a s y inttc2 interrupt port (note) cmp tc2m fc fs match fc/2 23 , fc/2 24, fs/2 15 fc/2 8 , fc/2 9 fc/2 3 , fc/2 4 fc/2 13 , fc/2 14, fs/2 5 page 102 9. 16-bit timer/counter2 (tc2) 9.2 control TMP86FS64FG 9.2 control the timer/counter 2 is controlled by a timer/counter 2 control register (tc2cr) and a 16-bit timer register 2 (tc2dr). note 1: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *: don't care note 2: when writing to the timer register 2 (tc2dr), always write to the lower side (tc2drl) and then the upper side (tc2drh) in that order. writing to only the lower side (tc2drl) or the upper side (tc2drh) has no effect. note 3: the timer register 2 (tc2dr) uses the value previously set in it for coinci dence detection until data is written to the upper side (tc2drh) after writing data to the lower side (tc2drl). note 4: set the mode and source clock when the tc2 stops (tc2s = 0). note 5: values to be loaded to the timer regi ster must satisfy the following condition. tc2dr > 1 (tc2dr 15 to tc2dr 11 > 1 at warm up) note 6: if a read instruction is executed for tc2cr, read data of bit 7, 6 and 1 are unstable. note 7: the high-frequency clock (fc) canbe selected on ly when the time mode at slow2 mode is selected. note 8: on entering stop mode, the tc2 start control (tc2s) is cl eared to "0" automatically. so, the timer stops. once the stop mode has been released, to start using the timer counter, set tc2s again. tc2dr (0025h, 0024h) 1514131211109876543210 tc2drh (0025h) tc2drl (0024h) (initial value: 1111 1111 1111 1111) r/w tc2cr (0013h) 76543210 tc2s tc2ck tc2m (initial value: **00 00*0) tc2s tc2 start control 0:stop and counter clear 1:start r/w tc2ck tc2 source clock select unit : [hz] normal1/2, idle1/2 mode divider slow1/2 mode sleep1/2 mode r/w dv7ck = 0dv7ck = 1 dv1ck = 0dv1ck = 1dv1ck = 0dv1ck = 1 000 fc/2 23 fc/2 24 fs/2 15 fs/2 15 dv21 fs/2 15 fs/2 15 001 fc/2 13 fc/2 14 fs/2 5 fs/2 5 dv11 fs/2 5 fs/2 5 010 fc/2 8 fc/2 9 fc/2 8 fc/2 9 dv6 ? ? 011 fc/2 3 fc/2 4 fc/2 3 fc/2 4 dv1 ? ? 100 ? ? ? ? ? fc (note7) ? 101 fs fs fs fs ? ? ? 110 reserved external clock (tc2 pin input) 111 tc2m tc2 operating mode select 0:timer/event counter mode 1:window mode r/w page 103 TMP86FS64FG 9.3 function the timer/counter 2 has three operating modes: timer, event counter and window modes. and if fc or fs is selected as th e source clock in timer mode, when sw itching the timer mode from slow1 to normal2, the timer/counter2 can generate warm-up time until the oscillator is stable. 9.3.1 timer mode in this mode, the internal clock is used for counting up. the contents of tc2dr are compared with the con- tents of up counter. if a match is found, a timer/counter 2 interrupt (inttc2) is generated, and the counter is cleared. counting up is resumed after the counter is cleared. when fc is selected for source cl ock at slow2 mode, lower 11-bits of tc2dr are ignored and generated a interrupt by matching upper 5-bits only. though, in this situation, it is necessary to set tc2drh only. note:when fc is selected as the source clock in timer mo de, it is used at warm-up for switching from slow1 mode to normal2 mode. table 9-1 source clock (internal clock) for timer/counter2 (at fc = 16 mhz, dv7ck=0) tc2c k normal1/2, idle1/2 mode slow1/2 mode sleep1/2 mode dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution maximum time set- ting resolu- tion maximum time set- ting resolu- tion maximum time set- ting resolu- tion maximum time set- ting resolu- tion maximum time set- ting resolu- tion maxi- mum time setting 000 524.29 [ms] 9.54 [h] 1.05 [s] 19.1 [h] 1 [s] 18.2 [h] 1 [s] 18.2 [h] 1 [s] 18.2 [h] 1 [s] 18.2 [h] 001 512.0 [ s] 33.55 [s] 1.02 [ms] 1.12 [min] 0.98 [ms] 1.07 [min] 0.98 [ms] 1.07 [min] 0.98 [ms] 1.07 [min] 0.98 [ms] 1.07 [min] 010 16.0 [ s] 1.05 [s] 32 [ s] 2.09 [s] 16.0 [ s] 1.05 [s] 32.0 [ s] 2.10 [s] ? ? ? ? 011 0.5 [ s] 32.77 [ms] 1.0 [ s] 65.5 [ms] 0.5 [ s] 32.77 [ms] 1.0 [ s] 65.5 [ms] ? ? ? ? 100? ?????? ?62.5 [ns]??? 101 30.52 [ s] 2 [s] 30.52 [ s] 2 [s] 30.52 [ s] 2 [s] 30.52 [ s]2 [s]???? example :sets the timer m ode with source clock fc/2 3 [hz] and generates an interrupt every 25 ms (at fc = 16 mhz, cgcr page 104 9. 16-bit timer/counter2 (tc2) 9.3 function TMP86FS64FG figure 9-2 timer mode timing chart inttc2 interrupt source clock up-counter tc2dr match detect counter clear timer start 01234 n 0 123 :? page 105 TMP86FS64FG 9.3.2 event counter mode in this mode, events are counted on the rising edge of the tc2 pin input. the contents of tc2dr are com- pared with the contents of the up counter. if a match is found, an inttc2 interrupt is generated, and the counter is cleared. counting up is resumed every the rising edge of the tc2 pin input after the up counter is cleared. match detect is executed on the falling edge of the tc2 pin. therefore, an inttc2 interrupt is generated at the falling edge after the match of tc2dr and up counter. the minimum input pulse width of tc2 pin is shown in table 9-2. two or more machine cycles are required for both the ?h? and ?l? levels of the pulse width. figure 9-3 event c ounter mode timing chart 9.3.3 window mode in this mode, counting up performed on the rising edge of an internal clock during tc2 external pin input (window pulse) is ?h? level. the contents of tc2dr are co mpared with the contents of up counter. if a match found, an inttc2 interrupt is genera ted, and the up-counter is cleared. the maximum applied frequency (tc2 input) must be considerably slower than the selected internal clock by the tc2cr page 106 9. 16-bit timer/counter2 (tc2) 9.3 function TMP86FS64FG figure 9-4 window mode timing chart example :generates an interrupt , inputting ?h? level pulse width of 120 ms or more. (at fc = 16 mhz, tbtcr page 107 TMP86FS64FG 10. 8-bit timercounter 3 (tc3) 10.1 configuration note: function input may not operate depending on i/o port setti ng. for more details, see the chapter "i/o port". figure 10-1 timercounter 3 (tc3) tc3ck tc3s fc/2 13 , fs/2 5 fc/2 12 , fs/2 4 fc/2 11 , fs/2 3 fc/2 10 , fs/2 2 fc/2 9 , fs/2 fc/2 8 fc/2 7 3 source clock capture clear tc3s inttc3 interrupt tc3 contorol register 8-bit timer register overflow detect h a b c d e f g s tc3m tc3cr edge detector tc3drb tc3dra capture acap tc3s falling rising a y b s match detect y 8-bit up-counter tc3 pin port (note) cmp page 108 10. 8-bit timercounter 3 (tc3) 10.1 configuration TMP86FS64FG 10.2 timercounter control the timercounter 3 is controlled by the timercounter 3 control register (tc3cr) and two 8-bit timer registers (tc3dra and tc3drb). note 1: fc: high-frequency clock [h z], fs: low-frequency clock [hz], * : don?t care note 2: set the operating mode and source clock when timercounter stops (tc3s = 0). note 3: to set the timer registers, the following relationship must be satisfied. tc3dra > 1 (timer/event counter mode) note 4: auto-capture (acap) can be used only in the timer and event counter modes. note 5: when the read instruction is executed to tc3cr, the bit 5 and 7 are read as a don?t care. note 6: do not program tc3dra when the timer is running (tc3s = 1). note 7: when the stop mode is entered, the start control (tc3 s) is cleared to 0 automatically, and the timer stops. after the stop mode is exited, tc3s must be set again to use the timer counter. timer register and control register tc3dra (0010h) 76543210 read/write (initial value: 1111 1111) tc3drb (0011h) read only (initial value: 1111 1111) tc3cr (0012h) 76543210 acap tc3s tc3ck tc3m (initial value: *0*0 0000) acap auto capture control 0: ? 1: auto capture r/w tc3s tc3 start control 0: stop and counter clear 1: start r/w tc3ck tc3 source clock select [hz] normal1/2, idle1/2 mode divider slow1/2, sleep1/2 mode r/w dv7ck = 0dv7ck = 1 dv1ck=0 dv1ck=1 dv1ck=0 dv1ck=1 000 fc/2 13 fc/2 14 fs/2 5 fs/2 5 dv11 fs/2 5 001 fc/2 12 fc/2 13 fs/2 4 fs/2 4 dv10 fs/2 4 010 fc/2 11 fc/2 12 fs/2 3 fs/2 3 dv9 fs/2 3 011 fc/2 10 fc/2 11 fs/2 2 fs/2 2 dv8 fs/2 2 100 fc/2 9 fc/2 10 fs/2 fs/2 dv7 fs/2 101 fc/2 8 fc/2 9 fc/2 8 fc/2 9 dv6 ? 110 fc/2 7 fc/2 8 fc/2 7 fc/2 8 dv5 ? 111 external clock (tc3 pin input) tc3m tc3 operating mode select 0: timer/event counter mode 1: capture mode r/w page 109 TMP86FS64FG 10.3 function timercounter 3 has three types of operating modes: timer, event counter and capture modes. 10.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 3a (tc3dra) value is detected, an inttc3 interrupt is generated and the up-counter is cleared. after being cleared , the up-counter restarts counting. setting tc3cr page 110 10. 8-bit timercounter 3 (tc3) 10.1 configuration TMP86FS64FG figure 10-3 timer mode timing chart match detect tc3cr page 111 TMP86FS64FG 10.3.2 event counter mode in the event counter mode, the up-counter counts up at the rising edge of the input pulse to the tc3 pin. when a match between the up-counter and tc3dra value is detected, an inttc3 interrupt is generated and up-counter is cleared. after being cleared, the up-counter restarts counting at each rising edge of the input pulse to the tc3 pin. since a match is detected at the falling edge of the input pulse to tc3 pin, an inttc3 interrupt request is generated at the falling edge im mediately after the up-counter reaches the value set in tc3dra. the maximum applied frequencies are shown in table 10 -2. the pulse width larger than one machine cycle is required for high-going and low-going pulses. setting tc3cr page 112 10. 8-bit timercounter 3 (tc3) 10.1 configuration TMP86FS64FG 10.3.3 capture mode in the capture mode, the pulse width, frequency and du ty cycle of the pulse input to the tc3 pin are mea- sured with the internal clock. the capture mode is used to decode remote control signals, and identify ac50/60 hz. when the falling edge of the tc3 input is detected afte r the timer starts, the up-co unter value is captured into tc3drb. hereafter, whenever the rising edge is detect ed, the up-counter value is captured into tc3dra and the inttc3 interrupt request is generated. the up-counter is cleared at this time. generally, read tc3drb and tc3dra during inttc3 interrupt processing. after the up-counter is cleared, counting is continued and the next up-counter value is captured into tc3drb. when the rising edge is detected immediately after the timer starts, th e up-counter value is captured into tc3dra only, but not into tc3drb. the inttc3 interrupt request is generated. when the read instruction is executed to tc3drb at this time, the va lue at the completion of the last capture (ff im mediately after a reset) is read. the minimum input pulse width must be larger than one cycle width of the source clock programmed in tc3cr page 113 TMP86FS64FG 11. 8-bit timercounter 4 (tc4) 11.1 configuration figure 11-1 timercounter 4 (tc4) pwm output mode clear 3 2 source clock 8-bit up-counter overflow detect toggle clear timer f/f match detect s y 0 1 y s s 1 0 y pdo mode port (note) ::?:?:? (note) a b c d e f g h y s cmp note: function i/o may not operate depending on i/o port setting. for more details, see the chapter "i/o port". tc4cr tc4dr inttc4 interrupt tc4s tc4s tc4s tc4m tc4ck tc4 pin pwm4 / pdo4 / pin fc/2 11 , fc2 12 or fs/2 3 fc/2 7 , fc2 8 fc/2 5 , fc2 6 fc/2 3 , fc2 4 fc/2 2 , fc2 3 fc/2, fc2 2 fc, fc/2 page 114 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86FS64FG 11.2 timercounter control the timercounter 4 is controlled by the timercounter 4 c ontrol register (tc4cr) and timer registers 4 (tc4dr). note 1: fc: high-frequency clock [hz ], fs: low-frequency clock [hz], * : don?t care note 2: to set the timer registers, the following relationship must be satisfied. 1 tc4dr 255 note 3: to start timer operation (tc4s = 0 1) or disable timer operation (tc4s = 1 0), do not change the tc4cr page 115 TMP86FS64FG note: o : available source clock page 116 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86FS64FG 11.3 function timercounter 4 has four types of operating modes: timer, event counter, programmable divider output (pdo), and pulse width modulation (pwm) output modes. 11.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 tc4dr value is detected, an inttc4 interrupt is generated and the up-counter is cleared. after being cleared, the up-counter restarts counting. table 11-1 source clock for timercounter 4 (example: fc = 16 mhz, fs = 32.768 khz) tc4ck normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] 000 128.0 32.6 256.0 65.3 244.14 62.2 244.14 62.2 244.14 62.2 001 8.0 2.0 16.0 4.1 8.0 2.0 16.0 4.1 ? ? 010 2.0 0.510 4.0 1.0 2.0 0.510 4.0 1.0 ? ? 011 0.5 0.128 1.0 0.255 0.5 0.128 1.0 0.255 ? ? page 117 TMP86FS64FG 11.3.2 event counter mode in the event counter mode, the up-counter counts up at the rising edge of the input pulse to the tc4 pin. when a match between the up-counter and the tc4dr va lue is detected, an inttc4 interrupt is generated and the up-counter is cl eared. after being cleared, the up-counter restarts counting at rising edge of the tc4 pin. since a match is detected at the falling edge of the input pulse to the tc4 pin, the inttc4 interrupt request is generated at the falling edge immediately after the up-counter reaches the value set in tc4dr. the minimum pulse width applied to the tc4 pin are shown in table 11-2. the pulse width larger than two machine cycles is required for high- and low-going pulses. note:the event counter mode can not used in the slow 1/2 and sleep1/2 modes since the external clock is not supplied in these modes. table 11-2 external source clock for timercounter 4 minimum pulse width normal1/2, idle1/2 mode high-going 2 3 /fc low-going 2 3 /fc page 118 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86FS64FG 11.3.3 programmable divi der output (pdo) mode the programmable divider output (pdo) mode is used to generated a pulse with a 50% duty cycle by count- ing with the internal clock. when a match between the up-counter and the tc4dr value is detected, the logic level output from the pdo4 pin is switched to the opposite state and inttc 4 interrupt request is generated. the up-counter is cleared at this time and then counting is continued. when a match between the up-counter and the tc4dr value is detected, the logic level outp ut from the pdo4 pin is switched to the opposite state again and inttc4 interrupt request is generated. the up-counter is cleared at this time, and then counting and pdo are continued. when the timer is stopped, the pdo4 pin is high. ther efore, if the timer is stopped when the pdo4 pin is low, the duty pulse may be shorter than the programmed value. figure 11-2 pdo mode timing chart example :generating 1024 hz pulse (fc = 16.0 mhz) ld (tc4cr), 00000110b : sets the pdo mode. (tc4m = 10, tc4ck = 001) ld (tc4dr), 3dh : 1/1024 2 7 /fc 2 (half cycle period) = 3dh ld (tc4cr), 00100110b : start tc4 internal clock counter match detect 0 12 n 0 12 n 0 1 2 n 01 2 n 0 1 n tc4dr pdo4 pin inttc4 interrupt request timer f/f page 119 TMP86FS64FG 11.3.4 pulse width modul ation (pwm) output mode the pulse width modulation (pwm) output mode is used to generate the pwm pulse with up to 8 bits of res- olution by an internal clock. when a match between the up-counter and the tc4dr value is detected, the logic level output from the pwm 4 pin becomes low. the up-counter continues counting. when the up-counter overflow occurs, the pwm 4 pin becomes high. the inttc4 interrupt request is generated at this time. when the timer is stopped, the pwm4 pin is high. therefore, if the timer is stopped when the pwm4 pin is low, one pmw cycle may be shor ter than the programmed value. tc4dr is serially connected to th e shift register. if tc4dr is programmed during pwm output, the data set to tc4dr is not shifted until one pwm cycle is complete d. therefore, a pulse can be modulated periodically. for the first time, the data written to tc4dr is shif ted when the timer is started by setting tc4cr page 120 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86FS64FG table 11-3 pwm mode (example: fc = 16 mhz) tc4ck normal1/2, idle1/2 mode dv7ck = 0dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution [ns] cycle [ s] resolution [ns] cycle [ s] resolution [ns] cycle [ s] resolution [ns] cycle [ s] 000???????? 001???????? 010???????? 011 500 128 1000 256 500 128 1000 256 100 250 64 500 128 250 64 500 128 101 125 32 250 64 125 32 250 64 110???????? page 121 TMP86FS64FG 12. 8-bit timercounter 5 (tc5) 12.1 configuration figure 12-1 timercounter 5 (tc5) pwm output mode clear 3 2 source clock 8-bit up-counter overflow detect toggle clear timer f/f match detect s y 0 1 y s s 1 0 y pdo mode port (note) ::?:?:? (note) a b c d e f g h y s cmp note: function i/o may not operate depending on i/o port setting. for more details, see the chapter "i/o port". tc5cr tc5dr inttc5 interrupt tc5s tc5s tc5s tc5m tc5ck tc5 pin pwm5 / pdo5 / pin fc/2 11 , fc2 12 or fs/2 3 fc/2 7 , fc2 8 fc/2 5 , fc2 6 fc/2 3 , fc2 4 fc/2 2 , fc2 3 fc/2, fc2 2 fc, fc/2 page 122 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86FS64FG 12.2 timercounter control the timercounter 5 is controlled by the timercounter 5 c ontrol register (tc5cr) and timer registers 5 (tc5dr). note 1: fc: high-frequency clock [hz ], fs: low-frequency clock [hz], * : don?t care note 2: to set the timer registers, the following relationship must be satisfied. 1 tc5dr 255 note 3: to start timer operation (tc5s = 0 1) or disable timer operation (tc5s = 1 0), do not change the tc5cr page 123 TMP86FS64FG note: o : available source clock page 124 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86FS64FG 12.3 function timercounter 5 has four types of operating modes: timer, event counter, programmable divider output (pdo), and pulse width modulation (pwm) output modes. 12.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 tc5dr value is detected, an inttc5 interrupt is generated and the up-counter is cleared. after being cleared, the up-counter restarts counting. table 12-1 source clock for timercounter 5 (example: fc = 16 mhz, fs = 32.768 khz) tc5ck normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] 000 128.0 32.6 256.0 65.3 244.14 62.2 244.14 62.2 244.14 62.2 001 8.0 2.0 16.0 4.1 8.0 2.0 16.0 4.1 ? ? 010 2.0 0.510 4.0 1.0 2.0 0.510 4.0 1.0 ? ? 011 0.5 0.128 1.0 0.255 0.5 0.128 1.0 0.255 ? ? page 125 TMP86FS64FG 12.3.2 event counter mode in the event counter mode, the up-counter counts up at the rising edge of the input pulse to the tc5 pin. when a match between the up-counter and the tc5dr va lue is detected, an inttc5 interrupt is generated and the up-counter is cl eared. after being cleared, the up-counter restarts counting at rising edge of the tc5 pin. since a match is detected at the falling edge of the input pulse to the tc5 pin, the inttc5 interrupt request is generated at the falling edge immediately after the up-counter reaches the value set in tc5dr. the minimum pulse width applied to the tc5 pin are shown in table 12-2. the pulse width larger than two machine cycles is required for high- and low-going pulses. note:the event counter mode can not used in the slow 1/2 and sleep1/2 modes since the external clock is not supplied in these modes. table 12-2 external source clock for timercounter 5 minimum pulse width normal1/2, idle1/2 mode high-going 2 3 /fc low-going 2 3 /fc page 126 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86FS64FG 12.3.3 programmable divi der output (pdo) mode the programmable divider output (pdo) mode is used to generated a pulse with a 50% duty cycle by count- ing with the internal clock. when a match between the up-counter and the tc5dr value is detected, the logic level output from the pdo5 pin is switched to the opposite state and inttc 5 interrupt request is generated. the up-counter is cleared at this time and then counting is continued. when a match between the up-counter and the tc5dr value is detected, the logic level outp ut from the pdo5 pin is switched to the opposite state again and inttc5 interrupt request is generated. the up-counter is cleared at this time, and then counting and pdo are continued. when the timer is stopped, the pdo5 pin is high. ther efore, if the timer is stopped when the pdo5 pin is low, the duty pulse may be shorter than the programmed value. figure 12-2 pdo mode timing chart example :generating 1024 hz pulse (fc = 16.0 mhz) ld (tc5cr), 00000110b : sets the pdo mode. (tc5m = 10, tc5ck = 001) ld (tc5dr), 3dh : 1/1024 2 7 /fc 2 (half cycle period) = 3dh ld (tc5cr), 00100110b : start tc5 internal clock counter match detect 0 12 n 0 12 n 0 1 2 n 01 2 n 0 1 n tc5dr pdo5 pin inttc5 interrupt request timer f/f page 127 TMP86FS64FG 12.3.4 pulse width modul ation (pwm) output mode the pulse width modulation (pwm) output mode is used to generate the pwm pulse with up to 8 bits of res- olution by an internal clock. when a match between the up-counter and the tc5dr value is detected, the logic level output from the pwm 5 pin becomes low. the up-counter continues counting. when the up-counter overflow occurs, the pwm 5 pin becomes high. the inttc5 interrupt request is generated at this time. when the timer is stopped, the pwm5 pin is high. therefore, if the timer is stopped when the pwm5 pin is low, one pmw cycle may be shor ter than the programmed value. tc5dr is serially connected to th e shift register. if tc5dr is programmed during pwm output, the data set to tc5dr is not shifted until one pwm cycle is complete d. therefore, a pulse can be modulated periodically. for the first time, the data written to tc5dr is shif ted when the timer is started by setting tc5cr page 128 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86FS64FG table 12-3 pwm mode (example: fc = 16 mhz) tc5ck normal1/2, idle1/2 mode dv7ck = 0dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution [ns] cycle [ s] resolution [ns] cycle [ s] resolution [ns] cycle [ s] resolution [ns] cycle [ s] 000???????? 001???????? 010???????? 011 500 128 1000 256 500 128 1000 256 100 250 64 500 128 250 64 500 128 101 125 32 250 64 125 32 250 64 110???????? page 129 TMP86FS64FG 13. 8-bit timercounter 6 (tc6) 13.1 configuration figure 13-1 timercounter 6 (tc6) pwm output mode clear 3 2 source clock 8-bit up-counter overflow detect toggle clear timer f/f match detect s y 0 1 y s s 1 0 y pdo mode port (note) ::?:?:? (note) a b c d e f g h y s cmp note: function i/o may not operate depending on i/o port setting. for more details, see the chapter "i/o port". tc6cr tc6dr inttc6 interrupt tc6s tc6s tc6s tc6m tc6ck tc6 pin pwm6 / pdo6 / pin fc/2 11 , fc2 12 or fs/2 3 fc/2 7 , fc2 8 fc/2 5 , fc2 6 fc/2 3 , fc2 4 fc/2 2 , fc2 3 fc/2, fc2 2 fc, fc/2 page 130 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86FS64FG 13.2 timercounter control the timercounter 6 is controlled by the timercounter 6 c ontrol register (tc6cr) and timer registers 6 (tc6dr). note 1: fc: high-frequency clock [hz ], fs: low-frequency clock [hz], * : don?t care note 2: to set the timer registers, the following relationship must be satisfied. 1 tc6dr 255 note 3: to start timer operation (tc6s = 0 1) or disable timer operation (tc6s = 1 0), do not change the tc6cr page 131 TMP86FS64FG note: o : available source clock page 132 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86FS64FG 13.3 function timercounter 6 has four types of operating modes: timer, event counter, programmable divider output (pdo), and pulse width modulation (pwm) output modes. 13.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 tc6dr value is detected, an inttc6 interrupt is generated and the up-counter is cleared. after being cleared, the up-counter restarts counting. table 13-1 source clock for timercounter 6 (example: fc = 16 mhz, fs = 32.768 khz) tc6ck normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] resolution [ s] maxi- mum time setting [ms] 000 128.0 32.6 256.0 65.3 244.14 62.2 244.14 62.2 244.14 62.2 001 8.0 2.0 16.0 4.1 8.0 2.0 16.0 4.1 ? ? 010 2.0 0.510 4.0 1.0 2.0 0.510 4.0 1.0 ? ? 011 0.5 0.128 1.0 0.255 0.5 0.128 1.0 0.255 ? ? page 133 TMP86FS64FG 13.3.2 event counter mode in the event counter mode, the up-counter counts up at the rising edge of the input pulse to the tc6 pin. when a match between the up-counter and the tc6dr va lue is detected, an inttc6 interrupt is generated and the up-counter is cl eared. after being cleared, the up-counter restarts counting at rising edge of the tc6 pin. since a match is detected at the falling edge of the input pulse to the tc6 pin, the inttc6 interrupt request is generated at the falling edge immediately after the up-counter reaches the value set in tc6dr. the minimum pulse width applied to the tc6 pin are shown in table 13-2. the pulse width larger than two machine cycles is required for high- and low-going pulses. note:the event counter mode can not used in the slow 1/2 and sleep1/2 modes since the external clock is not supplied in these modes. table 13-2 external source clock for timercounter 6 minimum pulse width normal1/2, idle1/2 mode high-going 2 3 /fc low-going 2 3 /fc page 134 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86FS64FG 13.3.3 programmable divi der output (pdo) mode the programmable divider output (pdo) mode is used to generated a pulse with a 50% duty cycle by count- ing with the internal clock. when a match between the up-counter and the tc6dr value is detected, the logic level output from the pdo6 pin is switched to the opposite state and inttc 6 interrupt request is generated. the up-counter is cleared at this time and then counting is continued. when a match between the up-counter and the tc6dr value is detected, the logic level outp ut from the pdo6 pin is switched to the opposite state again and inttc6 interrupt request is generated. the up-counter is cleared at this time, and then counting and pdo are continued. when the timer is stopped, the pdo6 pin is high. ther efore, if the timer is stopped when the pdo6 pin is low, the duty pulse may be shorter than the programmed value. figure 13-2 pdo mode timing chart example :generating 1024 hz pulse (fc = 16.0 mhz) ld (tc6cr), 00000110b : sets the pdo mode. (tc6m = 10, tc6ck = 001) ld (tc6dr), 3dh : 1/1024 2 7 /fc 2 (half cycle period) = 3dh ld (tc6cr), 00100110b : start tc6 internal clock counter match detect 0 12 n 0 12 n 0 1 2 n 01 2 n 0 1 n tc6dr pdo6 pin inttc6 interrupt request timer f/f page 135 TMP86FS64FG 13.3.4 pulse width modul ation (pwm) output mode the pulse width modulation (pwm) output mode is used to generate the pwm pulse with up to 8 bits of res- olution by an internal clock. when a match between the up-counter and the tc6dr value is detected, the logic level output from the pwm 6 pin becomes low. the up-counter continues counting. when the up-counter overflow occurs, the pwm 6 pin becomes high. the inttc6 interrupt request is generated at this time. when the timer is stopped, the pwm6 pin is high. therefore, if the timer is stopped when the pwm6 pin is low, one pmw cycle may be shor ter than the programmed value. tc6dr is serially connected to th e shift register. if tc6dr is programmed during pwm output, the data set to tc6dr is not shifted until one pwm cycle is complete d. therefore, a pulse can be modulated periodically. for the first time, the data written to tc6dr is shif ted when the timer is started by setting tc6cr page 136 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86FS64FG table 13-3 pwm mode (example: fc = 16 mhz) tc6ck normal1/2, idle1/2 mode dv7ck = 0dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution [ns] cycle [ s] resolution [ns] cycle [ s] resolution [ns] cycle [ s] resolution [ns] cycle [ s] 000???????? 001???????? 010???????? 011 500 128 1000 256 500 128 1000 256 100 250 64 500 128 250 64 500 128 101 125 32 250 64 125 32 250 64 110???????? page 137 TMP86FS64FG 14. asynchronous serial interface (uart ) 14.1 configuration figure 14-1 uart (asynch ronous serial interface) counter y a b c s s a b c d y e f g h uart status register uart control register 2 uart pin select register irda output control register uart control register 1 transmit data buffer receive data buffer fc/13 fc/26 fc/52 fc/104 fc/208 fc/416 fc/96 stop bit parity bit fc/2 6 fc/2 7 fc/2 8 rxd1 rxd2 txd1 txd2 baud rate generator transmit/receive clock 2 4 3 2 2 2 noise rejection circuit irda control irdacr scisel shift register transmit control circuit receive control circuit shift register m p x m p x m p x mpx: multiplexer uartcr1 tdbuf rdbuf inttrx inttrx uartsr uartcr2 inttc4 page 138 14. asynchronous serial interface (uart ) 14.2 control TMP86FS64FG 14.2 control uart is controlled by the uart control registers (uartcr1, uartcr2). the operating status can be moni- tored using the uart status register (uartsr). txd1 pin and rxd1 pin can be selected a port assignmen t by uart pin select regist er (scisel). and infrared data format (irda) output is available by setting irda ou tput control register (irdacr) through txd1 pin. note 1: when operations are disabled by se tting txe and rxe bit to ?0?, the setting be comes valid when data transmit or receive complete. when the transmit data is stored in the transmit data buf fer, the data are not transmitted. even if data transmit is enabled, until new data are written to the transmit data buffer, the current data are not transmitted. note 2: the transmit clock and the parity are common to transmit and receive. note 3: uartcr1 page 139 TMP86FS64FG note: when an inttxd is generated, tbep flag is set to "1" automatically. note 1: do not change scisel register during uart operation. note 2: set scisel register before performing the setting terminal of a i/o port when changing a terminal. uart status register uartsr (001bh) 76543210 perr ferr oerr rbfl tend tbep (initial value: 0000 11**) perr parity error flag 0: 1: no parity error parity error read only 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 uart receive data buffer rdbuf (001dh) 76543210read only (initial value: 0000 0000) uart transmit data buffer tdbuf (001dh) 76543210write only (initial value: 0000 0000) uart pin select register scisel (002ah) 76543210 txd sel rxd sel (initial value: **** *00*) txdesel txd connect pin select 0: 1: p41 p44 r/w rxdsel rxd connect pin select 0: 1: p42 p45 page 140 14. asynchronous serial interface (uart ) 14.3 transfer data format TMP86FS64FG 14.3 transfer data format in uart, an one-bit start bit (low level), stop bit (bit length selectable at high level, by uartcr1 ; even- or odd-number ed parity by uartcr1 |