![]() |
|
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 TMP86C829BUG
page 2 TMP86C829BUG the information contained herein is su bject to change without notice. 021023 _ d toshiba is continually working to improve the qual ity and reliability of its products. nevertheless, semiconductor devices in general can malfunction or fa il due to their inherent electrical sensitivity and vulnerability to physical stress. it is the responsibility of the buyer, when utilizing toshiba products , to comply with the standards of safety in making a safe design for the entire system, and to avoid situations in which a malfunction or failure of such toshiba products could cause loss of human life, bodily injury or damage to property. in developing your designs, please ensure that to shiba products are used within specified operating ranges as set forth in the most re cent toshiba products specifications. also, please keep in mind the precautio ns and conditions set forth in the ? handling guide for semiconductor devices, ? or ? toshiba semiconductor reliability handbook ? etc. 021023_a the toshiba products listed in this document are inte nded for usage in general electronics applications (computer, personal equipment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). these toshiba products are neither intended nor warranted for usage in equipment that requires extraordinarily high quality and/or reliability or a malfunction or failure of which may cause loss of human life or bodily injury ( ? unintended usage ? ). unintended usage include atomic energy control instruments, airplane or spaceship instruments, tr ansportation instruments, traffic signal instruments, combustion control instruments, medical instrument s, all types of safety devices, etc. unintended usage of toshiba products listed in this document shall be made at the customer's own risk. 021023_b the products described in this document shall not be used or embedded to any downstream products of which manufacture, use and/or sale are prohib ited under any applicable laws and regulations. 060106_q the information contained he rein is presented only as a guide for the applications of our products. no responsibility is assumed by tosh iba for any infringements of patents or other rights of the third parties which may result from its use. no license is granted by implication or otherwise under any patent or patent rights of toshiba or others. 021023_c the products described in this document may include products subject to the foreign exchange and foreign trade laws. 021023_f for a discussion of how the reliability of microcontro llers can be predicted, please refer to section 1.3 of the chapter entitled quality and reli ability assurance/hand ling precautions. 030619_s ? 2006 toshiba corporation all rights reserved page 3 TMP86C829BUG the functional differences on products basi s: tmp86cm29l, tm p86cx29b, tmp86ch21 and tmp86cx20 note 1: uart and sio can not use function sync hronously because each f unction pins are shared. note 2: with tmp86ch21aug the operating temperature (topr) is -20 to 85 when the supply voltage vdd is less than 2.0v. note 3: tmp86c820/420 don?t have the timer/counter-6 input/output and uart input/output. note 4: the electrial characteristics of tmp86cm29lug ar e different from that of tmp86c829/ch29/cm29b, tmp86ch21/ ch21a and tmp86c420/c820. for details, please refer to "e lectrical characteristics" in data sheet of tmp86cm29lug. note 5: the operating temperature (topr) of ad characteri stics of all products (tmp86c420/c820/ch21/ch21a/c829b/ch29b/ cm29b/cm29l) is -10 to 85 when the supply voltage vdd is less than 2. 0v. for details, please refer to "ad conver- sion characteristics" in data sheet of each product. note 6: the characteristic of power supply current differs in each product. for details , please refer to "electirical characteri stics" in data sheet of each product. products name tmp86cm29l tmp86c829b tmp86ch29b tmp86cm29b tmp86ch21 tmp86ch21a tmp86c420 tmp86c820 rom 32 k bytes c829: 8k bytes ch29: 16k bytes cm29: 32k bytes 16k bytes c420: 4k bytes c820: 8k bytes ram 1.5k bytes c829: 512bytes ch29: 1.5k bytes cm29: 1.5k bytes 512bytes 256bytes i/o port 39 pins minumum command execution time 0.25 sec at 16mhz supply voltage 1.8v to 3.6v at 8.0mhz/ 32.768khz 2.7v to 3.6v at 16mhz/ 32.768khz (note4) 1.8v to 5.5v at 4.2mhz/32.768khz 2.7v to 5.5v at 8.0mhz/32.768khz 4.5v to 5.5v at 16mhz/32.768khz 18-bit timer counter 1ch (ecin input is both edge or single edge) 1ch (ecin input is single edge) 8-bit timer counter 4ch 2ch time base timer 1ch watch dog timer 1ch uart/sio 1ch (note1) n.a. sio n.a 1ch key-on wakeup 4ch a/d converter 10-bit a/d: 8ch 8-bit a/d: 8ch lcd driver 32seg x 4com operating temperature -40 to 85 -40 to 85 (note2) -40 to 85 package(body size) lqfp64(10x10mm) qfp64(14x14mm) lqfp64(10x10mm) package (p-qfp64-1010-0.80c) n.a tmp86c829bfg tmp86ch29bfg tmp86cm29bfg tmp86ch21fg tmp86c420fg tmp86c820fg package (p-lqfp64-1010-0.50e) n.a TMP86C829BUG tmp86ch29bug tmp86cm29bug tmp86ch21ug tmp86c420ug tmp86c820ug package (p-lqfp64-1010-0.50d) tmp86cm29lug n.a. tmp86ch21aug n.a. TMP86C829BUG the functional differ ences on products basis: tmp86c829b/ch29b/cm29b/pm29a/ pm29b/fm29/cm29l. note 1: uart and sio can not use function sync hronously because each f unction pins are shared. note 2: an emulation chip (tmp86c929axb) can?t emulate the flash memory functions, cpu wait and serial prom mode. therefore, if the software which incl udes flash memory function or cpu wait is executed in tmp86c929axb, the opera- tion might be different from tmp86fm29/cm29l. note 3: the operating temperature (topr) of ad characteri stics of all products (tmp86c829b/ch29b/cm29b/pm29a/pm29b/ fm29/cm29l) is -10 to 85 when the supply voltage vdd is less than 2.0v . for details, please re fer to "ad conversion characteristics" in data sheet of each product. note 4: the typical value of high and low fr equency feedback resistor in tmp86fm29/cm29l are different from that of the other products. for details, please refer to "input/out put circuitry" in data sheet of each product. note 5: the characteristic of power supply current differs in each product. for details , please refer to "electirical characteri stics" in data sheet of each product. note 6: the recommended operating condition of serial prom mode in tmp86fm29 is different from mcu mode. fore details, please refer to "electirical characteri stics" in data sheet of each product. products name tmp86c829b tmp86ch29b tmp86cm29b tmp86pm29a tmp86pm29b tmp86fm29 tmp86cm29l rom 8k bytes (mask) 16k bytes (mask) 32k bytes (mask) 32k bytes (otp) 32k bytes (flash) 32k bytes (mask) ram 512 bytes 1.5k bytes dbr 128 bytes (flash memory control/status registers page 5 TMP86C829BUG note 1: tmp86fm29 has a cpu wait functi on which is a warming up (cpu halt) of cpu for stabilizing of power supply of flash memory. even though tmp86cm29l doesn?t have a flash memory, the cpu wait function is inserted to keep the compatibility with flash product (tmp86fm29) . during the cpu wait period except reset, cpu is halted but peripheral functions are not halted. therefore, if the interrupt occurs during the cpu wait period, the interrupt latch (il) is set and when imf has been set to "1 ", the interrupt service routine might be executed after cpu wait period . for details, please refer to "flash memory" in tmp86fm29 data sheet. tmp86fm29 (flash product) should be used as non-volatile product to confirm the software of tmp86cm29l because of the above reason. and tmp86pm29a/pm29b (otp pr oduct) should be used as non-volatile product to confirm the software of tmp86c829b/ch29b/cm29b. note 1: tmp86fm29/cm29l can't use lcd panel which is driven by 5v because the maximum recommended voltage is 3.6v. therefore, the voltage level of v3 pin always should be under 3.6v. note 2: the operating temperature of tmp86fm29/cm29l in type-1 and type-2 is -10 to 85 . for details, please refer to "lcd driver" and "electrical characteristics" in data sheet. note 3: the operating temperature of tmp86c829b/ch2 9b/cm29b in all types (type 1 to 5) is -40 to 85 . however, there is a voltage level limitation of v3 and vdd pin in each type. for details, please refer to "lcd driver" and "electrical characteristics" in data sheet. condition wait time? halt/operate cpu peripherals after reset release 2 10 /fc [s] halt halt changing from stop mode to normal mode (at eepcr TMP86C829BUG revision history date revision 2006/9/28 1 first release 2006/12/5 2 periodical updating.no change in contents. 2006/12/5 3 periodical updating.no change in contents. 2006/12/5 4 periodical updating.no change in contents. 2006/12/5 5 periodical updating.no change in contents. 2007/7/14 6 contents revised i table of contents TMP86C829BUG 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 (maskrom) .................................................................................................................. 9 2.1.3 data memory (ram) ............................................................................................................................... .. 9 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 (il15 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 (ef15 to ef4) ...................................................................................... 36 3.3 interrupt source selector (intsel) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.4 interrupt sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3.4.1 interrupt acceptance processing is packaged as follows. ....................................................................... 39 3.4.2 saving/restoring general-purpose registers ............................................................................................ 40 3.4.2.1 using push and pop instructions ii 3.4.2.2 using data transfer instructions 3.4.3 interrupt return ............................................................................................................................... ......... 42 3.5 software interrupt (intsw) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.5.1 address error detection .......................................................................................................................... 43 3.5.2 debugging ............................................................................................................................... ............... 43 3.6 undefined instruction interrupt (intundef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.7 address trap interrupt (intatrap) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.8 external interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 4. special function r egister (sfr) 4.1 sfr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 4.2 dbr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 5. i/o ports 5.1 port p1 (p17 to p10) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 5.2 port p2 (p22 to p20) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 5.3 port p3 (p33 to p30) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 5.4 port p5 (p57 to p50) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 5.5 port p6 (p67 to p60) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 5.6 port p7 (p77 to p70) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 6. watchdog timer (wdt) 6.1 watchdog timer configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 6.2 watchdog timer control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 6.2.1 malfunction detection methods using the watchdog timer ................................................................... 60 6.2.2 watchdog timer enable ......................................................................................................................... 61 6.2.3 watchdog timer disable ........................................................................................................................ 62 6.2.4 watchdog timer interrupt (intwdt) ...................................................................................................... 62 6.2.5 watchdog timer reset ........................................................................................................................... 63 6.3 address trap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 6.3.1 selection of address trap in internal ram (atas) ................................................................................ 64 6.3.2 selection of operation at address trap (atout) .................................................................................. 64 6.3.3 address trap interrupt (intatrap) ....................................................................................................... 64 6.3.4 address trap reset ............................................................................................................................... . 65 7. time base timer (tbt) 7.1 time base timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 7.1.1 configuration ............................................................................................................................... ........... 67 7.1.2 control ............................................................................................................................... ..................... 67 7.1.3 function ............................................................................................................................... ................... 68 7.2 divider output (dvo) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 7.2.1 configuration ............................................................................................................................... ........... 69 7.2.2 control ............................................................................................................................... ..................... 69 8. 18-bit timer/counter (tc1) iii 8.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 8.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 8.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 8.3.1 timer mode ............................................................................................................................... .............. 75 8.3.2 event counter mode ............................................................................................................................... 76 8.3.3 pulse width measurement mode ............................................................................................................ 77 8.3.4 frequency measurement mode .............................................................................................................. 78 9. 8-bit timercounter (tc3, tc4) 9.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 9.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 9.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 9.3.1 8-bit timer mode (tc3 and 4) ................................................................................................................ 87 9.3.2 8-bit event counter mode (tc3, 4) ........................................................................................................ 88 9.3.3 8-bit programmable divider ou tput (pdo) mode (tc3, 4) ..................................................................... 88 9.3.4 8-bit pulse width modulation (pwm) output mode (tc3, 4) .................................................................. 91 9.3.5 16-bit timer mode (tc3 and 4) .............................................................................................................. 93 9.3.6 16-bit event counter mode (tc3 and 4) ................................................................................................ 94 9.3.7 16-bit pulse width modulation (pwm) output mode (tc3 and 4) .......................................................... 94 9.3.8 16-bit programmable pulse generate (ppg) output mode (tc3 and 4) ............................................... 97 9.3.9 warm-up counter mode ......................................................................................................................... 99 9.3.9.1 low-frequency warm-up counter mode (normal1 normal2 slow2 slow1) 9.3.9.2 high-frequency warm-up counter mode (slow1 slow2 normal2 normal1) 10. 8-bit timercounter (tc5, tc6) 10.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 10.2 timercounter control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 10.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 10.3.1 8-bit timer mode (tc5 and 6) ............................................................................................................ 106 10.3.2 8-bit event counter mode (tc6) ........................................................................................................ 107 10.3.3 8-bit programmable divider output (pdo) mode (tc6) ..................................................................... 107 10.3.4 8-bit pulse width modulation (pwm) output mode (tc6) .................................................................. 110 10.3.5 16-bit timer mode (tc5 and 6) .......................................................................................................... 112 10.3.6 16-bit pulse width modulation (pwm) output mode (tc5 and 6) ...................................................... 113 10.3.7 16-bit programmable pulse generate (ppg) output mode (tc5 and 6) ........................................... 116 10.3.8 warm-up counter mode ..................................................................................................................... 118 10.3.8.1 low-frequency warm-up counter mode (normal1 normal2 slow2 slow1) 10.3.8.2 high-frequency warm-up counter mode (slow1 slow2 normal2 normal1) 11. asynchronous serial interface (uart ) 11.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 11.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 11.3 transfer data format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 11.4 transfer rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 11.5 data sampling method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 11.6 stop bit length . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 11.7 parity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 11.8 transmit/receive operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 11.8.1 data transmit operation .................................................................................................................... 126 iv 11.8.2 data receive operation ..................................................................................................................... 126 11.9 status flag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 11.9.1 parity error ............................................................................................................................... ........... 127 11.9.2 framing error ............................................................................................................................... ....... 127 11.9.3 overrun error ............................................................................................................................... ....... 127 11.9.4 receive data buffer full ..................................................................................................................... 128 11.9.5 transmit data buffer empty ............................................................................................................... 128 11.9.6 transmit end flag .............................................................................................................................. 129 12. synchronous serial interface (sio) 12.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 12.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 12.3 serial clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 12.3.1 clock source ............................................................................................................................... ........ 133 12.3.1.1 internal clock 12.3.1.2 external clock 12.3.2 shift edge ............................................................................................................................... ............. 135 12.3.2.1 leading edge 12.3.2.2 trailing edge 12.4 number of bits to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 12.5 number of words to transfer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 12.6 transfer mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 12.6.1 4-bit and 8-bit transfer modes ............................................................................................................. 136 12.6.2 4-bit and 8-bit receive modes ............................................................................................................. 138 12.6.3 8-bit transfer / receive mode ............................................................................................................... 139 13. 10-bit ad converter (adc) 13.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 13.2 register configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 13.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 13.3.1 software start mode ........................................................................................................................... 145 13.3.2 repeat mode ............................................................................................................................... ....... 145 13.3.3 register setting ............................................................................................................................... . 146 13.4 stop/slow modes during ad conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 13.5 analog input voltage and ad conversion result . . . . . . . . . . . . . . . . . . . . . . . 148 13.6 precautions about ad converter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 13.6.1 analog input pin voltage range ........................................................................................................... 149 13.6.2 analog input shared pins .................................................................................................................... 149 13.6.3 noise countermeasure ....................................................................................................................... 149 14. key-on wakeup (kwu) 14.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 14.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 14.3 function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 15. lcd driver 15.1 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 15.2 control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 15.2.1 lcd driving methods .......................................................................................................................... 155 v 15.2.2 frame frequency ............................................................................................................................... .. 156 15.2.3 driving method for lcd driver ............................................................................................................ 157 15.2.3.1 when using the booster circuit (lcdcr vi page 1 060116ebp TMP86C829BUG cmos 8-bit microcontroller ? the information contained herein is subject to change without notice. 021023_d ? toshiba is continually working to improve the quality and reli ability of its products. neverthel ess, semiconductor devices in general can malfunction or fail due to their inherent el ectrical sensitivity and vul nerability to physical stre ss. it is the responsibility of the buyer, when utilizing toshiba products, to comply with the standards of sa fety in making a safe design for the entire system, and to avoid situations in which a malfunction or failure of such toshiba products could cause loss of human life, bodily injury or damage to property. in developing your designs, pleas e ensure that toshiba products are used within specified operating ranges as set forth in the most recent toshiba products specifications. also, please keep in mind the precautions and conditions set forth in the ?handling gui de for semiconductor devices,? or ?toshiba se miconductor reliability handbook? etc. 021023_a ? the toshiba products listed in this document are intended for usage in general electronics applic ations (computer, personal eq uip- ment, office equipment, measuring equipment, industrial robotics, domestic appliances, etc.). these toshiba products are neithe r intended nor warranted for usage in equipment that requires extr aordinarily high quality and/or re liability or a malfunctionor failure of which may cause loss of human life or bod ily injury (?unintended usage?). unintended us age include atomic energy control instru ments, airplane or spaceship instruments, transporta tion instruments, traffic signal instrume nts, combustion control instruments, medi cal instru- ments, all types of safety dev ices, etc. unintended usage of toshiba products li sted in this document shall be made at the cust omer's own risk. 021023_b ? the products described in this document shall not be used or embedded to any downstream products of which manufacture, use and /or sale are prohibited under any appl icable laws and regulations. 060106_q ? the information contained herein is present ed only as a guide for the applications of our products. no responsibility is assum ed by toshiba for any infringements of patents or other rights of the th ird parties which may result from its use. no license is gran ted by impli- cation or otherwise under any patent or patent rights of toshiba or others. 021023_c ? the products described in this document are subjec t to the foreign exchange and foreign trade laws. 021023_e ? for a discussion of how the reliability of microcontrollers c an be predicted, please refer to section 1.3 of the chapter entit led quality and reliability assurance/h andling precautions. 030619_s TMP86C829BUG 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. 19interrupt sources (external : 5 internal : 14) 3. input / output ports (39 pins) large current output: 4pins (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 7. 8-bit timer counter : 4 ch - timer, event counter, programmable divider output (pdo), pulse width modulation (pwm) output, product no. rom (maskrom) ram package otp mcu emulation chip TMP86C829BUG 8192 bytes 512 bytes lqfp64-p-1010-0.50e tmp86pm29bug tmp86c929axb page 2 1.1 features TMP86C829BUG programmable pulse generation (ppg) modes 8. 8-bit uart/sio : 1 ch 9. 10-bit successive approximation type ad converter - analog input: 8 ch 10. key-on wakeup : 4 ch 11. lcd driver/controller built-in voltage booster for lcd driver with display memory lcd direct drive capability (max 32 seg 4 com) 1/4,1/3,1/2duties or static drive are programmably selectable 12. clock operation single clock mode dual clock mode 13. 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 TMP86C829BUG 1.2 pin assignment figure 1-1 pin assignment vss xout test vdd (xtin) p21 (xtout) p22 reset ( stop / int5 ) p20 (ain0) p60 (ecnt/ain2) p62 (stop2/ain4) p64 ( int0 /ain3) p63 (stop3/ain5) p65 (stop4/ain6) p66 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 p15(seg26/rxd/si) p17(seg24/ sck ) p50(seg23) p52(seg21) p51(seg22) p54(seg19) p53(seg20) p16(seg25/txd/so) seg3 seg4 seg5 seg6 seg7 p77 (seg8) p76 (seg9) p75 (seg10) (ecin/ain1) p61 xin p67(ain7/stop5) avdd p10(seg31) p11(seg30) p14(seg27/int3) p12(seg29/int1) varef p13(seg28/int2) p74 (seg11) p73 (seg12) p72 (seg13) p71 (seg14) p70 (seg15) p57 (seg16) p56 (seg17) p55 (seg18) seg2 seg1 seg0 com3 com2 com1 com0 v3 v2 v1 c1 c0 ( dvo ) p30 (tc3/ pdo3/pwm3 ) p31 (tc4/ pdo4/pwm4/ppg4 ) p32 (tc6/ pdo6/pwm6/ppg6 ) p33 page 4 1.3 block diagram TMP86C829BUG 1.3 block diagram figure 1-2 block diagram page 5 TMP86C829BUG 1.4 pin names and functions table 1-1 pin names and functions(1/3) pin name pin number input/output functions p17 seg24 sck 27 io o io port17 lcd segment output 24 serial clock i/o p16 seg25 txd so 26 io o o o port16 lcd segment output 25 uart data output serial data output p15 seg26 rxd si 25 io o i i port15 lcd segment output 26 uart data input serial data input p14 seg27 int3 24 io o i port14 lcd segment output 27 external interrupt 3 input p13 seg28 int2 23 io i i port13 lcd segment output 28 external interrupt 2 input p12 seg29 int1 22 io o i port12 lcd segment output 29 external interrupt 1 input p11 seg30 21 io o port11 lcd segment output 30 p10 seg31 20 io o port10 lcd segment output 31 p22 xtout 7 io o port22 resonator connecting pins(32.768 khz) for inputting external clock p21 xtin 6 io i port21 resonator connecting pins(32.768 khz) for inputting external clock p20 int5 stop 9 io i i port20 external interrupt 5 input stop mode release signal input p33 pdo6/pwm6/ppg6 tc6 64 io o i port33 pdo6/pwm6/ppg6 output tc6 input p32 pdo4/pwm4/ppg4 tc4 63 io o i port32 pdo4/pwm4/ppg4 output tc4 input p31 pdo3/pwm3 tc3 62 io o i port31 pdo3/pwm3 output tc3 input p30 dvo 61 io o port30 divider output p57 seg16 35 io o port57 lcd segment output 16 p56 seg17 34 io o port56 lcd segment output 17 page 6 1.4 pin names and functions TMP86C829BUG p55 seg18 33 io o port55 lcd segment output 18 p54 seg19 32 io o port54 lcd segment output 19 p53 seg20 31 io o port53 lcd segment output 20 p52 seg21 30 io o port52 lcd segment output 21 p51 seg22 29 io o port51 lcd segment output 22 p50 seg23 28 io o port50 lcd segment output 23 p67 ain7 stop5 17 io i i port67 analog input7 stop5 input p66 ain6 stop4 16 io i i port66 analog input6 stop4 input p65 ain5 stop3 15 io i i port65 analog input5 stop3 input p64 ain4 stop2 14 io i i port64 analog input4 stop2 input p63 ain3 int0 13 io i i port63 analog input3 external interrupt 0 input p62 ain2 ecnt 12 io i i port62 analog input2 ecnt input p61 ain1 ecin 11 io i i port61 analog input1 ecin input p60 ain0 10 io i port60 analog input0 p77 seg8 43 io o port77 lcd segment output 8 p76 seg9 42 io o port76 lcd segment output 9 p75 seg10 41 io o port75 lcd segment output 10 p74 seg11 40 io o port74 lcd segment output 11 p73 seg12 39 io o port73 lcd segment output 12 p72 seg13 38 io o port72 lcd segment output 13 p71 seg14 37 io o port71 lcd segment output 14 table 1-1 pin names and functions(2/3) pin name pin number input/output functions page 7 TMP86C829BUG p70 seg15 36 io o port70 lcd segment output 15 seg7 44 o lcd segment output 7 seg6 45 o lcd segment output 6 seg5 46 o lcd segment output 5 seg4 47 o lcd segment output 4 seg3 48 o lcd segment output 3 seg2 49 o lcd segment output 2 seg1 50 o lcd segment output 1 seg0 51 o lcd segment output 0 com3 52 o lcd common output 3 com2 53 o lcd common output 2 com1 54 o lcd common output 1 com0 55 o lcd common output 0 v3 56 i lcd voltage booster pin v2 57 i lcd voltage booster pin v1 58 i lcd voltage booster pin c1 59 i lcd voltage booster pin c0 60 i lcd voltage booster pin xin 2 i resonator connecting pins for high-frequency clock xout 3 o resonator connecting pins for high-frequency clock reset 8 io reset signal test 4 i test pin for out-going test. normally, be fixed to low. varef 18 i analog base voltage input pin for a/d conversion avdd 19 i analog power supply vdd 5 i power supply 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 TMP86C829BUG page 9 TMP86C829BUG 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 TMP86C829BUG memory is composed maskrom, ram, dbr(data buffer register) and sfr(special function register). they are all mapped in 64-kbyte address space. figure 2-1 shows the TMP86C829BUG memory address map. figure 2-1 memory address map 2.1.2 program memory (maskrom) the TMP86C829BUG has a 8192 bytes (address e000h to ffffh) of program memory (maskrom ). 2.1.3 data memory (ram) the TMP86C829BUG has 512bytes (address 0040h to 023fh) of internal ram. the first 192 bytes (0040h to 00ffh) of the internal ra m are located in the direct area; inst ructions with shorten operations are available against such an area. 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 e000 h maskrom: program memory maskrom 8192 bytes 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 TMP86C829BUG 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?. (TMP86C829BUG) 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 TMP86C829BUG 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 TMP86C829BUG 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 TMP86C829BUG 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 th e 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 TMP86C829BUG 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 TMP86C829BUG (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 TMP86C829BUG switching back and forth between slow1 and slow2 modes are performed by syscr2 page 16 2. operational description 2.2 system clock controller TMP86C829BUG 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 TMP86C829BUG 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 TMP86C829BUG 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 (stop5 to stop2) which is controlled by the stop mode release control register (stopcr). the stop pin is also used both as a port p20 and an int5 (external interrupt input 5) pin. stop mode is started by setting syscr1 page 19 TMP86C829BUG 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 stop5 to 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 0 set (syscr1). 7 ; starts stop mode sint5: reti example :starting stop mode from normal mode di ; imf 0 ld (syscr1), 10010000b ; starts after specified to the edge-sensitive release mode 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 TMP86C829BUG 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 TMP86C829BUG 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 TMP86C829BUG 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 TMP86C829BUG ? 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 TMP86C829BUG 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:w normal release mode ?s:w interrupt 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 TMP86C829BUG 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 TMP86C829BUG ? start the idle0 and sleep0 modes stop (disable) peripherals such as a timer counter. to start idle0 and sleep0 modes, set syscr2 page 27 TMP86C829BUG 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:w normal release mode ?s:w interrupt 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 TMP86C829BUG 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 TMP86C829BUG (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 TMP86C829BUG 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 TMP86C829BUG 2.3 reset circuit the TMP86C829BUG has four types of reset generation pro cedures: an external reset input, an address 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 reset pin outputs "l" level). 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. reset pin outputs "l" level during maximum 24/fc[s] (1.5 s at 16.0mhz). 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 TMP86C829BUG 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 TMP86C829BUG page 34 2. operational description 2.3 reset circuit TMP86C829BUG page 35 TMP86C829BUG 3. interrupt control circuit the TMP86C829BUG has a total of 19 interrupt sources excluding reset, of which 3 source levels are multiplexed. interrupts can be nested with priorities. four of the internal interrupt sour ces are non-maskable while the rest are maskable. interrupt sources are provided with interrupt latches (il) , which hold interrupt requests, and independent vectors. the interrupt latch is set to ?1? by th e generation of its interrupt request wh ich requests the cpu to accept its inter- rupts. interrupts are enabled or disabled by software using the interrupt master enable fl ag (imf) and in terrupt enable flag (ef). if more than one interrupts are generated simultaneously, interrup ts are accepted in order which is domi- nated by hardware. however, there are no prioritized interrupt factors among non-maskable interrupts. note 1: the intsel register is used to select the interrupt source to be enabled for each multiplexed source level (see 3.3 inte r- rupt source selector (intsel)). note 2: to use the address trap interrupt (intatrap), clear wdtcr1 page 36 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86C829BUG interrupt latches are not set to ?1? by an instruction. since interrupt latches can be read, the status fo r interrupt requests can be monitored by software. note: in main program, before manipulating the interrupt enable flag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf new ly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf becomes "0 " automatically, clearing imf need not execute normally on interrupt service routine. however, if using multiple inte rrupt on interrupt service routine, manipulating ef or il should be executed before setting imf="1". 3.2 interrupt enab le register (eir) the interrupt enable register (eir) enables and disables the acceptance of interrupts, except fo r the non-maskable interrupts (software interrupt, undefined instruction interr upt, address trap interrupt and watchdog interrupt). non- maskable interrupt is accepted regardless of the contents of the eir. the eir consists of an interrupt mast er enable flag (imf) and the individua l interrupt enable flags (ef). these registers are located on address 003ah and 003bh in sfr ar ea, and they can be read and written by an instructions (including read-modify-write instructions such as bit manipulation or operation instructions). 3.2.1 interrupt ma ster enable flag (imf) the interrupt enable register (imf ) enables and disables the acceptance of the whole maskable interrupt. while imf = ?0?, all maskable interrupts are not accepted regardless of the status on each individual interrupt enable flag (ef). by setting imf to ?1?, the interrupt becomes acceptable if the individuals are enabled. when an interrupt is accepted, imf is cleared to ?0? after the latest status on imf is stacked. thus the maskable inter- rupts which follow are disabled. by executing return interrupt instruction [reti/retn], the stacked data, which was the status before interrup t acceptance, is loaded on imf again. the imf is located on bit0 in eirl (address: 003ah in sfr), and can be read and written by an instruction. the imf is normally set and cl eared by [ei] and [di] instruction respectively. during reset, the imf is initial- ized to ?0?. 3.2.2 individual interrupt enable flags (ef15 to ef4) each of these flags enables and disables the acceptan ce of its maskable interrupt . setting the corresponding bit of an individual interrupt enable flag to ?1? enables acceptan ce of its interrupt, and setting the bit to ?0? dis- ables acceptance. during reset, all the i ndividual interrupt enable flags (ef15 to ef4) ar e initialized to ?0? and all maskable interrupts are not accepted until they are set to ?1?. note:in main program, before manipulating the interrupt enable flag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf newly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf become s "0" automatically, clearing imf need not execute nor- example 1 :clears interrupt latches di ; imf 0 ldw (ill), 111010000011 1111b ; il12, il10 to il6 0 ei ; imf 1 example 2 :reads interrupt latchess ld wa, (ill) ; w ilh, a ill example 3 :tests interrupt latches test (ill). 7 ; if il7 = 1 then jump jr f, sset page 37 TMP86C829BUG mally on interrupt service routine. however, if using mult iple interrupt on interrupt service routine, manipulat- ing ef or il should be executed before setting imf="1". example 1 :enables interrupts individually and sets imf di ; imf 0 ldw : (eirl), 1110100010100000b ; ef15 to ef13, ef11, ef7, ef5 1 note: imf should not be set. : ei ; imf 1 example 2 :c compiler description example unsigned int _io (3ah) eirl; /* 3ah shows eirl address */ _di(); eirl = 10100000b; : _ei(); page 38 3. interrupt control circuit 3.2 interrupt enable register (eir) TMP86C829BUG note 1: to clear any one of bits il7 to il4, be sure to write "1" into il2 and il3. note 2: in main program, before manipulating the interrupt enable fl ag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf newly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf becomes "0" automatically, clear ing imf need not execute normally on inter- rupt service routine. however, if using multiple interrupt on interrupt service routine, mani pulating ef or il should be exe- cuted before setting imf="1". note 3: do not clear il with read-modify-w rite instructions such as bit operations. note 1: *: don?t care note 2: do not set imf and the interrupt enable flag (ef15 to ef4) to ?1? at the same time. note 3: in main program, before manipulating the interrupt enable fl ag (ef) or the interrupt latch (il), be sure to clear imf to "0" (disable interrupt by di instruction). then set imf newly again as required after operating on the ef or il (enable interrupt by ei instruction) in interrupt service routine, because the imf becomes "0" automatically, clear ing imf need not execute normally on inter- rupt service routine. however, if using multiple interrupt on interrupt service routine, mani pulating ef or il should be exe- cuted before setting imf="1". interrupt latches (initial value: 00000000 000000**) ilh,ill (003dh, 003ch) 1514131211109876543210 il15 il14 il13 il12 il11 il10 il9 il8 il7 il6 il5 il4 il3 il2 ilh (003dh) ill (003ch) il15 to il2 interrupt latches at rd 0: no interrupt request 1: interrupt request at wr 0: clears the interrupt request 1: (interrupt latch is not set.) r/w interrupt enable registers (initial value: 00000000 0000***0) eirh,eirl (003bh, 003ah) 1514131211109876543210 ef15 ef14 ef13 ef12 ef11 ef10 ef9 ef8 ef7 ef6 ef5 ef4 imf eirh (003bh) eirl (003ah) ef15 to ef4 individual-interrupt enable flag (specified for each bit) 0: 1: disables the acceptance of each maskable interrupt. enables the acceptance of each maskable interrupt. r/w imf interrupt master enable flag 0: 1: disables the acceptance of all maskable interrupts enables the acceptance of all maskable interrupts page 39 TMP86C829BUG 3.3 interrupt sour ce selector (intsel) each interrupt source that shares the interrupt source level with another interrupt source is allowed to enable the interrupt latch only when it is selected in the intsel register. the interrupt controller does not hold interrupt requests corresponding to interrupt sour ces that are not selected in the intsel register. th erefore, the intsel reg- ister must be set appropriately befo re interrupt requests are generated. the following interrupt sources share their interrupt sour ce level; the source is selected onnthe register intsel. 1. intrxd and intsio share the interrupt source level whose priority is 10. 2. int3 and inttc3 share the interrupt source level whose priority is 15. 3. int5 and inttc5 share the interrupt so urce level whose priority is 16. 3.4 interrupt sequence an interrupt request, which raised inte rrupt latch, is held, until interrupt is accepted or interrupt latch is cleared to ?0? by resetting or an instruct ion. interrupt acceptance sequence requires 8 machine cycles (2 s @16 mhz) after the completion of the current instruction. the interrupt service task terminates upon execution of an interrupt return instruction [reti] (for maskable interrupts) or [retn] (for non-maskable interrupts). figure 3-1 shows the timing chart of interrupt acceptance processing. 3.4.1 interrupt acceptance proc essing is packaged as follows. a. the interrupt master enab le flag (imf) is cleared to ?0? in or der to disable the acceptance of any fol- lowing interrupt. b. the interrupt latch (il) for the interrupt source accepted is cleared to ?0?. c. the contents of the program coun ter (pc) and the program status word, including the interrupt master enable flag (imf), are saved (pushed) on the st ack in sequence of psw + imf, pch, pcl. mean- while, the stack pointer (s p) is decremented by 3. d. the entry address (interrupt vect or) of the corresponding interrupt service program, loaded on the vec- tor table, is transferred to the program counter. e. the instruction stored at the entry address of the inte rrupt service program is executed. note:when the contents of psw are saved on the stack, the contents of imf are also saved. interrupt sour ce selector intsel (003eh) 76543210 - il9er - - - - il14er il15er (initial value: *0** **00) il9er selects intrxd or intsio 0: intrxd 1: intsio r/w il14er selects int3 or inttc3 0: int3 1: inttc3 r/w il15er selects int5 or inttc5 0: int5 1: inttc5 r/w page 40 3. interrupt control circuit 3.4 interrupt sequence TMP86C829BUG note 1: a: return address entry address, b: entry address, c: address which reti instruction is stored note 2: on condition that interrupt is enabled, it takes 38/fc [s ] or 38/fs [s] at maximum (if the interrupt latch is set at the first machine cycle on 10 cycle instruction) to start interrupt acceptance processing since its interrupt latch is set. figure 3-1 timing chart of interrupt acceptance/return in terrupt instruction example: correspondence be tween vector table address for inttbt an d the entry address of the interrupt service program figure 3-2 vector table address,entry address a maskable interrupt is not accepted until the imf is set to ?1? even if th e maskable interrupt higher than the level of current servicing interrupt is requested. in order to utilize nested interrupt service, the imf is set to ?1? in the interrupt service program. in this case, acceptable interrupt sources are selectively en abled by the individual interrupt enable flags. to avoid overloaded nesting, clear the individual interrupt enable flag whose interrupt is currently serviced, before setting imf to ?1?. as for non-maskable interr upt, keep interrupt service shorten compared with length between interrupt requests; otherwise the status cannot be recovered as non-maskable interrupt would simply nested. 3.4.2 saving/restoring general-purpose registers during interrupt acceptance processing , the program counter (pc) and the program status word (psw, includes imf) are automati cally saved on the stack, but the accumulato r and others are not. these registers are saved by software if necessary. when multiple interrupt se rvices are nested, it is also necessary to avoid using the same data memory area for saving registers. the fo llowing methods are used to save/restore the general- purpose registers. a b a c + 1 execute instruction sp pc execute instruction n n ? 2 n - 3 n ? 2n ? 1 n ? 1 n a + 2 a + 1 c + 2 b + 3 b + 2 b + 1 a + 1 a a ? 1 execute reti instruction interrupt acceptance execute instruction interrupt service task 1-machine cycle interrupt request interrupt latch (il) imf d2h 03h d203h d204h 06h vector table address entry address 0fh vector interrupt service program fff2h fff3h page 41 TMP86C829BUG 3.4.2.1 using push and pop instructions if only a specific register is saved or interrupts of the same source are nested , general-purpose registers can be saved/restored using the push/pop instructions. figure 3-3 save/store register using push and pop instructions 3.4.2.2 using data transfer instructions to save only a specific register wi thout nested interrupts, data tran sfer instructions are available. example :save/store register us ing push and pop instructions pintxx: push wa ; save wa register (interrupt processing) pop wa ; restore wa register reti ; return example :save/store register us ing data transfer instructions pintxx: ld (gsava), a ; save a register (interrupt processing) ld a, (gsava) ; restore a register reti ; return pcl pch psw at acceptance of an interrupt at execution of push instruction at execution of reti instruction at execution of pop instruction b-4 b-3 b-2 b-1 b pcl pch psw pcl pch psw sp address (example) sp sp sp a w b-5 page 42 3. interrupt control circuit 3.4 interrupt sequence TMP86C829BUG figure 3-4 saving/restoring general-purpose r egisters under interrupt processing 3.4.3 interrupt return interrupt return instructions [reti]/[retn] perform as follows. as for address trap interrupt (intatrap), it is requir ed to alter stacked data for program counter (pc) to restarting address, during interrupt service program. note:if [retn] is executed with the above data unaltered, the program returns to the address trap area and intatrap occurs again.when interrupt acceptance pr ocessing has completed, stacked data for pcl and pch are located on address (sp + 1) and (sp + 2) respectively. interrupt requests are sampled during the final cycle of the instruction being executed. thus, the next inter- rupt can be accepted immediat ely after the interrupt retu rn instruction is executed. [reti]/[retn] interrupt return 1. program counter (pc) and program status word (psw, includes imf) are restored from the stack. 2. stack pointer (sp) is incremented by 3. example 1 :returning from address trap interrupt (intatrap) service program pintxx: pop wa ; recover sp by 2 ld wa, return address ; push wa ; alter stacked data (interrupt processing) retn ; return example 2 :restarting without returning interrupt (in this case, psw (includes imf) befo re interrupt acceptance is discarded.) pintxx: inc sp ; recover sp by 3 inc sp ; inc sp ; (interrupt processing) ld eirl, data ; set imf to ?1? or clear it to ?0? jp restart address ; jump into restarting address interrupt acceptance interrupt service task restoring registers saving registers interrupt return saving/restoring general-purpose registers using push/pop data transfer instruction main task page 43 TMP86C829BUG note 1: it is recommended that stack pointer be return to rate before intatrap (increment 3 times), if return inter- rupt instruction [retn] is not utilized during inte rrupt service program under intatrap (such as example 2). note 2: when the interrupt processing time is longer than the interrupt request generation time, the interrupt service task is performed but not the main task. 3.5 software interrupt (intsw) executing the swi instruction generates a software interr upt and immediately starts interrupt processing (intsw is highest prioritized interrupt). use the swi instruction only for detection of the address error or for debugging. 3.5.1 address error detection ffh is read if for some cause such as noise the cpu attempts to fetch an instruction from a non-existent memory address during single chip mode. code ffh is th e swi instruction, so a software interrupt is gener- ated and an address error is detect ed. the address error detection range can be further expanded by writing ffh to unused areas of the program memory. address trap reset is generated in case that an instruction is fetched from ram, dbr or sfr areas. 3.5.2 debugging debugging efficiency can be increased by placing the swi instruction at the software break point setting address. 3.6 undefined instruct ion interrupt (intundef) taking code which is not defined as authorized instru ction for instruction causes intundef. intundef is gen- erated when the cpu fetches such a co de and tries to execute it. intundef is accepted even if non-maskable inter- rupt is in process. contemporary process is broken and intundef interrupt process starts, soon after it is requested. note: the undefined instruction interrupt (intundef) forces cpu to jump into vector address, as software interrupt (swi) does. 3.7 address trap interrupt (intatrap) fetching instruction from unauthorized area for instructio ns (address trapped area) cause s reset output or address trap interrupt (intatrap). intatrap is accepted even if non-maskable interrupt is in process. contemporary pro- cess is broken and intatrap interrupt pro cess starts, soon afte r it is requested. note: the operating mode under address trapped, whether to be reset output or interrupt processing, is selected on watchdog timer control register (wdtcr). 3.8 external interrupts the TMP86C829BUG has 5 external interrupt inputs. these inputs are equipped with di gital noise reject circuits (pulse inputs of less than a certa in time are elimin ated as noise). edge selection is also possible with int1 to 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). page 44 3. interrupt control circuit 3.8 external interrupts TMP86C829BUG 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 ? ef7 = 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 ? ef14 = 1 and il14er=0 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 ? ef15 = 1 and il15er=0 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 45 TMP86C829BUG 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 46 3. interrupt control circuit 3.8 external interrupts TMP86C829BUG page 47 TMP86C829BUG 4. special function register (sfr) the TMP86C829BUG adopts the memory mapped i/o system, and all peripheral control and data transfers are performed through the special function register (sfr) or the data buffer register (dbr). the sfr is mapped on address 0000h to 003fh, dbr is mapped on address 0f80h to 0fffh. this chapter shows the arrangement of the special functi on register (sfr) and data buffer register (dbr) for TMP86C829BUG. 4.1 sfr address read write 0000h reserved 0001h p1dr 0002h p2dr 0003h p3dr 0004h p3outcr 0005h p5dr 0006h p6dr 0007h p7dr 0008h p1prd - 0009h p2prd - 000ah p3prd - 000bh p5prd - 000ch p6cr 000dh p7prd - 000eh adccr1 000fh adccr2 0010h treg1al 0011h treg1am 0012h treg1ah 0013h treg1b 0014h tc1cr1 0015h tc1cr2 0016h tc1sr - 0017h reserved 0018h tc3cr 0019h tc4cr 001ah tc5cr 001bh tc6cr 001ch ttreg3 001dh ttreg4 001eh ttreg5 001fh ttreg6 0020h adcdr1 - 0021h adcdr2 - 0022h reserved 0023h reserved 0024h reserved 0025h uartsr uartcr1 page 48 4. special function register (sfr) 4.1 sfr TMP86C829BUG note 1: do not access reserved areas by the program. note 2: ? ; cannot be accessed. note 3: write-only registers and interrupt latches cannot use the read-modify-write instructions (bit manipulation instructions such as set, clr, etc. and logical operation instructions such as and, or, etc.). 0026h - uartcr2 0027h reserved 0028h lcdcr 0029h p1lcr 002ah p5lcr 002bh p7lcr 002ch pwreg3 002dh pwreg4 002eh pwreg5 002fh pwreg6 0030h reserved 0031h reserved 0032h reserved 0033h reserved 0034h - wdtcr1 0035h - wdtcr2 0036h tbtcr 0037h eintcr 0038h syscr1 0039h syscr2 003ah eirl 003bh eirh 003ch ill 003dh ilh 003eh intsel 003fh psw address read write page 49 TMP86C829BUG 4.2 dbr note 1: do not access reserved areas by the program. address read write 0f80h seg1/0 0f81h seg3/2 0f82h seg5/4 0f83h seg7/6 0f84h seg9/8 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 reserved 0f9dh reserved 0f9eh reserved 0f9fh reserved address read write 0fa0h reserved : : : : 0fbfh reserved address read write 0fc0h reserved : : : : 0fdfh reserved address read write 0fe0h reserved : : : : 0fffh reserved page 50 4. special function register (sfr) 4.2 dbr TMP86C829BUG note 2: ? ; cannot be accessed. note 3: write-only registers and interrupt latches cannot use the read-modify-write instructions (bit manipulation instructions such as set, clr, etc. and logical operation instructions such as and, or, etc.). page 51 TMP86C829BUG 5. i/o ports the TMP86C829BUG has 6 parallel input /output ports (39 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, serial interface input/output, uart input/output and segment output. port p2 3-bit i/o port low-frequency resonator connections, exte rnal interrupt input, stop mode release signal input. port p3 4-bit i/o port timer/counter input/output and divider output. port p5 8-bit i/o port segment output. port p6 8-bit i/o port analog input, external interrupt input, timer/counter input and stop mode release signal input. port p7 8-bit i/o port segment output. ! " # ! " # ! " # $ % ! " # ! " # ! " # &' $ &' $ ( ) page 52 5. i/o ports 5.1 port p1 (p17 to p10) TMP86C829BUG 5.1 port p1 (p17 to p10) port p1 is an 8-bit i nput/output port which is al so used as an external interrup t input, serial interface input/output, uart input/output and segment output of lcd. when used as a segment pins of lcd, the respective bit of p1lcr should be set to ?1?. when used as an input port or a secondary function (e xcept for segment) pins, the respective output latch (p1dr) should be set to ?1? and its corresponding p1lcr bit should be set to ?0?. when used as an output port, the respec- tive p1lcr bit should be set to ?0?. during reset, the output latch is initialized to ?1?. p1 port output latch (p1dr) and p1 port terminal input (p1prd) are located on their respective address. when read the output latch data, the p1dr should be r ead and when read the termin al input data, the p1prd reg- ister should be read. if the terminal input data which is configured as lcd segment output is read, unstable data is read. figure 5-2 port p1 port p1 control register p1dr (0001h) r/w 76543210 p17 seg24 sck p16 seg25 txd so p15 seg26 rxd si p14 seg27 int3 p13 seg28 int2 p12 seg29 int1 p11 seg30 p10 seg31 (initial value: 1111 1111) p1lcr (0029h) 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 p1prd (0008h) read only 76543210 p17 p16 p15 p14 p13 p12 p11 p10 ! " ! " page 53 TMP86C829BUG 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 p2dr 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 should be r ead and when read the termin al input data, the p2prd reg- ister should be read. if a read instruction is execute d for port p2, read data of bits 7 to 3 are unstable. figure 5-3 port p2 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. port p2 control register p2dr (0002h) r/w 76543210 p22 xtout p21 xtin p20 int5 stop (initial value: **** *111) 76543210 p2prd (0009h) read only p22 p21 p20 ! "#" $ % $ % $ % page 54 5. i/o ports 5.3 port p3 (p33 to p30) TMP86C829BUG 5.3 port p3 (p33 to p30) port p3 is a 4-bit input/output port. it is also used as a timer/counter input/output, divider output. when used as a timer/counter output or divider output, respective output latch (p3dr) should be set to ?1?. it can be selected whether ou tput circuit of p3 port is c-mos output or a sink open drain individually, by setting p3outcr. when a corresponding bit of p3 outcr is ?0?, the output circuit is selected to a sink open drain and when a corresponding bit of p3outcr is ?1?, the output circuit is selected to a c-mos output. when used as an input port or timer/counter input, respective output control (p3outcr) should be set to ?0? after p3dr is set to ?1?. during reset, the p3dr is initialized to ?1?, and the p3outcr is initialized to ?0?. p3 port output latch (p3dr) and p3 port terminal input (p3prd) are located on their respective address. when read the output latch data, the p3dr should be r ead and when read the termin al input data, the p3prd reg- ister should be read. if a read instruction is execute d for port p3, read data of bits 7 to 4 are unstable. figure 5-4 port p3 port p3 control register p3dr (0003h) r/w 76543210 p33 pwm6 pdo6 ppg6 tc6 p32 pwm4 pdo4 ppg4 tc4 p31 pwm3 pdo3 tc3 p30 dvo (initial value: **** 1111) p3outcr (0004h) 76543210 (initial value: **** 0000) p3outcr port p3 output circuit control (set for each bit individually) 0: sink open-drain output 1: c-mos ouput r/w p3prd (000ah) read only 76543210 p33 p32 p31 p30 |