![]() |
|
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 TMP86PH22UG
page 2 TMP86PH22UG 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 precautions and conditions set forth in the ? handling guide for semiconductor devices, ? or ? toshiba semiconductor reliability handbook ? etc. 021023_a the toshiba products listed in this document are 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, transportation 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 prohibited 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/7 1 first release 2006/5/10 2 periodical updating. no change in contents. 2006/9/8 3 contents revised 2008/8/29 4 contents revised caution in setting the ua rt noise rejection time when uart is used, settings of rxdnc are limited depend ing on the transfer clock specified by brg. the com- bination "o" is available but please do not select the combination "?". the transfer clock generated by timer/counter in terrupt is calculated by the following equation : transfer clock [hz] = time r/counter source clock [hz] brg setting transfer clock [hz] rxdnc setting 00 (no noise rejection) 01 (reject pulses shorter than 31/fc[s] as noise) 10 (reject pulses shorter than 63/fc[s] as noise) 11 (reject pulses shorter than 127/fc[s] as noise) 000 fc/13 o o o ? 110 (when the transfer clock gen- erated by timer/counter inter- rupt is the same as the right side column) fc/8 o ? ? ? fc/16 o o ? ? fc/32ooo ? the setting except the a b o v eoooo i table of contents TMP86PH22UG 1.1 features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 pin assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.3 block diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1.4 pin names and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2. operational description 2.1 cpu core functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.1.1 memory address map ............................................................................................................................... 9 2.1.2 program memory (otp) ........................................................................................................................... 9 2.1.3 data memory (ram) ............................................................................................................................... 10 2.2 system clock controller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.2.1 clock generator ...................................................................................................................................... 10 2.2.2 timing generator .................................................................................................................................... 12 2.2.2.1 configuration of timing generator 2.2.2.2 machine cycle 2.2.3 operation mode control circuit .............................................................................................................. 13 2.2.3.1 single-clock mode 2.2.3.2 dual-clock mode 2.2.3.3 stop mode 2.2.4 operating mode control ......................................................................................................................... 18 2.2.4.1 stop mode 2.2.4.2 idle1/2 mode and sleep1/2 mode 2.2.4.3 idle0 and sleep0 modes (idle0, sleep0) 2.2.4.4 slow mode 2.3 reset circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 2.3.1 external reset input ............................................................................................................................... 31 2.3.2 address trap reset ............................................................................................................................... ... 32 2.3.3 watchdog timer reset .............................................................................................................................. 32 2.3.4 system clock reset ............................................................................................................................... ... 32 3. interrupt control circuit 3.1 interrupt latches (il19 to il2) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 3.2 interrupt enable register (eir) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 3.2.1 interrupt master enable flag (imf) .......................................................................................................... 36 3.2.2 individual interrupt enable flags (ef19 to ef4) ...................................................................................... 37 note 3: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 3.3 interrupt sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.3.1 interrupt acceptance processing is packaged as follows. ....................................................................... 39 3.3.2 saving/restoring general-purpose registers ............................................................................................ 40 3.3.2.1 using push and pop instructions 3.3.2.2 using data transfer instructions 3.3.3 interrupt return ........................................................................................................................................ 41 3.4 software interrupt (intsw) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.4.1 address error detection .......................................................................................................................... 42 3.4.2 debugging .............................................................................................................................................. 42 ii 3.5 undefined instruction interrupt (intundef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.6 address trap interrupt (intatrap) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.7 external interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4. special function r egister (sfr) 4.1 sfr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 4.2 dbr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 5. i/o ports 5.1 port p1 (p17 to p10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 5.2 port p2 (p22 to p20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 5.3 port p3 (p37, p34 to p33) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 5.4 port p5 (p57 to p50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 5.5 port p6 (p64 to p61) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 5.6 port p7 (p76 to p70) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 6. watchdog timer (wdt) 6.1 watchdog timer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 6.2 watchdog timer control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 6.2.1 malfunction detection methods using the watchdog timer ................................................................... 64 6.2.2 watchdog timer enable ......................................................................................................................... 65 6.2.3 watchdog timer disable ........................................................................................................................ 66 6.2.4 watchdog timer interrupt (intwdt) ...................................................................................................... 66 6.2.5 watchdog timer reset ........................................................................................................................... 67 6.3 address trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 6.3.1 selection of address trap in internal ram (atas) ................................................................................ 68 6.3.2 selection of operation at address trap (atout) .................................................................................. 68 6.3.3 address trap interrupt (intatrap) ....................................................................................................... 68 6.3.4 address trap reset ............................................................................................................................... . 69 7. time base timer (tbt) 7.1 time base timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 7.1.1 configuration .......................................................................................................................................... 71 7.1.2 control .................................................................................................................................................... 71 7.1.3 function .................................................................................................................................................. 72 7.2 divider output (dvo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 7.2.1 configuration .......................................................................................................................................... 73 7.2.2 control .................................................................................................................................................... 73 8. 18-bit timer/counter (tc1) 8.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 8.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 8.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 8.3.1 timer mode ............................................................................................................................................. 79 iii 8.3.2 event counter mode ............................................................................................................................... 80 8.3.3 pulse width measurement mode ............................................................................................................ 81 8.3.4 frequency measurement mode .............................................................................................................. 82 9. 8-bit timercounter (tc5, tc6) 9.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 9.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 9.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 9.3.1 8-bit timer mode (tc5 and 6) ................................................................................................................ 91 9.3.2 8-bit event counter mode (tc5, 6) ........................................................................................................ 92 9.3.3 8-bit programmable divider ou tput (pdo) mode (tc5, 6) ..................................................................... 92 9.3.4 8-bit pulse width modulation (pwm) output mode (tc5, 6) .................................................................. 95 9.3.5 16-bit timer mode (tc5 and 6) .............................................................................................................. 97 9.3.6 16-bit event counter mode (tc5 and 6) ................................................................................................ 98 9.3.7 16-bit pulse width modulation (pwm) output mode (tc5 and 6) .......................................................... 98 9.3.8 16-bit programmable pulse generate (ppg) output mode (tc5 and 6) ............................................. 101 9.3.9 warm-up counter mode ....................................................................................................................... 103 9.3.9.1 low-frequency warm-up counter mode (normal1 9.3.9.2 high-frequency warm-up counter mode (slow1 10. real-time clock 10.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 10.2 control of the rtc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 10.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 11. asynchronous serial interface (uart ) 11.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 11.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 11.3 transfer data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 11.4 transfer rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 11.5 data sampling method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 11.6 stop bit length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 11.7 parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 11.8 transmit/receive operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 11.8.1 data transmit operation .................................................................................................................... 112 11.8.2 data receive operation ..................................................................................................................... 112 11.9 status flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 11.9.1 parity error ............................................................................................................................... ........... 113 11.9.2 framing error ............................................................................................................................... ....... 113 11.9.3 overrun error ............................................................................................................................... ....... 113 11.9.4 receive data buffer full ..................................................................................................................... 114 11.9.5 transmit data buffer empty ............................................................................................................... 114 11.9.6 transmit end flag .............................................................................................................................. 115 12. synchronous serial interface (sio) 12.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 12.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 iv 12.3 serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 12.3.1 clock source ............................................................................................................................... ........ 119 12.3.1.1 internal clock 12.3.1.2 external clock 12.3.2 shift edge ............................................................................................................................... ............. 121 12.3.2.1 leading edge 12.3.2.2 trailing edge 12.4 number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 12.5 number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 12.6 transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 12.6.1 4-bit and 8-bit transfer modes ............................................................................................................. 122 12.6.2 4-bit and 8-bit receive modes ............................................................................................................. 124 12.6.3 8-bit transfer / receive mode ............................................................................................................... 125 13. 8-bit ad converter (adc) 13.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 13.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 13.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130 13.3.1 ad conveter operation ...................................................................................................................... 130 13.3.2 ad converter operation ..................................................................................................................... 130 13.3.3 stop and slow mode during ad conversion ................................................................................. 131 13.3.4 analog input voltage and ad conversion result ............................................................................... 132 13.4 precautions about ad converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 13.4.1 restrictions for ad conversion interrupt (intadc) usage ................................................................. 133 13.4.2 analog input pin voltage range ........................................................................................................... 133 13.4.3 analog input shared pins .................................................................................................................... 133 13.4.4 noise countermeasure ........................................................................................................................ 133 14. key-on wakeup (kwu) 14.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 14.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 14.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 15. lcd driver 15.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 15.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 15.2.1 lcd driving methods .......................................................................................................................... 139 15.2.2 frame frequency ............................................................................................................................... .. 140 15.2.3 lcd drive voltage ............................................................................................................................... 141 15.2.4 adjusting the lcd panel drive capability ............................................................................................ 141 15.3 lcd display operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 15.3.1 display data setting ............................................................................................................................ 14 2 15.3.2 blanking ............................................................................................................................... ............... 142 15.4 control method of lcd driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 15.4.1 initial setting ............................................................................................................................... ......... 143 15.4.2 store of display data ........................................................................................................................... 143 15.4.3 example of lcd driver output ............................................................................................................. 145 16. otp operation v 16.1 operating mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 16.1.1 mcu mode ............................................................................................................................... ........... 151 16.1.1.1 program memory 16.1.1.2 data memory 16.1.1.3 input/output circuiry 16.1.2 prom mode ............................................................................................................................... ........ 153 16.1.2.1 programming flowchart (high-speed program writing) 16.1.2.2 program writing using a general-purpose prom programmer 17. input/output circuit 17.1 control pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 17.2 input/output ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 18. electrical characteristics 18.1 absolute maximum ratings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 18.2 recommended operating condition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 18.3 dc characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 18.4 lcd characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 18.5 ad conversion characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 18.6 ac characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 18.7 timer counter 1 input (ecin) characteristics . . . . . . . . . . . . . . . . . . . . . . . . . . 167 18.8 dc characteristics, ac characteristics (prom mode) . . . . . . . . . . . . . . . . . . . 168 18.8.1 read operation in prom mode .......................................................................................................... 168 18.8.2 program operation (high-speed) (topr = 25 ........................................................................... 169 18.9 recommended oscillating conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 18.10 handling precaution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 19. 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). vi page 1 060116ebp TMP86PH22UG 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. nevertheless, semiconductor devices in general can malfunction or fail due to their inherent el ectrical sensitivity and vulnerability 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 TMP86PH22UG the TMP86PH22UG is a single-chip 8-bit high-speed a nd high-functionality microcomputer incorporating 16384 bytes of one-time prom. it is pin-compatible w ith the tmp86ch22ug/tmp86c822ug (mask rom version). the TMP86PH22UG can realize operations equivalent to those of the tmp86ch22ug/tmp86c822ug by pro- gramming the on-chip prom. 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. 18interrupt sources (external : 5 internal : 13) 3. input / output ports (i/o : 32 pins output : 1 pin) large current output: 3pins (typ. 20ma), led direct drive 4. watchdog timer 5. prescaler - time base timer - divider output function 6. 18-bit timer/counter : 1ch - timer mode - event counter mode - pulse width measurement mode - frequency measurement mode product no. rom (eprom) ram package mask rom mcu emulation chip TMP86PH22UG 16384 bytes 512 bytes p-lqfp44-1010-0.80b tmp86ch22ug/ tmp86c822ug tmp86c923xb page 2 1.1 features TMP86PH22UG 7. 8-bit timer counter : 2 ch - timer, event counter, programmable divider output (pdo), pulse width modulation (pwm) output, programmable pulse generation (ppg) modes 8. 8-bit uart : 1 ch 9. 8-bit sio: 1 ch 10. 8-bit successive approximation type ad converter (with sample hold) analog inputs: 4ch 11. key-on wakeup : 1 ch 12. lcd driver/controller - lcd direct drive capability (max 23 seg 4 com) - 1/4,1/3,1/2duties or static drive are programmably selectable 13. clock operation single clock mode dual clock mode 14. low power consumption operation stop mode: oscillation stops. (battery/capacitor back-up.) slow1 mode: low power consumption operation usin g low-frequency clock.(high-frequency clock stop.) slow2 mode: low power consumption operation usin g low-frequency clock.(high-frequency clock oscillate.) idle0 mode: cpu stops, and only the time-based-tim er(tbt) on peripherals operate using high fre- quency clock. release by falling edge of th e source clock which is set by tbtcr page 3 TMP86PH22UG 1.2 pin assignment figure 1-1 pin assignment 1 2 3 4 5 6 7 8 9 10 11 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 34 35 36 37 38 39 40 41 42 43 44 p53 (seg20) [a3] p55 (seg18) [a5] p56 (seg17) [a6] p70 (seg15) [a8] p57 (seg16) [a7] p73 (seg12) [a11] p72 (seg13) [a10] p71 (seg14) [a9] p54 (seg19) [a4] p52 (seg21) [a2] p51 (seg22) [a1] [a12] (seg11) p74 (seg10) p75 (seg9) p76 [a13] com3 [a15] com1 [a16] com0 vlc ( pdo6/pwm6/ppg6 /tc6) p33 [ pgm ] ( pdo5/pwm5 /tc5) p34 ( dvo ) p37 [a14] com2 vss xout test vdd (xtin) p21 (xtout) p22 reset ( int5 / stop ) p20 [d1] (ecin/ain1) p61 [d2] (ecnt/ain2) p62 xin p63(ain3/ int0 )[d3] p10(seg31/rxd) p11(seg30/txd) p12(seg29/int1)[d0] p14(seg27/int3)[d6] p15(seg26/si)[d7] p16(seg25/so)[ oe ] p17(seg24/--sck)[ ce ] p50(seg23)[a0] p64(ain4/stop2)[d4] p13(seg28/int2)[d5] page 4 1.3 block diagram TMP86PH22UG 1.3 block diagram figure 1-2 block diagram page 5 TMP86PH22UG 1.4 pin names and functions the TMP86PH22UG has mcu mode and prom mode. table 1-1 shows the pin functions in mcu mode. the prom mode is explained later in a separate chapter. table 1-1 pin names and functions(1/3) pin name pin number input/output functions p17 seg24 --sck 21 io o i port17 lcd segment output 24 serial clock i/o p16 seg25 so 20 io o o port16 lcd segment output 25 serial data output p15 seg26 si 19 io o i port15 lcd segment output 26 serial data input p14 seg27 int3 18 io o i port14 lcd segment output 27 external interrupt 3 input p13 seg28 int2 17 io o i port13 lcd segment output 28 external interrupt 2 input p12 seg29 int1 16 io o i port12 lcd segment output 29 external interrupt 1 input p11 seg30 txd 15 io o i port11 lcd segment output 30 uart data output p10 seg31 rxd 14 io o i port10 lcd segment output 31 uart data input p22 xtout 7 io o port22 resonator connecting pins(32.768khz) for inputting external clock p21 xtin 6 io i port21 resonator connecting pins(32.768khz) for inputting external clock p20 stop int5 9 io i i port20 stop mode release signal input external interrupt 5 input p37 dvo 44 o o port37 divider output p34 tc5 pdo5/pwm5 43 io i o port34 tc5 input pdo5/pwm5 output p33 tc6 pdo6/pwm6/ppg6 42 io i o port33 tc6 input pdo6/pwm6/ppg6 output p57 seg16 29 io o port57 lcd segment output 16 p56 seg17 28 io o port56 lcd segment output 17 page 6 1.4 pin names and functions TMP86PH22UG p55 seg18 27 io o port55 lcd segment output 18 p54 seg19 26 io o port54 lcd segment output 19 p53 seg20 25 io o port53 lcd segment output 20 p52 seg21 24 io o port52 lcd segment output 21 p51 seg22 23 io o port51 lcd segment output 22 p50 seg23 22 io o port50 lcd segment output 23 p64 ain4 stop2 13 io i i port64 ad converter analog input 4 stop2 input p63 ain3 int0 12 io i i port63 ad converter analog input 3 external interrupt 0 input p62 ain2 ecnt 11 io i i port62 ad converter analog input 2 ecnt input p61 ain1 ecin 10 io i i port61 ad converter analog input 1 ecin input p76 seg9 36 io o port76 lcd segment output 9 p75 seg10 35 io o port75 lcd segment output 10 p74 seg11 34 io o port74 lcd segment output 11 p73 seg12 33 io o port73 lcd segment output 12 p72 seg13 32 io i port72 lcd segment output 13 p71 seg14 31 io o port71 lcd segment output 14 p70 seg15 30 io o port70 lcd segment output 15 com3 37 o lcd common output 3 com2 38 o lcd common output 2 com1 39 o lcd common output 1 com0 40 o lcd common output 0 xin 2 i resonator connecting pins for high-frequency clock table 1-1 pin names and functions(2/3) pin name pin number input/output functions page 7 TMP86PH22UG xout 3 o resonator connecting pins for high-frequency clock reset 8 i reset signal test 4 i test pin for out-going test. normally, be fixed to low. vdd 5 i +5v vss 1 i 0(gnd) table 1-1 pin names and functions(3/3) pin name pin number input/output functions page 8 1.4 pin names and functions TMP86PH22UG page 9 TMP86PH22UG 2. operational description 2.1 cpu core functions the cpu core consists of a cpu, a system cl ock controller, and an interrupt controller. this section provides a description of the cpu core, the program memory, the data memory, and the reset circuit. 2.1.1 memory address map the TMP86PH22UG memory is composed otp, ram, dbr(data buffer register) and sfr(special func- tion register). they are all mapped in 64-kbyte address space. figure 2-1 shows the TMP86PH22UG memory address map. figure 2-1 memory address map 2.1.2 program memory (otp) the TMP86PH22UG has a 16384 bytes (address c000h to ffffh) of progr am memory (otp ). sfr 0000 h 64 bytes sfr: ram: special function register includes: i/o ports peripheral control registers peripheral status registers system control registers program status word random access memory includes: data memory stack 003f h ram 0040 h 512 bytes 023f h dbr 0f80 h 128 bytes dbr: data buffer register includes: peripheral control registers peripheral status registers lcd display memory 0fff h c000 h otp: program memory otp 16384 bytes ffb0 h vector table for interrupts (16 bytes) ffbf h ffc0 h vector table for vector call instructions (32 bytes) ffdf h ffe0 h vector table for interrupts (32 bytes) ffff h page 10 2. operational description 2.2 system clock controller TMP86PH22UG 2.1.3 data memory (ram) the TMP86PH22UG has 512bytes (address 0040h to 023f h) of internal ram. the first 192 bytes (0040h to 00ffh) of the internal ram are locat ed in the direct area; instructions with shorten operations are available against such an area. the data memory contents become un stable when the power supply is turned on; therefore, the data memory should be initialized by an initialization routine. 2.2 system clock controller the system clock controller consists of a clock generator, a timing generator, and a standby controller. figure 2-2 syst em colck control 2.2.1 clock generator the clock generator generates the basic clock which pr ovides the system clocks supplied to the cpu core and peripheral hardware. it contains two oscillation ci rcuits: one for the high-frequency clock and one for the low-frequency clock. power consumption can be reduced by switching of the standby controller to low-power operation based on the low-frequency clock. the high-frequency (fc) clock and low-frequency (fs) clock can easily be obtained by connecting a resonator between the xin/xout and xtin/xtout pins respectively. clock input from an exte rnal oscillator is also possible. in this case, external clock is applied to xin/xtin pin with xout/xtout pin not connected. example :clears ram to ?00h?. (TMP86PH22UG) ld hl, 0040h ; start address setup ld a, h ; initial value (00h) setup ld bc, 01ffh sramclr: ld (hl), a inc hl dec bc jrs f, sramclr tbtcr syscr2 syscr1 xin xout xtin xtout fc 0036 h 0038 h 0039 h fs timing generator control register timing generator standby controller system clocks clock generator control high-frequency clock oscillator low-frequency clock oscillator clock generator system control registers page 11 TMP86PH22UG figure 2-3 examples of resonator connection note:the function to monitor the basic clock directly at external is not provided for hardware, however, with dis- abling all interrupts and watchdog timers, the oscillation frequency can be adjusted by monitoring the pulse which the fixed frequency is outputted to the port by the program. the system to require the adjustment of the oscilla tion frequency should create the program for the adjust- ment in advance. xout xin (open) xout xin xtout xtin (open) xtout xtin (a) crystal/ceramic resonator (b) external oscillator (c) crystal (d) external oscillator high-frequency clock low-frequency clock page 12 2. operational description 2.2 system clock controller TMP86PH22UG 2.2.2 timing generator the timing generator generates the various system cloc ks supplied to the cpu core and peripheral hardware from the basic clock (fc or fs). the timing generator provides the following functions. 1. generation of main system clock 2. generation of divider output ( dvo ) pulses 3. generation of source clocks for time base timer 4. generation of source clocks for watchdog timer 5. generation of internal source clocks for timer/counters 6. generation of warm-up clocks for releasing stop mode 7. lcd 2.2.2.1 configuration of timing generator the timing generator consists of a 2-stage prescaler, a 21-stage divider, a main system clock generator, and machine cycle counters. an input clock to the 7th stage of the divider depends on the operating mode, syscr2 page 13 TMP86PH22UG note 1: in single clock mode, do not set dv7ck to ?1?. note 2: do not set ?1? on dv7ck while the low-frequency clock is not operated stably. note 3: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *: don?t care note 4: in slow1/2 and sleep1/2 modes, the dv7ck setting is ineffective, and fs is input to the 7th stage of the divider. note 5: when stop mode is entered from normal1/2 mode, the dv 7ck setting is ineffective during the warm-up period after release of stop mode, and the 6th stage of the divider is input to the 7th stage during this period. 2.2.2.2 machine cycle instruction execution and peripheral hardware operat ion are synchronized with the main system clock. the minimum instruction execution uni t is called an ?machine cycle?. th ere are a total of 10 different types of instructions for the tlcs-870/c series: ra nging from 1-cycle instructions which require one machine cycle for execution to 10-cyc le instructions which require 10 machine cycles fo r execution. 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 operation mode control circuit the operation mode control circuit starts and stops the oscillation circuits for the high-frequency and low- frequency clocks, and switches the main system clock. there are three operating modes: single clock mode, dual clock mode and stop mode. these modes are cont rolled by the system cont rol registers (syscr1 and syscr2). figure 2-6 shows the operating mode transition diagram. 2.2.3.1 single-clock mode only the oscillation circuit for the high-frequenc y clock is used, and p21 (xtin) and p22 (xtout) pins are used as input/output ports . the main-system clock is obtained from the high-frequency clock. in the single-clock mode, the machine cycle time is 4/fc [s]. (1) normal1 mode in this mode, both the cpu core and on-chip pe ripherals operate using the high-frequency clock. the TMP86PH22UG is placed in this mode after reset. timing generator control register tbtcr (0036h) 76543210 (dvoen) (dvock) dv7ck (tbten) (tbtck) (initial value: 0000 0000) dv7ck selection of input to the 7th stage of the divider 0: fc/2 8 [hz] 1: fs r/w main system clock state machine cycle s3 s2 s1 s0 s3 s2 s1 s0 1/fc or 1/fs [s] page 14 2. operational description 2.2 system clock controller TMP86PH22UG (2) idle1 mode in this mode, the internal oscillation circuit remains active. the cpu and the watchdog timer are halted; however on-chip peripherals remain active (operate using the high-frequency clock). idle1 mode is started by syscr2 page 15 TMP86PH22UG switching back and forth between slow1 and slow2 modes are performed by syscr2 page 16 2. operational description 2.2 system clock controller TMP86PH22UG note 1: normal1 and normal2 modes are generically called no rmal; slow1 and slow2 are called slow; idle0, idle1 and idle2 are called idle; sleep0, sleep1 and sleep2 are called sleep. note 2: the mode is released by fa lling edge of tbtcr page 17 TMP86PH22UG note 1: always set retm to ?0? when transiting from normal mode to stop mode. always set retm to ?1? when transiting from slow mode to stop mode. note 2: when stop mode is released with reset pin input, a return is made to normal1 regardless of the retm contents. note 3: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *; don?t care note 4: bits 1 and 0 in syscr1 are read as undefined data when a read instruction is executed. note 5: as the hardware becomes stop mode under outen = ?0?, input value is fixed to ?0?; therefore it may cause external interrupt request on account of falling edge. note 6: when the key-on wakeup is used, relm should be set to "1". note 7: port p20 is used as stop pin. therefore, when stop mode is started, outen does not affect to p20, and p20 becomes high-z mode. note 8: the warmig-up time should be set correctly for using oscillator. note 1: a reset is applied if both xen and xten are cleared to ?0?, xen is cleared to ?0? when sysck = ?0?, or xten is cleared to ?0? when sysck = ?1?. note 2: *: don?t care, tg: timing generator, *; don?t care note 3: bits 3, 1 and 0 in syscr2 are always read as undefined value. note 4: do not set idle and tghalt to ?1? simultaneously. note 5: because returning from idle0/sleep0 to normal1/slow 1 is executed by the asynchronous internal clock, the period of idle0/sleep0 mode might be shorter than the period setting by tbtcr page 18 2. operational description 2.2 system clock controller TMP86PH22UG 2.2.4 operating mode control 2.2.4.1 stop mode stop mode is controlled by the system control register 1, the stop pin input and key-on wakeup input (stop2) which is controlled by the stop mode release control register (stopcr). the stop pin is also used both as a port p20 and an int5 (external interrupt input 5) pin. stop mode is started by setting syscr1 page 19 TMP86PH22UG figure 2-7 level-s ensitive release mode note 1: even if the stop pin input is low after warm-up start, the stop mode is not restarted. note 2: in this case of changing to the level-s ensitive mode from the edge-s ensitive mode, the release mode is not switched until a rising edge of the stop pin input is detected. (2) edge-sensitive release mode (relm = ?0?) in this mode, stop mode is released by a rising edge of the stop pin input. this is used in appli- cations where a relatively short pr ogram is executed repeat edly at periodic intervals. this periodic signal (for example, a clock from a low-power consumption oscillator) is input to the stop pin. in the edge-sensitive release mode, stop mode is started even when the stop pin input is high level. do not use any stop2 pin input for releasing stop mode in edge-sensitive release mode. figure 2-8 edge-sensitive release mode example 2 :starting stop mode from normal mode with an int5 interrupt. pint5: test (p2prd). 0 ; to reject noise, stop mode does not start if jrs f, sint5 port p20 is at high ld (syscr1), 01010000b ; sets up the level-sensitive release mode. di ; imf example :starting stop mode from normal mode di ; imf v ih normal operation warm up stop operation confirm by program that the stop pin input is low and start stop mode. always released if the stop pin input is high. stop pin xout pin stop mode is released by the hardware. normal operation normal operation normal operation v ih stop mode is released by the hardware at the rising edge of stop pin input. warm up stop mode started by the program. stop operation stop operation stop pin xout pin page 20 2. operational description 2.2 system clock controller TMP86PH22UG stop mode is released by the following sequence. 1. in the dual-clock mode, when returning to normal2, both the high-frequency and low- frequency clock oscillators are turned on; when returning to slow1 mode, only the low- frequency clock oscillator is turned on. in the single-clock mode, only the high-frequency clock oscillator is turned on. 2. a warm-up period is inserted to allow oscillation time to stabilize. during warm up, all internal operations remain halted. four differ ent warm-up times can be selected with the syscr1 page 21 TMP86PH22UG figure 2-9 stop mode start/release instruction address a + 4 0 instruction address a + 3 turn on turn on warm up 0 n halt set (syscr1). 7 turn off (a) stop mode start (example: start with set (syscr1). 7 instruction located at address a) a + 6 a + 5 a + 4 a + 3 a + 2 n + 2 n + 3 n + 4 a + 3 n + 1 instruction address a + 2 2 1 0 3 (b) stop mode release count up turn off halt oscillator circuit program counter instruction execution divider main system clock oscillator circuit stop pin input program counter instruction execution divider main system clock page 22 2. operational description 2.2 system clock controller TMP86PH22UG 2.2.4.2 idle1/2 mode and sleep1/2 mode idle1/2 and sleep1/2 modes are controlled by the system control register 2 (syscr2) and maskable interrupts. the following status is maintained during these modes. 1. operation of the cpu and watchdog timer (wdt) is halted. on-chip peripherals continue to operate. 2. the data memory, cpu registers, program status word and port output latches are all held in the status in effect before these modes were entered. 3. the program counter holds the address 2 ahead of th e instruction which starts these modes. figure 2-10 idle1/ 2 and sleep1/2 modes reset reset input ?0? ?1? (interrupt release mode) yes no no cpu and wdt are halted interrupt request imf interrupt processing normal release mode yes starting idle1/2 and sleep1/2 modes by instruction execution of the instruc- tion which follows the idle1/2 and sleep1/2 modes start instruction page 23 TMP86PH22UG ? start the idle1/2 and sleep1/2 modes after imf is set to "0", set the individual inte rrupt enable flag (ef) which releases idle1/2 and sleep1/2 modes. to start idle1/2 and sl eep1/2 modes, set syscr2 page 24 2. operational description 2.2 system clock controller TMP86PH22UG figure 2-11 idle1/2 and sleep1/2 modes start/release halt halt halt halt operate instruction address a + 2 a + 3 a + 2 a + 4 a + 3 a + 3 halt set (syscr2). 4 operate operate operate acceptance of interrupt ?r:wnormal release mode ?s:winterrupt release mode main system clock interrupt request program counter instruction execution watchdog timer main system clock interrupt request program counter instruction execution watchdog timer main system clock interrupt request program counter instruction execution watchdog timer (a) idle1/2 and sleep1/2 modes start (example: star ting with the set instruction located at address a) (b) idle1/2 and sleep1/2 modes release page 25 TMP86PH22UG 2.2.4.3 idle0 and sleep0 modes (idle0, sleep0) idle0 and sleep0 modes are controlled by the system control register 2 (syscr2) and the time base timer control register (tbtcr). the following stat us is maintained during idle0 and sleep0 modes. 1. timing generator stops feeding clock to peripherals except tbt. 2. the data memory, cpu registers, program status word and port output latches are all held in the status in effect before idle0 and sleep0 modes were entered. 3. the program counter holds the address 2 ahead of the instru ction which starts idle0 and sleep0 modes. note: before starting idle0 or sleep0 mode, be sure to stop (disable) peripherals. figure 2-12 idle 0 and sleep0 modes yes (normal release mode) yes (interrupt release mode) no yes reset input cpu and wdt are halted reset tbt source clock falling edge tbtcr page 26 2. operational description 2.2 system clock controller TMP86PH22UG ? start the idle0 and sleep0 modes stop (disable) peripherals such as a timer counter. to start idle0 and sleep0 modes, set syscr2 page 27 TMP86PH22UG figure 2-13 idle0 and slee p0 modes start/release halt halt operate instruction address a + 2 halt operate set (syscr2). 2 halt operate acceptance of interrupt halt ?r:wnormal release mode ?s:winterrupt release mode main system clock interrupt request program counter instruction execution watchdog timer main system clock tbt clock tbt clock program counter instruction execution watchdog timer main system clock program counter instruction execution watchdog timer a + 3 a + 2 a + 4 a + 3 a + 3 (a) idle0 and sleep0 modes start (example: starting with the set instruction located at address a (b) idle and sleep0 modes release page 28 2. operational description 2.2 system clock controller TMP86PH22UG 2.2.4.4 slow mode slow mode is controlled by the sy stem control register 2 (syscr2). the following is the methods to switch the mode with the warm-up counter. (1) switching from normal2 mode to slow1 mode first, set syscr2 page 29 TMP86PH22UG (2) switching from slow1 mode to normal2 mode note: after sysck is cleared to ?0?, executing the in structions is continiued by the low-frequency clock for the period synchronized with low-frequency and high-frequency clocks. first, set syscr2 page 30 2. operational description 2.2 system clock controller TMP86PH22UG figure 2-14 switching between the normal2 and slow modes set (syscr2). 7 normal2 mode clr (syscr2). 7 set (syscr2). 5 normal2 mode turn off (a) switching to the slow mode slow1 mode slow2 mode clr (syscr2). 5 (b) switching to the normal2 mode high- frequency clock low- frequency clock main system clock instruction execution sysck xen high- frequency clock low- frequency clock main system clock instruction execution sysck xen slow1 mode warm up during slow2 mode page 31 TMP86PH22UG 2.3 reset circuit the TMP86PH22UG has four types of reset generation proce dures: an external reset in put, an addres s trap reset, a watchdog timer reset and a system cloc k reset. of these reset, the address trap reset, the watchdog timer and the system clock reset are a malfunction re set. when the malfunction reset request is detected, reset occurs during the maximum 24/fc[s]. the malfunction reset circuit such as watchdog timer reset, address trap reset and system clock reset is not initial- ized when power is turned on. therefore, reset may occur during maximum 24/fc[s] (1.5 s at 16.0 mhz) when power is turned on. table 2-3 shows on-chip hardware initialization by reset action. 2.3.1 external reset input the reset pin contains a schmitt trigger (hysteresis) with an internal pull-up resistor. when the reset pin is held at ?l? level for at least 3 machin e cycles (12/fc [s]) wi th the power supply volt- age within the operating voltage range and oscillation stab le, a reset is applied and the internal state is initial- ized. when the reset pin input goes high, the reset operation is rele ased and the program execution starts at the vector address stored at addresses fffeh to ffffh. figure 2-15 reset circuit table 2-3 initializing internal status by reset action on-chip hardware initial value on-chip hardware initial value program counter (pc) (fffeh) prescaler and divider of timing generator 0 stack pointer (sp) not initialized general-purpose registers (w, a, b, c, d, e, h, l, ix, iy) not initialized jump status flag (jf) not initialized watchdog timer enable zero flag (zf) not initialized output latches of i/o ports refer to i/o port circuitry 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 flags (ef) 0 control registers refer to each of control register interrupt latches (il) 0 lcd data buffer not initialized ram not initialized internal reset reset vdd malfunction reset output circuit watchdog timer reset address trap reset system clock reset page 32 2. operational description 2.3 reset circuit TMP86PH22UG 2.3.2 address trap reset if the cpu should start looping for some cause such as noise and an attempt be made to fetch an instruction from the on-chip ram (when wdtcr1 page 33 TMP86PH22UG page 34 2. operational description 2.3 reset circuit TMP86PH22UG page 35 TMP86PH22UG 3. interrupt control circuit the TMP86PH22UG has a total of 18 interrupt sources excl uding reset. interrupts can be nested with priorities. four of the internal interrupt sources ar e 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: to use the address trap interrupt (intatrap), clear wdtcr1 page 36 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86PH22UG the interrupt latches are located on address 002eh, 003ch and 003dh in sfr area. each latch can be cleared to "0" individually by instruction. however, il2 and il3 sh ould 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 instru ctions are used, interrupt re quest would be cleared inade- quately if interrupt is requested while such instructions are executed. interrupt latches are not set to ?1? by an instruction. since interrupt latches can be read, the status 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 002ch, 003ah and 003bh in sfr area, and they can be read and written by an instructions (including read-modify-write instructions such as bit manipulation or operation instructions). 3.2.1 interrupt 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 example 2 :reads interrupt latchess ld wa, (ill) ; w example 3 :tests interrupt latches test (ill). 7 ; if il7 = 1 then jump jr f, sset page 37 TMP86PH22UG 3.2.2 individual interrupt enable flags (ef19 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 individual interrupt enable flags (ef19 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 example 2 :c compiler description example unsigned int _io (3ah) eirl; /* 3ah shows eirl address */ _di(); eirl = 10100000b; : _ei(); page 38 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86PH22UG 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) (initial value: ****0000) ile (002eh) 76543210 ???? ???? page 39 TMP86PH22UG 3.3 interrupt sequence an interrupt request, which raised interrupt latch, is held, until interrupt is accepted or interrupt latch is cleared to ?0? by resetting or an 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.3.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. 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 and the entry address of the interrupt service program figure 3-2 vector table address,entry address 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 fff2h fff3h page 40 3. interrupt control circuit 3.3 interrupt sequence TMP86PH22UG 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.3.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. 3.3.2.1 using push and pop instructions if only a specific register is saved or interrupts of the same source are nested , general-purpose registers can be saved/restored using the push/pop instructions. figure 3-3 save/store register using push and pop instructions 3.3.2.2 using data transfer instructions to save only a specific register 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 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 41 TMP86PH22UG figure 3-4 saving/restoring general-purpose r egisters under interrupt processing 3.3.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. 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 [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 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 42 3. interrupt control circuit 3.4 software interrupt (intsw) TMP86PH22UG interrupt requests are sampled during the final cycle of the instruction being executed. thus, the next inter- rupt can be accepted immediately after the interrupt retu rn instruction is executed. 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.4 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.4.1 address error detection ffh is read if for some cause such as noise the cpu attempts to fetch an instruction from a non-existent memory address during single chip mode. code ffh is 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.4.2 debugging debugging efficiency can be increased by placing the swi instruction at the software break point setting address. 3.5 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.6 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). 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 page 43 TMP86PH22UG 3.7 external interrupts the TMP86PH22UG has 5 external interrupt inputs. these in puts 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 int3. the int0 /p63 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 /p63 pin function selection are performed by the external interrupt control register (eintcr). 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 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. 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 ? ef9 = 1 falling edge or rising edge pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are consid- ered to be signals. int3 int3 imf ? ef17 = 1 falling edge or rising edge pulses of less than 7/fc [s] are eliminated as noise. pulses of 25/fc [s] or more are considered to be signals. in the slow or the sleep mode, pulses of less than 1/fs [s] are eliminated as noise. pulses of 3.5/fs [s] or more are consid- ered to be signals. int5 int5 imf ? ef19 = 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 44 3. interrupt control circuit 3.7 external interrupts TMP86PH22UG 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. external interrupt control register eintcr76543210 (0037h) int1nc int0en - - int3es int2es int1es (initial value: 00** 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 p63/ int0 pin configuration 0: p63 input/output port 1: int0 pin (port p63 should be set to an input mode) 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 45 TMP86PH22UG 4. special function register (sfr) the TMP86PH22UG adopts the memory mapped i/o system, and all periphe ral control and data transfers are per- formed through the special function register (sfr) or the data buffer register (dbr). the sfr is mapped on address 0000h to 003fh, dbr is mapped on address 0f80h to 0fffh. this chapter shows the arrangement of the special functi on register (sfr) and data buffer register (dbr) for TMP86PH22UG. 4.1 sfr address read write 0000h reserved 0001h p1dr 0002h p2dr 0003h p3dr 0004h p3outcr 0005h p5dr 0006h p6dr 0007h p7dr 0008h reserved 0009h p1cr 000ah p5cr 000bh p6cr1 000ch p6cr2 000dh p7cr 000eh adccr1 000fh adccr2 0010h treg1al 0011h treg1am 0012h treg1ah 0013h treg1b 0014h tc1cr1 0015h tc1cr2 0016h tc1sr - 0017h rtccr 0018h reserved 0019h reserved 001ah tc5cr 001bh tc6cr 001ch reserved 001dh reserved 001eh ttreg5 001fh ttreg6 0020h adcdr2 - 0021h adcdr1 - 0022h reserved 0023h reserved 0024h reserved 0025h uartsr uartcr1 page 46 4. special function register (sfr) 4.1 sfr TMP86PH22UG note 1: do not access reserved areas by the program. note 2: ? page 47 TMP86PH22UG 4.2 dbr address read write 0f80h reserved 0f81h reserved 0f82h reserved 0f83h reserved 0f84h seg9 0f85h seg11/10 0f86h seg13/12 0f87h seg15/14 0f88h seg17/16 0f89h seg19/18 0f8ah seg21/20 0f8bh seg23/22 0f8ch seg25/24 0f8dh seg27/26 0f8eh seg29/28 0f8fh seg31/30 0f90h siobr0 0f91h siobr1 0f92h siobr2 0f93h siobr3 0f94h siobr4 0f95h siobr5 0f96h siobr6 0f97h siobr7 0f98h - siocr1 0f99h siosr siocr2 0f9ah - stopcr 0f9bh rdbuf tdbuf 0f9ch p2prd - 0f9dh p3prd - 0f9eh p1lcr 0f9fh p5lcr page 48 4. special function register (sfr) 4.2 dbr TMP86PH22UG note 1: do not access reserved areas by the program. note 2: ? page 49 TMP86PH22UG 5. i/o ports the TMP86PH22UG have 6 parallel input /output ports (33 pins) as follows. 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) primary function secondary functions port p1 8-bit i/o port external interrupt input, uart input/output, serial interface input/output and segment output. port p2 3-bit i/o port low-frequency resonator connections, external interrupt input, stop mode release signal input. port p3 2-bit i/o port 1-bit output port timer/counter input/output and divider output. port p5 8-bit i/o port lcd segment output. port p6 4-bit i/o port analog input, external interrupt input, timer/counter input and stop mode release signal input. port p7 7-bit i/o port lcd segment output. 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 old new 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 50 5. i/o ports 5.1 port p1 (p17 to p10) TMP86PH22UG 5.1 port p1 (p17 to p10) port p1 is an 8-bit input/output port which can be configured as an input or an output in one-bit unit. input/output mode is specified by the p1 control register (p1cr). during reset, the p1dr, p1cr an d p1lcr are initi alized to ?0?. port p1 is also used as uart input/output, an external interrupt input, serial in terface input/output and segment output of lcd. it is necessary to set registers for using each function. the following table shows register program- ming for multi function ports. when the port p16 is used, set not only p16 port registers but also p31 port register. also set not only port p17 registers but also p32 regist er similarly. though the TMP86PH22UG do not have p31 and p32 ports, it is necessary to set p3 port registers for keeping software compatibility with tmp86c923xb. for detail, refer to table 5-2 and table 5-3 and then refer to description of p3outcr and p3dr registers. note: asterisk (*) indicates "1" or "0" either of which can be selected. note 1: when p16 is used as port output, set in order each register s as follows. if it is not set appropriately, an overcurrent may flow causing damage to the emulation chip (86c923xb). step 1. p3outcr page 51 TMP86PH22UG note 1: when p17 is used as port output, set in order each register s as follows. if it is not set appropriately, an overcurrent may flow causing damage to the emulation chip (86c923xb). step 1. p3outcr page 52 5. i/o ports 5.1 port p1 (p17 to p10) TMP86PH22UG figure 5-2 port 1 note 1: when p16 and p17 is used as port output or sio output, set in order each registers according to notes of table 5-2 and table 5-3. note 2: the port placed in input mode reads the pin input stat e. therefore, when the input and output modes are used together, the output latch (p1dr) contents for the port in input mode might be changed by executing a bit manipulation instruction. p1dr (0001h) r/w 76543210 p17 seg24 sck p16 seg25 so p15 seg26 si p14 seg27 int3 p13 seg28 int2 p12 seg29 int1 p11 seg30 txd p10 seg31 rxd (initial value: 0000 0000) p1lcr (0f9eh) 76543210 (initial value: 0000 0000) p1lcr port p1/segment output control (set for each bit individually) 0: p1 input/output port or secondary function (expect for segment) 1: segment output r/w p1cr (0009h) 76543210 (initial value: 0000 0000) p1cr p1 port input/output control (set for each bit individually) 0: input mode, so output or sck output 1: output mode r/w stop outen p1lcri input p1lcr[i] p1cr[i] input p1cr[i] p1i output latch txd output so output p3outcr page 53 TMP86PH22UG 5.2 port p2 (p22 to p20) port p2 is a 3-bit input/output port. it is also used as an external interr upt, a stop mode release signal input, and low-frequency crys tal oscillator con- nection pins. when used as an input port or a secondary function pins, respective output latch (p2dr) should be set to ?1?. during reset, the output latch is initialized to ?1?. a low-frequency crystal osci llator (32.768 khz) is connected to pins p21 (xtin) and p22 (xtout) in the dual- clock mode. in the single-clock mode, pins p21 and p22 can be used as normal input/output ports. it is recommended that pin p20 should be used as an exte rnal interrupt input, a stop mode release signal input, or an input port. if it is used as an output port, the in terrupt latch is set on the falling edge of the output pulse. p2 port output latch (p2dr) and p2 port terminal input (p2prd) are located on their respective address. when read the output latch data, the p2dr register should be read and when read the terminal input data, the p2prd register should be read. if a read instruction is executed for port p2, r ead data of bits 7 to 3 are unstable. figure 5-3 port 2 note: port p20 is used as stop pin. therefore, when stop mode is started, outen does not affect to p20, and p20 becomes high-z mode. p2dr (0002h) r/w 76543210 p22 xtout p21 xtin p20 int5 stop (initial value: **** *111) p2prd (0f9ch) read only 76543210 p22 p21 p20 output latch output latch output latch data input (p2prd[0]) data input data output (p2dr[1]) data output (p2dr[0]) data input second function input data input (p2prd[1]) data input data input (p2prd[2]) data output (p2dr[2]) stop outen xten note1 : stop is bit7 in syscr1. note2 : outen is bit4 in syscr1. fs p22 (xtout) p21 (xtin) p20 (int5, stop) osc. enable d q d q d q page 54 5. i/o ports 5.3 port p3 (p37, p34 to p33) TMP86PH22UG 5.3 port p3 (p37, p34 to p33) port p3 is a 1-bit output and a 2-bit input/output port. it can be selected whether output circuit of p34 to p33 port is c-mos output or a sink open drain individually, by setting p3outcr. when a corresponding bit of p3outcr is ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p3 outcr is ?1?, the output circuit is selected to a c-mos output. during reset, the p3dr is initialized to "1", and the p3outcr is initialized to "0". port p3 is also used as a timer/counter input/output, di vider output. it is necessary to set registers for using each function. the following table shows register programming for multi function ports. p3 port output latch (p3dr) and p3 port terminal in put (p3prd) are located on th eir respective address. when read the output latch data, the p3dr should be read and when read the terminal input data, the p3prd register should be read. if a read instruction is executed for each regi sters of p3 port, read data of reserved bits are unstable. figure 5-4 port 3 table 5-5 register programming for p34 to p33 function (port p34 to p33) programmed value p3dr[4:3] p3outcr[4:3] port input or timer counter input "1" "0" port "0" output "0" programming for each applications port "1" output or timer counter output "1" table 5-6 register programming for p37 function (port p37) programmed value p3dr[7] port "0" output "0" port "1" output or divider output "1" data output (p3dr[i]) second function output stop outen p3outcr[i] dq p3i p3outcr[i] input data input (p3prd[i]) output latch read (p3dr[i]) second function input dq output latch a) p34, p33 data output (p3dr[7]) second function output stop note1 : i = 4,3 note2 : stop is bit7 in syscr1. note3 : outen is bit4 in syscr1. outen dq p37 p3outcr[7] output latch b) p37 page 55 TMP86PH22UG note 1: make sure to write "1" to bit2 to bit0 in p3dr. note 2: if a read instruction is executed for p3dr, read data of bits 6 to 5 and bit 2 to 0 are unstable. note 1: when p16 and p17 is used as port output or sio output, set in order each registers according to notes of table 1-2 and table 1-3. note 2: if a read instruction is executed for p3outcr, read data of bits 7 to 5 and bit 0 are unstable. note 3: make sure to write "0" to bit 0 in p3outcr. note 1: if a read instruction is executed for p3prd, read data of bits 7 to 5 and bits 2 to 0 are unstable. p3dr (0003h) r/w 76543210 p37 dvo p34 pwm5 pdo5 tc5 p33 pwm6 pdo6 ppg6 tc6 "1" "1" "1" (initial value: 1**1 1***) p3outcr (0004h) 76543210 p34 p33 sioen2 sioen1 "0" (initial value: **** 0000) p34, p33 port p3 output circuit control (set for each bit individually) 0: sink open-drain output 1: c-mos output r/w sioen2 port p17 control 0: sck input, port input, port output or lcd output 1: sck output sioen1 port p16 control 0: port input, port output or lcd output 1: so output p3prd (0f9dh) read only 76543210 p34 p33 page 56 5. i/o ports 5.4 port p5 (p57 to p50) TMP86PH22UG 5.4 port p5 (p57 to p50) port p5 is an 8-bit input/output port which can be configured as an input or an output in one-bit unit. input/output mode is spedified by the p5 control register (p5cr). during reset, the p5dr, p5cr an d p5lcr are initi alized to ?0?. port p5 is also used as a segment out put of lcd. it is necessary to set re gisters for using each function. the fol- lowing table shows register programming for multi function ports. note: asterisk (*) indicates "1" or "0" either of which can be selected. figure 5-5 port 5 table 5-7 register programming for p57 to p50 function (port p57 to p50) programmed value p5dr[7:0] p5cr[7:0] p5lcr[7:0] port input * "0" "0" port "0" output "0" "1" "0" port "1" output and uart output "1" "1" "0" lcd segment output * * "1" table 5-8 values read from p5dr and register programming conditions values read from p5dr p5cr p5lcr "0" "0" terminal input data "0" "1" "0" "1" "0" output latch contents "1" stop outen p5lcr[i] input p5lcr[i] p5cr[i] input p5cr[i] p5i output latch note1 : i = 7 to 0 note2 : stop is bit7 in syscr1 note3 : outen is bit4 in syscr1 dq lcd data output data input (p5dr[i]) data output (p5dr[i]) dq dq page 57 TMP86PH22UG note: the port placed in input mode reads the pin input state. t herefore, when the input and output modes are used together, the output latch (p5dr) contents for the port in input m ode might be changed by executing a bit manipulation instruction. p5dr (0005h) r/w 76543210 p57 seg16 p56 seg17 p55 seg18 p54 seg19 p53 seg20 p52 seg21 p51 seg22 p50 seg23 (initial value: 0000 0000) p5lcr (0f9fh) 76543210 (initial value: 0000 0000) p5lcr port p5/segment output control (set for each bit individually) 0: p5 input/output port 1: lcd segment output r/w p5cr (000ah) 76543210 (initial value: 0000 0000) p5cr p5 port input/output control (set for each bit individually) 0: input mode 1: output mode r/w page 58 5. i/o ports 5.5 port p6 (p64 to p61) TMP86PH22UG 5.5 port p6 (p64 to p61) port p6 is an 4-bit input/output port which can be configured as an input or an output in one-bit unit. input/output mode is specified by the p6 control register (p6cr1) and input control register (p6cr2). during reset, the output latch (p6dr) and p6cr1 are initialized to "0", p6cr2 is initialized to "1". port p6 is also used as an analog input, key on wake up input, timer/counter input and external interrupt input. it is necessary to set registers for usi ng each function. the follow ing table shows register programming for multi func- tion ports. note: asterisk (*) indicates "1" or "0" either of which can be selected. table 5-9 register programming for p64 to p61 function (port p64 to p61) programmed value p6dr[4:1] p6cr1[4:1] p6cr2[4:1] port input, external interrupt input or timer counter input *"0""1" analog input or key on wake up input * "0" "0" port "0" output "0" "1" * port "1" output "1" "1" * table 5-10 values read from p6dr and register programming conditions values read from p6dr p6cr1 p6cr2 "0" "0" "0" "0" "1" terminal input data "1" "0" output latch contents "1" page 59 TMP86PH22UG figure 5-6 port 6 and p6cr note 1: make sure to write "0" to bit7 to bit5, bit0 in p6cr1. p6dr (0006h) r/w 76543210 p64 ain4 stop2 p63 ain3 int0 p62 ain2 ecnt p61 ain1 ecin (initial value: ***0 000*) p6cr1 (000bh) 76543210 "0" "0" "0" "0" (initial value: ***0 000*) p6cr1 i/o control for port p6 (specified for each bit) 0: port input, key on wake up input, analog input, external input or timer counter input 1: port output r/w p6cr2 (000ch) 76543210 (initial value: ***1 111*) p6cr2 p6 port input control (specified for each bit) 0: analog input or key on wake up input 1: port input, external interrupt input or timer counter input r/w p6i dq dq p6cr2[i] p6cr2[i] input p6cr1[i] p6cr1[i] input data input (p6dr[i]) data output (p6dr[i]) stop outen analog input ainds sain note1 : i = 3 to 1 note2 : stop is bit 7 in syscr1. note3 : sain is ad input select signal. note4 : stop2en is bit4 in stopcr. dq second function input p64 dq dq p6cr2[4] p6cr2[4] input p6cr1[4] p6cr1[4] input data output (p6dr[4]) stop outen analog input ainds stop2 key-on wakeup dq data input (p6dr[4]) a) p63 to p61 sain b) p64 page 60 5. i/o ports 5.6 port p7 (p76 to p70) TMP86PH22UG 5.6 port p7 (p76 to p70) port p7 is a 7-bit input/output port which can be configur ed as an input or an output in one-bit unit. input/output mode is spedified by the p7 control register (p7cr). during reset, the p7dr, p7cr an d p7lcr are initi alized to ?0?. port p7 is also used as a segment out put of lcd. it is necessary to set re gisters for using each function. the fol- lowing table shows register programming for multi function ports. note: asterisk (*) indicates "1" or "0" either of which can be selected. figure 5-7 port 7 table 5-11 register programming for p76 to p70 function (port p76 to p70) programmed value p7dr[6:0] p7cr[6:0] p7lcr[6:0] port input * "0" "0" port "0" output "0" "1" "0" port "1" output and uart output "1" "1" "0" lcd segment output * * "1" table 5-12 values read from p7dr and register programming conditions values read from p7dr p7cr p7lcr "0" "0" terminal input data "0" "1" "0" "1" "0" output latch contents "1" stop outen p7lcr[i] input p7lcr[i] p7cr[i] input p7cr[i] p7i output latch dq lcd data output note1 : i = 6 to 0 note2 : stop is bit7 in syscr1. note3 : outen is bit4 in syscr1. data input (p7dr[i]) data output (p7dr[i]) dq dq page 61 TMP86PH22UG note: because the lcd driver does not operate co rrectly, always set "0" to bit7 of p7lcr. note: the port placed in input mode reads the pin input state. t herefore, when the input and output modes are used together, the output latch (p7dr) contents for the port in input m ode might be changed by executing a bit manipulation instruction. p7dr (0007h) r/w 76543210 p76 seg9 p75 seg10 p74 seg11 p73 seg12 p72 seg13 p71 seg14 p70 seg15 (initial value: 0000 0000) p7lcr (0fa0h) 76543210 "0" (initial value: 0000 0000) p7lcr port p7/segment output control (set for each bit individually) 0: p7 input/output port 1: lcd segment output r/w p7cr (000dh) 76543210 (initial value: 0000 0000) p7cr p7 port input/output control (set for each bit individually) 0: input mode 1: output mode r/w page 62 5. i/o ports 5.6 port p7 (p76 to p70) TMP86PH22UG page 63 TMP86PH22UG 6. watchdog timer (wdt) the watchdog timer is a fail-safe system to detect rapidly 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 or fs/2 15 fc/2 21 or fs/2 13 fc/2 19 or fs/2 11 fc/2 17 or fs/2 9 page 64 6. watchdog timer (wdt) 6.2 watchdog timer control TMP86PH22UG 6.2 watchdog timer control the watchdog timer is controlled by the watchdog timer control registers (wdtcr1 and wdtcr2). the watch- dog timer is automatically enabled after the reset release. 6.2.1 malfunction detection me thods using the watchdog timer the cpu malfunction is detected, as shown below. 1. set the detection time, select the output, and clear the binary counter. 2. clear the binary counter repeatedly within the specified detection time. if the cpu malfunctions such as en dless loops or the deadlock condition s occur for some reason, the watch- dog timer output is activated by the binary-counter overflow unless the binary counters are cleared. when wdtcr1 page 65 TMP86PH22UG note 1: after clearing wdtout to ?0?, the program cannot set it to ?1?. note 2: fc: high-frequency clock [hz], fs : low-frequency clock [hz], *: don?t care note 3: wdtcr1 is a write-only register and must not be used with any of read-modify-write instructions. if wdtcr1 is read, a don?t care is read. note 4: to activate the stop mode, disable the watchdog timer or clear the counter immediately before entering the stop mode. after clearing the counter, clear the counter again immediately after the stop mode is inactivated. note 5: to clear wdten, set the register in accordance wi th the procedures shown in ?1.2.3 watchdog timer disable?. note 1: the disable code is valid only when wdtcr1 page 66 6. watchdog timer (wdt) 6.2 watchdog timer control TMP86PH22UG 6.2.3 watchdog timer disable to disable the watchdog timer, set the register in accordance with the fo llowing procedures . setting the reg- ister in other procedures causes a malfunction of the microcontroller. 1. set the interrupt master flag (imf) to ?0?. 2. set wdtcr2 to the clear code (4eh). 3. set wdtcr1 page 67 TMP86PH22UG 6.2.5 watchdog timer reset when a binary-counter overflow occurs while wdt cr1 page 68 6. watchdog timer (wdt) 6.3 address trap TMP86PH22UG 6.3 address trap the watchdog timer control register 1 and 2 share the a ddresses with the control regi sters to generate address traps. 6.3.1 selection of address tr ap in internal ram (atas) wdtcr1 page 69 TMP86PH22UG 6.3.4 address trap reset while wdtcr1 page 70 6. watchdog timer (wdt) 6.3 address trap TMP86PH22UG page 71 TMP86PH22UG 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 000 fc/2 23 fs/2 15 fs/2 15 001 fc/2 21 fs/2 13 fs/2 13 010 fc/2 16 fs/2 8 ? 011 fc/2 14 fs/2 6 ? 100 fc/2 13 fs/2 5 ? 101 fc/2 12 fs/2 4 ? 110 fc/2 11 fs/2 3 ? 111 fc/2 9 fs/2 ? fc/2 23 or fs/2 15 fc/2 21 or fs/2 13 fc/2 16 or fs/2 8 fc/2 14 or fs/2 6 fc/2 13 or fs/2 5 fc/2 12 or fs/2 4 fc/2 11 or fs/2 3 fc/2 9 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 72 7. time base timer (tbt) 7.1 time base timer TMP86PH22UG 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 source clock enable tbt interrupt period tbtcr page 73 TMP86PH22UG 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 00 fc/2 13 fs/2 5 fs/2 5 01 fc/2 12 fs/2 4 fs/2 4 10 fc/2 11 fs/2 3 fs/2 3 11 fc/2 10 fs/2 2 fs/2 2 tbtcr output latch port output latch mpx dvoen tbtcr page 74 7. time base timer (tbt) 7.2 divider output (dvo) TMP86PH22UG example :1.95 khz pulse output (fc = 16.0 mhz) ld (tbtcr) , 00000000b ; dvock page 75 TMP86PH22UG 8. 18-bit timer/counter (tc1) 8.1 configuration figure 8-1 timer/counter1 tc1cr1 treg1b f/f tc1sr cmp tc1cr2 c b y a s h c d e f g b a a b y c s treg1a l treg1a m treg1a h window pulse generator edge detector 18- bit up-counter edge detector 10 11 00 s y y pin ecnt pin clear signal ecin pin wgpsck tc1m sgedg inttc1 2 3 22 1 12121 wgpsck sgedg sgp seg tc1c tc1s tc1m tc1ck 2 1 1 11 seg 1 pulse width measurement mode frequency measurement mode timer/event count modes p33 tc6out tc6out fc/2 12 or fs/2 4 fc/2 13 or fs/2 5 fc/2 14 or fs/2 6 fs/2 15 or fc/2 23 fs/2 5 or fc/2 13 fs/2 3 or fc/2 11 fc/2 7 fc/2 3 fs fc pwm6 /pdo6 /ppg6 page 76 8. 18-bit timer/counter (tc1) 8.2 control TMP86PH22UG 8.2 control the timer/counter 1 is controlled by timer/counter 1 control registers (tc1cr1/tc1cr2), an 18-bit timer register (treg1a), and an 8-bit inte rnal window gate pulse setting register (treg1b). timer register 76543210 treg1ah (0012h) r/w ?????? ???? ?? page 77 TMP86PH22UG note 1: fc; high-frequency clock [hz] fs; low-frequency clock [hz] * ; don?t care note 2: writing to the low-byte of the timer register 1a (tre g1al, treg1am), the compare func tion is inhibited until the high- byte (treg1ah) is written. note 3: set the mode and source clock, and edge (selection) when the tc1 stops (tc1s=00). note 4: ?fc? can be selected as the source clock only in the timer mode during slow mode and in the pulse width measurement mode during normal 1/2 or idle 1/2 mode. note 5: when a read instruction is executed to the timer register (treg1a), the counter immediate value, not the register set value, is read out. therefore it is impossible to read out the written value of treg1a. to read the counter value, the read instruction should be executed when the coun ter stops to avoid reading unstable value. note 6: set the timer r egister (treg1a) to : 001: 010: 011: 100: 101: 110: fc fs fc/2 23 fc/2 13 fc/2 11 fc/2 7 fc/2 3 fc fs fs/2 15 fs/2 5 fs/2 3 fc/2 7 fc/2 3 fc - fs/2 15 fs/2 5 fs/2 3 - - fc - fs/2 15 fs/2 5 fs/2 3 - - 111: external clock (ecin pin input) tc1m tc1 mode select 00: 01: 10: 11: timer/event counter mode reserved pulse width measurement mode frequency measurement mode r/w page 78 8. 18-bit timer/counter (tc1) 8.2 control TMP86PH22UG note 1: fc; high-frequency clock [hz] fs; low-frequency clock [hz] *; don't care note 2: set the mode, source clock, and edge (selection) when the tc1 stops (tc1s = 00). note 3: if there is no need to use pwm6 / pdo6 / ppg6 as window gate pulse of tc1 always write "0" to tc6out . note 4: make sure to write tc1cr2 "0" to bit 0 in tc1cr2. note 5: when using the event counter mode or pulse width measurement mode, set seg to "0". timer/counter 1 control register 2 76543210 tc1cr2 (0015h) seg sgp sgedg wgpsck tc6out "0" (initial value: p33 no output to p33 r/w page 79 TMP86PH22UG 8.3 function tc1 has four operating modes. the timer mode of the tc 1 is used at warm-up when switching form slow mode to normal2 mode. 8.3.1 timer mode in this mode, counting up is perfor med using the internal clock. the c ontents of tregia are compared with the contents of up-counter. if a match is found, an in ttc1 interrupt is generated, and the counter is cleared. counting up resumes after the counter is cleared. note: when fc is selected for the source clock in slow mode, the lower bits 11 of treg1a is invalid, and a match of the upper bits 7 makes interrupts. tc1 status register tc1sr (0016h) 7 6 543210 hecf heovf "0" "0" "0" "0" "0" "0" (initial value: 0000 0000) hecf operating status monitor 0: 1: stop (during tb) or disable under counting (during ta) read only heovf counter overflow monitor 0: 1: no overflow overflow status table 8-1 source clock (internal clock) of timer/counter 1 source clock resolution maximum time setting normal1/2, idle1/2 mode slow mode sleep mode fc = 16 mhz fs =32.768 khz fc = 16 mhz fs =32.768 khz dv7ck = 0 dv7ck = 1 fc/2 23 [hz] fs/2 15 [hz] fs/2 15 [hz] fs/2 15 [hz] 0.52 s 1 s 38.2 h 72.8 h fc/2 13 fs/2 5 fs/2 5 fs/2 5 512 ms 0.98 ms 2.2 min 4.3 min fc/2 11 fs/2 3 fs/2 3 fs/2 3 128 ms 244 ms 0.6 min 1.07 min fc/2 7 fc/2 7 --8 m s-2 . 1 s- fc/2 3 fc/2 3 - - 0.5 ms - 131.1 ms - fc fc fc (note) - 62.5 ns - 16.4 ms - fs fs - - - 30.5 ms - 8 s page 80 8. 18-bit timer/counter (tc1) 8.3 function TMP86PH22UG figure 8-2 timing chart for timer mode 8.3.2 event counter mode it is a mode to count up at the falling edge of the ecin pin input. when using this mode, set tc1cr1 page 81 TMP86PH22UG 8.3.3 pulse width measurement mode in this mode, pulse widths are coun ted on the falling edge of logical and-ed pulse between ecin pin input (window pulse) and the internal clock. when using this mode, set tc1cr1 page 82 8. 18-bit timer/counter (tc1) 8.3 function TMP86PH22UG 8.3.4 frequency measurement mode in this mode, the frequency of ecin pin input pulse is measured. when using this mode, set tc1cr1 page 83 TMP86PH22UG table 8-3 table setting ta and tb (wgpsck = 10, fc = 16 mhz) setting value setting time setting value setting time 0 16.38ms 8 8.19ms 1 15.36ms 9 7.17ms 2 14.34ms a 6.14ms 3 13.31ms b 5.12ms 4 12.29ms c 4.10ms 5 11.26ms d 3.07ms 6 10.24ms e 2.05ms 7 9.22ms f 1.02ms table 8-4 table setting ta and tb (wgpsck = 10, fs = 32.768 khz) setting valuen setting time setting value setting time 0 31.25ms 8 15.63ms 1 29.30ms 9 13.67ms 2 27.34ms a 11.72ms 3 25.39ms b 9.77ms 4 23.44ms c 7.81ms 5 21.48ms d 5.86ms 6 19.53ms e 3.91ms 7 17.58ms f 1.95ms page 84 8. 18-bit timer/counter (tc1) 8.3 function TMP86PH22UG figure 8-5 timing chart for the frequency measurement mode (window gate pulse falling interrupt) 1 0 2 3 54 1 2 3 56 4 6 0 ecin pin input and-ed pulse (internal signal) inttc1 interrupt window gate pulse up counter tc1cr1 page 85 TMP86PH22UG 9. 8-bit timercounter (tc5, tc6) 9.1 configuration figure 9-1 8-bit timercouter 5, 6 8-bit up-counter decode en a y b s a b y c d e f g h s a y b s s a y b toggle q set clear 8-bit up-counter a b y c d e f g h s decode en toggle q set clear pwm mode pdo, ppg mode pdo mode pwm, ppg mode pwm mode pwm mode 16-bit mode 16-bit mode 16-bit mode 16-bit mode timer, event counter mode overflow overflow timer, event couter mode 16-bit mode clear clear fc/2 7 fc/2 5 fc/2 3 fc/2 fc fc/2 7 fc/2 5 fc/2 3 fc/2 fc pdo, pwm, ppg mode pdo, pwm mode 16-bit mode fc/2 11 or fs/2 3 fc/2 11 or fs/2 3 fs fs tc6cr tc5cr ttreg6 pwreg6 ttreg5 pwreg5 tc5 pin tc6 pin tc6s tc5s inttc5 interrupt request inttc6 interrupt request tff6 tff5 pdo 6/pwm 6/ ppg 6 pin pdo 5/pwm 5/ pin tc5ck tc6ck tc5m tc5s tff5 tc6m tc6s tff6 timer f/f6 timer f/f5 page 86 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG 9.2 timercounter control the timercounter 5 is controlled by the timercounter 5 control register (tc5cr) and two 8-bit timer registers (ttreg5, pwreg5). note 1: do not change the timer register (t treg5) setting while the timer is running. note 2: do not change the timer register (pwreg5) setting in the operating mode except the 8-bit and 16-bit pwm modes while the timer is running. note 1: fc: high-frequency clock [hz] fs: low-frequency clock[hz] note 2: do not change the tc5m, tc5ck and tff5 settings while the timer is running. note 3: to stop the timer operation (tc5s= 1 page 87 TMP86PH22UG note 7: the timer register settings are limited depending on the timer operating mode. for the detailed descriptions, see table 9- 3. note 8: the operating clock fc in the slow or sleep mode can be used only as the high-frequency warm-up mode. page 88 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG the timercounter 6 is controlled by the timercounter 6 control register (tc6cr) and two 8-bit timer registers (ttreg6 and pwreg6). note 1: do not change the timer register (t treg6) setting while the timer is running. note 2: do not change the timer register (pwreg6) setting in the operating mode except the 8-bit and 16-bit pwm modes while the timer is running. note 1: fc: high-frequency clock [hz] fs: low-frequency clock [hz] note 2: do not change the tc6m, tc6ck and tff6 settings while the timer is running. note 3: to stop the timer operation (tc6s= 1 page 89 TMP86PH22UG note 6: to the timercounter in the 16-bit mode, select the so urce clock by programming tc5cr page 90 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG note: n = 5 to 6 table 9-3 constraints on register values being compared operating mode register value 8-bit timer/event counter 1 page 91 TMP86PH22UG 9.3 function the timercounter 5 and 6 have the 8-bit timer, 8-bit ev ent counter, 8-bit programmable divider output (pdo), 8- bit pulse width modulation (pwm) output modes. the time rcounter 5 and 6 (tc5, 6) are cascadable to form a 16- bit timer. the 16-bit timer has the operat ing modes such as the 16-bit timer, 16-bit event counter, warm-up counter, 16-bit pulse width modulation (pwm) output and 16-bit programmable pulse generation (ppg) modes. 9.3.1 8-bit timer mode (tc5 and 6) in the timer mode, the up-counter counts up using the internal clock. when a match between the up-counter and the timer register j (ttregj) value is detected, an inttcj interrupt is generated and the up-counter is cleared. after being cl eared, the up-counter restarts counting. note 1: in the timer mode, fix tcjcr page 92 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG figure 9-2 8-bit timer mode timing chart (tc6) 9.3.2 8-bit event counter mode (tc5, 6) in the 8-bit event counter mode, the up-counter counts up at the falling edge of the input pulse to the tcj pin. when a match between the up-counter and the ttregj value is detected, an inttcj interrupt is generated and the up-counter is cleared. after being cleared, the up-counter restarts counti ng at the falling edge of the input pulse to the tcj pin. two machine cycles are required for the low- or high-level pulse input to the tcj pin. therefore, a maximum freque ncy to be supplied is fc/2 4 hz in the normal1/2 or idle1/2 mode, and fs/2 4 hz in the slow1/2 or sleep1/2 mode. note 1: in the event counter mode, fix tcjcr page 93 TMP86PH22UG note 1: in the programmable divider output mode, do not change the ttregj setting while the timer is running. since ttregj is not in the shift register configur ation in the programmable divider output mode, the new value programmed in ttregj is in effect immediately after programming. therefore, if ttregi is changed while the timer is running, an ex pected operation may not be obtained. note 2: when the timer is stopped during pdo output, the pdoj pin holds the output status when the timer is stopped. to change the output status, program tcjcr page 94 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG figure 9-4 8-bit pdo mode timing chart (tc6) 12 0 n 0 n 0 n 0 n 0 1 2 2 1 2 1 2 3 1 0 n ? internal source clock counter match detect match detect match detect match detect held at the level when the timer is stopped set f/f write of "1" tc6cr page 95 TMP86PH22UG 9.3.4 8-bit pulse wi dth modulation (pwm) output mode (tc5, 6) this mode is used to generate a pulse-width modulated (pwm) signals with up to 8 bits of resolution. the up-counter counts up using the internal clock. when a match between the up-counter and the pwregj value is detected, the logic level output from the timer f/fj is switched to the opposite state. the counter continues counting. the logic level output from the timer f/fj is switched to the opposite state again by the up-co unter overflow, and the counter is cleared. the inttcj interrupt request is generated at this time. since the initial value can be set to the timer f/fj by tcjcr page 96 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG figure 9-5 8-bit pwm mo de timing chart (tc6) 1 0 n n+1 ff 0 n n+1 ff 0 1 m m+1 ff 0 1 1 p n ? internal source clock counter write to pwreg4 write to pwreg4 m p m p n ? shift registar shift shift shift shift match detect match detect one cycle period match detect match detect n m p n tc6cr page 97 TMP86PH22UG 9.3.5 16-bit timer mode (tc5 and 6) in the timer mode, the up-counter counts up using the internal clock. the timercounter 5 and 6 are cascad- able to form a 16-bit timer. when a match between the up-counter and the timer regi ster (ttreg5, ttreg6) valu e is detected after the timer is started by setting tc6cr page 98 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG 9.3.6 16-bit event c ounter mode (tc5 and 6) 9.3.7 16-bit pulse width modulatio n (pwm) output mode (tc5 and 6) this mode is used to generate a pulse-width modulated (pwm) signals with up to 16 bits of resolution. the timercounter 5 and 6 are cascadable to form the 16-bit pwm signal generator. the counter counts up using the internal clock or external clock. when a match between the up-counter and the timer register (pwreg5, pwreg6) value is detected, the logic level output from the timer f/f6 is switched to the opposite state. the counter continues counting. the logic level output from the timer f/f6 is switched to the opposite state again by the counter overflow, and the counter is cleared. the inttc6 interrupt is generated at this time. two machine cycles are required for the high- or low-level pulse input to the tc5 pin. therefore, a maxi- mum frequency to be supplied is fc/2 4 hz in the normal1 or idle1 mode, and fs/2 4 to in the slow1/2 or sleep1/2 mode. since the initial value can be set to the timer f/f6 by tc6cr page 99 TMP86PH22UG clr (tc6cr).3: stops the timer. clr (tc6cr).7 : sets the pwm 6 pin to the high level. note 3: to enter the stop mode, stop the timer and then enter the stop mode. if the stop mode is entered with- out stopping of the timer when fc, fc/2 or fs is select ed as the source clock, a pulse is output from the pwm 6 pin during the warm-up period time after exiting the stop mode. table 9-7 16-bit pwm output mode source clock resolution repeated cycle normal1/2, idle1/2 mode slow1/2, sleep1/2 mode fc = 16 mhz fs = 32.768 khz fc = 16 mhz fs = 32.768 khz dv7ck = 0 dv7ck = 1 fc/2 11 fs/2 3 [hz] fs/2 3 [hz] 128 example :generating a pulse with 1-ms high-level width and a period of 32.768 ms (fc = 16.0 mhz) setting ports ldw (pwreg5), 07d0h : sets the pulse width. ld (tc5cr), 33h : sets the operating clock to fc/2 3 , and 16-bit pwm output mode (lower byte). ld (tc6cr), 056h : sets tff6 to the initial value 0, and 16-bit pwm signal generation mode (upper byte). ld (tc6cr), 05eh : starts the timer. page 100 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG figure 9-7 16-bit pwm m ode timing chart (tc5 and tc6) 1 0 an an+1 ffff 0 an an+1 ffff 0 1 bm bm+1 ffff 0 bm cp b c 1 1 cp n a an ? ? ? internal source clock 16-bit shift register shift shift shift shift counter match detect match detect one cycle period match detect match detect an bm cp an m p tc6cr page 101 TMP86PH22UG 9.3.8 16-bit programmable pulse generate (ppg) ou tput mode (tc5 and 6) this mode is used to generate pulses with up to 16- bits of resolution. the timer counter 5 and 6 are cascad- able to enter the 16-bit ppg mode. the counter counts up using the inte rnal clock or external clock. when a match between the up-counter and the timer register (pwreg5, pwreg6 ) value is detected, the logic level output from the timer f/f6 is switched to the opposite state. the counter continues counting. the logic level output from the timer f/f6 is switched to the opposite state again when a match betw een the up-counter and th e timer register (ttreg5, ttreg6) value is detected, and the counter is cleared. the inttc6 interrupt is generated at this time. since the initial value can be set to the timer f/f6 by tc6cr page 102 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG figure 9-8 16-bit ppg mode timing chart (tc5 and tc60) 1 0 mn mn+1 qr-1 mn qr-1 1 mn mn+1 mn+1 0 qr 0 qr 1 0 internal source clock counter write of "0" match detect match detect match detect mn mn mn match detect match detect ? n m ? ? r q ? held at the level when the timer stops f/f clear tc6cr page 103 TMP86PH22UG 9.3.9 warm-up counter mode in this mode, the warm-up period time is obtained to assure oscillation stability when the system clocking is switched between the high-frequency and low-frequency. the timer counter 5 and 6 are cascadable to form a 16-bit timercouter. the warm-up counter mode has two types of mode; switching from the high-frequency to low-frequency, and vice-versa. note 1: in the warm-up counter mode, fi x tcicr page 104 9. 8-bit timercounter (tc5, tc6) 9.1 configuration TMP86PH22UG 9.3.9.2 high-frequency warm-up counter mode (slow1 in this mode, the warm-up period time from a stop of the high-frequency clock fc to the oscillation sta- bility is obtained. before starting the timer, set sy scr2 page 105 TMP86PH22UG 10. real-time clock the TMP86PH22UG include a real time counter (rtc). a low-frequency clock can be used to provide a periodic interrupt (0.0625[s],0.125[s],0 .25[s],0.50[s]) at a programm ed interval, implement the clock function. the rtc can be used in the mode in which the low-frequency oscillator is active (except for the sleep0 mode). 10.1 configuration figure 10-1 confi guration of the rtc 10.2 control of the rtc the rtc is controlled by the rtc control register (rtccr). note 1: program the rtccr during low-frequency oscillation (when syscr2 page 106 10. real-time clock 10.3 function TMP86PH22UG 10.3 function the rtc counts up on the internal low-frequency clock. when rtccr page 107 TMP86PH22UG 11. asynchronous serial interface (uart ) 11.1 configuration figure 11-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 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 baud rate generator transmit/receive clock 2 4 3 2 2 2 noise rejection circuit m p x transmit control circuit shift register shift register receive control circuit mpx: multiplexer uartcr1 tdbuf rdbuf inttxd intrxd uartsr uartcr2 rxd txd inttc5 page 108 11. asynchronous serial interface (uart ) 11.2 control TMP86PH22UG 11.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). note 1: when operations are disabled by se tting txe and rxe bit to ?0?, the setting becomes valid when data transmit or receive complete. when the transmit data is stored in the transmit data buffer, the data are not transmitted. even if data transmit is enabled, until new data are written to the transmit data buffer, the current data are not transmitted. note 2: the transmit clock and the parity are common to transmit and receive. note 3: uartcr1 page 109 TMP86PH22UG note: when an inttxd is generated, tbep flag is set to "1" automatically. uart status register uartsr (0025h) 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 (0f9bh) 76543210read only (initial value: 0000 0000) uart transmit data buffer tdbuf (0f9bh) 76543210write only (initial value: 0000 0000) page 110 11. asynchronous serial interface (uart ) 11.3 transfer data format TMP86PH22UG 11.3 transfer data format in uart, an one-bit start bit (low level), stop bit (bit length selectable at high level, by uartcr1 ; even- or odd-number ed parity by uartcr1 |