Part Number Hot Search : 
M0765RG E28F640 D1800N LT1055AM SUT484J 9LV16 C201NE AC121
Product Description
Full Text Search
 

To Download TMP86CS64AFG Datasheet File

  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 TMP86CS64AFG
page 2 TMP86CS64AFG 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 2006/2/6 1 first release 2006/6/29 2 periodical updating.no change in contents. 2006/8/21 3 contents revised

i table of contents TMP86CS64AFG 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 (maskrom) ................................................................................................................ 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) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 5.2 port p1 (p17 to p10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 5.3 port p2 (p22 to p20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 5.4 port p3 (p37 to p30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 5.5 port p4 (p47 to p40) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 5.6 port p5 (p57 to p50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 5.7 port p6 (p67to p60) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 5.8 port p7 (p77 to p70) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 5.9 port p8 (p87 to p80) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.10 port p9 (p97 to p90) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 5.11 port pa (pa7 to pa0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.12 port pb (pb7 to pb0) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 6. watchdog timer (wdt) 6.1 watchdog timer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 6.2 watchdog timer control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 6.2.1 malfunction detection methods using the watchdog timer ................................................................... 72 6.2.2 watchdog timer enable ......................................................................................................................... 73 6.2.3 watchdog timer disable ........................................................................................................................ 74 6.2.4 watchdog timer interrupt (intwdt) ...................................................................................................... 74 6.2.5 watchdog timer reset ........................................................................................................................... 75 6.3 address trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 6.3.1 selection of address trap in internal ram (atas) ................................................................................ 76 6.3.2 selection of operation at address trap (atout) .................................................................................. 76 6.3.3 address trap interrupt (intatrap) ....................................................................................................... 76 6.3.4 address trap reset ............................................................................................................................... . 77 7. time base timer (tbt) 7.1 time base timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 7.1.1 configuration ............................................................................................................................... ........... 79 7.1.2 control ............................................................................................................................... ..................... 79 7.1.3 function ............................................................................................................................... ................... 80 7.2 divider output (dvo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 7.2.1 configuration ............................................................................................................................... ........... 81 7.2.2 control ............................................................................................................................... ..................... 81
iii 8. 16-bit timercounter 1 (tc1) 8.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 8.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84 8.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 8.3.1 timer mode ............................................................................................................................... .............. 86 8.3.2 external trigger timer mode .................................................................................................................. 88 8.3.3 event counter mode ............................................................................................................................... 90 8.3.4 window mode ............................................................................................................................... .......... 91 8.3.5 pulse width measurement mode ............................................................................................................ 92 8.3.6 programmable pulse generate (ppg) output mode ............................................................................. 95 9. 16-bit timer/counter2 (tc2) 9.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 9.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 9.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 9.3.1 timer mode ............................................................................................................................... ............ 101 9.3.2 event counter mode .............................................................................................................................. 103 9.3.3 window mode ............................................................................................................................... ........ 103 10. 8-bit timercounter 3 (tc3) 10.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 10.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 10.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 10.3.1 timer mode ............................................................................................................................... .......... 107 figure 10-3 ................................................................................................................ .................................... 109 10.3.3 capture mode ............................................................................................................................... ...... 110 11. 8-bit timercounter 4 (tc4) 11.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 11.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 11.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 11.3.1 timer mode ............................................................................................................................... .......... 114 11.3.2 event counter mode ........................................................................................................................... 115 11.3.3 programmable divider output (pdo) mode ....................................................................................... 116 11.3.4 pulse width modulation (pwm) output mode .................................................................................... 117 12. 8-bit timercounter 5 (tc5) 12.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 12.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 12.3.1 timer mode ............................................................................................................................... .......... 122 12.3.2 event counter mode ........................................................................................................................... 123 12.3.3 programmable divider output (pdo) mode ....................................................................................... 124 12.3.4 pulse width modulation (pwm) output mode .................................................................................... 125
iv 13. 8-bit timercounter 6 (tc6) 13.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 13.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 13.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 13.3.1 timer mode ............................................................................................................................... .......... 130 13.3.2 event counter mode ........................................................................................................................... 131 13.3.3 programmable divider output (pdo) mode ....................................................................................... 132 13.3.4 pulse width modulation (pwm) output mode .................................................................................... 133 14. asynchronous serial interface (uart ) 14.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 14.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 14.3 transfer data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 14.4 infrared (irda) data format transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 14.5 transfer rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 14.6 data sampling method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 14.7 stop bit length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 14.8 parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 14.9 transmit/receive operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 14.9.1 data transmit operation .................................................................................................................... 141 14.9.2 data receive operation ..................................................................................................................... 141 14.10 status flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 14.10.1 parity error ............................................................................................................................... ......... 142 14.10.2 framing error ............................................................................................................................... ..... 142 14.10.3 overrun error ............................................................................................................................... ..... 142 14.10.4 receive data buffer full ................................................................................................................... 143 14.10.5 transmit data buffer empty ............................................................................................................. 143 14.10.6 transmit end flag ............................................................................................................................ 14 4 15. synchronous serial interface (sio1) 15.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 15.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 15.3 serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 15.3.1 clock source ............................................................................................................................... ........ 147 15.3.1.1 internal clock 15.3.1.2 external clock 15.3.2 shift edge ............................................................................................................................... ............. 149 15.3.2.1 leading edge 15.3.2.2 trailing edge 15.4 number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 15.5 number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 15.6 transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 15.6.1 4-bit and 8-bit transfer modes ............................................................................................................. 150 15.6.2 4-bit and 8-bit receive modes ............................................................................................................. 152 15.6.3 8-bit transfer / receive mode ............................................................................................................... 153 16. synchronous serial interface (sio2) 16.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
v 16.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 16.3 serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 16.3.1 clock source ............................................................................................................................... ........ 159 16.3.1.1 internal clock 16.3.1.2 external clock 16.3.2 shift edge ............................................................................................................................... ............. 161 16.3.2.1 leading edge 16.3.2.2 trailing edge 16.4 number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 16.5 number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 16.6 transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 16.6.1 4-bit and 8-bit transfer modes ............................................................................................................. 162 16.6.2 4-bit and 8-bit receive modes ............................................................................................................. 164 16.6.3 8-bit transfer / receive mode ............................................................................................................... 165 17. 10-bit ad converter (adc) 17.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 17.2 register configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 17.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 17.3.1 software start mode ........................................................................................................................... 173 17.3.2 repeat mode ............................................................................................................................... ....... 173 17.3.3 register setting ............................................................................................................................... . 174 17.4 stop/slow modes during ad conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 17.5 analog input voltage and ad conversion result . . . . . . . . . . . . . . . . . . . . . . . 176 17.6 precautions about ad converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 17.6.1 analog input pin voltage range ........................................................................................................... 177 17.6.2 analog input shared pins .................................................................................................................... 177 17.6.3 noise countermeasure ....................................................................................................................... 177 18. key-on wakeup (kwu) 18.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 18.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 18.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 19. input/output circuitry 19.1 control pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 19.2 input/output ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 20. electrical characteristics 20.1 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 20.2 recommended operating condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 20.3 dc characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185 20.4 ad conversion characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 20.5 ac characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 20.6 recommended oscillating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 20.7 handling precaution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
vi 21. 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).
page 1 060116ebp TMP86CS64AFG 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 TMP86CS64AFG 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 - timer, event counter, capture modes 9. 8-bit timer counter : 3 ch - timer, event counter, pulse width modulation (pwm) output, product no. rom (maskrom) ram package flash mcu emulation chip TMP86CS64AFG 61440 bytes 2048 bytes p-qfp100-1420-0.65a tmp86fs64fg tmp86c964xb
page 2 1.1 features TMP86CS64AFG 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. idle1 mode: cpu stops and peripherals operate us ing high frequency clock. release by interru- puts(cpu restarts). idle2 mode: cpu stops and peripherals operate usin g high and low frequency clock. release by inter- ruputs. (cpu restarts). sleep0 mode: cpu stops, and only the time-based-t imer(tbt) on peripherals operate using low fre- quency clock.release by falling edge of th e source clock which is set by tbtcr. sleep1 mode: cpu stops, and peripherals operate using low frequency clock. release by interru- put.(cpu restarts). sleep2 mode: cpu stops and peripherals operate using high and low frequency clock. release by interruput. 16. wide operation voltage: 4.5 v to 5.5 v at 16 mhz /32.768 khz 2.7 v to 5.5 v at 8 mhz /32.768 khz
page 3 TMP86CS64AFG 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 (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 TMP86CS64AFG 1.3 block diagram
page 5 TMP86CS64AFG figure 1-2 block diagram
page 6 1.4 pin names and functions TMP86CS64AFG 1.4 pin names and functions 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG
page 11 TMP86CS64AFG 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 TMP86CS64AFG memory consists of ram and special function register (sfr), which are mapped to a 64 kbyte address space. the TMP86CS64AFG memory consists of maskrom, ram, special function register (sfr) and data buffer resister (dbr), which are mapped to a 64 kbyte address space. figure 2-1 shows the TMP86CS64AFG 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 maskrom: program memory maskrom 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 TMP86CS64AFG 2.1.2 program memory (maskrom) TMP86CS64AFG incorporates the 61440-byte (add resses from 1000h through ffffh) program memory (maskrom). 2.1.3 data memory (ram) TMP86CS64AFG incorporates the 2048-byte (addres ses from 0040h through 083fh) ram. since the address space from 0040h through 00ffh within the on-ch ip 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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. this function enables to operate the peripheral circuits without program change by inputting fc/8 to the 1st stage of the divider when the operation clock is multiplied by 2. (ex., 8 mhz to 16 mhz) the input clock to the 7th stage of the divider depends on syscr2, tbtcr and cgcr settings, as shown in table 2-2. the prescaler and divider are cl eared to 0 upon reset and entry to/exit from the stop mode. note: tbtcr indicates the bit 4 (dv7ck) of the timing generator (tbtcr). hereafter, this nota- tional convention is used for each f unctional bit of the register. note 1: do not set tbtcr to 1 during the normal1 or idle1 mode. note 2: since the input clock to the 1st stage of the divider is stopped in the slow1/2 or sleep1/2 mode, output from the 1st to 7th stages of the divider is also stopped. table 2-1 divider output divider output dv1ck = 0 dv1ck = 1 dv1g dv2g dv3g dv4 dv5 dv1g dv2g dv3g dv4 dv5 fc/2 3 fc/2 4 fc/2 5 fc/2 6 fc/2 7 fc/2 4 fc/2 5 fc/2 6 fc/2 7 fc/2 8 table 2-2 input clock to 7th stage of the divider [hz] normal1, idle1 mode normal2, idle2 mode (sysck=0) slow1/2, sleep1/2 mode (sysck = 1) dv7ck = 0 dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 fc/2 8 fc/2 9 fc/2 8 fc/2 9 fs fs
page 15 TMP86CS64AFG 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 tbtcr high-frequency clock fc low-frequency clock fc cgcr prescaler divider divider selector selector selector fc or fs dv1 dv2 dv3 dv4 dv5 dv6 dv7 dv8 dv9 dv10 dv 11 dv12 dv13 dv14 dv15 dv16 dv17 dv18 dv20 dv21 machine cycle counter 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 s a y b s a y b s b0 b1 a0 y0 a1 y1 6 5 4 3 2 1 1 2 0 main system clock generator warm-up controller watchdog timer timercounter, time base timer, divider output, etc.
page 16 2. operational descriptions 2.2 system clock controller TMP86CS64AFG 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 TMP86CS64AFG 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 to 1 in the normal1 mode. when the idle0 mode is entered, the cpu is halted and the timing generator stops clocking to the peripherals except tbt. when detecting the falling edge of the source clock set in tbtcr, the timing generator star ts clocking to all on-chip peripherals. when the idle0 mode is exited, the cpu restarts operation and returns to the normal1 mode. the idle0 mode is entered and returned to the normal1 mode regardless of setting in tbtcr. interrupt processing is performe d when imf = 1, ef8 (tbt interrupt enable flag) = 1, and tbtcr = 1. when the idle0 mode is entered with tbtcr = 1, inttbt interrupt latch is set after returning to the normal mode. 2.2.3.2 dual-clock mode in the dual-clock mode, two oscillators for hi gh-frequency and low-frequency are used. the p21 (xtin) and p22 (xtout) pins are used for the low-fr equency clock pins. (in the dual-clock mode, these pins can not be used as i/o ports.) the main system clock is generated by the high-frequency clock in the normal2 and idle2 modes, and the low-frequency clock in the slow1/2 and sleep1/2 modes. therefore, the machine cycle time is 4/fc [s] in the normal2 and idle2 modes, and 4/fs [s] (122 s @ fs = 32.768 khz) in the slow and sleep modes. the tlcs-870/c series is put in the single-clock mode during reset. to use the dual-clock mode, oscil- late the low-frequency clock at the top of the program. (1) normal2 mode the cpu core operates with high-frequency clock. on-chip peripherals op erate with high- and low-frequency clocks.
page 18 2. operational descriptions 2.2 system clock controller TMP86CS64AFG (2) slow2 mode the cpu core operates with low-frequency clock. switching from normal2 to slow2, and vise-versa is programmed in syscr2. do not clear xten to 0 in the slow2 mode. (3) slow1 mode power dissipation can be reduced by stopping high-frequency clock oscillation, and operating the cpu core and on-chip periphera ls with low-frequency clock. switching from slow1 to slow2, and vise-ver sa is programmed in syscr2. in the slow1 and sleep1 modes, output from the 1st to 6th stages is stopped. (4) idle2 mode the cpu and watchdog timer are halted, and on-chip peripherals are operated with the high- and low-frequency clocks. entering and exiting the idle2 mode is the same as for the idle1 mode. after exiting the idle2 mode, the cpu returns to the normal2 mode. (5) sleep1 mode the cpu and watchdog timer are halted, and on-c hip peripherals are operated with the low-fre- quency clock. entering and exit ing the sleep1 mode is the same as for the idle1 mode. after exit- ing the sleep1 mode, th cpu returns to the sl ow1 mode. high-frequency clock oscillation is stopped. in the slow1 and sleep1 modes, ou tput from the 1st to 6th stages is stopped. (6) sleep2 mode the sleep2 mode is the idle mode correspondin g to the slow2 mode. the sleep2 mode is the same as the slow2 mode except that high-frequency clock is activated. (7) sleep0 mode the cpu and on-chip peripherals are halted ex cept oscillator and tbt. the sleep0 mode is entered by setting the system control register syscr2 to 1 in the slow1 mode. when the sleep0 mode is entered, the cpu is halted and the timing generator stops clocking to the peripherals except tbt. when detecting th e falling edge of the source clock set in tbtcr, the timing generator starts the clocking operation to all on-chip peripherals. when the sleep0 mode is exited, the cpu restar ts operation and returns to the slow1 mode. the cpu enters to the sleep0 mode and returns to the slow1 mode regardless of setting in tbtcr. interrupt processing is performe d when imf = 1, ef8 (tbt interrupt enable flag) = 1, and tbtcr = 1. when the sleep0 mode is entered with tbtcr = 1, inttbt interrupt latch is set after returning to the slow1 mode.
page 19 TMP86CS64AFG 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. figure 2-6 operat ing mode transition idle0 mode reset normal1 mode stop normal2 mode slow2 mode slow1 mode idle1 mode idle2 mode sleep2 mode sleep1 mode sleep0 mode (a) single-clock mode (b) dual-clock mode syscr2 = "1" syscr1 = "1" syscr2 = "1" syscr1 = "1" syscr2 = "1" syscr2 = "1" syscr1 = "1" interrupt stop pin input interrupt stop pin input interrupt interrupt stop pin input (note 2) (note 2) syscr2 = "1" syscr2 = "0" syscr2 = "1" syscr2 = "0" syscr2 = "1" syscr2 = "1" syscr2 = "0" syscr2 = "1" reset released
page 20 2. operational descriptions 2.2 system clock controller TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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, the time to return to the normal1/slow1 mode from the idle0/sleep0 mode is shorter than the period time specified in tbtcr. note 6: upon exit from the idle1/2 or sleep1/2 mode, idle is automatically cleared to 0. note 7: upon exit from the idle0 or sleep0 mode, tghalt is automatically cleared to 0. note 8: when setting tghal to 1, stop functions of on-chip peripherals beforehand. if not stopped, an interrupt latch to the peripherals may be set immediately afte r the idle0 or sleep0 mode is exited. system control register 2 7 6 5 4 3210 syscr2 (0039h) xen xten sysck idle tghal t (initial value: 1000 *0**) xen high-frequency oscillator control 0: stop oscillation 1: continue or start oscillation r/w xten low-frequency oscillator control 0: stop oscillation 1: continue or start oscillation sysck system clock select (write)/monitor (read) 0: high-frequency clock (normal1/normal2/idle1/idle2) 1: low-frequency clock (slow/sleep) idle cpu and wdt control (idle1/2, sleep1/2 mode) 0: cpu, wdt enabled 1: cpu, wdt disabled (enter idle1/2, sleep1/2 mode) r/w tghalt tg control (idle0, sleep0 mode) 0: clocking operation to all peripherals from tg 1: stop the clocking operation to peripherals except tbt from tg (enter idle0, sleep0 mode) r/w
page 23 TMP86CS64AFG 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 to 1, and the following status is held in the stop mode. 1. both high-frequency and low-fre quency oscillations are stopped, and all internal behaviors are stopped. 2. the data memory, registers, and program status words and port output latches hold the status before the stop mode is entered. 3. the prescaler and divider of the timing generator are cleared to 0. 4. the program counter holds the address of the instruction after next to the instruction (e.g., [set(syscr1).7]) by which the stop mode is entered. the stop mode contains the level-sensitive and e dge-sensitive exit modes which can be selected in syscr1. in the case of the edge-sensitive exit mode, stop5 to stop2 must be disabled. note 1: unlike the key-on wake-up input pin, the stop pin does not have the function to disable input. to use the stop mode, the stop pin must be used to exit the stop mode. note 2: during stop period (from the start of the stop mode to the end of warm-up period time), interrupt latches are set to 1 due to external interrupt signal changes, and interrupts may be accepted immedi- ately after the stop mode is exited. therefore, disable interrupts before entering the stop mode. before enabling interrupts after the stop mode is exited, clear unnecessary interrupt latches before- hand. (1) level-sensitive exit mode (relm = 1) in this mode, the stop mode is exited by setting the stop pin to high or stop5 to stop2 (can be specified to each bit in stopcr) to low. this mode is used for capacitor back-up when the main power supply is cut off and long tern battery back-up. when the stop pin input is set to high or stop5 to stop2 is set to low, executing an instruction to enter the stop mode does not enter the stop mode, but immediately starts the exit sequence (warm-up). when the stop mode is entered in the level-sensitive exit mode, it is required to check that the stop pin input is programmed to low and the stop5 to stop2 pin input is programmed to high by the following methods. 1. testing the port condition. 2. using the int5 interrupt (an interrupt is generated at the falling edge of the int5 pin input) example 1 :entering the stop mode from the normal mode by testing a port p20 ld (syscr1), 01010000b : sets the level-sensitive exit mode. sstoph: test (p2prd) . 0 : wait state until the stop pin input becomes low. jrs f, sstoph di : imf0 set (syscr1) . 7 : enters the stop mode.
page 24 2. operational descriptions 2.2 system clock controller TMP86CS64AFG 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 TMP86CS64AFG 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 depending on the characteristics of the oscillator. 3. after the warm-up period time, program execution resumes with the instruction immedi- ately following the instruction that activated the stop mode. note 1: when the stop mode is exited, the prescala r and divider of the timing generator are cleared to 0. note 2: the stop mode is exited by setting the reset pin to low, that immediately performs the normal reset operation. note 3: to exit the stop mode with a low hold voltage, the following cautions must be observed. the power supply voltage must be at the operating voltage level before exiting the stop mode. the reset pin must also be high, rising together with the power supply voltage. in this case, if an external time constant circuit is connected, the reset pin input voltage increases at a slower pace than the power supply voltage. at this time, there is a danger that a reset may occur if the input voltage level of the reset pin drops below the non-inverting high-level input voltage (hys- teresis input). note 1: since the warm-up period time is obtained by dividing the basic clock by the divider, any fre- quency fluctuations will lead to small warm- up period time error. the warm-up period time should be considered as an approximate value. table 2-5 warm-up time (fc = 16.0 mhz, fs = 32.768 khz) wut warm-up time [ms] return to the normal mode return to the slow mode dv1ck=0 dv1ck=1 00 01 10 11 12.288 4.096 3.072 1.024 24.576 8.192 6.144 2.048 750 250 5.85 1.95
page 26 2. operational descriptions 2.2 system clock controller TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG ? 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 to 1. ? exiting idle1/2 or sleep1/2 mode upon return from the idel1/2 or sleep1/2 m ode, the interrupt master enable flag (imf) determines the action taken after exiting the idle1/2 or sleep1/2 mode; i.e., whether execu- tion resumes with an interrupt service routine. when exiting the idle1//2 or sleep1/2 mode, syscr2 is automatically cleared to 0, and the operating mode is returned to the mode before entering the idle1/2 or sleep1/2 mode. the idle1/2 or sleep1/2 mode is exited by setting the reset pin to low. in this case, the normal1 mode is activated afte r exitig the idle1/2 or sleep1/2. (1) program execution resuming with the instruction (imf = 0) the idle1/2 or sleep1/2 mode is exited by the individual interrupt enable flag (ef). program execution resumes with the instruction immediately following the instruction that activated the idle1/2 or sleep1/2 mode. normally the instructi on latches (il) of the interrupt source used to exit the idle1/2 or sleep1/2 mode must be cleared to 0 by the load instruction. (2) program execution resuming with the interrupt service routine (imf = 1) the idel1/2 or sleep1/2 mode is exited by an interrupt source enabled by the individual inter- rupt enable flag (ef). execution resumes with the interrupt service routine. upon completion of the interrupt service routine, program execution resume s with the instruction immediately following the instruction that activated the idel1/2 or sleep1/2 mode. note: when a watchdog timer interrupt is generated immediately before entering the idel1/2 or sleep1/2 mode, the watchdog timer interrupt is processed without entering the idel1/2 or sleep1/2 mode.
page 29 TMP86CS64AFG 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 TMP86CS64AFG 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 tbt interrupt enabled falling the tbt source clock imf = "1" ye s "1" no no entering the idle0 or sleep0 mode (instruction) execution of the instruction immediately following the instruction that activated the idle0 or sleep0 mode
page 31 TMP86CS64AFG ? entering idle0 or sleep0 mode disable on-chip peripherals such as a timer counter. to enter the idle0 or sleep0 mode, set syscr2 to 1. ? exiting idle0 or sleep0 mode upon return from the idel0 or sleep0 mode, th e interrupt master enable flag (imf) deter- mines the action taken after exiting the idel0 or sleep0 mode; i.e., whether execution resumes with an interrupt service routin e. when exiting the idel0 or sleep0 mode, syscr2 is automatically cleared to 0, and the operating mode is returned to the mode before entering the idel0 or sleep0 mode. when tbtcr is set to 1 at this time. the inttbt interrupt latch is set. the idle0 or sleep0 mode is exited by setting the reset pin to low. in this case, the normal1 mode is act ivated after exiting the idle1/2 or sleep1/2. note: the idle0 or sleep0 mode is entered and exited regardless of tbtcr setting. (1) program execution resuming with the instruction (imf, ef8, tbtcr = 0) when detecting the falling edge of the so urce clock set in tbtcr, the idle0 or sleep0 mode is exited. when the idle0 or s leep0 mode is exited, program execution resumes with the instruction immediately following the instruction that activated the idle0 or sleep0 mode. when tbtcr is set to 1, the time base timer interrupt latch is set. (2) program execution resuming with th e interrupt service routine (imf, ef8, tbtcr = 1) when detecting the falling edge of the so urce clock set in tbtcr, the idle0 or sleep0 mode is exited, and then inttbt interrupt processing is performed. note 1: the idle0 or sleep0 mode is returned to the normal1 or sleep1 mode by the asynchro- nous internal clock specified in tbtcr , the period time of idle0 or sleep0 mode is shorter than the period set in tbtcr. note 2: when a watchdog timer interrupt is generat ed immediately before entering the idle1/2 or sleep1/2 mode, the watchdog timer interrupt is processed, without entering the idle1/2 or sleep1/2 mode. note 3: when il8er in interrupt source selector (intsel) is set to "1", the program execution resumes with the instruction immediately following the in struction that activated the idle0 or sleep0 mode even though all of imf, ef8 and tbtcr are set to "1".
page 32 2. operational descriptions 2.2 system clock controller TMP86CS64AFG 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 TMP86CS64AFG 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 to switch the main sy stem clock to the low-frequency clock. clear syscr2 to 0 to stop the high-frequency oscillator. note: the high-frequency clock oscillati on can be continued to return quickly to the normal2 mode. to enter the stop mode from the slow m ode, the high-frequency clock must be stopped. when the low-frequency clock oscillation is unstable, wait unti l the oscillation is stabilized before performing the above oper ation. the timercounter (tc2) is convenient to chec k the low-frequency clock oscillation stability.) example 1 :switching from the normal2 mode to slow1 mode. set (syscr2) . 5 : syscr21 : (switches the system clock to the low-frequency clock for the slow2 mode.) clr (syscr2) . 7 : syscr20(stops the high-frequency oscillation.) example 2 :switching to the slow1 mode after checking the low-frequency clock oscillation stability with tc2 set (syscr2). 6 : syscr21 : (starts low-frequency oscillation.) ld (tc2cr), 14h : sets the mode for tc2. ldw (tc2drl), 8000h :sets the warm-up time. : (determines the time depending on the resonator.) di : imf0 set (eirh). 4 : enables the inttc2. ei : imf1 set (tc2cr). 5 : starts inttc2. | pinttc2: clr (tc2cr). 5 : stops inttc2. set (syscr2). 5 : syscr21 : (switches the system clock to the low-frequency clock.) clr (syscr2). 7 : syscr20(stops the high-frequency clock.) reti | vinttc2: dw pinttc2 : inttc2 vector table
page 34 2. operational descriptions 2.2 system clock controller TMP86CS64AFG (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 to 1 to oscillate the high-frequency clock. after the warm-up period time required to assure oscillation stability with the timercounter (tc2) has elapsed, clear syscr2 to 0 to switch the system clock to the high-frequency clock. the slow mode is also exited by setting the reset pin to low, which immediately performs normal reset operation. the normal1 mode is entered after a reset release. example :switching from slow1 mode to normal2 mode with tc2 (fc = 16 mhz, warm-up time = 4.0 ms) set (syscr2) . 7 : syscr21 :(starts high-frequency oscillation.) ld (tc2cr), 10h : sets the tc2 mode. ld (tc2drh), 0f8h : sets the warm-up time. : (determines the time depending on the frequency and resonator.) di : imf0 set (eirh). 4 : enables inttc2 interrupt. ei : imf1 set (tc2cr). 5 : starts tc2. | pinttc2 clr (tc2cr). 5 : stops tc2. clr (syscr2). 5 : syscr20 : (switches the system clock to the high-frequency clock.) reti | vinttc2: dw pinttc2 : inttc2 vector table high-frequency clock fc low-frequency clock fc main system clock sysck
page 35 TMP86CS64AFG 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 TMP86CS64AFG 2.3 reset circuit TMP86CS64AFG has four types of reset, that are an exte rnal reset, address trap reset, watchdog timer reset and system clock reset. an address trap reset, watchdog timer reset and system clock reset are internal factor resets. when detecting these reset requests, TMP86CS64AFG 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 TMP86CS64AFG 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 = 1) or the sfr area, an address-trap-res et is generated. the reset time is a maximum of 24/ fc [s] (1.5 s @16.0 mhz). if the cpu runs away due to spurious noises and a ttempts to fetch an instruction from the on-chip ram (wdtcr1 = 1), the dbr or the sf r area, an address-trap-reset is ge nerated. the reset time is a max- imum of 24/fc [s] (1.5 s @16.0 mhz). note:either a reset or an interrupt can be selected fo r an address-trap. an address-tr ap area can be specified. note 1: "a" is the address in on-chip ram (wdtcr1=1), sfr or dbr area. note 2: during the reset release process, the reset vector "r" is read out, and an instruction at the address "r" is fetched and decoded. figure 2-16 addr ess trap reset 2.3.3 watchdog timer reset refer to "watchdog timer". 2.3.4 system clock reset either one of the following conditions is met, a system clock reset is generated automatically to prevent the cpu to be in the deadlock condition. (oscillation is continued.) ? syscr2 and syscr2 are cleared to 0. ? syscr2 is cleared to 0 when syscr2 = 0. ? syscr2 is cleared to 0 when syscr2 = 1. the reset time is a maximum of 24/fc [s] (1.5 s @160.0 mhz). reset input vdd reset internal factor reset output circuit watchdog timer address trap detection system clock detection instruction execution internal reset signal an address-trap is generated jp a 4/fc to 12/fc [s] max 24/fc [s] 16/fc [s] reset released instruction at r address
page 38 2. operational descriptions 2.3 reset circuit TMP86CS64AFG
page 39 TMP86CS64AFG 3. interrupt control circuit the TMP86CS64AFG has a total of 21 interrupt sources ex cluding 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 to ?0? (it is set for the ?reset request? after reset is cancelled). for details , see ?address trap?. note 3: to use the watchdog timer interrupt (intwdt), clear wdtcr1 to "0" (it is set for the "reset request" after reset is released). for details, see "watchdog timer". 3.1 interrupt latches (il15 to il2) an interrupt latch is provided for eac h interrupt source, except for a software interrupt and an executed the unde- fined instruction interrupt. when interrupt request is genera ted, the latch is set to ?1?, and the cpu is requested to accept the interrupt if its interrupt is enabled. the interrupt latch is cleared to "0" immediately after accepting inter- rupt. all interrupt latches are initialized to ?0? during reset. interrupt factors enable condition interrupt latch vector address priority internal/external (reset) non-maskable ? fffe 1 internal intswi (software interrupt) non-maskable ? fffc 2 internal intundef (executed the undefined instruction interrupt) non-maskable ? fffc 2 internal intatrap (address trap interrupt) non-maskable il2 fffa 2 internal intwdt (watchdog timer interrupt) non-maskable il3 fff8 2 external int0 imf? ef4 = 1, int0en = 1 il4 fff6 5 external int1 imf? ef5 = 1 il5 fff4 6 internal inttc4 imf? ef6 = 1 il6 fff2 7 internal inttc5 imf? ef7 = 1 il7 fff0 8 internal inttbt imf? ef8 = 1, il8er = 0 il8 ffee 9 external int2 imf? ef8 = 1, il8er = 1 internal inttc1 imf? ef9 = 1, il9er = 0 il9 ffec 10 external int3 imf? ef9 = 1, il9er = 1 internal inttc3 imf? ef10 = 1 il10 ffea 11 internal inttc6 imf? ef11 = 1 il11 ffe8 12 internal inttc2 imf? ef12 = 1 il12 ffe6 13 internal intsio1 imf? ef13 = 1, il13er = 0 il13 ffe4 14 external int4 imf? ef13 = 1, il13er = 1 internal inttrx imf? ef14 = 1, il14er = 0 il14 ffe2 15 external int5 imf? ef14 = 1, il14er = 1 internal intadc imf? ef15 = 1, il15er = 0 il15 ffe0 16 internal intsio2 imf? ef15 = 1, il15er = 1
page 40 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86CS64AFG 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 TMP86CS64AFG 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) TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG has 6 external interrupt inputs. these inputs are equipped with di gital 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 TMP86CS64AFG 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=0). in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int2 int2 imf ? ef8 = 1 and il8er=1 falling edge or rising edge pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals.(at cgcr=0). in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int3 int3 imf ? ef9 = 1 and il9er=1 falling edge or rising edge pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals.(at cgcr=0). in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int4 int4 imf ? ef13 = 1 and il13er=1 falling edge, rising edge, falling and rising edge or h level pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals.(at cgcr=0). in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are considered to be signals. int5 int5 imf ? ef14 = 1 and il14er=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.
page 49 TMP86CS64AFG 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 TMP86CS64AFG
page 51 TMP86CS64AFG 4. special function register (sfr) the TMP86CS64AFG adopts the memory mapped i/o system , and all peripheral contro l and data transfers are performed through the special function register (sfr) or the data buffer register (dbr). the sfr is mapped on address 0000h to 003fh, dbr is mapped on address 0f80h to 0fffh. this chapter shows the arrangement of the special functi on register (sfr) and data buffer register (dbr) for TMP86CS64AFG. 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 TMP86CS64AFG 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 TMP86CS64AFG 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 TMP86CS64AFG 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 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 address read write 0fe0h reserved : : : : 0fffh reserved
page 55 TMP86CS64AFG 5. i/o ports the TMP86CS64AFG 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 56 5. i/o ports TMP86CS64AFG 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 57 TMP86CS64AFG 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 58 5. i/o ports TMP86CS64AFG 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 is set to ?1?, port p20 becomes high-z (input mode). note 2: each terminal has a protect diode. please refer to section ?input/output circuitry; (2) input/output ports?. p2dr (0002h) 76543210 p22 xtout p21 xtin p20 int5 stop1 (initial value: **** *111) p2r (002ch) 76543210 p22in p21in p20in (initial value: **** ****) read only output latch output latch output latch data input (p20in) data input (p20) data output control input data input (p21in) data input (p21) data output data input (p22in) data input (p22) data output stop outen xten fs osc.enable d q p20 d q p21 d q p22
page 59 TMP86CS64AFG 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 60 5. i/o ports TMP86CS64AFG 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 61 TMP86CS64AFG 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 62 5. i/o ports TMP86CS64AFG 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 63 TMP86CS64AFG 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 . during reset, p6cr and p6dr are initialized to ? 0 ? and adccr1 is set to ? 1 ? . at the same time, the input data of p67 to p60 are fixed to ? 0 ? level. when port p6 is used as input port, the corresponding bit in p6cr and p6dr should be set to input mode (p6cr = ? 0 ? , p6dr = ? 1 ? ). when used as output port, the corresponding bit in p6cr should be set to ? 1 ? . when used as analog input port, the corresponding bit in p6cr and p6dr should be set to analog input mode (p6cr = ? 0 ? , p6dr = ? 0 ? ) and adccr1 is set to ? 0 ? , then the ad conversion is started. setting p6dr to ? 0 ? is necessary to prevent generating the penetr ation electric current. so the output latch of the po rt used as analog input should be set to ? 0 ? beforehand. actually selection of the c onversion input channels is specified by adccr1. pins used for analog input can be used as i/o port. during ad conversion, output instructions should not be exe- cuted to keep a precision. in addition, a variable signal should not be input to a port adjacent to the analog input dur- ing ad conversion. when the ad converter is in use (p6dr = ? 0 ? ), bits mentioned above are read as ? 0 ? by executing input instruc- tions. note 1: i = 7 to 0 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 note 3: sain: ad input channel select signal figure 5-8 port p6 analog input pull-up resistor (typ. 80 k ? ) ainds sain stop outen data input data output p6cri p6i p6pui d q vdd output latch
page 64 5. i/o ports TMP86CS64AFG 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 65 TMP86CS64AFG 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. during reset, p7cr and p7 dr are initialized to ? 0 ? and adccr1 is set to ? 1 ? . at the same time, the input data of p77 to p70 are fixed to ? 0 ? level. when port p7 is used as input port, the corresponding bit in p7cr and p7dr should be set to input mode (p7cr = ? 0 ? , p7dr = ? 1 ? ). when used as output port, the corresponding bit in p7cr should be set to ? 1 ? . when used as analog input port, the corresponding bit in p7cr and p7dr should be set to analog input mode (p7cr = ? 0 ? , p7dr = ? 0 ? ) and adccr1 is set to ? 0 ? , then the ad conversion is started. setting p7dr to ? 0 ? is necessary to prevent generating the penetr ation electric current. so the output latch of the port used as analog input should be set to ? 0 ? beforehand. actually selection of the conversion input channels is specified by adccr1. pins used for analog input can be used as i/o port. during ad conversion, output instructions should not be exe- cuted to keep a precision. in addition, a variable signal should not be input to a port adjacent to the analog input dur- ing ad conversion. when the ad converter is in use (p7dr = ? 0 ? ), bits mentioned above are read as ? 0 ? by executing input instruc- tions. note 1: i = 7 to 0, j = 5 to 2 note 2: stop: bit 7 in syscr1, outen: bit 4 in syscr1 note 3: sain: bit 0 to 3 in adccra note 4: sotpjen: bit 4 to 7 in stopcr figure 5-9 port p7 analog input ainds sain stop outen data input data output p7cri stopjen p7i d q key on wake up pull-up resistor (typ. 80 k ? ) p7pui vdd output latch
page 66 5. i/o ports TMP86CS64AFG 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 67 TMP86CS64AFG 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 68 5. i/o ports TMP86CS64AFG 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 69 TMP86CS64AFG 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 70 5. i/o ports TMP86CS64AFG 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 71 TMP86CS64AFG 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 72 6. watchdog timer (wdt) 6.2 watchdog timer control TMP86CS64AFG 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 is set to ?1? at this time, the reset request is generated and then internal hardware is initialized. when wdtcr1 is set to ?0?, a watchdog timer interrupt (intwdt) is generated. the watchdog timer temporarily stops counting in th e stop mode including the warm-up or idle/sleep mode, and automatically restarts (continues counting) when the stop/idle/sleep mode is inactivated. note:the watchdog timer consists of an internal divider and a two-stage binary counter. when the clear code 4eh is written, only the binary counter is cleared, but not the internal divider . the minimum binary-counter overflow time, that depends on the timing at which the clear code (4eh) is written to the wdtcr2 register, may be 3/ 4 of the time set in wdtcr1. therefore, writ e the clear code using a cycle shorter than 3/4 of the time set to wdtcr1. example :setting the watchdog timer detection time to 2 21 /fc [s], and resetting the cpu malfunction detection ld (wdtcr2), 4eh : clears the binary counters. ld (wdtcr1), 00001101b : wdtt 10, wdtout 1 ld (wdtcr2), 4eh : clears the binary counters (always clears immediately before and after changing wdtt). within 3/4 of wdt detection time : : ld (wdtcr2), 4eh : clears the binary counters. within 3/4 of wdt detection time : : ld (wdtcr2), 4eh : clears the binary counters.
page 73 TMP86CS64AFG 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 = 0. note 2: *: don?t care note 3: the binary counter of the watchdog timer must not be cleared by the interrupt task. note 4: write the clear code 4eh using a cycle shor ter than 3/4 of the time set in wdtcr1. 6.2.2 watchdog timer enable setting wdtcr1 to ?1? enables the watc hdog timer. since wdtcr1 is initialized to ?1? during reset, the watchdog timer is enabled automatically after the reset release. watchdog timer control register 1 wdtcr1 (0034h) 76543210 (atas) (atout) wdten wdtt wdtout (initial value: **11 1001) wdten watchdog timer enable/disable 0: disable (writing the disable code to wdtcr2 is required.) 1: enable write only wdtt watchdog timer detection time [s] normal1/2 mode slow1/2 mode write only dv7ck = 0 dv7ck = 1 dv1ck=0 dv1ck=1 dv1ck=0 dv1ck=1 00 2 25 /fc 2 26 /fc 2 17 /fs 2 17 /fs 2 17 /fs 01 2 23 /fc 2 24 /fc 2 15 /fs 2 15 /fs 2 15 fs 10 2 21 fc 2 22 fc 2 13 /fs 2 13 /fs 2 13 fs 11 2 19 /fc 2 20 /fc 2 11 /fs 2 11 /fs 2 11 /fs wdtout watchdog timer output select 0: interrupt request 1: reset request write only watchdog timer control register 2 wdtcr2 (0035h) 76543210 (initial value: **** ****) wdtcr2 write watchdog timer control code 4eh: clear the watchdog timer binary counter (clear code) b1h: disable the watchdog timer (disable code) d2h: enable assigning address trap area others: invalid write only
page 74 6. watchdog timer (wdt) 6.2 watchdog timer control TMP86CS64AFG 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 to ?0?. 4. set wdtcr2 to the disable code (b1h). note:while the watchdog timer is disabled, the binary counters of the watchdog timer are cleared. 6.2.4 watchdog time r interrupt (intwdt) when wdtcr1 is cleared to ?0?, a watchdog timer interrupt request (intwdt) is generated by the binary-counter overflow. a watchdog timer interrupt is the non-maskable interr upt which can be accepted regardless of the interrupt master flag (imf). when a watchdog timer interrupt is generated while the other interrupt including a watchdog timer interrupt is already accepted, the new watchdog timer interrupt is processed immediately and the previous interrupt is held pending. therefore, if watchdog timer interrupts are generated continuously without execution of the retn instruction, too many levels of nesting may cause a malfunction of the microcontroller. to generate a watchdog timer interrupt, set the stack pointer before setting wdtcr1. example :disabling the watchdog timer di : imf 0 ld (wdtcr2), 04eh : clears the binary coutner ldw (wdtcr1), 0b101h : wdten 0, wdtcr2 disable code table 6-1 watchdog timer detection time (example: fc = 16.0 mhz, fs = 32.768 khz) wdtt watchdog timer detection time[s] normal1/2 mode slow mode dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 00 2.097 4.194 4 4 4 01 524.288 m 1.049 1 1 1 10 131.072 m 262.144 m 250 m 250 m 250 m 11 32.768 m 65.536 m 62.5 m 62.5 m 62.5 m example :setting watchdog timer interrupt ld sp, 083fh : sets the stack pointer ld (wdtcr1), 00001000b : wdtout 0
page 75 TMP86CS64AFG 6.2.5 watchdog timer reset when a binary-counter overflow occurs while wdt cr1 is set to ?1?, a watchdog timer reset request is generated. when a watchdog timer reset request is generated, the internal hardware is reset. the reset time is maximum 24/fc [s] (1.5 s @ fc = 16.0 mhz). note:when a watchdog timer reset is generated in the sl ow1 mode, the reset time is maximum 24/fc (high-fre- quency clock) since the high-frequency cl ock oscillator is restarted. however, when crystals have inaccura- cies upon start of the high-frequency clock oscillator, the reset time should be considered as an approximate value because it has slight errors. figure 6-2 watchdog timer interrupt clock binary counter overflow intwdt interrupt request (wdtcr1= "0") 2 17 /fc 2 19 /fc [s] (wdtt=11) write 4e h to wdtcr2 1 2 30 1 2 3 0 internal reset (wdtcr1= "1") a reset occurs
page 76 6. watchdog timer (wdt) 6.3 address trap TMP86CS64AFG 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 specifies whether or not to generate address traps in the inte rnal ram area. to execute an instruction in the internal ram area, clear wdtcr1 to ?0?. to enable the wdtcr1 set- ting, set wdtcr1 and then write d2h to wdtcr2. executing an instruction in the sfr or dbr area generates an address trap unconditionally regardless of the setting in wdtcr1. 6.3.2 selection of operati on at address trap (atout) when an address trap is generated, either the inte rrupt request or the reset request can be selected by wdtcr1. 6.3.3 address trap interrupt (intatrap) while wdtcr1 is ?0?, if the cpu should start looping for some cause such as noise and an attempt be made to fetch an instruction from the on-chip ram (while wdtcr1 is ?1?), dbr or the sfr area, address trap interrupt (intatrap) will be generated. an address trap interrupt is a non-maskable interrupt which can be accepted regardless of the interrupt mas- ter flag (imf). when an address trap interrupt is generated while th e other interrupt including a watchdog timer interrupt is already accepted, the new address trap is processed immediately and the previous interrupt is held pending. therefore, if address trap interrupts are generated continuously without execution of the retn instruction, too many levels of nesting may cause a malfunction of the microcontroller. to generate address trap interrupts, set the stack pointer beforehand. watchdog timer control register 1 wdtcr1 (0034h) 7654 3 21 0 atas atout (wdten) (wdtt) (wdtout) (initial value: **11 1001) atas select address trap generation in the internal ram area 0: generate no address trap 1: generate address traps (after setting atas to ?1?, writing the control code d2h to wdtcr2 is reguired) write only atout select opertion at address trap 0: interrupt request 1: reset request watchdog timer control register 2 wdtcr2 (0035h) 76543210 (initial value: **** ****) wdtcr2 write watchdog timer control code and address trap area control code d2h: enable address trap area selection (atrap control code) 4eh: clear the watchdog timer binary counter (wdt clear code) b1h: disable the watchdog timer (wdt disable code) others: invalid write only
page 77 TMP86CS64AFG 6.3.4 address trap reset while wdtcr1 is ?1?, if the cpu should start looping for some cause such as noise and an attempt be made to fetch an instruction from the on-chip ram (while wdtcr1 is ?1?), dbr or the sfr area, address trap reset will be generated. when an address trap reset request is generated, the in ternal hardware is reset. the reset time is maximum 24/fc [s] (1.5 s @ fc = 16.0 mhz). note:when an address trap reset is generated in the slow1 mode, the reset time is maximum 24/fc (high-fre- quency clock) since the high-frequency cl ock oscillator is restarted. however, when crystals have inaccura- cies upon start of the high-frequency clock oscillator, the reset time should be considered as an approximate value because it has slight errors.
page 78 6. watchdog timer (wdt) 6.3 address trap TMP86CS64AFG
page 79 TMP86CS64AFG 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 80 7. time base timer (tbt) 7.1 time base timer TMP86CS64AFG 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 inttbt
page 81 TMP86CS64AFG 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 dvo pin output dvock divider output control register (a) configuration (b) timing chart data output 2 a b c y d s d q dvo pin 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 10 ,fc/2 11 or fs/2 2
page 82 7. time base timer (tbt) 7.2 divider output (dvo) TMP86CS64AFG 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 83 TMP86CS64AFG 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 84 8. 16-bit timercounter 1 (tc1) 8.2 timercounter control TMP86CS64AFG 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 85 TMP86CS64AFG 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 to "1". therefore, to read the captured value, wait at least one cycle of the internal source clock before reading tc1drb for the first time.
page 86 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86CS64AFG 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 to ?1? captures the up-counter value into the timer reg- ister 1b (tc1drb) with the auto-capture function. use the auto-capture function in the operative conditio n of tc1. a cap- tured value may not be fixed if it's read after the execution of the timer stop or auto-capture disa ble. read the capture value in a capture enabled condition. since the up-counter value is captured into tc1drb by the source clock of up-counter after setting tc1cr to "1". therefore, to read the captured value, wait at leas t one cycle of the internal source clock before reading tc1drb for the first time. note: since the up-counter value is captured into tc1drb by the source clock of up-counter after setting tc1cr to "1". therefore, to read the captured value, wait at least one cycle of the internal source clock before reading tc1drb for the first time. table 8-1 internal source clock for timercounter 1 (example: fc = 16 mhz, fs = 32.768 khz) tc1ck normal1/2, idle1/2 mode slow, sleep mode dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 resolution [ s] maximum time setting [s] resolution [ s] maximum time set- ting [s] resolution [ s] maximum time setting [s] resolution [ s] maximum time setting [s] resolution [ s] maximum time setting [s] 00 128 8.39 256 16.78 244.14 16.0 244.14 16.0 244.14 16.0 01 8.0 0.524 16 1.05 8.0 0.524 16.0 0.838 ? ? 10 0.5 32.77 m 1 65.53 m 0.5 32.77 m 1.0 52.42 m ? ? example 1 :setting the timer mode with source clock fc/2 11 [hz] and generating an interrupt 1 second later (fc = 16 mhz, tbtcr = ?0?, cgcr = ?0?) ldw (tc1dra), 1e84h ; sets the timer register (1 s 2 11 /fc = 1e84h) di ; imf = ?0? set (eirh). 1 ; enables inttc1 ei ; imf = ?1? ld (tc1cr), 00000000b ; selects the source clock and mode ld (tc1cr), 00010000b ; starts tc1 example 2 :auto-capture ld (tc1cr), 01010000b ; acap1 1 : : ld wa, (tc1drb) ; reads the capture value
page 87 TMP86CS64AFG 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 88 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86CS64AFG 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. ? when tc1cr is set to ?1? (trigger st art and stop) when a match between the up-counter and the tc1dra value is detected after the timer starts, the up-counter is cleared and halted and an inttc1 interrupt request is generated. if the edge opposite to trigger edge is detected before detecting a match between the up-counter and the tc1dra, the up-counter is cleared and ha lted without generating an interrupt request. therefore, this mode can be used to det ect exceeding the specified pulse by interrupt. after being halted, the up-count er restarts counting when th e trigger edge is detected. ? when tc1cr is set to ?0? (trigger start) when a match between the up-counter and the tc1dra value is detected after the timer starts, the up-counter is cleared and halted and an inttc1 interrupt request is generated. the edge opposite to the trigger edge has no effect in count up. the trigger edge for the next count- ing is ignored if detecting it before detectin g a match between the up-counter and the tc1dra. since the tc1 pin input has the noise rejection, pulses of 4/fc [s] or less are rejected as noise. a pulse width of 12/fc [s] or more is required to ensure edge detectio n. the rejection circuit is turned off in the slow1/2 or sleep1/2 mode, but a pulse width of one machine cycl e or more is required. example 1 :generating an interrupt 1 ms after the rising edge of the input pulse to the tc1 pin (fc =16 mhz, cgcr = ?0?) ldw (tc1dra), 007dh ; 1ms 2 7 /fc = 7dh di ; imf = ?0? set (eirh). 1 ; enables inttc1 interrupt ei ; imf = ?1? ld (tc1cr), 00000100b ; selects the source clock and mode ld (tc1cr), 00100100b ; starts tc1 external trigger, mett1 = 0 example 2 :generating an interrupt when the low-level pulse with 4 ms or more width is input to the tc1 pin (fc =16 mhz, cgcr = ?0?) ldw (tc1dra), 01f4h ; 4 ms 2 7 /fc = 1f4h di ; imf = ?0? set (eirh). 1 ; enables inttc1 interrupt ei ; imf = ?1? ld (tc1cr), 00000100b ; selects the source clock and mode ld (tc1cr), 01110100b ; starts tc1 external trigger, mett1 = 0
page 89 TMP86CS64AFG 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 90 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86CS64AFG 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. 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. after being cleared, the up-counter restarts counting at each edge of the input pulse to the tc1 pin. since a match between the up-counter and the value set to tc1dra is detected at the edge opposite to the selected edge, an inttc1 interrupt request is generated after a match of the value at the edge opposite to the selected edge. two or more machine cycles are required for th e low-or high-level pulse input to the tc1 pin. setting tc1cr to ?1? captures the up-counter value into tc1drb with the auto capture function. use the auto-capture function in the operative condition of tc1. a captured value may not be fixed if it's read after the execution of the timer stop or auto-capture disable. read the captu re value in a captu re enabled condi- tion. since the up-counter value is captured into tc1drb by the source clock of up-counter after setting tc1cr to "1". theref ore, to read the captured value, wait at least one cycle of the internal source clock before reading tc1drb for the first time. figure 8-4 event c ounter mode timing chart table 8-2 input pulse width to tc1 pin minimum pulse width [s] normal1/2, idle1/2 mode slow1/2, sleep1/2 mode high-going 2 3 /fc 2 3 /fs low-going 2 3 /fc 2 3 /fs at the rising edge (tc1s = 10) inttc1 interrput request tc1 pin input up-counter tc1dra ? 2 1 0 n timer start 2 1 0 n match detect counter clear n ? 1
page 91 TMP86CS64AFG 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. figure 8-5 window mode timing chart match detect tc1dra inttc1 interrput request interrput request internal clock counter tc1dra tc1 pin input internal clock counter tc1 pin input inttc1 (a) positive logic (tc1s = 10) (b) negative logic (tc1s = 11) ? ? match detect 1 0 7 47 5 46 31 2 1 0 7 5 3 6 2 0 2 3 counter clear timer start 890 1 9 timer start counter clear count start count stop count start count start count stop count start
page 92 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86CS64AFG 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. ? when tc1cr is set to ?1? (single-edge capture) either high- or low-level input pulse width can be measured. to measure the high-level input pulse width, set the rising edge to tc1cr. to measure the low-level input pulse width, set the falling edge to tc1cr. when detecting the edge opposite to the trigger ed ge used to start countin g after the timer starts, the up-counter captures the up-counter value in to tc1drb and generates an inttc1 interrupt request. the up-counter is cleared at this time, a nd then restarts counting wh en detecting the trigger edge used to start counting. ? when tc1cr is set to ?0? (double-edge capture) the cycle starting with either the high- or low-going input pulse can be measured. to measure the cycle starting with the high-going pulse, set the ri sing edge to tc1cr. to measure the cycle starting with the low-going pulse, set the falling edge to tc1cr. when detecting the edge opposite to the trigger ed ge used to start countin g after the timer starts, the up-counter captures the up-counter value in to tc1drb and generates an inttc1 interrupt request. the up-counter continues counting up, a nd captures the up-counter value into tc1drb and generates an inttc1 interrupt request when detecting the trigger edge used to start counting. the up-counter is cleared at this time, and then continues counting. note 1: the captured value must be read from tc1drb until the next trigger edge is detected. if not read, the cap- tured value becomes a don?t care. it is recommended to us e a 16-bit access instruction to read the captured value from tc1drb. note 2: for the single-edge capture, the counter after capt uring the value stops at ?1? until detecting the next edge. therefore, the second captured value is ?1? larger than the captured value i mmediately after counting starts. note 3: the first captured value after the timer starts may be read incorrectively, therefore, ignore the first captured value.
page 93 TMP86CS64AFG example :duty measurem ent (resolution fc/2 7 [hz], cgcr = ?0?) clr (inttc1sw). 0 ; inttc1 serv ice switch initial setting address set to convert inttc1sw at each inttc1 ld (tc1cr), 00000110b ; sets the tc1 mode and source clock di ; imf = ?0? set (eirh). 1 ; enables inttc1 ei ; imf = ?1? ld (tc1cr), 00100110b ; starts tc1 with an external trigger at mcap1 = 0 : pinttc1: cpl (inttc1sw). 0 ; inttc1 interrupt, inverts and tests inttc1 service switch jrs f, sinttc1 ld a, (tc1drbl) ; reads tc1drb (high-level pulse width) ld w,(tc1drbh) ld (hpulse), wa ; stores high-level pulse width in ram reti sinttc1: ld a, (tc1drbl) ; reads tc1drb (cycle) ld w,(tc1drbh) ld (width), wa ; stores cycle in ram : reti ; duty calculation : vinttc1: dw pinttc1 ; inttc1 interrupt vector width hpulse tc1 pin inttc1 interrupt request inttc1sw
page 94 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86CS64AFG 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 95 TMP86CS64AFG 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 specifies either the edge of the input pulse to the tc1 pin or the command start. tc1cr specifies whether a duty pulse is produced continuously or not (one-shot pulse). ? when tc1cr is set to ?0? (continuous pulse generation) when a match between the up-counter and the tc1drb value is detected after the timer starts, the level of the ppg pin is inverted and an inttc1 interrupt request is generated. the up-counter contin- ues counting. when a match between the up-counter and the tc1dra value is detected, the level of the ppg pin is inverted and an inttc1 interrupt requ est is generated. the up-counter is cleared at this time, and then continues counting and pulse generation. when tc1s is cleared to ?00? during ppg output, the ppg pin retains the level immediately before the counter stops. ? when tc1cr is set to ?1? (one-shot pulse generation) when a match between the up-counter and the tc1drb value is detected after the timer starts, the level of the ppg pin is inverted and an inttc1 interrupt request is generated. the up-counter contin- ues counting. when a match between the up-counter and the tc1dra value is detected, the level of the ppg pin is inverted and an inttc1 interrupt re quest is generated. tc1cr is cleared to ?00? automatically at this time, and the timer stops. the pulse generated by ppg retains the same level as that when the timer stops. since the output level of the ppg pin can be set with tc1cr when the timer starts, a positive or neg- ative pulse can be generated. since the inverted level of the timer f/f1 output level is output to the ppg pin, specify tc1cr to ?0? to set the high level to the ppg pin, and ?1? to set the low level to the ppg pin. upon reset, the timer f/f1 is initialized to ?0?. note 1: to change tc1dra or tc1drb during a run of the ti mer, set a value sufficiently larger than the count value of the counter. setting a value smaller than the count value of the counter during a run of the timer may generate a pulse different from that specified. note 2: do not change tc1cr during a run of the ti mer. tc1cr can be set correctly only at initial- ization (after reset). when the timer stops during pp g, tc1cr can not be set correctly from this point onward if the ppg output has the level which is inverted of the level when the timer starts. (setting tc1cr specifies the timer f/f1 to the level inverted of the programmed value.) therefore, the timer f/f1 needs to be initialized to ensure an arbitrar y level of the ppg output. to initialize the timer f/f1, change tc1cr to the timer mode (it is not required to start the timer mode), and then set the ppg mode. set tc1cr at this time. note 3: in the ppg mode, the follow ing relationship must be satisfied. tc1dra > tc1drb note 4: set tc1drb after changing the mode of tc1m to the ppg mode.
page 96 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86CS64AFG 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 = ?0?) setting port ld (tc1cr), 10000111b ; sets the ppg mode, selects the source clock ldw (tc1dra), 007dh ; sets the cycle (1 ms 2 7 /fc ms = 007dh) ldw (tc1drb), 0019h ; sets the low-level pulse width (200 s 2 7 /fc = 0019h) ld (tc1cr), 10010111b ; starts the timer example :after stopping ppg, setting the ppg pin to a high-level to restart ppg (fc = 16 mhz, cgcr = ?0?) setting port ld (tc1cr), 10000111b ; sets the ppg mode, selects the source clock ldw (tc1dra), 007dh ; sets the cycle (1 ms 2 7 /fc s = 007dh) ldw (tc1drb), 0019h ; sets the low-level pulse width (200 s 2 7 /fc = 0019h) ld (tc1cr), 10010111b ; starts the timer :: ld (tc1cr), 10000111b ; stops the timer ld (tc1cr), 10000100b ; sets the timer mode ld (tc1cr), 00000111b ; sets the ppg mode, tff1 = 0 ld (tc1cr), 00010111b ; starts the timer q r d ppg pin function output port output enable i/o port output latch shared with ppg output data output toggle set clear q tc1cr write to tc1cr internal reset match to tc1drb match to tc1dra tc1cr clear timer f/f1 inttc1 interrupt request
page 97 TMP86CS64AFG 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 98 8. 16-bit timercounter 1 (tc1) 8.3 function TMP86CS64AFG
page 99 TMP86CS64AFG 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 100 9. 16-bit timer/counter2 (tc2) 9.2 control TMP86CS64AFG 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 101 TMP86CS64AFG 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 = ?0? ) ldw (tc2dr), 061ah ; sets tc2dr (25 ms 3 2 8 /fc = 061ah) di ; imf= ?0? set (eirh). 4 ; enables inttc2 interrupt ei ; imf= ?1? ld (tc2cr), 00001000b ; source clock / mode select ld (tc2cr), 00101000b ; starts timer
page 102 9. 16-bit timer/counter2 (tc2) 9.3 function TMP86CS64AFG 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 103 TMP86CS64AFG 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. note:it is not available window mode in the slow/sl eep mode. therefore, at the window mode in normal mode, the timer should be halted by setting tc2cr to "0" before the slow/sleep mode is entered. example :sets the event counter mode and gene rates an inttc2 interrupt 640 counts later. ldw (tc2dr), 640 ; sets tc2dr di ; imf= ?0? set (eirh). 4 ;enables inttc2 interrupt ei ; imf= ?1? ld (tc2cr), 00011100b ; tc2 source vclock / mode select ld (tc2cr), 00111100b ; starts tc2 table 9-2 timer/counter 2 external input clock pulse width minimum input pulse width [s] normal1/2, idle1/2 mode slow1/2, sleep1/2 mode ?h? width 2 3 /fc 2 3 /fs ?l? width 2 3 /fc 2 3 /fs n inttc2 interrupt tc2 pin input counter tc2dr match detect counter clear timer start 0 1 2 3 n 0 1 2 3
page 104 9. 16-bit timer/counter2 (tc2) 9.3 function TMP86CS64AFG 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 = ?0? , cgcr = ?0?) ldw (tc2dr), 00eah ; sets tc2dr (120 ms 3 213 /fc = 00eah) di ; imf= ?0? set (eirh). 4 ; enables inttc2 interrupt ei ; imf= ?1? ld (tc2cr), 00000101b ; tc2sorce clock / mode select ld (tc2cr), 00100101b ; starts tc2 match detect :? :? inttc2 interrupt internal clock counter tc2dr tc2 pin input counter clear 12 3 n 0 1 2 timer start
page 105 TMP86CS64AFG 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 106 10. 8-bit timercounter 3 (tc3) 10.1 configuration TMP86CS64AFG 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 107 TMP86CS64AFG 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 to 1 captures the up- counter value into the timer register b (tc3drb) with the auto-capture function. the count value during timer operation can be checked by executing the read instruction to tc3drb. note:00h which is stored in the up-counter immediately after detection of a match is not captured into tc3drb. (figure 10-2) figure 10-2 auto-capture function table 10-1 source clock for timercounter 3 (example: fc = 16 mhz, fs = 32.768 khz) tc3ck normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0dv7ck = 1 dv1ck = 0dv1ck = 1dv1ck = 0dv1ck = 1 reso- lution [ s] maximum time setting [ms] reso- lution [ s] maximum time setting [ms] reso- lution [ s] maximum time setting [ms] reso- lution [ s] maximum time setting [ms] reso- lution [ s] resolution [ms] 000 512 130.6 1024 261.1 976.56 249.0 976.56 249.0 976.56 249.0 001 256 65.3 512 130.6 488.28 124.5 488.28 124.5 488.28 124.5 010 128 32.6 256 65.3 244.14 62.3 244.14 62.3 244.14 62.3 011 64 16.3 128 32.6 122.07 31.1 122.07 31.1 122.07 31.1 100 32 8.2 64 16.3 61.01 15.6 61.01 15.6 61.01 15.6 101 16 4.1 32 8.2 16.0 4.1 32.0 8.2 ? ? 110 8 2.0 16 4.1 8.0 2.0 16.0 4.1 ? ? tc3drb note: in the case that tc3drb is c8h clock up-counter match detect c7 c8 tc3dra c8 00 01 c7 c8 c6 c6 01
page 108 10. 8-bit timercounter 3 (tc3) 10.1 configuration TMP86CS64AFG figure 10-3 timer mode timing chart match detect tc3cr tc3drb tc3dra inttc3 interrupt source clock counter source clock counter (a) timer mode (b) auto capture ? ? 7 6 3 4 5 0 n timer start 1 2 3 2 1 4 0 n counter clear capture n + 1 n m + 2 m + 1 m m capture m + 2 m + 1 n + 1 n
page 109 TMP86CS64AFG 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 to 1 captures the up-counter value into tc3drb with the auto-capture function. the count value during a timer operation can be checked by the read instruction to tc3drb. note:00h which is stored in the up-counter immediately after detection of a match is not captured into tc3drb. (figure 10-2) figure 10-4 event count er mode timing chart example :inputting 50 hz pulse to tc3, and generating interrupts every 0.5 s ld (tc3cr), 00001110b : sets the clock mode ld (tc3dra), 19h : 0.5 s 1/50 = 25 = 19h ld (tc3cr), 00011110b : starts tc3. table 10-2 maximum frequencies applied to tc3 minimum pulse width normal1/2, idle1/2 mode slow1/2, sleep1/2 mode high-going 2 2 /fc 2 2 /fs low-going 2 2 /fc 2 2 /fs n inttc3 interrupt tc3 pin input counter tc3dra match detect counter clear timer start 0 1 2 3 n 0 1 2 3
page 110 10. 8-bit timercounter 3 (tc3) 10.1 configuration TMP86CS64AFG 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. the inttc3 interrupt request is generated if the up-c ounter overflow (ffh) occurs during capture operation before the edge is detected. tc3dra is set to ffh a nd the up-counter is cleared. counting is continued by the up-counter, but capture operation and overflow detect ion are stopped until tc3dra is read. generally, read tc3drb first because capture operation and ove rflow detection resume by reading tc3dra. figure 10-5 captur e mode timing chart read of tc3dra source clock counter tc3dra tc3 pin input tc3drb inttc3 interrupt request i fe 2 3 1 0 1 k-1 1 capture capture capture capture capture m ff (overflow) k n 0 ff tc3cr i i+1 i-1 0 k m m+1 m-1 n-1 0 n 2 1 3 internal waveform fe overflow timer start
page 111 TMP86CS64AFG 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 112 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86CS64AFG 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 setting. during timer operation (tc4s = 1 1), do not change it, either. if the setting is programmed during timer operation, c ounting is not performed correctly. note 4: the event counter and pwm output modes ar e used only in the nomal1/2 and idle1/2 modes. note 5: when the stop mode is entered, the start control (tc4s) is cleared to ?0? automatically. note 6: the bit 6 and 7 of tc4cr are read as a don?t care when these bits are read. note 7: in the timer, event counter and pdo modes, do not change the tc4dr setting when the timer is running. note 8: when the high-frequency clock fc exceeds 10 mhz, do not select the source clock of tc4ck = 110. note 9: the operating clock fs can not be used in norm al1 or idel1 mode (when low-frequency oscillation is stopped.) note 10:for available source cl ocks depending on the operation mode, refer to the following table. timer register and control register tc4dr (0018) 76543210 read/write (initial value: 1111 1111) tc4cr (0014) 76543210 tc4s tc4ck tc4m read/write (initial value: **00 0000) tc4s tc4 start control 0: stop and counter clear 1: start r/w tc4ck tc4 source clock select [hz] normal1/2, idle1/2 mode divider slow1/2, sleep1/2 mode r/w dv7ck = 0dv7ck = 1 dv1ck = 0dv1ck = 1dv1ck = 0dv1ck = 1 000 fc/2 11 fc/2 12 fs/2 3 fs/2 3 dv9 fs/2 3 001 fc/2 7 fc/2 8 fc/2 7 fc/2 8 dv5 ? 010 fc/2 5 fc/2 6 fc/2 5 fc/2 6 dv3 ? 011 fc/2 3 fc/2 4 fc/2 3 fc/2 4 dv1 ? 100 fc/2 2 fc/2 3 fc/2 2 fc/2 3 ?? 101 fc/2 fc/2 2 fc/2 fc/2 2 ?? 110 fc fc/2 fc fc/2 ? ? 111 external clock (tc4 pin input) tc4m tc4 operating mode select 00: timer/event counter mode 01: reserved 10: programmable divider output (pdo) mode 11: pulse width modulation (pwm) output mode r/w tc4ck timer mode event counter mode pdo mode pwm mode 000 o ? o ? 001 o ? o ? 010 o ? o ? 011 o ?? o 100 ? ?? o 101 ??? o 110 ?? ? o 111 ? o ?
page 113 TMP86CS64AFG note: o : available source clock
page 114 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86CS64AFG 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 115 TMP86CS64AFG 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 116 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86CS64AFG 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 117 TMP86CS64AFG 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 to 1. note 1: the pwm output mode can be used onl y in the normal1/2 and idel 1/2 modes. note 2: in the pwm output mode, program tc4dr immedi ately after the inttc4 interrupt request is generated (typically in the inttc4 interrupt service routine.) when the programming of tc4dr and the inttc4 inter- rupt occur at the same time, an unstable value is shif ted, that may result in generation of pulse different from the programmed value until the next inttc4 interrupt request is issued. figure 11-3 pwm output mode timing chart (tc4) internal clock shift register counter n 0 ? ? 1 n + 1 ff 0 1 n n + 1 ff 01 m pwm cycle match detect mp n n m data shift rewrite data shift match detect match detect data shift n n m rewrite rewrite pwm4 pin inttc4 interrupt request timer f/f tc4dr tc4cr
page 118 11. 8-bit timercounter 4 (tc4) 11.1 configuration TMP86CS64AFG 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 119 TMP86CS64AFG 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 120 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86CS64AFG 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 setting. during timer operation (tc5s = 1 1), do not change it, either. if the setting is programmed during timer operation, c ounting is not performed correctly. note 4: the event counter and pwm output modes ar e used only in the nomal1/2 and idle1/2 modes. note 5: when the stop mode is entered, the start control (tc5s) is cleared to ?0? automatically. note 6: the bit 6 and 7 of tc5cr are read as a don?t care when these bits are read. note 7: in the timer, event counter and pdo modes, do not change the tc5dr setting when the timer is running. note 8: when the high-frequency clock fc exceeds 10 mhz, do not select the source clock of tc5ck = 110. note 9: the operating clock fs can not be used in norm al1 or idel1 mode (when low-frequency oscillation is stopped.) note 10:for available source cl ocks depending on the operation mode, refer to the following table. timer register and control register tc5dr (0019) 76543210 read/write (initial value: 1111 1111) tc5cr (0015) 76543210 tc5s tc5ck tc5m read/write (initial value: **00 0000) tc5s tc5 start control 0: stop and counter clear 1: start r/w tc5ck tc5 source clock select [hz] normal1/2, idle1/2 mode divider slow1/2, sleep1/2 mode r/w dv7ck = 0dv7ck = 1 dv1ck = 0dv1ck = 1dv1ck = 0dv1ck = 1 000 fc/2 11 fc/2 12 fs/2 3 fs/2 3 dv9 fs/2 3 001 fc/2 7 fc/2 8 fc/2 7 fc/2 8 dv5 ? 010 fc/2 5 fc/2 6 fc/2 5 fc/2 6 dv3 ? 011 fc/2 3 fc/2 4 fc/2 3 fc/2 4 dv1 ? 100 fc/2 2 fc/2 3 fc/2 2 fc/2 3 ?? 101 fc/2 fc/2 2 fc/2 fc/2 2 ?? 110 fc fc/2 fc fc/2 ? ? 111 external clock (tc5 pin input) tc5m tc5 operating mode select 00: timer/event counter mode 01: reserved 10: programmable divider output (pdo) mode 11: pulse width modulation (pwm) output mode r/w tc5ck timer mode event counter mode pdo mode pwm mode 000 o ? o ? 001 o ? o ? 010 o ? o ? 011 o ?? o 100 ? ?? o 101 ??? o 110 ?? ? o 111 ? o ?
page 121 TMP86CS64AFG note: o : available source clock
page 122 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86CS64AFG 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 123 TMP86CS64AFG 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 124 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86CS64AFG 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 125 TMP86CS64AFG 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 to 1. note 1: the pwm output mode can be used onl y in the normal1/2 and idel 1/2 modes. note 2: in the pwm output mode, program tc5dr immedi ately after the inttc5 interrupt request is generated (typically in the inttc5 interrupt service routine.) when the programming of tc5dr and the inttc5 inter- rupt occur at the same time, an unstable value is shif ted, that may result in generation of pulse different from the programmed value until the next inttc5 interrupt request is issued. figure 12-3 pwm output mode timing chart (tc5) internal clock shift register counter n 0 ? ? 1 n + 1 ff 0 1 n n + 1 ff 01 m pwm cycle match detect mp n n m data shift rewrite data shift match detect match detect data shift n n m rewrite rewrite pwm5 pin inttc5 interrupt request timer f/f tc5dr tc5cr
page 126 12. 8-bit timercounter 5 (tc5) 12.1 configuration TMP86CS64AFG 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 127 TMP86CS64AFG 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 128 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86CS64AFG 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 setting. during timer operation (tc6s = 1 1), do not change it, either. if the setting is programmed during timer operation, c ounting is not performed correctly. note 4: the event counter and pwm output modes ar e used only in the nomal1/2 and idle1/2 modes. note 5: when the stop mode is entered, the start control (tc6s) is cleared to ?0? automatically. note 6: the bit 6 and 7 of tc6cr are read as a don?t care when these bits are read. note 7: in the timer, event counter and pdo modes, do not change the tc6dr setting when the timer is running. note 8: when the high-frequency clock fc exceeds 10 mhz, do not select the source clock of tc6ck = 110. note 9: the operating clock fs can not be used in norm al1 or idel1 mode (when low-frequency oscillation is stopped.) note 10:for available source cl ocks depending on the operation mode, refer to the following table. timer register and control register tc6dr (0017) 76543210 read/write (initial value: 1111 1111) tc6cr (0016) 76543210 tc6s tc6ck tc6m read/write (initial value: **00 0000) tc6s tc6 start control 0: stop and counter clear 1: start r/w tc6ck tc6 source clock select [hz] normal1/2, idle1/2 mode divider slow1/2, sleep1/2 mode r/w dv7ck = 0dv7ck = 1 dv1ck = 0dv1ck = 1dv1ck = 0dv1ck = 1 000 fc/2 11 fc/2 12 fs/2 3 fs/2 3 dv9 fs/2 3 001 fc/2 7 fc/2 8 fc/2 7 fc/2 8 dv5 ? 010 fc/2 5 fc/2 6 fc/2 5 fc/2 6 dv3 ? 011 fc/2 3 fc/2 4 fc/2 3 fc/2 4 dv1 ? 100 fc/2 2 fc/2 3 fc/2 2 fc/2 3 ?? 101 fc/2 fc/2 2 fc/2 fc/2 2 ?? 110 fc fc/2 fc fc/2 ? ? 111 external clock (tc6 pin input) tc6m tc6 operating mode select 00: timer/event counter mode 01: reserved 10: programmable divider output (pdo) mode 11: pulse width modulation (pwm) output mode r/w tc6ck timer mode event counter mode pdo mode pwm mode 000 o ? o ? 001 o ? o ? 010 o ? o ? 011 o ?? o 100 ? ?? o 101 ??? o 110 ?? ? o 111 ? o ?
page 129 TMP86CS64AFG note: o : available source clock
page 130 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86CS64AFG 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 131 TMP86CS64AFG 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 132 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86CS64AFG 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 133 TMP86CS64AFG 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 to 1. note 1: the pwm output mode can be used onl y in the normal1/2 and idel 1/2 modes. note 2: in the pwm output mode, program tc6dr immedi ately after the inttc6 interrupt request is generated (typically in the inttc6 interrupt service routine.) when the programming of tc6dr and the inttc6 inter- rupt occur at the same time, an unstable value is shif ted, that may result in generation of pulse different from the programmed value until the next inttc6 interrupt request is issued. figure 13-3 pwm output mode timing chart (tc6) internal clock shift register counter n 0 ? ? 1 n + 1 ff 0 1 n n + 1 ff 01 m pwm cycle match detect mp n n m data shift rewrite data shift match detect match detect data shift n n m rewrite rewrite pwm6 pin inttc6 interrupt request timer f/f tc6dr tc6cr
page 134 13. 8-bit timercounter 6 (tc6) 13.1 configuration TMP86CS64AFG 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 135 TMP86CS64AFG 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 136 14. asynchronous serial interface (uart ) 14.2 control TMP86CS64AFG 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 and uartcr1 should be set to ?0? before uartcr1 is changed. note: when uartcr2 = ?01?, pulses longer than 96/fc [s] are always regarded as signals; when uartcr2 = ?10?, longer than 192/fc [s]; and when uart cr2 = ?11?, longer than 384/fc [s]. uart control register1 uartcr1 (001bh) 76543210 txe rxe stbt even pe brg (initial value: 0000 0000) txe transfer operation 0: 1: disable enable write only rxe receive operation 0: 1: disable enable stbt transmit stop bit length 0: 1: 1 bit 2 bits even even-numbered parity 0: 1: odd-numbered parity even-numbered parity pe parity addition 0: 1: no parity parity brg transmit clock select 000: 001: 010: 011: 100: 101: 110: 111: fc/13 [hz] fc/26 fc/52 fc/104 fc/208 fc/416 tc4 ( input inttc4) fc/96 uart control register2 uartcr2 (001ch) 7654321 0 rxdnc stopbr (initial value: **** *000) rxdnc selection of rxd input noise rejectio time 00: 01: 10: 11: no noise rejection (hysteresis input) rejects pulses shorter than 31/fc [s] as noise rejects pulses shorter than 63/fc [s] as noise rejects pulses shorter than 127/fc [s] as noise write only stopbr receive stop bit length 0: 1: 1 bit 2 bits
page 137 TMP86CS64AFG 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 138 14. asynchronous serial interface (uart ) 14.3 transfer data format TMP86CS64AFG 14.3 transfer data format in uart, an one-bit start bit (low level), stop bit (bit length selectable at high level, by uartcr1), and parity (select parity in uartcr1

; even- or odd-number ed parity by uartcr1) are added to the transfer data. the transfer data formats are shown as follows. figure 14-2 tran sfer data format figure 14-3 caution on c hanging transfer data format note: in order to switch the transfer data format, perfor m transmit operations in the above figure 14-3 sequence except for the initial setting. start bit 0 bit 1 bit 6 bit 7 stop 1 start bit 0 bit 1 bit 6 bit 7 stop 1 stop 2 start bit 0 bit 1 bit 6 bit 7 parity stop 1 start bit 0 bit 1 bit 6 bit 7 parity stop 1 stop 2 pe 0 0 1 1 stbt frame length 0 1 123 89101112 0 1 without parity / 1 stop bit with parity / 1 stop bit without parity / 2 stop bit with parity / 2 stop bit
page 139 TMP86CS64AFG 14.4 infrared (irda) da ta format transfer mode infrared data format (irda) output is available by se tting irda output control register (irdacr) through txd1 pin. figure 14-4 example of infrared data format (compariso n of normal outpu t and irda output) irda output control register irdacr (001ah) 76543210 irda sel (initial value: **** ***0) irdasel irda output / uart output select 0: 1: uart output irda output r/w uart output irda output start bit stop bit d0 d1 d2 d7 3/16 bit width
page 140 14. asynchronous serial interface (uart ) 14.5 transfer rate TMP86CS64AFG 14.5 transfer rate the baud rate of uart is set of uartcr1. th e example of the baud rate are shown as follows. when tc4 is used as the uart transfer rate (when uartcr1 = ?110?), the tr ansfer clock and transfer rate are determined as follows: transfer clock [hz] = tc4 source clock [hz] / ttreg4 setting value transfer rate [baud] = transfer clock [hz] / 16 14.6 data sampling method the uart receiver keeps sampling input using the cloc k selected by uartcr1 until a start bit is detected in rxd1 pin input. rt clock starts detecting ?l? level of the rxd1 pin. once a start bit is detected, the start bit, data bits, stop bi t(s), and parity bit are sample d at three times of rt7, rt8, and rt9 during one receiver clock interval (rt clock). (rt0 is the position where the bit supposedly starts.) bit is determined according to major- ity rule (the data are the same tw ice or more out of three samplings). figure 14-5 data sampling method table 14-1 transfer rate (example) brg source clock 16 mhz 8 mhz 4 mhz 000 76800 [baud] 38400 [baud] 19200 [baud] 001 38400 19200 9600 010 19200 9600 4800 011 9600 4800 2400 100 4800 2400 1200 101 2400 1200 600 rt0 1 2 3 4 5 6 7 8 9101112 1314 15  01234567891011 bit 0 start bit bit 0 start bit (a) without noise rejection circuit rt clock internal receive data rt0 1 2 3 4 5 6 7 8 9101112 1314 15  01234567891011 bit 0 start bit bit 0 start bit rt clock internal receive data (b) with noise rejection circuit rxd1 pin rxd1 pin
page 141 TMP86CS64AFG 14.7 stop bit length select a transmit stop bit length (1 bit or 2 bits) by uartcr1. 14.8 parity set parity / no parity by uartcr1 and set parity type (odd- or even-numbered) by uartcr1. 14.9 transmit/receive operation 14.9.1 data transmit operation set uartcr1 to ?1?. read uartsr to check ua rtsr = ?1?, then write data in tdbuf (transmit data buffer). writing data in tdbuf zero-cl ears uartsr, transfers the data to the transmit shift register and the data are sequentially output from the txd1 pin. the data output include a one-bit start bit, stop bits whose number is specified in uartcr1 and a parity bit if pari ty addition is specified. select the data transfer baud rate using uartcr1. when data transmit st arts, transmit buffer empty flag uartsr is set to ?1? a nd an inttrx interrupt is generated. while uartcr1 = ?0? and from when ?1? is written to uartcr1 to when send data are written to tdbuf, the txd1 pin is fixed at high level. when transmitting data, first read uartsr, then write data in tdbuf. otherwise, uartsr is not zero-cleared and transm it does not start. 14.9.2 data receive operation set uartcr1 to ?1?. when data are received via the rxd1 pin, the receive data are transferred to rdbuf (receive data buffer). at this time, the data transmitted includes a start bit and stop bit(s) and a parity bit if parity addition is specified. when stop bit(s) are received, data only are extracted and transferred to rdbuf (receive data buffer). then the receive buffer full flag uartsr is set and an inttrx inter- rupt is generated. select the data transfer baud rate using uartcr1. if an overrun error (oerr) occurs when data are received, the da ta are not transferre d to rdbuf (receive data buffer) but discarded; data in the rdbuf are not affected. note:when a receive operation is disabled by setting ua rtcr1 bit to ?0?, the setting becomes valid when data receive is completed. however, if a framing error occurs in data receive, the receive-disabling setting may not become valid. if a framing error occurs , be sure to perform a re-receive operation.
page 142 14. asynchronous serial interface (uart ) 14.10 status flag TMP86CS64AFG 14.10status flag 14.10.1parity error when parity determined using the receive data bits diff ers from the received parity bit, the parity error flag uartsr is set to ?1?. the uartsr is cl eared to ?0? when the rdbuf is read after read- ing the uartsr. figure 14-6 generati on of parity error 14.10.2framing error when ?0? is sampled as the stop bit in the receive data, framing error flag uartsr is set to ?1?. the uartsr is cleared to ?0? when the rdbuf is r ead after reading the uartsr. figure 14-7 generati on of framing error 14.10.3overrun error when all bits in the next data are received while unread data are still in rdbuf, overrun error flag uartsr is set to ?1?. in this case, the receive data is discarded; data in rdbuf are not affected. the uartsr is cleared to ?0? when the rdbuf is read af ter reading the uartsr. parity stop shift register pxxxx0 * 1pxxxx0 xxxx0 ** rxd1 pin uartsr inttrx interrupt after reading uartsr then rdbuf clears perr. final bit stop shift register xxxx0 * 0xxxx0 xxx0 ** rxd1 pin uartsr inttrx interrupt after reading uartsr then rdbuf clears ferr.
page 143 TMP86CS64AFG figure 14-8 generati on of overrun error note:receive operations are di sabled until the overrun error flag uartsr is cleared. 14.10.4receive data buffer full loading the received data in rdbuf sets receive data buffer full flag uartsr to "1". the uartsr is cleared to ?0? when the rdbuf is read after reading the uartsr. figure 14-9 generat ion of receive data buffer full note:if the overrun error flag uartsr is set during the period between reading the uartsr and reading the rdbuf, it cannot be cleared by only reading the rdbuf. therefore, after reading the rdbuf, read the uartsr again to check whether or not the overrun er ror flag which should have been cleared still remains set. 14.10.5transmit data buffer empty when no data is in the transmit buffer tdbuf, uartsr is set to ?1?, that is, when data in tdbuf are transferred to the transmit shif t register and data transmit star ts, transmit data buffer empty flag uartsr is set to ?1?. the uartsr is cleared to ?0? when the tdbuf is written after reading the uartsr. final bit stop shift register xxxx0 * 1xxxx0 yyyy xxx0 ** rxd1 pin uartsr inttrx interrupt after reading uartsr then rdbuf clears oerr. rdbuf uartsr final bit stop shift register xxxx0 * 1xxxx0 xxxx yyyy xxx0 ** rxd1 pin uartsr inttrx interrupt rdbuf after reading uartsr then rdbuf clears rbfl.
page 144 14. asynchronous serial interface (uart ) 14.10 status flag TMP86CS64AFG figure 14-10 generation of tr ansmit data buffer empty 14.10.6transmit end flag when data are transmitted and no data is in tdbuf (uartsr = ?1?), transmit end flag uartsr is set to ?1?. the uartsr is cleared to ?0? when the data transmit is stated after writing the tdbuf. figure 14-11 generation of transmit end flag and trans mit data buffer empty shift register data write data write zzzz xxxx yyyy start bit 0 final bit stop 1xxxx0 ***** 1 * 1xxxx **** 1x ***** 1 1yyyy0 tdbuf txd1 pin uartsr inttrx interrupt after reading uartsr writing tdbuf clears tbep. shift register * 1yyyy *** 1 xx **** 1 x ***** 1 stop start 1yyyy0 bit 0 txd1 pin uartsr uartsr inttrx interrupt data write for tdbuf
page 145 TMP86CS64AFG 15. synchronous serial interface (sio1) the TMP86CS64AFG has a clocked-synchronous 8-bit serial interface. serial interface has an 8-byte transmit and receive data buffer that can automatically and continuously transfer up to 64 bits of data. serial interface is connected to outside peri pherl devices via so1, si1, sck1 port. 15.1 configuration figure 15-1 serial interface sio control / status register serial clock shift clock shift register 3 2 1 0 7 6 5 4 transmit and receive data buffer (8 bytes in dbr) control circuit cpu serial data output serial data input 8-bit transfer 4-bit transfer serial clock i/o buffer control circuit so1 si1 sck 1 sio1cr2 sio1cr1 sio1sr intsio1 interrupt request
page 146 15. synchronous serial interface (sio1) 15.2 control TMP86CS64AFG 15.2 control the serial interface is controlled by sio control registers (sio1cr1/sio1cr2 ). the serial interface status can be determined by reading sio status register (sio1sr). the transmit and receive data buffer is controlled by th e sio1cr2. the data buff er is assigned to address 0f90h to 0f97h for sio in the dbr area, and can continuously transfer up to 8 words (bytes or nibbles) at one time. when the specified number of words has b een transferred, a buffer empty (in th e transmit mode) or a buffer full (in the receive mode or tran smit/receive mode) interrupt (intsio1) is generated. when the internal clock is used as the serial clock in the 8-bit receive mode and the 8-bit transmit/receive mode, a fixed interval wait can be applied to the serial clock fo r each word transferred. four different wait times can be selected with sio1cr2. note 1: fc; high-frequency clock [hz], fs; low-frequency clock [hz] note 2: set sios to "0" and sioinh to "1" when setting the transfer mode or serial clock. note 3: sio1cr1 is write-only register, which cannot access any of in read-modify-write instruction such as bit operate, etc. sio control register 1 sio1cr176543210 (0028h) sios sioinh siom sck (initial value: 0000 0000) sios indicate transfer start / stop 0: stop write only 1: start sioinh continue / abort transfer 0: continuously transfer 1: abort transfer (automatically cleared after abort) siom transfer mode select 000: 8-bit transmit mode 010: 4-bit transmit mode 100: 8-bit transmit / receive mode 101: 8-bit receive mode 110: 4-bit receive mode except the above: reserved sck serial clock select normal1/2, idle1/2 mode slow1/2 sleep1/2 mode write only dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 1 dv1ck = 1 000 fc/2 13 fc/2 14 fs/2 5 fs/2 5 fs/2 5 001 fc/2 8 fc/2 9 fc/2 8 fc/2 9 - 010 fc/2 7 fc/2 8 fc/2 7 fc/2 8 - 011 fc/2 6 fc/2 7 fc/2 6 fc/2 7 - 100 fc/2 5 fc/2 6 fc/2 5 fc/2 6 - 101 fc/2 4 fc/2 5 fc/2 4 fc/2 5 - 110 reserved 111 external clock (input from sck1 pin ) sio control register 2 sio1cr276543210 (0029h) wait buf (initial value: ***0 0000)
page 147 TMP86CS64AFG note 1: the lower 4 bits of each buffer are used during 4-bit tr ansfers. zeros (0) are stored to the upper 4bits when receiving. note 2: transmitting starts at the lowest address. received data are also stored starting from the lowest address to the highest address. ( the first buffer address transmitted is 0f90h ). note 3: the value to be loaded to buf is held after transfer is completed. note 4: sio1cr2 must be set when the serial interface is stopped (siof = 0). note 5: *: don't care note 6: sio1cr2 is write-only register, which cannot access any of in read-modify-write instruction such as bit operate, etc. note 1: t f ; frame time, t d ; data transfer time note 2: after sios is cleared to "0", siof is cleared to "0" at the termination of transfer or the setting of sioinh to "1". figure 15-2 fr ame time (t f ) and data transfer time (t d ) 15.3 serial clock 15.3.1 clock source internal clock or external clock for the source clock is selected by sio1cr1. wait wait control always sets "00" except 8-bit transmit / receive mode. write only 00: t f = t d (non wait) 01: t f = 2t d (wait) 10: t f = 4t d (wait) 11: t f = 8t d (wait) buf number of transfer words (buffer address in use) 000: 1 word transfer 0f90h 001: 2 words transfer 0f90h ~ 0f91h 010: 3 words transfer 0f90h ~ 0f92h 011: 4 words transfer 0f90h ~ 0f93h 100: 5 words transfer 0f90h ~ 0f94h 101: 6 words transfer 0f90h ~ 0f95h 110: 7 words transfer 0f90h ~ 0f96h 111: 8 words transfer 0f90h ~ 0f97h sio status register sio1sr76543210 (0029h) siof sef siof serial transfer operating status moni- tor 0: 1: transfer terminated transfer in process read only sef shift operating status monitor 0: 1: shift operation terminated shift operation in process td tf (output) s ck1 output
page 148 15. synchronous serial interface (sio1) 15.3 serial clock TMP86CS64AFG 15.3.1.1 internal clock any of six frequencies can be selected. the serial clock is output to the outside on the sck1 pin. the sck1 pin goes high when transfer starts. when data writing (in the transmit mo de) or reading (in the receive mode or the transmit/receive mode) cannot keep up with the serial clock rate, there is a wa it function that automatically stops the serial clock and holds the next shift operation until the read/write processing is completed. note: 1 kbit = 1024 bit (fc = 16 mhz, fs = 32.768 khz) figure 15-3 automatic wait fu nction (at 4-bit transmit mode) 15.3.1.2 external clock an external clock connected to the sck 1 pin is used as the serial clock. in this case, output latch of this port should be set to "1". to ensure shifting, a pulse width of at least 4 machine cycles is required. this pulse is needed for the shift operatio n to execute certainly. actually, there is necessary processing time for interrupting, writing, and reading. the minimum pulse is determined by setting the mode and the pro- gram. therfore, maximum transfer frequenc y will be 488.3k bit/sec (at fc=16mhz). table 15-1 serial clock rate normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 sck clock baud rate clock baud rate clock baud rate clock baud rate clock baud rate 000 fc/2 13 1.91 kbps fc/2 14 0.95 kbps fs/2 5 1024 bps fs/2 5 1024 bps fs/2 5 1024 bps 001 fc/2 8 61.04 kbps fc/2 9 30.52 kbps fc/2 8 61.04 kbps fc/2 9 30.52 kbps -- 010 fc/2 7 122.07 kbps fc/2 8 61.04 kbps fc/2 7 122.07 kbps fc/2 8 61.04 kbps -- 011 fc/2 6 244.14 kbps fc/2 7 122.07 kbps fc/2 6 244.14 kbps fc/2 7 122.07 kbps -- 100 fc/2 5 488.28 kbps fc/2 6 244.14 kbps fc/2 5 488.28 kbps fc/2 6 244.14 kbps -- 101 fc/2 4 976.56 kbps fc/2 5 488.28 kbps fc/2 4 976.56 kbps fc/2 5 488.28 kbps -- 110---------- 111 external external external external external external external external external external a 1 a 2 b 0 b 1 b 2 b 3 c 0 c 1 a 3 a c b a 0 pin (output) pin (output) written transmit data a utomat i ca ll y wait function sck1 so1
page 149 TMP86CS64AFG figure 15-4 external clock pulse width 15.3.2 shift edge the leading edge is used to transmit, a nd the trailing edge is used to receive. 15.3.2.1 leading edge transmitted data are shifted on the leading edge of the serial clock (falling edge of the sck 1 pin input/ output). 15.3.2.2 trailing edge received data are shifted on th e trailing edge of the serial clock (rising edge of the sck 1 pin input/out- put). figure 15-5 shift edge 15.4 number of bits to transfer either 4-bit or 8-bit serial transfer can be selected. when 4-bit serial transfer is selected, only the lower 4 bits of the transmit/receive data buffer re gister are used. the upper 4 bits are cleared to ?0? when receiving. the data is transferred in sequence star ting at the least significant bit (lsb). 15.5 number of w ords to transfer up to 8 words consisting of 4 bits of data (4-bit serial tran sfer) or 8 bits (8-bit serial tr ansfer) of data can be trans- ferred continuously. the number of words to be transferred can be selected by sio1cr2. t sckl t sckh tcyc = 4/fc (in the normal1/2, idle1/2 modes) 4/fs (in the slow1/2, sleep1/2 modes) t sckl , t sckh > 4tcyc sck1 pin (output) bit 1 bit 2 bit 3 * 321 3210 ** 32 *** 3 bit 0 shift register shift register bit 1 bit 0 bit 2 bit 3 0 *** **** 210 * 10 ** 3210 (a) leading edge (b) trailing edge * ; don?t care so1 pin si1 pin sck1 pin sck1 pin
page 150 15. synchronous serial interface (sio1) 15.6 transfer mode TMP86CS64AFG an intsio1 interrupt is generated when the specified number of words has been transferred. if the number of words is to be changed during transfer , the serial interface must be stopped before making the ch ange. the number of words can be changed during automatic-wa it operation of an internal clock. in this case, the serial interface is not required to be stopped. figure 15-6 number of words to transfer (example: 1word = 4bit) 15.6 transfer mode sio1cr1 is used to select the tran smit, receive, or transmit/receive mode. 15.6.1 4-bit and 8-bit transfer modes in these modes, firstly set the sio control register to the transmit mode, and then write first transmit data (number of transfer words to be transfer red) to the data buffer registers (dbr). after the data are written, the transmission is star ted by setting sio1cr1 to ?1?. the data are then output sequentially to the so pin in synchronous with th e serial clock, starting with the least significant bit (lsb). as soon as the lsb has been output, the data are transferred from the data buffer register to the shift register. when the final data bit has b een transferred and the data buffer re gister is empty, an intsio1 (buffer empty) interrupt is generated to request the next transmitted data. when the internal clock is used, the serial clock will stop and an automatic-wait will be initiated if the next transmitted data are not loaded to the data buffer regist er by the time the number of data words specified with the sio1cr2 has been transmitted. writing even one word of data cancels the automatic-wait; there- fore, when transmitting two or more words, always wr ite the next word before transmission of the previous word is completed. note:automatic waits are also canceled by writing to a dbr not being used as a transmit data buffer register; there- fore, during sio do not use such dbr for other applicati ons. for example, when 3 words are transmitted, do not use the dbr of the remained 5 words. a 1 a 2 a 3 a 0 a 1 a 2 a 3 b 0 b 1 b 2 b 3 c 0 c 1 c 2 c 3 a 0 a 1 a 0 a 2 a 3 b 0 b 1 b 2 b 3 c 0 c 1 c 2 c 3 (a) 1 word transmit (b) 3 words transmit (c) 3 words receive so1 pin intsio1 interrupt intsio1 interrupt intsio1 interrupt so1 pin si1 pin sck1 pin sck1 pin sck1 pin
page 151 TMP86CS64AFG when an external clock is used, the data must be writte n to the data buffer register before shifting next data. thus, the transfer speed is determin ed by the maximum delay time from the generation of the interrupt request to writing of the data to the data buffer register by the interrupt service program. the transmission is ended by clear ing sio1cr1 to ?0? or se tting sio1cr1 to ?1? in buffer empty interrupt service program. sio1cr1 is cleared, the operation will end after all bi ts of words are transmitted. that the transmission has ended can be determin ed from the status of sio1sr because sio1sr is cleared to ?0? when a transfer is completed. when sio1cr1 is set, the transmission is immediately ended and sio1sr is cleared to ?0?. when an external clock is used, it is also necessary to clear sio1cr1 to ?0? before shifting the next data; if sio1cr1 is not cleared before shift out, dummy data will be transmitted and the operation will end. if it is necessary to change th e number of words, si o1cr1 should be cleared to ?0?, then sio1cr2 must be rewritten after confirming that sio1sr has been cleared to ?0?. figure 15-7 transfer m ode (example: 8bit, 1word tr ansfer, internal clock) a 1 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 a 0 dbr b a clear sios write (a) write (b) sck1 pin (output) so1 pin intsio1 interrupt sio1cr1 sio1sr sio1sr sio1sr
page 152 15. synchronous serial interface (sio1) 15.6 transfer mode TMP86CS64AFG figure 15-8 transfer mode (example: 8b it, 1word transfer , external clock) figure 15-9 transmiiied data ho ld time at end of transfer 15.6.2 4-bit and 8- bit receive modes after setting the control registers to the receive mode, set sio1cr1 to ?1? to enab le receiving. the data are then transferred to the shift register via the si pin in synchronous with the serial clock. when one word of data has been received, it is tran sferred from the shift register to the data buffer register (dbr). when the number of words specified with the sio1cr2 has been received, an intsio1 (buffer full) interrupt is generated to request that these data be read out. the da ta are then read from the da ta buffer registers by the interrupt service program. when the internal clock is used, and the previous data are not read from the data buffer register before the next data are received, the serial cloc k will stop and an automatic-wait will be initiated until the data are read. a wait will not be initiated if even one data word has been read. note:waits are also canceled by readi ng a dbr not being used as a received data buffer register is read; therefore, during sio1 do not use such dbr for other applications. a 1 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 a 0 dbr b a clear sios write (a) write (b) sck1 pin (input) so1 pin intsio1 interrupt sio1cr1 sio1sr sio1sr msb of last word t sodh = min 3.5/fc [s] ( in the normal1/2, idle1/2 modes) t sodh = min 3.5/fs [s] (in the slow1/2, sleep1/2 modes) sck1 pin so1 pin sio1sr
page 153 TMP86CS64AFG when an external clock is used, the shift operation is synchronized with the extern al clock; therefore, the previous data are read before the next data are transferred to the data buffer register. if the previous data have not been read, the next data will not be transferred to th e data buffer register and th e receiving of any more data will be canceled. when an external clock is used, th e maximum transfer speed is determined by the delay between the time when the interrupt request is gene rated and when the data received have been read. the receiving is ended by clearing sio1cr1 to ?0? or setting sio1cr1 to ?1? in buffer full interrupt service program. when sio1cr1 is cleared, th e current data are transferred to the buffer. after sio1cr1 cleared, the receiving is ended at the ti me that the final bit of the data has been received. that the receiving has ended can be determined from the status of sio1sr . sio1sr is cleared to ?0? when the receiving is ended. after confirmed the receiving te rmination, the final recei ving data is read. when sio1cr1 is set, the receivi ng is immediately ended and sio1sr is cleared to ?0?. (the received data is ignored, and it is not required to be read out.) if it is necessary to change the number of words in external clock operation, sio1cr1 should be cleared to ?0? then sio1cr2 mu st be rewritten after confirming that sio1sr has been cleared to ?0?. if it is necessary to chan ge the number of words in internal clock, during automatic-wait operation which occurs after completion of data receiving, sio1cr2 must be rewr itten before the received data is read out. note:the buffer contents are lost when the transfer mode is switched. if it should become necessary to switch the transfer mode, end receiving by clearing sio1cr1 to ?0?, read the last data and then switch the trans- fer mode. figure 15-10 receive mode (example: 8b it, 1word transfer, internal clock) 15.6.3 8-bit trans fer / receive mode after setting the sio control register to the 8-bit transmit/recei ve mode, write the data to be transmitted first to the data buffer registers (dbr). af ter that, enable the transmit/receive by setting sio1cr1 to ?1?. when transmitting, the data are output from the so1 pin at leading edges of the serial clock. when receiving, the data are input to th e si1 pin at the trailing edges of the serial clock. when the all receive is enabled, 8-bit data are transferred from the shift re gister to the data buffer register. an intsio1 interrupt is generated when the number of data words specified with the sio1cr2 has been transferred. usually, read the receive data from the buffer register in the interrupt service. the data buffer register is used for both transmitting and receiving; therefore, always writ e the data to be transmitted af ter reading the all received data. when the internal clock is used, a wait is initiated until the received data are read and the next transfer data are written. a wait will not be initiated if ev en one transfer data word has been written. a 1 a 0 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 dbr b a clear sios read out read out sck1 pin (output) si1 pin intsio1 interrupt sio1cr1 sio1sr sio1sr
page 154 15. synchronous serial interface (sio1) 15.6 transfer mode TMP86CS64AFG when an external clock is used, the shift operation is synchronized with the external clock; therefore, it is necessary to read the received data and write the data to be transmitted next before starting the next shift oper- ation. when an external clock is us ed, the transfer speed is determined by the maximum delay between genera- tion of an interrupt request and the received data are read and the data to be transmitted next are written. the transmit/receive operation is ended by clearing sio1cr1 to ?0? or setting sio1cr1 to ?1? in intsio1 interrupt service program. when sio1cr1 is cleared, the current data ar e transferred to the buff er. after sio1cr1 cleared, the transmitting/ receiving is ended at the time that the fi nal bit of the data has been transmitted. that the transmitting/receiving has ended can be determined fr om the status of sio1sr. sio1sr is cleared to ?0? when the transmitting/recei ving is ended. when sio1cr1 is set, th e transmit/receive operation is imm ediately ended and sio1sr is cleared to ?0?. if it is necessary to change the number of words in external clock operation, sio1cr1 should be cleared to ?0?, then sio1cr2 must be rewritten after confirming that sio1sr has been cleared to ?0?. if it is necessary to change the number of words in internal clock, during automatic-wait operation which occurs after completion of transmit /receive operation, sio1 cr2 must be rewrit ten before reading and writing of the receive/transmit data. note:the buffer contents are lost when the transfer mode is switched. if it should become necessary to switch the transfer mode, end receiving by clearing sio1cr1 to ?0?, read the last data and then switch the trans- fer mode. figure 15-11 transfer / receive mode (examp le: 8bit, 1word transfe r, internal clock) a 1 a 0 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 c 1 c 0 c 2 c 3 c 4 c 5 c b c 6 c 7 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 clear sios dbr d a read out (c) write (a) read out (d) write (b) sck1 pin (output) so1 pin intsio1 interrupt sio1cr1 sio1sr sio1sr si1 pin
page 155 TMP86CS64AFG figure 15-12 transmitted data hold ti me at end of tr ansfer / receive bit 7 of last word bit 6 t sodh = min 4/fc [s] ( in the normal1/2, idle1/2 modes) t sodh = min 4/fs [s] (in the slow1/2, sleep1/2 modes) sck1 pin so1 pin sio1sr
page 156 15. synchronous serial interface (sio1) 15.6 transfer mode TMP86CS64AFG
page 157 TMP86CS64AFG 16. synchronous serial interface (sio2) the TMP86CS64AFG has a clocked-synchronous 8-bit serial interface. serial interface has an 8-byte transmit and receive data buffer that can automatically and continuously transfer up to 64 bits of data. serial interface is connected to outside peri pherl devices via so2, si2, sck2 port. 16.1 configuration figure 16-1 serial interface sio control / status register serial clock shift clock shift register 3 2 1 0 7 6 5 4 transmit and receive data buffer (8 bytes in dbr) control circuit cpu serial data output serial data input 8-bit transfer 4-bit transfer serial clock i/o buffer control circuit so2 si2 sck 2 sio2cr2 sio2cr1 sio2sr intsio2 interrupt request
page 158 16. synchronous serial interface (sio2) 16.2 control TMP86CS64AFG 16.2 control the serial interface is controlled by sio control registers (sio2cr1/sio2cr2 ). the serial interface status can be determined by reading sio status register (sio2sr). the transmit and receive data buffer is controlled by th e sio2cr2. the data buff er is assigned to address 0f98h to 0f9fh for sio in the dbr area, and can continuou sly transfer up to 8 words (bytes or nibbles) at one time. when the specified number of words has been transferre d, a buffer empty (in the tran smit mode) or a buffer full (in the receive mode or tr ansmit/receive mode) interrup t (intsio2) is generated. when the internal clock is used as the serial clock in the 8-bit receive mode and the 8-bit transmit/receive mode, a fixed interval wait can be applied to the serial clock fo r each word transferred. four different wait times can be selected with sio2cr2. note 1: fc; high-frequency clock [hz], fs; low-frequency clock [hz] note 2: set sios to "0" and sioinh to "1" when setting the transfer mode or serial clock. note 3: sio2cr1 is write-only register, which cannot access any of in read-modify-write instruction such as bit operate, etc. sio control register 1 sio2cr176543210 (0fb4h) sios sioinh siom sck (initial value: 0000 0000) sios indicate transfer start / stop 0: stop write only 1: start sioinh continue / abort transfer 0: continuously transfer 1: abort transfer (automatically cleared after abort) siom transfer mode select 000: 8-bit transmit mode 010: 4-bit transmit mode 100: 8-bit transmit / receive mode 101: 8-bit receive mode 110: 4-bit receive mode except the above: reserved sck serial clock select normal1/2, idle1/2 mode slow1/2 sleep1/2 mode write only dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 1 dv1ck = 1 000 fc/2 15 fc/2 16 fs/2 7 fs/2 7 fs/2 7 001 fc/2 8 fc/2 9 fc/2 8 fc/2 9 - 010 fc/2 7 fc/2 8 fc/2 7 fc/2 8 - 011 fc/2 6 fc/2 7 fc/2 6 fc/2 7 - 100 fc/2 5 fc/2 6 fc/2 5 fc/2 6 - 101 fc/2 4 fc/2 5 fc/2 4 fc/2 5 - 110 reserved 111 external clock (input from sck2 pin ) sio control register 2 sio2cr276543210 (0fb5h) wait buf (initial value: ***0 0000)
page 159 TMP86CS64AFG note 1: the lower 4 bits of each buffer are used during 4-bit tr ansfers. zeros (0) are stored to the upper 4bits when receiving. note 2: transmitting starts at the lowest address. received data are also stored starting from the lowest address to the highest address. ( the first buffer address transmitted is 0f98h ). note 3: the value to be loaded to buf is held after transfer is completed. note 4: sio2cr2 must be set when the serial interface is stopped (siof = 0). note 5: *: don't care note 6: sio2cr2 is write-only register, which cannot access any of in read-modify-write instruction such as bit operate, etc. note 1: t f ; frame time, t d ; data transfer time note 2: after sios is cleared to "0", siof is cleared to "0" at the termination of transfer or the setting of sioinh to "1". figure 16-2 fr ame time (t f ) and data transfer time (t d ) 16.3 serial clock 16.3.1 clock source internal clock or external clock for the source clock is selected by sio2cr1. wait wait control always sets "00" except 8-bit transmit / receive mode. write only 00: t f = t d (non wait) 01: t f = 2t d (wait) 10: t f = 4t d (wait) 11: t f = 8t d (wait) buf number of transfer words (buffer address in use) 000: 1 word transfer 0f98h 001: 2 words transfer 0f98h ~ 0f99h 010: 3 words transfer 0f98h ~ 0f9ah 011: 4 words transfer 0f98h ~ 0f9bh 100: 5 words transfer 0f98h ~ 0f9ch 101: 6 words transfer 0f98h ~ 0f9dh 110: 7 words transfer 0f98h ~ 0f9eh 111: 8 words transfer 0f98h ~ 0f9fh sio status register sio2sr76543210 (0fb5h) siof sef siof serial transfer operating status moni- tor 0: 1: transfer terminated transfer in process read only sef shift operating status monitor 0: 1: shift operation terminated shift operation in process td tf (output) s ck2 output
page 160 16. synchronous serial interface (sio2) 16.3 serial clock TMP86CS64AFG 16.3.1.1 internal clock any of six frequencies can be selected. the serial clock is output to the outside on the sck2 pin. the sck2 pin goes high when transfer starts. when data writing (in the transmit mo de) or reading (in the receive mode or the transmit/receive mode) cannot keep up with the serial clock rate, there is a wa it function that automatically stops the serial clock and holds the next shift operation until the read/write processing is completed. note: 1 kbit = 1024 bit (fc = 16 mhz, fs = 32.768 khz) figure 16-3 automatic wait fu nction (at 4-bit transmit mode) 16.3.1.2 external clock an external clock connected to the sck 2 pin is used as the serial clock. in this case, output latch of this port should be set to "1". to ensure shifting, a pulse width of at least 4 machine cycles is required. this pulse is needed for the shift operatio n to execute certainly. actually, there is necessary processing time for interrupting, writing, and reading. the minimum pulse is determined by setting the mode and the pro- gram. therfore, maximum transfer frequenc y will be 488.3k bit/sec (at fc=16mhz). table 16-1 serial clock rate normal1/2, idle1/2 mode slow1/2, sleep1/2 mode dv7ck = 0 dv7ck = 1 dv1ck = 0 dv1ck = 1 dv1ck = 0 dv1ck = 1 sck clock baud rate clock baud rate clock baud rate clock baud rate clock baud rate 000 fc/2 15 0.48 kbps fc/2 16 0.24 kbps fs/2 7 256 bps fs/2 7 256 bps fs/2 7 256 bps 001 fc/2 8 61.04 kbps fc/2 9 30.52 kbps fc/2 8 61.04 kbps fc/2 9 30.52 kbps -- 010 fc/2 7 122.07 kbps fc/2 8 61.04 kbps fc/2 7 122.07 kbps fc/2 8 61.04 kbps -- 011 fc/2 6 244.14 kbps fc/2 7 122.07 kbps fc/2 6 244.14 kbps fc/2 7 122.07 kbps -- 100 fc/2 5 488.28 kbps fc/2 6 244.14 kbps fc/2 5 488.28 kbps fc/2 6 244.14 kbps -- 101 fc/2 4 976.56 kbps fc/2 5 488.28 kbps fc/2 4 976.56 kbps fc/2 5 488.28 kbps -- 110---------- 111 external external external external external external external external external external a 1 a 2 b 0 b 1 b 2 b 3 c 0 c 1 a 3 a c b a 0 pin (output) pin (output) written transmit data a utomat i ca ll y wait function sck2 so2
page 161 TMP86CS64AFG figure 16-4 external clock pulse width 16.3.2 shift edge the leading edge is used to transmit, a nd the trailing edge is used to receive. 16.3.2.1 leading edge transmitted data are shifted on the leading edge of the serial clock (falling edge of the sck 2 pin input/ output). 16.3.2.2 trailing edge received data are shifted on th e trailing edge of the serial clock (rising edge of the sck 2 pin input/out- put). figure 16-5 shift edge 16.4 number of bits to transfer either 4-bit or 8-bit serial transfer can be selected. when 4-bit serial transfer is selected, only the lower 4 bits of the transmit/receive data buffer re gister are used. the upper 4 bits are cleared to ?0? when receiving. the data is transferred in sequence star ting at the least significant bit (lsb). 16.5 number of w ords to transfer up to 8 words consisting of 4 bits of data (4-bit serial tran sfer) or 8 bits (8-bit serial tr ansfer) of data can be trans- ferred continuously. the number of words to be transferred can be selected by sio2cr2. t sckl t sckh tcyc = 4/fc (in the normal1/2, idle1/2 modes) 4/fs (in the slow1/2, sleep1/2 modes) t sckl , t sckh > 4tcyc sck2 pin (output) bit 1 bit 2 bit 3 * 321 3210 ** 32 *** 3 bit 0 shift register shift register bit 1 bit 0 bit 2 bit 3 0 *** **** 210 * 10 ** 3210 (a) leading edge (b) trailing edge * ; don?t care so2 pin si2 pin sck2 pin sck2 pin
page 162 16. synchronous serial interface (sio2) 16.6 transfer mode TMP86CS64AFG an intsio2 interrupt is generated when the specified number of words has been transferred. if the number of words is to be changed during transfer , the serial interface must be stopped before making the ch ange. the number of words can be changed during automatic-wa it operation of an internal clock. in this case, the serial interface is not required to be stopped. figure 16-6 number of words to transfer (example: 1word = 4bit) 16.6 transfer mode sio2cr1 is used to select the tran smit, receive, or transmit/receive mode. 16.6.1 4-bit and 8-bit transfer modes in these modes, firstly set the sio control register to the transmit mode, and then write first transmit data (number of transfer words to be transfer red) to the data buffer registers (dbr). after the data are written, the transmission is star ted by setting sio2cr1 to ?1?. the data are then output sequentially to the so pin in synchronous with th e serial clock, starting with the least significant bit (lsb). as soon as the lsb has been output, the data are transferred from the data buffer register to the shift register. when the final data bit has b een transferred and the data buffer re gister is empty, an intsio2 (buffer empty) interrupt is generated to request the next transmitted data. when the internal clock is used, the serial clock will stop and an automatic-wait will be initiated if the next transmitted data are not loaded to the data buffer regist er by the time the number of data words specified with the sio2cr2 has been transmitted. writing even one word of data cancels the automatic-wait; there- fore, when transmitting two or more words, always wr ite the next word before transmission of the previous word is completed. note:automatic waits are also canceled by writing to a dbr not being used as a transmit data buffer register; there- fore, during sio do not use such dbr for other applicati ons. for example, when 3 words are transmitted, do not use the dbr of the remained 5 words. a 1 a 2 a 3 a 0 a 1 a 2 a 3 b 0 b 1 b 2 b 3 c 0 c 1 c 2 c 3 a 0 a 1 a 0 a 2 a 3 b 0 b 1 b 2 b 3 c 0 c 1 c 2 c 3 (a) 1 word transmit (b) 3 words transmit (c) 3 words receive so2 pin intsio2 interrupt intsio2 interrupt intsio2 interrupt so2 pin si2 pin sck2 pin sck2 pin sck2 pin
page 163 TMP86CS64AFG when an external clock is used, the data must be writte n to the data buffer register before shifting next data. thus, the transfer speed is determin ed by the maximum delay time from the generation of the interrupt request to writing of the data to the data buffer register by the interrupt service program. the transmission is ended by clear ing sio2cr1 to ?0? or se tting sio2cr1 to ?1? in buffer empty interrupt service program. sio2cr1 is cleared, the operation will end after all bi ts of words are transmitted. that the transmission has ended can be determin ed from the status of sio2sr because sio2sr is cleared to ?0? when a transfer is completed. when sio2cr1 is set, the transmission is immediately ended and sio2sr is cleared to ?0?. when an external clock is used, it is also necessary to clear sio2cr1 to ?0? before shifting the next data; if sio2cr1 is not cleared before shift out, dummy data will be transmitted and the operation will end. if it is necessary to change th e number of words, si o2cr1 should be cleared to ?0?, then sio2cr2 must be rewritten after confirming that sio2sr has been cleared to ?0?. figure 16-7 transfer m ode (example: 8bit, 1word tr ansfer, internal clock) a 1 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 a 0 dbr b a clear sios write (a) write (b) sck2 pin (output) so2 pin intsio2 interrupt sio2cr1 sio2sr sio2sr sio2sr
page 164 16. synchronous serial interface (sio2) 16.6 transfer mode TMP86CS64AFG figure 16-8 transfer mode (example: 8b it, 1word transfer , external clock) figure 16-9 transmiiied data ho ld time at end of transfer 16.6.2 4-bit and 8- bit receive modes after setting the control registers to the receive mode, set sio2cr1 to ?1? to enab le receiving. the data are then transferred to the shift register via the si pin in synchronous with the serial clock. when one word of data has been received, it is tran sferred from the shift register to the data buffer register (dbr). when the number of words specified with the sio2cr2 has been received, an intsio2 (buffer full) interrupt is generated to request that these data be read out. the da ta are then read from the da ta buffer registers by the interrupt service program. when the internal clock is used, and the previous data are not read from the data buffer register before the next data are received, the serial cloc k will stop and an automatic-wait will be initiated until the data are read. a wait will not be initiated if even one data word has been read. note:waits are also canceled by readi ng a dbr not being used as a received data buffer register is read; therefore, during sio2 do not use such dbr for other applications. a 1 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 a 0 dbr b a clear sios write (a) write (b) sck2 pin (input) so2 pin intsio2 interrupt sio2cr1 sio2sr sio2sr msb of last word t sodh = min 3.5/fc [s] ( in the normal1/2, idle1/2 modes) t sodh = min 3.5/fs [s] (in the slow1/2, sleep1/2 modes) sck2 pin so2 pin sio2sr
page 165 TMP86CS64AFG when an external clock is used, the shift operation is synchronized with the extern al clock; therefore, the previous data are read before the next data are transferred to the data buffer register. if the previous data have not been read, the next data will not be transferred to th e data buffer register and th e receiving of any more data will be canceled. when an external clock is used, th e maximum transfer speed is determined by the delay between the time when the interrupt request is gene rated and when the data received have been read. the receiving is ended by clearing sio2cr1 to ?0? or setting sio2cr1 to ?1? in buffer full interrupt service program. when sio2cr1 is cleared, th e current data are transferred to the buffer. after sio2cr1 cleared, the receiving is ended at the ti me that the final bit of the data has been received. that the receiving has ended can be determined from the status of sio2sr . sio2sr is cleared to ?0? when the receiving is ended. after confirmed the receiving te rmination, the final recei ving data is read. when sio2cr1 is set, the receivi ng is immediately ended and sio2sr is cleared to ?0?. (the received data is ignored, and it is not required to be read out.) if it is necessary to change the number of words in external clock operation, sio2cr1 should be cleared to ?0? then sio2cr2 mu st be rewritten after confirming that sio2sr has been cleared to ?0?. if it is necessary to chan ge the number of words in internal clock, during automatic-wait operation which occurs after completion of data receiving, sio2cr2 must be rewr itten before the received data is read out. note:the buffer contents are lost when the transfer mode is switched. if it should become necessary to switch the transfer mode, end receiving by clearing sio2cr1 to ?0?, read the last data and then switch the trans- fer mode. figure 16-10 receive mode (example: 8b it, 1word transfer, internal clock) 16.6.3 8-bit trans fer / receive mode after setting the sio control register to the 8-bit transmit/recei ve mode, write the data to be transmitted first to the data buffer registers (dbr). af ter that, enable the transmit/receive by setting sio2cr1 to ?1?. when transmitting, the data are output from the so2 pin at leading edges of the serial clock. when receiving, the data are input to th e si2 pin at the trailing edges of the serial clock. when the all receive is enabled, 8-bit data are transferred from the shift re gister to the data buffer register. an intsio2 interrupt is generated when the number of data words specified with the sio2cr2 has been transferred. usually, read the receive data from the buffer register in the interrupt service. the data buffer register is used for both transmitting and receiving; therefore, always writ e the data to be transmitted af ter reading the all received data. when the internal clock is used, a wait is initiated until the received data are read and the next transfer data are written. a wait will not be initiated if ev en one transfer data word has been written. a 1 a 0 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 dbr b a clear sios read out read out sck2 pin (output) si2 pin intsio2 interrupt sio2cr1 sio2sr sio2sr
page 166 16. synchronous serial interface (sio2) 16.6 transfer mode TMP86CS64AFG when an external clock is used, the shift operation is synchronized with the external clock; therefore, it is necessary to read the received data and write the data to be transmitted next before starting the next shift oper- ation. when an external clock is us ed, the transfer speed is determined by the maximum delay between genera- tion of an interrupt request and the received data are read and the data to be transmitted next are written. the transmit/receive operation is ended by clearing sio2cr1 to ?0? or setting sio2cr1 to ?1? in intsio2 interrupt service program. when sio2cr1 is cleared, the current data ar e transferred to the buff er. after sio2cr1 cleared, the transmitting/ receiving is ended at the time that the fi nal bit of the data has been transmitted. that the transmitting/receiving has ended can be determined fr om the status of sio2sr. sio2sr is cleared to ?0? when the transmitting/recei ving is ended. when sio2cr1 is set, th e transmit/receive operation is imm ediately ended and sio2sr is cleared to ?0?. if it is necessary to change the number of words in external clock operation, sio2cr1 should be cleared to ?0?, then sio2cr2 must be rewritten after confirming that sio2sr has been cleared to ?0?. if it is necessary to change the number of words in internal clock, during automatic-wait operation which occurs after completion of transmit /receive operation, sio2 cr2 must be rewrit ten before reading and writing of the receive/transmit data. note:the buffer contents are lost when the transfer mode is switched. if it should become necessary to switch the transfer mode, end receiving by clearing sio2cr1 to ?0?, read the last data and then switch the trans- fer mode. figure 16-11 transfer / receive mode (examp le: 8bit, 1word transfe r, internal clock) a 1 a 0 a 2 a 3 a 4 a 5 a 6 a 7 b 0 b 1 b 2 b 3 b 4 b 5 b 6 b 7 c 1 c 0 c 2 c 3 c 4 c 5 c b c 6 c 7 d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 clear sios dbr d a read out (c) write (a) read out (d) write (b) sck2 pin (output) so2 pin intsio2 interrupt sio2cr1 sio2sr sio2sr si2 pin
page 167 TMP86CS64AFG figure 16-12 transmitted data hold ti me at end of tr ansfer / receive bit 7 of last word bit 6 t sodh = min 4/fc [s] ( in the normal1/2, idle1/2 modes) t sodh = min 4/fs [s] (in the slow1/2, sleep1/2 modes) sck2 pin so2 pin sio2sr
page 168 16. synchronous serial interface (sio2) 16.6 transfer mode TMP86CS64AFG
page 169 TMP86CS64AFG 17. 10-bit ad converter (adc) the TMP86CS64AFG have a 10-bit successi ve approximation ty pe ad converter. 17.1 configuration the circuit configuration of the 10-bit ad converter is shown in figure 17-1. it consists of control register adccr1 and adccr2 , converted value register adcdr1 and adcdr2, a da converter, a sample-hold circuit, a compar ator, and a successive comparison circuit. note: before using ad converter, set appropriate value to i/o port register conbining a analog input port. for details, see the sec- tion on "i/o ports". figure 17-1 10-bit ad converter 2 4 10 8 ainds adrs r/2 r/2 r ack amd irefon ad conversion result register 1, 2 ad converter control register 1, 2 adbf eocf intadc sain n successive approximate circuit adccr2 adcdr1 adcdr2 adccr1  sample hold circuit a s en shift clock da converter analog input multiplexer y reference voltage analog comparator 2 3 control circuit avss varef avdd ain0 ain15
page 170 17. 10-bit ad converter (adc) 17.2 register configuration TMP86CS64AFG 17.2 register configuration the ad converter consists of the following four registers: 1. ad converter control register 1 (adccr1) this register selects the analog channels and operatio n mode (software start or repeat) in which to per- form ad conversion and controls the ad converter as it starts operating. 2. ad converter control register 2 (adccr2) this register selects the ad conversion time and co ntrols the connection of the da converter (ladder resistor network). 3. ad converted value register 1 (adcdr1) this register used to store the digital value fter being converted by the ad converter. 4. ad converted value register 2 (adcdr2) this register monitors the oper ating status of the ad converter. note 1: select analog input channel during ad converter stops (adcdr2 = "0"). note 2: when the analog input channel is all use dis abling, the adccr1 should be set to "1". note 3: during conversion, do not perform port output instruction to maintain a precision for all of the pins because analog inp ut port use as general input port. and for port near to anal og input, do not input intense signaling of change. note 4: the adccr1 is automatically cleared to "0" after starting conversion. note 5: do not set adccr1 newly again during ad conv ersion. before setting adccr1 newly again, check adcdr2 to see that the conversion is completed or wait until the interrupt signal (intadc) is generated (e.g., interrupt handling routine). note 6: after stop or slow/sleep mode are started, ad conver ter control register1 (adccr1) is all initialized and no data can be written in this register. therfore, to use ad converter again, set the adccr1 newly after returning to normal1 or normal2 mode. ad converter control register 1 adccr1 (000eh) 76543210 adrs amd ainds sain (initial value: 0001 0000) adrs ad conversion start 0: 1: - ad conversion start r/w amd ad operating mode 00: 01: 10: 11: ad operation disable software start mode reserved repeat mode ainds analog input control 0: 1: analog input enable analog input disable sain analog input channel select 0000: 0001: 0010: 0011: 0100: 0101: 0110: 0111: 1000: 1001: 1010: 1011: 1100: 1101: 1110: 1111: ain0 ain1 ain2 ain3 ain4 ain5 ain6 ain7 ain8 ain9 ain10 ain11 ain12 ain13 ain14 ain15
page 171 TMP86CS64AFG note 1: always set bit0 in adccr2 to "0" and set bit4 in adccr2 to "1". note 2: when a read instruction for adccr2, bi t6 to 7 in adccr2 read in as undefined data. note 3: after stop or slow/sleep mode are started, ad conver ter control register2 (adccr2) is all initialized and no data can be written in this register. therfore, to use ad converter again, set the adccr2 newly after returning to normal1 or normal2 mode. note 1: setting for " ? " in the above table are inhibited. fc: high frequency oscillation clock [hz] note 2: set conversion time setting should be kept more t han the following time by analog reference voltage (varef) . ad converter control register 2 adccr2 (000fh) 76543210 irefon "1" ack "0" (initial value: **0* 000*) irefon da converter (ladder resistor) connection control 0: 1: connected only during ad conversion always connected r/w ack ad conversion time select (refer to the following table about the con- version time) 000: 001: 010: 011: 100: 101: 110: 111: 39/fc reserved 78/fc 156/fc 312/fc 624/fc 1248/fc reserved table 17-1 ack setting and conversion time (at cgcr="0") condition conversion time 16 mhz 8 mhz 4 mhz 2 mhz 10 mhz 5 mhz 2.5 mhz ack 000 39/fc - - - 19.5 s - - 15.6 s 001 reserved 010 78/fc - - 19.5 s 39.0 s - 15.6 s 31.2 s 011 156/fc - 19.5 s 39.0 s 78.0 s 15.6 s 31.2 s 62.4 s 100 312/fc 19.5 s39.0 s 78.0 s 156.0 s 31.2 s 62.4 s124.8 s 101 624/fc 39.0 s78.0 s 156.0 s - 62.4 s124.8 s- 110 1248/fc 78.0 s 156.0 s - - 124.8 s- - 111 reserved table 17-2 ack setting and conversion time (at cgcr="1") condition conversion time 16 mhz 8 mhz 4 mhz 2 mhz 10 mhz 5 mhz 2.5 mhz ack 000 39/fc - - - 19.5 s - - 15.6 s 001 reserved 010 156/fc - 19.5 s 39.0 s 78.0 s 15.6 s 31.2 s 62.4 s 011 312/fc 19.5 s39.0 s 78.0 s 156.0 s 31.2 s 62.4 s124.8 s 100 624/fc 39.0 s78.0 s 156.0 s - 62.4 s124.8 s- 101 1248/fc 78.0 s 156.0 s - - 124.8 s- - 110 2096/fc 156.0 s------ 111 reserved - varef = 4.5 to 5.5 v 15.6 s and more - varef = 2.7 to 5.5 v 31.2 s and more
page 172 17. 10-bit ad converter (adc) 17.2 register configuration TMP86CS64AFG note 1: the adcdr2 is cleared to "0" when reading the a dcdr1. therfore, the ad conversion result should be read to adcdr2 more first than adcdr1. note 2: the adcdr2 is set to "1" when ad conversion star ts, and cleared to "0" when ad conversion finished. it also is cleared upon entering stop mode or slow mode . note 3: if a read instruction is executed for a dcdr2, read data of bit3 to bit0 are unstable. ad converted value register 1 adcdr1 (0027h) 76543210 ad09 ad08 ad07 ad06 ad05 ad04 ad03 ad02 (initial value: 0000 0000) ad converted value register 2 adcdr2 (0026h) 76543210 ad01 ad00 eocf adbf (initial value: 0000 ****) eocf ad conversion end flag 0: 1: before or during conversion conversion completed read only adbf ad conversion busy flag 0: 1: during stop of ad conversion during ad conversion
page 173 TMP86CS64AFG 17.3 function 17.3.1 software start mode after setting adccr1 to ?01? (software start mode), set adccr1 to ?1?. ad conver- sion of the voltage at the analog input pin specified by adccr1 is thereby started. after completion of the ad conversion, the conversion result is stored in ad converted value registers (adcdr1, adcdr2) and at the same time adcdr2 is set to 1, the ad conversion finished inter- rupt (intadc) is generated. adrs is automatically cleared afte r ad conversion has started. do not set adccr1 newly again (restart) during ad conversion. before setting adrs newly again, check adcdr2 to see that the conversion is completed or wait until the interrupt signa l (intadc) is generated (e.g., interrupt handling rou- tine). figure 17-2 software start mode 17.3.2 repeat mode ad conversion of the voltage at the analog input pin specified by adccr1 is performed repeatedly. in this mode, ad conversion is started by setti ng adccr1 to ?1? after setting adccr1 to ?11? (repeat mode). after completion of the ad conversion, the conversion result is stored in ad converted value registers (adcdr1, adcdr2) and at the same time adcdr2 is set to 1, the ad conversion finished inter- rupt (intadc) is generated. in repeat mode, each time one ad conversion is complete d, the next ad conversion is started. to stop ad conversion, set adccr1 to ?00? (disable mode) by writing 0s. the ad convert operation is stopped immediately. the converted valu e at this time is not stored in the ad converted value register. adcdr1 status eocf cleared by reading conversion result conversion result read adcdr2 intadc interrupt request adcdr2 adccr1 1st conversion result 2nd conversion result indeterminate ad conversion start ad conversion start a dcdr1 a dcdr2 conversion result read conversion result read conversion result read
page 174 17. 10-bit ad converter (adc) 17.3 function TMP86CS64AFG figure 17-3 repeat mode 17.3.3 regi ster setting 1. set up the ad converter control register 1 (adccr1) as follows: ? choose the channel to ad convert using ad input channel select (sain). ? specify analog input enable fo r analog input control (ainds). ? specify amd for the ad converter control operation mode (software or repeat mode). 2. set up the ad converter control register 2 (adccr2) as follows: ? set the ad conversion time using ad conversion time (ack). for details on how to set the con- version time, refer to figure 17-1, figure 17-2 and ad converter control register 2. ? choose irefon for da converter control. 3. after setting up (1) and (2) above, set ad conversion start (adrs) of ad converter control register 1 (adccr1) to ?1?. if software start mode has been selected, ad conversi on starts immediately. 4. after an elapse of the specified ad conversion time, the ad converted value is stored in ad con- verted value register 1 (adcdr1) and the ad conv ersion finished flag (e ocf) of ad converted value register 2 (adcdr2) is set to ?1?, upon wh ich time ad conversion interrupt intadc is gener- ated. 5. eocf is cleared to ?0? by a read of the conversion result. however, if reconverted before a register read, although eocf is cl eared the previous conversi on result is retained until the next conversion is completed. a dcdr1,adcdr2 eocf cleared by reading conversion result conversion result read a dcdr2 intadc interrupt request conversion operation a dccr1 indeterminate ad conversion start adccr1 ?11? ?00? 1st conversion result ad convert operation suspended. conversion result is not stored. 2nd conversion result 3rd conversion result a dcdr1 a dcdr2 2nd conversion result 3rd conversion result 1st conversion result conversion result read conversion result read conversion result read conversion result read conversion result read
page 175 TMP86CS64AFG 17.4 stop/slow modes during ad conversion when standby mode (stop or slow mode) is entered fo rcibly during ad conversi on, the ad convert operation is suspended and the ad converter is in itialized (adccr1 and adccr2 are initia lized to initial value). also, the conversion result is indeterminate. (conversion results up to the previous operation are cleared, so be sure to read the conversion results before entering standby mode (sto p or slow mode).) when restored from standby mode (stop or slow mode), ad conversion is not automatically restarted, so it is necessa ry to restart ad conversion. note that since the analog reference voltage is automatically disconnected, there is no possibility of current flowing into the analog reference voltage. example :after selecting the conversion time 19.5 s at 16 mhz and the analog input channel ain3 pin, perform ad con- version once. after checking eocf, read the converted value, store the lower 2 bits in address 0009eh nd store the upper 8 bits in address 0009fh in ram. the operation mode is software start mode. : (port setting) : ;set port register approrriately before setting ad converter registers. : : (refer to section i/o port in details) ld (adccr1) , 00100011b ; select ain3 ld (adccr2) , 11011000b ;select conversion time(312/fc) and operation mode set (adccr1) . 7 ; adrs = 1(ad conversion start) sloop : test (adcdr2) . 5 ; eocf= 1 ? jrs t, sloop ld a , (adcdr2) ; read result data ld (9eh) , a ld a , (adcdr1) ; read result data ld (9fh), a
page 176 17. 10-bit ad converter (adc) 17.5 analog input voltage and ad conversion result TMP86CS64AFG 17.5 analog input voltage and ad conversion result the analog input voltage is corresponded to the 10-bit dig ital value converted by the ad as shown in figure 17-4. figure 17-4 analog i nput voltage and ad c onversion result (typ.) 1 0 01 h 02 h 03 h 3fd h 3fe h 3ff h 2 3 1021 1022 1023 1024 analog input voltage 1024 ad conversion result varef avss
page 177 TMP86CS64AFG 17.6 precautions about ad converter 17.6.1 analog input pin voltage range make sure the analog input pins (ain0 to ain15) are used at voltages within varef to avss. if any volt- age outside this range is applied to one of the analog input pins, the converted value on that pin becomes uncer- tain. the other analog input pins also are affected by that. 17.6.2 analog input shared pins the analog input pins (ain0 to ain15) are shared with input/output ports. when using any of the analog inputs to execute ad conversion, do not execute input/output instructions for all other ports. this is necessary to prevent the accuracy of ad conversi on from degrading. not only these analog input sh ared pins, some other pins may also be affected by noise arising from input/o utput to and from adjacent pins. 17.6.3 noise countermeasure the internal equivalent circuit of the analog input pins is shown in figure 17-5. the higher the output impedance of the analog input source, more easily they are susceptible to no ise. therefore, make sure the out- put impedance of the signal source in your design is 5 k ? or less. toshiba also recommends attaching a capac- itor external to the chip. figure 17-5 analog i nput equivalent circuit and exam ple of input pin processing da converter aini analog comparator internal resistance permissible signal source impedance internal capacitance 5 k ? (typ) c = 22 pf (typ.) 5 k ? (max) note) i = 15 to 0
page 178 17. 10-bit ad converter (adc) 17.6 precautions about ad converter TMP86CS64AFG
page 179 TMP86CS64AFG 18. key-on wakeup (kwu) in the TMP86CS64AFG, the stop mode is released by not only p20( int5 / stop ) pin but also four (stop2 to stop5) pins. when the stop mode is released by stop2 to stop5 pins, the stop pin needs to be used. in details, refer to the following section " 18.2 control ". 18.1 configuration figure 18-1 key-on wakeup circuit 18.2 control stop2 to stop5 pins can controlled by key-on wakeup c ontrol register (stopcr). it can be configured as enable/disable in 1-bit unit. when thos e pins are used for stop mode releas e, configure corresponding i/o pins to input mode by i/o port register beforehand. 18.3 function stop mode can be entered by setting up the system control register (syscr1), and can be exited by detecting the "l" level on stop2 to stop5 pins, which are enabled by stopcr, for releasing stop mode (note1). key-on wakeup control register stopcr76543210 (0031h) stop5 stop4 stop3 stop2 (initial value: 0000 ****) stop5 stop mode released by stop5 0:disable 1:enable write only stop4 stop mode released by stop4 0:disable 1:enable write only stop3 stop mode released by stop3 0:disable 1:enable write only stop2 stop mode released by stop2 0:disable 1:enable write only stopcr int5 stop stop mode release signal (1: release) (0031h) stop2 stop3 stop4 stop5 stop2 stop3 stop4 stop5
page 180 18. key-on wakeup (kwu) 18.3 function TMP86CS64AFG also, each level of the stop2 to stop5 pins can be co nfirmed by reading correspondi ng i/o port data register, check all stop2 to stop5 pins "h" that is enabled by stopcr before the stop mode is startd (note2,3). note 1: when the stop mode released by the edge release mo de (syscr1 = ?0?), inhibit input from stop2 to stop5 pins by key-on wakeup control register (stopcr) or must be set "h" level into stop2 to stop5 pins that are available input during stop mode. note 2: when the stop pin input is high or stop2 to stop5 pins input which is enabled by stopcr is low, executing an instruction which starts stop mode wi ll not place in stop mode but instead will immediately start the release sequence (warm up). note 3: the input circuit of key-on wakeup input and port i nput is separated?aso each input voltage threshold value is diffrent. therefore, a value comes from port input before stop mode start may be diffrent from a value which is detected by key-on wakeup input (figure 18-2). note 4: stop pin doesn?t have the control register such as stop cr, so when stop mode is released by stop2 to stop5 pins, stop pin also should be used as stop mode release function. note 5: in stop mode, key-on wakeup pin which is enabled as input mode (for releasing stop mode) by key-on wakeup control register (stopcr) may genarate the penet ration current, so the said pin must be disabled ad conversion input (analog voltage input). note 6: when the stop mode is released by stop2 to stop5 pins, the level of stop pin should hold "l" level (figure 18-3). figure 18-2 key-on wakeup input and port input figure 18-3 priority of stop pin and stop2 to stop5 pins table 18-1 release level (edge) of stop mode pin name release level (edge) syscr1="1" (note2) syscr1="0" stop "h" level rising edge stop2 "l" level don?t use (note1) stop3 "l" level don?t use (note1) stop4 "l" level don?t use (note1) stop5 "l" level don?t use (note1) port input external pin key-on wakeup input stop pin a) stop release stop mode stop mode stop pin "l" b) release stop mode stop mode in case of stop2 to stop5 stop2 pin
page 181 TMP86CS64AFG 19. input/output circuitry 19.1 control pins the input/output circuitries of the TMP86CS64AFG control pins are shown below. note: the test pin of the tmp86ps64 does not have a pull-down resistor. fix the test pin at low-level in mcu mode. control pin i/o input/output circuitry remarks xin xout input output resonator connecting pins (high-frequency) r f = 1.2 m ? (typ.) r o = 1.5 k ? (typ.) xtin xtout input output resonator connecting pins (low-frequency) r f = 6 m ? (typ.) r o = 220 k ? (typ.) reset input hysteresis input pull-up resistor r in = 220 k ? (typ.) r = 1 k ? (typ.) test input pull-down resistor r in = 70 k ? (typ.) r = 1 k ? (typ.) fc r f r o osc. enable xin xout vdd vdd fs r f r o osc. enable xtin xtout vdd xten vdd r r in vdd vdd r in r d 1 vdd
page 182 19. input/output circuitry 19.1 control pins TMP86CS64AFG 19.2 input/output ports port i/o input/output circuitry remarks p0 i/o tri-state i/o r = 100 ? (typ.) p1 p3 p5 p8 p9 i/o tri-state i/o hysteresis input high current output (n-ch)(p5, p9) r = 100 ? (typ.) p6 p7 i/o tri-state i/o programmable pull-up r in = 80 k ? (typ.) r = 100 ? (typ.) pa pb i/o tri-state i/o hysteresis input programmable pull-up r in = 80 k ? (typ.) r = 100 ? (typ.) p2 i/o sink open drain output hysteresis input r = 100 ? (typ.) p4 i/o sink open drain i/o or tri-state i/o hysteresis input r = 100 ? (typ.) initial "high-z" disable data output pin input vdd r initial "high-z" disable data output pin input vdd r initial "high-z" disable data output pin input vdd r r in initial "high-z" disable data output pin input vdd r r in vdd r initial "high-z" data output pin input pch control disable vdd initial "high-z" data output data input pin input r
page 183 TMP86CS64AFG 20. electrical characteristics 20.1 absolute maximum ratings the absolute maximum ratings are rated values which must not be exceeded during operat ion, even for an instant. any one of the ratings must not be exceeded. if any absolute maximum ra ting is exceeded, a device may break down or its performance may be degraded, causi ng it to catch fire or ex plode resulting in injury to the user. thus, when designing products which include this de vice, ensure that no absolute maximu m rating value will ever be exceeded. (v ss = 0 v) parameter symbol pins ratings unit supply voltage v dd ? 0.3 to 6.5 v input voltage v in ? 0.3 to v dd + 0.3 output voltage v out ? 0.3 to v dd + 0.3 output current (per 1 pin) i outh except open drain ? 3.2 ma i out1 except p5, p9 3.2 i out2 p5 30 i out3 p9 output current (total) i out1 except p5, p9 60 i out2 p5 i out3 p9 power dissipation [t opr = 85 c] pd 250 mw soldering temperature (time) tsld 260 (10 s) c storage temperature tstg ? 55 to 125 operating temperature topr ? 40 to 85
page 184 20. electrical characteristics 20.2 recommended operating condition TMP86CS64AFG 20.2 recommended op erating condition the recommended operating co nditions for a device are operating conditions under which it can be guaranteed that the device will operate as specified. if the device is used under operating conditions other than the recommended operating conditions (supply voltage, operating temperature range, specified ac/dc values etc.), malfunction may occur. thus, when designing products which include this device, ensure that the recommended operating conditions for the device are always adhered to. (v ss = 0 v, topr = ? 40 to 85 c) parameter symbol pins condition min max unit supply voltage v dd fc = 16 mhz, each operation modes 4.5 5.5 v fc = 8 mhz, each operation modes 2.7 fs = 32.768 khz, each operation modes 2.7 stop mode 2.0 input high level v ih1 hysteresis v dd 4.5 v v dd 0.70 v dd v ih2 hysteresis v dd 0.75 v ih3 v dd < 4.5 v v dd 0.90 input low level v il1 hysteresis v dd 4.5 v 0 v dd 0.30 v il2 hysteresis v dd 0.25 v il3 v dd < 4.5 v v dd 0.10 clock frequency fc xin, xout v dd = 2.7 v to 5.5 v 1.0 8.0 mhz v dd = 4.5 v to 5.5 v 1.0 16.0 fs xtin, xtout 30.0 34.0 khz
page 185 TMP86CS64AFG 20.3 dc characteristics note 1: typical values show those at topr = 25 c, v dd = 5 v note 2: input current (i in1 , i in3 ); the current through pull-up or pull-down resistor is not included. note 3: i dd does not include i ref current. (v ss = 0 v, topr = ? 40 to 85 c) parameter symbol pins condition min typ. max unit hysteresis voltage v hs hysteresis input ? 0.9 ? v input current i in1 test v dd = 5.5 v, v in = 5.5 v/0 v ?? 2 a i in2 sink open drain, tri-state port i in3 stop , reset input resistance r in1 test ?70? k ? r in2 reset 100 220 450 r in3 programmable pull up (p6, p7, pa, pb) v dd = 5.5 v 40 80 200 osc. feedback resistance rfx xin-xout ? 1.2 ? m ? rfxt xtin-xtout ? 6 ? output leakage current i lo1 sink open drain port v dd = 5.5 v, v out = 5.5 v ??2 a i lo2 tri-state port v dd = 5.5 v, v out = 5.5 v/0 v ?? 2 "h" output voltage v oh tri-state port v dd = 4.5 v, i oh = ? 0.7 ma 4.1 ? ? v ?l? output voltage v ol3 except xout, p5, p9 v dd = 4.5 v, i ol = 1.6 ma ??0.4 ?l? output current i ol1 except xout, p5, p9 v dd = 4.5 v, v ol = 0.4 v ?1.6? ma i ol3 high current port (p5, p9) v dd = 4.5 v, v ol = 1.0 v ?20? supply current in normal 1, 2 mode i dd v dd = 5.5 v v in = 5.3 v/0.2 v fc = 16 mhz fs = 32.768 khz ?78 supply current in idle 1, 2 mode ?45 supply current in slow 1 mode v dd = 3.0 v v in = 2.8 v/0.2 v fs = 32.768 khz ?1020 a supply current in sleep 0, 1 mode ?612 supply current in stop mode v dd = 5.5 v v in = 5.3 v/0.2 v ?0.510
page 186 20. electrical characteristics 20.4 ad conversion characteristics TMP86CS64AFG 20.4 ad conversi on characteristics note 1: total error includes all error except a quantization error, and is defined as a maximum deviation from the ideal convers ion line. note 2: conversion time is different in recommended value by power supply voltage. about conversion time, please re fer to "register framing". note 3: please use input voltage to ain input pin in limit of v aref f ? v ss . when voltage of range outside is input, conversion value bec omes unsettled and gives affect to other channel conversion value. note 4: analog reference voltage range: ? v aref = v aref ? a vss (v ss = 0 v, 4.5 v v dd 5.5 v, topr = ? 40 to 85 c) parameter symbol condition min typ. max unit analog reference voltage v aref a vdd ? 1.0 ? a vdd v power supply voltage of analog control circuit a vdd v dd a vss v ss analog reference of voltage range (note4) ? v aref v aref ? a vss 3.5 ? v dd analog input voltage v ain v ss ? v aref power supply current of analog reference voltage i ref v dd = a vdd = v aref = 5.5 v v ss = a vss = 0.0 v ?0.61.0ma non linearity error v dd = a vdd = 5.0 v v ss = a vss = 0.0 v v aref = 5.0 v ?? 2 lsb zero point error ?? 2 full scale error ?? 2 to t a l e r r o r ?? 4 (v ss = 0 v, 2.7 v v dd < 4.5 v, topr = ? 40 to 85 c) parameter symbol condition min typ. max unit analog reference voltage v aref a vdd ? 1.0 ? a vdd v power supply voltage of analog control circuit a vdd v dd a vss v ss analog reference of voltage range (note 4) ? v aref v aref ? v ss 2.5 ? v dd analog input voltage v ain v ss ? v aref power supply current of analog reference voltage i ref v dd = a vdd = v aref = 4.5 v v ss = a vss = 0.0 v ?0.50.8ma non linearity error v dd = a vdd = 2.7 v v ss = a vss = 0.0 v v aref = 2.7 v ?? 2 lsb zero point error ?? 2 full scale error ?? 2 to t a l e r r o r ?? 4
page 187 TMP86CS64AFG 20.5 ac characteristics (v ss = 0 v, v dd = 4.5 to 5.5 v, topr = ? 40 to 85 c) parameter symbol condition min typ. max unit machine cycle time tcy normal 1, 2 mode 0.25 ? 4 s idle 0, 1, 2 mode slow 1, 2 mode 117.6 ? 133.3 sleep 0, 1, 2 mode high level clock pulse width t wch for external clock operation (xin input) fc = 16 mhz ? 31.25 ? ns low level clock pulse width t wcl high level clock pulse width t wsh for external clock operation (xtin input) fs = 32.768 khz ? 15.26 ? s low level clock pulse width t wsl (v ss = 0 v, v dd = 2.7 to 4.5 v, topr = ? 40 to 85 c) parameter symbol condition min typ. max unit machine cycle time tcy normal 1, 2 mode 0.5 ? 4 s idle 0, 1, 2 mode slow 1, 2 mode 117.6 ? 133.3 sleep 0, 1, 2 mode high level clock pulse width t wch for external clock operation (xin input) fc = 8 mhz ? 62.5 ? ns low level clock pulse width t wcl high level clock pulse width t wsh for external clock operation (xtin input) fs = 32.768 khz ? 15.26 ? s low level clock pulse width t wsl
page 188 20. electrical characteristics 20.6 recommended oscillating conditions TMP86CS64AFG 20.6 recommended osc illating conditions note 1: to ensure stable oscillation, the resonator position, load capacitance, etc. must be appropriate. because these factors are greatly affected by board patterns, please be sure to evaluate operation on the board on which the device will act ually be mounted. note 2: for the resonators to be used with toshiba microcont rollers, we recommend ceramic resonators manufactured by murata manufacturing co., ltd. for details, please visit the website of murata at the following url: http://www.murata.com 20.7 handling precaution - the solderability test conditions for lead-free produc ts (indicated by the suffix g in product name) are shown below. 1. when using the sn-37pb solder bath solder bath temperature = 230 c dipping time = 5 seconds number of times = once r-type flux used 2. when using the sn-3.0ag-0.5cu solder bath solder bath temperature = 245 c dipping time = 5 seconds number of times = once r-type flux used note: the pass criteron of the above test is as follows: solderability rate until forming 95 % - when using the device (oscillator) in places exposed to high electric fields such as cathode-ray tubes, we recommend electrically shielding the package in order to maintain normal operating condition. xin xout c 2 c 1 xtin ( 1) high-frequency oscillation (2) low-frequency oscillatio xtout c 2 c 1
page 189 TMP86CS64AFG 21. package dimension p-qfp100-1420-0.65a unit: mm
page 190 21. package dimension TMP86CS64AFG
this is a technical document that de scribes the operating functi ons and electrical specif ications of the 8-bit microcontroller series tlcs-870/c (lsi). toshiba provides a variety of development tools a nd basic software to enable efficient software development. these development tools have specifi cations that support advances in microcomputer hardware (lsi) and can be used extensively. both the hardware and so ftware are supported continuous ly with version updates. the recent advances in cmos lsi production technology have be en phenomenal and microcomputer systems for lsi design are constant ly being improved. the products described in this document may also be revised in the future. be sure to check the latest specific ations before using. toshiba is developing highly integrated, high-perfo rmance microcomputers using advanced mos production technology and especially well proven cmos technology. we are prepared to meet the requests for custom packaging for a variet y of application areas. we are confident that our products can satisfy your application needs now and in the future.


▲Up To Search▲   

 
Price & Availability of TMP86CS64AFG

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X