![]() |
|
If you can't view the Datasheet, Please click here to try to view without PDF Reader . |
|
Datasheet File OCR Text: |
rene s a s 1 6 -bit s in g le- c hip mi c r oco mp u te r m16 c family / m16 c /tin y s erie s m16c/26a group(m16c/26a,m16c/26t) 16 rev. 1.00 revision date: mar.15, 2005 hardware manual www.renesas.com before using this material, please visit our website to verify that this is the most current document available. rej09b0202-0100
keep safety first in your circuit designs! notes regarding these materials renesas technology corporation puts the maximum effort into making semiconductor prod- ucts better and more reliable, but there is always the possibility that trouble may occur with them. trouble with semiconductors may lead to personal injury, fire or property damage. remember to give due consideration to safety when making your circuit designs, with ap- propriate measures such as (i) placement of substitutive, auxiliary circuits, (ii) use of non- flammable material or (iii) prevention against any malfunction or mishap. these materials are intended as a reference to assist our customers in the selection of the renesas technology corporation product best suited to the customer's application; they do not convey any license under any intellectual property rights, or any other rights, belonging to renesas technology corporation or a third party. renesas technology corporation assumes no responsibility for any damage, or infringe- ment of any third-party's rights, originating in the use of any product data, diagrams, charts, programs, algorithms, or circuit application examples contained in these materials. all information contained in these materials, including product data, diagrams, charts, pro- grams and algorithms represents information on products at the time of publication of these materials, and are subject to change by renesas technology corporation without notice due to product improvements or other reasons. it is therefore recommended that custom- ers contact renesas technology corporation or an authorized renesas technology cor- poration product distributor for the latest product information before purchasing a product listed herein. the information described here may contain technical inaccuracies or typographical errors. renesas technology corporation assumes no responsibility for any damage, liability, or other loss rising from these inaccuracies or errors. please also pay attention to information published by renesas technology corporation by various means, including the renesas technology corporation semiconductor home page (http://www.renesas.com). when using any or all of the information contained in these materials, including product data, diagrams, charts, programs, and algorithms, please be sure to evaluate all informa- tion as a total system before making a final decision on the applicability of the information and products. renesas technology corporation assumes no responsibility for any dam- age, liability or other loss resulting from the information contained herein. renesas technology corporation semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is poten- tially at stake. please contact renesas technology corporation or an authorized renesas technology corporation product distributor when considering the use of a product con- tained herein for any specific purposes, such as apparatus or systems for transportation, vehicular, medical, aerospace, nuclear, or undersea repeater use. the prior written approval of renesas technology corporation is necessary to reprint or reproduce in whole or in part these materials. if these products or technologies are subject to the japanese export control restrictions, they must be exported under a license from the japanese government and cannot be im- ported into a country other than the approved destination. any diversion or reexport contrary to the export control laws and regulations of japan and/ or the country of destination is prohibited. please contact renesas technology corporation for further details on these materials or t he products contained therein. how to use this manual 1. introduction this hardware manual provides detailed information on the m16c/26 group (m16c/26a, m16c/26t) microcom- puters. users are expected to have basic knowledge of electric circuits, logical circuits and microcomputers. 2. register diagram the symbols, and descriptions, used for bit function in each register are shown below. function xxx register bit name bit symbol symbol address after reset xxx xxx 00h rw rw rw wo ro xxx0 xxx1 (b2) (b4 - b3) xxx bit reserved bit xxx7 set to "0" 0: xxx 1: xxx nothing is assigned. when write, set to "0". when read, its content is indeterminate. xxx bit 0 0: xxx 0 1: xxx 1 0: do not set a value 1 1: xxx b1 b0 xxx bit function varies depending on mode of operation xxx5 xxx6 0 rw rw b7 b6 b5 b4 b3 b2 b1 b0 *1 *2 *4 *3 0 *5 *1 blank:set to "0" or "1" according to the application 0: set to "0" 1: set to "1" x: nothing is assigned *2 rw: read and write ro: read only wo: write only ? nothing is assigned *3 ?reserved bit reserved bit. set to specified value. *4 ?nothing is assigned nothing is assigned to the bit concerned. as the bit may be use for future functions, set to "0" when writing to this bit. ?do not set a value the operation is not guaranteed when a value is set. ?function varies depending on mode of operation bit function varies depending on peripheral function mode. refer to respective register for each mode. 3. m16c family documents the following documents were prepared for the m16c family. (1) document contents short sheet hardware overview data sheet hardware overview and electrical characteristics hardware manual hardware specifications (pin assignments, memory maps, peripheral specifications, electrical characteristics, timing charts) software manual detailed description of assembly instructions and microcomputer perfor- mance of each instruction application note ?application examples of peripheral functions ?sample programs ?introduction to the basic functions in the m16c family ?programming method with assembly and c languages renesas technical update preliminary report about the specification of a product, a document, etc. notes : 1. before using this material, please visit the our website to verify that this is the most current document available. a-1 table of contents quick reference by address _____________________ b-1 1. overview _____________________________________ 1 1.1 applications ............................................................................................................... .. 1 1.2 performance outline ................................................................................................... 2 1.3 block diagram ............................................................................................................. 4 1.4 product list ............................................................................................................... .. 6 1.5 pin configuration ........................................................................................................ 9 1.6 pin description .......................................................................................................... 11 2. central processing unit (cpu)___________________ 13 2.1 data registers (r0, r1, r2 and r3) ......................................................................... 13 2.2 address registers (a0 and a1) ................................................................................ 13 2.3 frame base register (fb) ........................................................................................ 14 2.4 interrupt table register (intb) ................................................................................ 14 2.5 program counter (pc) .............................................................................................. 14 2.6 user stack pointer (usp) and interrupt stack pointer (isp) ................................. 14 2.7 static base register (sb) ......................................................................................... 14 2.8 flag register (flg) ................................................................................................... 14 2.8.1 carry flag (c flag) ............................................................................................. 14 2.8.2 debug flag (d flag) ........................................................................................... 14 2.8.3 zero flag (z flag) .............................................................................................. 14 2.8.4 sign flag (s flag) ............................................................................................... 14 2.8.5 register bank select flag (b flag) .................................................................. 14 2.8.6 overflow flag (o flag) ....................................................................................... 14 2.8.7 interrupt enable flag (i flag) ............................................................................ 14 2.8.8 stack pointer select flag (u flag) .................................................................... 14 2.8.9 processor interrupt priority level (ipl) ........................................................... 14 2.8.10 reserved area .................................................................................................. 14 3. memory______________________________________ 15 4. special function register (sfr) _________________ 16 5. reset________________________________________ 22 5.1 hardware reset ......................................................................................................... 22 5.1.1 hardware reset 1 ............................................................................................... 22 5.1.2 hardware reset 2 ............................................................................................... 22 a-2 5.2 software reset .......................................................................................................... 23 5.3 watchdog timer reset ............................................................................................. 23 5.4 oscillation stop detection reset ............................................................................. 23 5.5 voltage detection circuit .......................................................................................... 25 6. processor mode ______________________________ 31 7. clock generation circuit ................................................ 32 7.1 main clock ................................................................................................................. 39 7.2 sub clock .................................................................................................................. .40 7.3 on-chip oscillator clock .......................................................................................... 41 7.4 pll clock .................................................................................................................. .41 7.5 cpu clock and peripheral function clock ............................................................. 43 7.5.1 cpu clock ........................................................................................................... 43 7.5.2 peripheral function clock(f 1 , f 2 , f 8 , f 32 , f 1sio , f 2sio , f 8sio , f 32sio , f ad, f c32 ) ........ 43 7.5.3 clockoutput function ....................................................................................... 43 7.6 power control ............................................................................................................ 44 7.6.1 normal operation mode .................................................................................... 44 7.6.2 wait mode ........................................................................................................... 45 7.6.3 stop mode .......................................................................................................... 47 7.7 system clock protective function .......................................................................... 51 7.8 oscillation stop and re-oscillation detect function ............................................. 51 7.8.1 operation when the cm27 bit is set to "0" (oscillation stop detection reset) ...... 52 7.8.2 operation when the cm27 bit is set to "1" (oscillation stop and re-oscillation detect interrupt) ... 52 7.8.3 how to use oscillation stop and re-oscillation detect function ................. 53 8. protection____________________________________ 54 9. interrupt _____________________________________ 55 9.1 type of interrupts ...................................................................................................... 55 9.1.1 software interrupts ............................................................................................ 56 9.1.2 hardware interrupts ........................................................................................... 57 9.2 interrupts and interrupt vector ................................................................................ 58 9.2.1 fixed vector tables ........................................................................................... 58 9.2.2 relocatable vector tables ................................................................................. 59 9.3 interrupt control ........................................................................................................ 60 9.3.1 i flag ................................................................................................................... .63 9.3.2 ir bit ................................................................................................................... .63 9.3.3 ilvl2 to ilvl0 bits and ipl ............................................................................... 63 a-3 9.4 interrupt sequence ................................................................................................... 64 9.4.1 interrupt response time ................................................................................... 65 9.4.2 variation of ipl when interrupt request is accepted ..................................... 65 9.4.3 saving registers ................................................................................................ 66 9.4.4 returning from an interrupt routine ................................................................ 68 9.5 interrupt priority ........................................................................................................ 6 8 9.5.1 interrupt priority resolution circuit ................................................................. 68 ______ 9.6 int interrupt .............................................................................................................. .70 ______ 9.7 nmi interrupt .............................................................................................................. 71 9.8 key input interrupt .................................................................................................... 71 9.9 address match interrupt ........................................................................................... 72 10. watchdog timer _____________________________ 74 10.1 count source protective mode .............................................................................. 75 10.2 cold start / warm start ............................................................................................ 76 11. dmac ______________________________________ 77 11.1 transfer cycles ....................................................................................................... 82 11.2. dma transfer cycles .............................................................................................. 84 11.3 dma enable .............................................................................................................. 85 11.4 dma request ........................................................................................................... 85 11.5 channel priority and dma transfer timing ......................................................... 86 12. timer_______________________________________ 87 12.1 timer a .................................................................................................................. .. 89 12.1.1. timer mode ...................................................................................................... 92 12.1.2. event counter mode ....................................................................................... 93 12.1.3. one-shot timer mode ..................................................................................... 98 12.1.4. pulse width modulation (pwm) mode ......................................................... 100 12.2 timer b .................................................................................................................. 103 12.2.1 timer mode .................................................................................................... 106 12.2.2 event counter mode ...................................................................................... 107 12.2.3 pulse period and pulse width measurement mode ................................... 108 12.2.4 a/d trigger mode .......................................................................................... 110 12.3 three-phase motor control timer function ....................................................... 112 12.3.1 position-data-retain function ....................................................................... 123 12.3.2 three-phase/port output switch function .................................................. 125 a-4 13. serial i/o ___________________________________ 127 13.1. uarti (i=0 to 2) .................................................................................................... 127 13.1.1. clock synchronous serial i/o mode ............................................................ 137 13.1.2. clock asynchronous serial i/o (uart) mode ............................................ 145 13.1.3 special mode 1 (i 2 c bus mode)(uart2) ...................................................... 153 13.1.4 special mode 2 (uart2) ................................................................................ 163 13.1.5 special mode 3 (ie bus mode )(uart2) ..................................................... 168 13.1.6 special mode 4 (sim mode) (uart2) .......................................................... 170 14. a/d converter ______________________________ 175 14.1 operation modes ................................................................................................... 181 14.1.1 one-shot mode .............................................................................................. 181 14.1.2 repeat mode .................................................................................................. 183 14.1.3 single sweep mode ...................................................................................... 185 14.1.4 repeat sweep mode 0 ................................................................................... 187 14.1.5 repeat sweep mode 1 ................................................................................... 189 14.1.6 simultaneous sample sweep mode ............................................................. 191 14.1.7 delayed trigger mode 0 ................................................................................. 194 14.1.8 delayed trigger mode 1 ................................................................................. 200 14.2 resolution select function .................................................................................. 206 14.3 sample and hold ................................................................................................... 206 14.4 power consumption reducing function ............................................................ 206 14.5 output impedance of sensor under a/d conversion ........................................ 207 15. crc calculation circuit ______________________ 208 15.1. crc snoop ........................................................................................................... 208 16. programmable i/o ports ______________________ 211 16.1 port pi direction register (pdi register, i = 1, 6 to 10)...................................... 211 16.2 port pi register (pi register, i = 1, 6 to 10) ......................................................... 211 16.3 pull-up control register 0 to pull-up control register 2 (pur0 to pur2 registers) ........ 211 16.4 port control register ............................................................................................ 212 16.5 pin assignment control register (pacr) ............................................................ 212 16.6 digital debounce function .................................................................................... 212 17. flash memory version _______________________ 225 17.1 flash memory performance ................................................................................. 225 17.2 memory map .......................................................................................................... 227 a-5 17.3 functions to prevent flash memory from rewriting ........................................ 230 17.3.1 rom code protect function ......................................................................... 230 17.3.2 id code check function ............................................................................... 230 17.4 cpu rewrite mode ................................................................................................ 232 17.4.1 ew0 mode ....................................................................................................... 233 17.4.2 ew1 mode ....................................................................................................... 233 17.5 register description ............................................................................................. 234 17.5.1 flash memory control register 0 (fmr0) ..................................................... 234 17.5.2 flash memory control register 1 (fmr1) ..................................................... 235 17.5.3 flash memory control register 4 (fmr4) ..................................................... 235 17.6 precautions in cpu rewrite mode ...................................................................... 240 17.6.1 operation speed ............................................................................................ 240 17.6.2 prohibited instructions .................................................................................. 240 17.6.3 interrupts ........................................................................................................ 240 17.6.4 how to access................................................................................................ 240 17.6.5 writing in the user rom space .................................................................... 240 17.6.6 dma transfer .................................................................................................. 241 17.6.7 writing command and data .......................................................................... 241 17.6.8 wait mode ....................................................................................................... 241 17.6.9 stop mode ....................................................................................................... 241 17.6.10 low power consumption mode and on-chip oscillator-low power consumption mode .......................................................................... 241 17.7 software commands ............................................................................................ 242 17.7.1 read array command (ff16)........................................................................ 242 17.7.2 read status register command (7016) ....................................................... 242 17.7.3 clear status register command (5016) ....................................................... 243 17.7.4 program command (4016) ............................................................................ 243 17.7.5 block erase .................................................................................................... 244 17.8 status register ...................................................................................................... 246 17.8.1 sequence status (sr7 and fmr00 bits ) ..................................................... 246 17.8.2 erase status (sr5 and fmr07 bits) ............................................................. 246 17.8.3 program status (sr4 and fmr06 bits) ........................................................ 246 17.8.4 full status check ........................................................................................... 247 17.9 standard serial i/o mode ...................................................................................... 249 17.9.1 id code check function ............................................................................... 249 17.9.2 example of circuit application in standard serial i/o mode ..................... 253 17.10 parallel i/o mode ................................................................................................. 255 17.10.1 rom code protect function ....................................................................... 255 a-6 18. electrical characteristics _____________________ 256 18.1. normal version ..................................................................................................... 256 18.2. t version ............................................................................................................... 2 75 19. usage precaution ___________________________ 294 19.1 sfr ....................................................................................................................... .. 294 19.1.1 precaution for 48 pin version ....................................................................... 294 19.1.2 precaution for 42 pin version ....................................................................... 294 19.2 pll frequency synthesizer ................................................................................. 295 19.3 power control ........................................................................................................ 296 19.4 protect ................................................................................................................... . 298 19.5 interrupts ............................................................................................................... 2 99 19.5.1 reading address 0000016 ............................................................................. 299 19.5.2 setting the sp ................................................................................................. 299 _______ 19.5.3 the nmi interrupt ........................................................................................... 299 19.5.4 changing the interrupt generation factor .................................................. 300 19.5.6 rewrite the interrupt control register ......................................................... 301 19.5.7 watchdog timer interrupt ............................................................................. 302 19.6 dmac ..................................................................................................................... 3 03 19.6.1 write to dmae bit in dmicon register ....................................................... 303 19.7 timer..................................................................................................................... .. 304 19.7.1 timer a ............................................................................................................ 304 19.7.2 timer b ............................................................................................................ 308 19.8 serial i/o (clock-synchronous serial i/o) ........................................................... 311 19.8.1 transmission/reception................................................................................. 311 19.8.2 transmission .................................................................................................. 312 19.8.3 reception ........................................................................................................ 313 19.9 serial i/o (uart mode) ......................................................................................... 314 19.9.1 special mode 1 (i 2 c bus mode) ..................................................................... 314 19.9.2 special mode 2 ............................................................................................... 314 19.9.3 special mode 4 (sim mode) ........................................................................... 314 19.10 a/d converter ...................................................................................................... 315 19.11 programmable i/o ports ..................................................................................... 317 19.12 electric characteristic differences between mask rom and flash memory version microcomputers ..................................................................... 318 19.13 mask rom version .............................................................................................. 318 19.13.1 internal rom area ........................................................................................ 318 19.13.2 reserve bit .................................................................................................... 318 a-7 19.14 flash memory version ........................................................................................ 319 19.14.1 functions to inhibit rewriting flash memory ........................................... 319 19.14.2 stop mode .................................................................................................... 319 19.14.3 wait mode ..................................................................................................... 319 19.14.4 low power dissipation mode, on-chip oscillator low power dissipation mode ...... 319 19.14.5 writing command and data ......................................................................... 319 19.14.6 program command ...................................................................................... 319 19.14.7 operation speed ........................................................................................... 319 19.14.8 instructions prohibited in ew0 mode ........................................................ 320 19.14.9 interrupts ...................................................................................................... 320 19.14.10 how to access ............................................................................................ 320 19.14.11 writing in the user rom area .................................................................... 320 19.14.12 dma transfer............................................................................................... 320 19.14.13 regarding programming/erasure times and execution time .............. 321 19.14.14 definition of programming/erasure times .............................................. 321 19.14.15 flash memory version electrical characteristics 10,000 e/w cycle products (u7, u9) ............................................................................. 321 19.14.16 boot mode .................................................................................................. 321 19.15 noise .................................................................................................................... 322 19.16 instruction for a device use ............................................................................... 323 appendix 1. package dimensions _________________ 324 appendix 2. functional difference ________________ 325 appendix 2.1 differences between m16c/26a and m16c/26t................................... 325 appendix 2.2 differences between m16c/26a and m16c/26 ..................................... 326 register index _________________________________ 327 b-1 quick reference by address 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 0010 16 0011 16 0012 16 0013 16 0014 16 0015 16 0016 16 0017 16 0018 16 0019 16 001a 16 001b 16 001c 16 001d 16 001e 16 001f 16 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 0027 16 0028 16 0029 16 002a 16 002b 16 002c 16 002d 16 002e 16 002f 16 0030 16 0031 16 0032 16 0033 16 0034 16 0035 16 0036 16 0037 16 0038 16 0039 16 003a 16 003b 16 003c 16 003d 16 003e 16 003f 16 address note: the blank areas are reserved and cannot be accessed by users. register symbol page 0040 16 0041 16 0042 16 0043 16 0044 16 0045 16 0046 16 0047 16 0048 16 0049 16 004a 16 004b 16 004c 16 004d 16 004e 16 004f 16 0050 16 0051 16 0052 16 0053 16 0054 16 0055 16 0056 16 0057 16 0058 16 0059 16 005a 16 005b 16 005c 16 005d 16 005e 16 005f 16 0060 16 0061 16 0062 16 0063 16 0064 16 0065 16 0066 16 0067 16 0068 16 0069 16 006a 16 006b 16 006c 16 006d 16 006e 16 006f 16 0070 16 0071 16 0072 16 0073 16 0074 16 0075 16 0076 16 0077 16 0078 16 0079 16 007a 16 007b 16 007c 16 007d 16 007e 16 007f 16 watchdog timer start register wdts watchdog timer control register wdc processor mode register 0 pm0 system clock control register 0 cm0 system clock control register 1 cm1 address match interrupt enable register aier protect register prcr processor mode register 1 pm1 oscillation stop detection register cm2 pll control register 0 plc0 processor mode register 2 pm2 address match interrupt register 0 rmad0 address match interrupt register 1 rmad1 dma0 control register dm0con dma0 transfer counter tcr0 dma1 control register dm1con dma1 source pointer sar1 dma1 destination pointer dar1 dma0 destination pointer dar0 dma0 source pointer sar0 voltage detection register 1 vcr1 voltage detection register 2 vcr2 voltage down detection interrupt register d4int uart0 transmit interrupt control register s0tic uart0 receive interrupt control register s0ric uart1 transmit interrupt control register s1tic uart1 receive interrupt control register s1ric dma1 transfer counter tcr1 int3 interrupt control register int3ic int5 interrupt control register int5ic int4 interrupt control register int4ic uart2 bus collision detection interrupt control register bcnic dma0 interrupt control register dm0ic dma1 interrupt control register dm1ic key input interrupt control register kupic a/d conversion interrupt control register adic uart2 transmit interrupt control register s2tic uart2 receive interrupt control register s2ric timer a0 interrupt control register ta0ic timer a1 interrupt control register ta1ic timer a2 interrupt control register ta2ic timer a3 interrupt control register ta3ic timer a4 interrupt control register ta4ic timer b0 interrupt control register tb0ic timer b2 interrupt control register tb2ic int0 interrupt control register int0ic int1 interrupt control register int1ic int2 interrupt control register int2ic timer b1 interrupt control register tb1ic 31 31 34 35 73 54 36 75 75 73 73 26 26 38 37 26 81 81 81 80 81 81 81 80 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 address register symbol page b-2 quick reference by address note 1: the blank areas are reserved and cannot be accessed by users. note 2: this register is included in the flash memory version. 0080 16 0081 16 0082 16 0083 16 0084 16 0085 16 0086 16 01b0 16 01b1 16 01b2 16 01b3 16 01b4 16 01b5 16 01b6 16 01b7 16 01b8 16 01b9 16 01ba 16 01bb 16 01bc 16 01bd 16 01be 16 01bf 16 0250 16 0251 16 0252 16 0253 16 0254 16 0255 16 0256 16 0257 16 0258 16 0259 16 025a 16 025b 16 025c 16 025d 16 025e 16 025f 16 02e0 16 02e1 16 02e2 16 02e3 16 02e4 16 02e5 16 02e6 16 02e7 16 02e8 16 02e9 16 033d 16 033e 16 033f 16 peripheral clock select register pclkr flash memory control register 0 fmr0 flash memory control register 1 fmr1 236 236 37 (note 2) (note 2) address register symbol page (note 2) flash memory control register 4 fmr4 237 pin assignment control register pacr on-chip oscillator control register rocr 134, 221 35 p1 7 digital debounce register p17ddr nmi digital debounce register nddr 222 222 three phase protect control register tprc 0340 16 0341 16 0342 16 0343 16 0344 16 0345 16 0346 16 0347 16 0348 16 0349 16 034a 16 034b 16 034c 16 034d 16 034e 16 034f 16 0350 16 0351 16 0352 16 0353 16 0354 16 0355 16 0356 16 0357 16 0358 16 0359 16 035a 16 035b 16 035c 16 035d 16 035e 16 035f 16 0360 16 0361 16 0362 16 0363 16 0364 16 0365 16 0366 16 0367 16 0368 16 0369 16 036a 16 036b 16 036c 16 036d 16 036e 16 036f 16 0370 16 0371 16 0372 16 0373 16 0374 16 0375 16 0376 16 0377 16 0378 16 0379 16 037a 16 037b 16 037c 16 037d 16 037e 16 037f 16 timer a1-1 register ta11 timer a2-1 register ta21 dead time timer dtt timer b2 interrupt occurrence frequency set counter ictb2 three-phase pwm control register 0 invc0 three-phase pwm control register 1 invc1 three-phase output buffer register 0 idb0 three-phase output buffer register 1 idb1 interrupt request cause select register ifsr uart2 special mode register u2smr uart2 receive buffer register u2rb uart2 transmit buffer register u2tb uart2 transmit/receive control register 0 u2c0 uart2 transmit/receive mode register u2mr uart2 transmit/receive control register 1 u2c1 uart2 bit rate generator u2brg timer a4-1 register ta41 uart2 special mode register 2 u2smr2 uart2 special mode register 3 u2smr3 uart2 special mode register 4 u2smr4 117 117 117 114 115 116 116 116 116 136 136 135 135 132 131 131 133 134 131 62, 70 address register symbol page position-data-retain function contol register pdrf 124 port function contol register pfcr interrupt request cause select register 2 ifsr2a 62 126 126 b-3 quick reference by address note : the blank areas are reserved and cannot be accessed by users. 0380 16 0381 16 0382 16 0383 16 0384 16 0385 16 0386 16 0387 16 0388 16 0389 16 038a 16 038b 16 038c 16 038d 16 038e 16 038f 16 0390 16 0391 16 0392 16 0393 16 0394 16 0395 16 0396 16 0397 16 0398 16 0399 16 039a 16 039b 16 039c 16 039d 16 039e 16 039f 16 03a0 16 03a1 16 03a2 16 03a3 16 03a4 16 03a5 16 03a6 16 03a7 16 03a8 16 03a9 16 03aa 16 03ab 16 03ac 16 03ad 16 03ae 16 03af 16 03b0 16 03b1 16 03b2 16 03b3 16 03b4 16 03b5 16 03b6 16 03b7 16 03b8 16 03b9 16 03ba 16 03bb 16 03bc 16 03bd 16 03be 16 03bf 16 count start flag tabsr trigger select register trgsr timer a0 register ta0 timer a1 register ta1 timer a2 register ta2 timer b0 register tb0 timer b1 register tb1 timer b2 register tb2 one-shot start flag onsf timer a0 mode register ta0mr timer a1 mode register ta1mr timer a2 mode register ta2mr timer b0 mode register tb0mr timer b1 mode register tb1mr timer b2 mode register tb2mr up-down flag udf timer a3 register ta3 timer a4 register ta4 timer a3 mode register ta3mr timer a4 mode register ta4mr clock prescaler reset flag cpsrf uart0 transmit/receive mode register u0mr uart0 transmit buffer register u0tb uart0 receive buffer register u0rb uart1 transmit/receive mode register u1mr uart1 transmit buffer register u1tb uart1 receive buffer register u1rb uart0 bit rate generator u0brg uart0 transmit/receive control register 0 u0c0 uart0 transmit/receive control register 1 u0c1 uart1 bit rate generator u1brg uart1 transmit/receive control register 0 u1c0 uart1 transmit/receive control register 1 u1c1 dma1 request cause select register dm1sl dma0 request cause select register dm0sl uart transmit/receive control register 2 ucon timer b2 special mode register tb2sc 90, 105, 119 91 91, 105 91, 119 90 105 105 105, 119 89 89, 120 89 104 104 111, 118 132 131 131 133 134 131 132 131 131 133 134 131 133 79 80 90 90, 117 90, 117 90 90, 117 89, 120 89, 120 104, 120 address register symbol page crc snoop address register crcsar crc mode register crcmr crc data register crcd crc input register crcin 03c0 16 03c1 16 03c2 16 03c3 16 03c4 16 03c5 16 03c6 16 03c7 16 03c8 16 03c9 16 03ca 16 03cb 16 03cc 16 03cd 16 03ce 16 03cf 16 03d0 16 03d1 16 03d2 16 03d3 16 03d4 16 03d5 16 03d6 16 03d7 16 03d8 16 03d9 16 03da 16 03db 16 03dc 16 03dd 16 03de 16 03df 16 03e0 16 03e1 16 03e2 16 03e3 16 03e4 16 03e5 16 03e6 16 03e7 16 03e8 16 03e9 16 03ea 16 03eb 16 03ec 16 03ed 16 03ee 16 03ef 16 03f0 16 03f1 16 03f2 16 03f3 16 03f4 16 03f5 16 03f6 16 03f7 16 03f8 16 03f9 16 03fa 16 03fb 16 03fc 16 03fd 16 03fe 16 03ff 16 a/d control register 1 adcon1 port p9 register p9 pull-up control register 0 pur0 port control register pcr a/d register 7 ad7 a/d register 0 ad0 a/d register 1 ad1 a/d register 2 ad2 a/d register 3 ad3 a/d register 4 ad4 a/d register 5 ad5 a/d register 6 ad6 a/d control register 0 adcon0 a/d control register 2 adcon2 port p1 register p1 port p1 direction register pd1 port p6 register p6 port p6 direction register pd6 port p7 register p7 port p7 direction register pd7 port p8 register p8 port p8 direction register pd8 port p9 direction register pd9 port p10 register p10 port p10 direction register pd10 pull-up control register 1 pur1 pull-up control register 2 pur2 179 179 179 179 179 179 179 179 177 177 177 219 218 219 219 218 218 219 219 218 218 219 218 220 220 220 221 address register symbol page a/d convert status register 0 adstat0 179 a/d trigger control register adtrgcon 178 209 209 209 209 m16c/26a group(m16c/26a, m16c/26t) single-chip 16-bit cmos microcomputer rej09b0202-0100 rev.1.00 mar. 15, 2005 page 1 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r 1. overview the m16c/26a group(m16c/26a, m16c/26t) of single-chip microcomputers is built using the high-perfor- mance silicon gate cmos process using a m16c/60 series cpu core and is packaged in a 42-pin and 48- pin plastic molded qfp. these single-chip microcomputers operate using sophisticated instructions featur- ing a high level of instruction efficiency. with 1m bytes of address space, they are capable of executing instructions at high speed. in addition, this microcomputer contains a multiplier and a dmac which com- bined with fast instruction processing capability, makes it suitable for control of various oa, communication, and industrial equipment which requires high-speed arithmetic/logic operations. there is a normal-ver. for m16c/26a and t-ver. and v-ver. for m16c/26t. 1.1 applications audio, cameras, office equipment, communications equipment, portable equipment, home appliances (inverter solution), auotmotives, motor control, etc 1. overview page 2 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m item performance cpu number of basic instructions 91 instructions minimun instruction execution 50 ns (f(bclk)= 20mh z , v cc = 3.0v to 5.5v) (m16c/26a, m16c/26t(t-ver.)) time 100 ns (f(bclk)= 10mh z , v cc = 2.7v to 5.5v) (m16c/26a) 50 ns (f(bclk)= 20mh z , v cc = 4.2v to 5.5v -40 to 105 c) (m16c/26t(v-ver.)) 62.5 ns (f(bclk)= 16mh z , v cc = 4.2v to 5.5v -40 to 125 c) (m16c/26t(v-ver.)) operation mode single chip mode address space 1m byte memory capacity rom/ram : see the product list peripheral port input/output : 39 lines function multifunction timer timera:16 bits x 5 channels, timerb:16 bits x 3 channels three-phase motor control timer serial i/o 2 channels (uart, clock synchronous serial i/o) 1 channel (uart, clock synchronous, i 2 c bus (1) , or iebus (2) ) a/d converter 10 bit a/d converter : 1 circuit, 12 channels dmac 2 channels crc calcuration circuit 2 polynomial (crc-ccitt and crc-16) with msb/lsb selectable watchdog timer 15 bits x 1 channel (with prescaler) interrupt 20 internal and 8 external sources, 4 software sources, 7 levels clock generation circuit 4 circuits main clock(*), sub-clock(*) on-chip oscillator, pll frequency synthesizer (*)these circuit contain a built-in feedback resister. oscillation stop detection main clock oscillation stop, re-oscillation detection function voltage detection circuit available(m16c/26a, option (4) ), absent(m16c/26t) electrical power supply voltage v cc =3.0v to 5.5v ( f(bclk)=20mh z ) (m16c/26a) characteristics v cc = 2.7v to 5.5v ( f(bclk)=10mh z ) v cc =3.0v to 5.5v (m16c/26t(t-ver.)) v cc =4.2v to 5.5v (m16c/26t(v-ver.)) power consumption 16ma (vcc=5v, f(bclk)=20mhz) 25 a (vcc=3v, f(bclk)=f(x cin )=32khz on ram) 1.8 a (vcc=3v, f(bclk)=f(x cin )=32khz, in wait mode) 0.7 a (vcc=3v, in stop mode) flash memory program/erase supply voltage 2.7v to 5.5v (m16c/26a) version 3.0v to 5.5v (m16c/26t(t-ver.)) 4.2v to 5.5v (m16c/26t(v-ver.)) program and erase endurance 100 times (all area) or 1,000 times (block 0 to 3) / 10,000 times (block a, block b) (3) operating ambient temperature -20 to 85 c / -40 to 85 c (3) (m16c/26a) -40 to 85 c (m16c/26t(t-ver.)) -40 to 105 c / -40 to 125 c (m16c/26t(v-ver.)) package 48-pin plastic molded qfp notes: 1. i 2 c bus is a trademark of koninklijke philips electronics n. v. 2. iebus is a trademark of nec electronics corporation. 3. see table 1.6 product code for the program and erase endurance, and operating ambient temperature. 4. the option is on a request basis. table 1.1. performance outline of m16c/26a group(m16c/26a, m16c/26t) (48-pin device) 1.2 performance outline table 1.1 lists performance outline of m16c/26a group 48-pin device. table 1.2 lists performance outline of m16c/26a group 42-pin device. 1. overview page 3 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m table 1.2. performance outline of m16c/26a group (m16c/26a) (42-pin device) item performance cpu number of basic instructions 91 instructions minimun instruction execution 50 ns (f(bclk)= 20mh z , v cc = 3.0v to 5.5v) time 100 ns (f(bclk)= 10mh z , v cc = 2.7v to 5.5v) operation mode single chip mode address space 1m byte memory capacity rom/ram : see the product list peripheral port input/output : 33 lines function multifunction timer timera:16 bits x 5 channels, timerb:16 bits x 3 channels three-phase motor control timer serial i/o 1 channel (uart, clock synchronous serial i/o) 1 channel (uart, clock synchronous, i 2 c bus (1) , or iebus (2) ) a/d converter 10 bit a/d converter : 1 circuit, 10 channels dmac 2 channels crc calcuration circuit 2 polynomial (crc-ccitt and crc-16) with msb/lsb selectable watchdog timer 15 bits x 1 channel (with prescaler) interrupt 18 internal and 8 external sources, 4 software sources, 7 levels clock generation circuit 4 circuits main clock(*), sub-clock(*) on-chip oscillator, pll frequency synthesizer (*)these circuit contain a built-in feedback resister. oscillation stop detection main clock oscillation stop, re-oscillation detection function voltage detection circuit available (option (4) ) electrical power supply voltage v cc =3.0v to 5.5v ( f(bclk)=20mh z ) characteristics v cc = 2.7v to 5.5v ( f(bclk)=10mh z ) power consumption 16ma (vcc=5v, f(bclk)=20mhz) 25 a (vcc=3v, f(bclk)=f(x cin )=32khz on ram) 1.8 a (vcc=3v, f(bclk)=f(x cin )=32khz, in wait mode) 0.7 a (vcc=3v, in stop mode) flash memory program/erase supply voltage 2.7v to 5.5v program and erase endurance 100 times (all area) or 1,000 times (block 0 to 3) / 10,000 times (block a, block b) (3) operating ambient temperature -20 to 85 c / -40 to 85 c (3) package 42-pin plastic molded ssop notes: 1. i 2 c bus is a trademark of koninklijke philips electronics n. v. 2. iebus is a trademark of nec electronics corporation. 3. see table 1.6 product code for the program and erase endurance, and operating ambient temperature. 4. the option is on a request basis. 1. overview page 4 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m i/o ports internal peripheral functions timer timer a0 (16 bits) timer a1 (16 bits) timer a2 (16 bits) timer a3 (16 bits) timer a4 (16 bits) timer b0 (16 bits) timer b1 (16 bits) timer b2 (16 bits) watchdog timer (15bits) a/d converter (10bits x 12 channels) u(s)art/sio (channel 0) serial ports system clock generator x in -x out x cin -x cout on-chip oscillator m16c/60 series 16-bit cpu core r0l r0h r1l r1h r2 r3 a0 a1 fr r0l r0h r1l r1h r2 r3 a0 a1 fb registers sb pc isp usp program counter stack pointers intb vector table flg flag register memory multiplier flash rom ram u(s)art/sio (channel 1) u(s)art/sio/i 2 c bus/iebus (channel 2) 3-phase pwm port p1 3 port p6 8 port p7 8 port p8 8 port p9 4 port p10 8 flash rom (data flash) dmac (2 channels) pll frequency synthesizer crc calculation circuit (ccitt, crc-16) 1.3 block diagram figure 1.1 is a block diagram of the m16c/26a group, 48-pin device. figure 1.1. m16c/26a group(m16c/26a, m16c/26t), 48-pin version block diagram 1. overview page 5 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 1.2 is a block diagram of the m16c/26a group, 42-pin device. figure 1.2. m16c/26a group(m16c/26a), 42-pin version block diagram i/o ports internal peripheral functions timer timer a0 (16 bits) timer a1 (16 bits) timer a2 (16 bits) timer a3 (16 bits) timer a4 (16 bits) timer b0 (16 bits) timer b1 (16 bits) timer b2 (16 bits) watchdog timer (15bits) a/d converter (10bits x 10 channels) u(s)art/sio (channel 0) serial ports system clock generator x in -x out x cin -x cout on-chip oscillator m16c/60 series 16-bit cpu core r0l r0h r1l r1h r2 r3 a0 a1 fr r0l r0h r1l r1h r2 r3 a0 a1 fb registers sb pc isp usp program counter stack pointers intb vector table flg flag register memory multiplier flash rom ram u(s)art/sio/i 2 c bus/iebus (channel 2) 3-phase pwm port p1 3 port p6 4 port p7 8 port p8 8 port p9 2 port p10 8 flash rom (data flash) dmac (2 channels) pll frequency synthesizer crc calculation circuit (ccitt, crc-16) 1. overview page 6 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 1.4 product list tables 1.3 to 1.5 list the m16c/26a group products and figure 1.3 shows the type numbers, memory sizes and packages. table 1.6 lists the product code of flash memory version and masked rom version for m16c/26a, and figure 1.4 shows the marking diagram of flash memory version and masked rom version. please contact renesas technology corp. or an authorized renesas technology corp. product distributor for the product code and the marking diagram of m16c/26t table 1.3. product list (1) -m16c/26a as of march 2005 type no. rom capacity ram capacity package type remarks m30260m3a-xxxgp (d) 24k byte 1k byte m30260m6a-xxxgp (d) 48k byte 2k byte 48p6q m30260m8a-xxxgp (d) 64k byte 2k byte m30263m3a-xxxfp (d) 24k byte 1k byte m30263m6a-xxxfp (d) 48k byte 2k byte 42p2r m30263m8a-xxxfp (d) 64k byte 2k byte m30260f3agp (d) 24k + 4k byte 1k byte m30260f6agp (d) 48k + 4k byte 2k byte 48p6q m30260f8agp (d) 64k + 4k byte 2k byte m30263f3afp (d) 24k + 4k byte 1k byte m30263f6afp (d) 48k + 4k byte 2k byte 42p2r m30263f8afp (d) 64k + 4k byte 2k byte (p) : under planning (d) : under development table 1.4. product list (2) -m16c/26t t-ver. as of march 2005 (p) : under planning (d) : under development notes. the specification of m16c/26t varies from the one of m16c/26a. table 1.5. product list (3) -m16c/26t v-ver. as of march 2005 (p) : under planning (d) : under development notes. the specification of m16c/26t varies from the one of m16c/26a. mask rom version flash rom version type no. rom capacity ram capacity package type remarks m30260m3t-xxxgp (p) 24k byte 1k byte m30260m6t-xxxgp (p) 48k byte 2k byte 48p6q mask rom version m30260m8t-xxxgp (p) 64k byte 2k byte m30260f3tgp (d) 24k + 4k byte 1k byte m30260f6tgp (d) 48k + 4k byte 2k byte 48p6q flash rom version m30260f8tgp (d) 64k + 4k byte 2k byte type no. rom capacity ram capacity package type remarks m30260m3v-xxxgp (p) 24k byte 1k byte m30260m6v-xxxgp (p) 48k byte 2k byte 48p6q mask rom version m30260m8v-xxxgp (p) 64k byte 2k byte m30260f3vgp (d) 24k + 4k byte 1k byte m30260f6vgp (d) 48k + 4k byte 2k byte 48p6q flash rom version m30260f8vgp (d) 64k + 4k byte 2k byte 1. overview page 7 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m package type: gp : package 48p6q (m16c/26a, m16c/26at) fp : package 42p2r (m16c/26a) version: a : m16c/26a t : m16c/26at t-ver. v : m16c/26at v-ver. rom / ram capacity: 3: (24k+4k) bytes (note 1) / 1k bytes 6: (48k+4k) bytes (note 1) / 2k bytes 8: (64k+4k) bytes (note 1) / 2k bytes note 1: only flash memory version exists in "+4k bytes" memory type: m: mask rom version f: flash memory version type no. m 3 0 2 6 0 m 8 a - xxx g p - 6 3 m16c/26a group m16c family shows pin count, (the value itself has no specific meaning) product code: see table 1.6 product code rom number: rom number is omitted in flash memory version figure 1.3. type no., memory size, and package product code package internal rom (program area) program and erase endurance temperature range internal rom (data area) operating ambient temperature temperature range lead-free u3 u5 u7 u9 100 1,000 0 c to 60 c 100 10,000 0 c to 60 c -40 c to 85 c -20 c to 85 c -40 c to 85 c -20 c to 85 c -40 c to 85 c -20 c to 85 c program and erase endurance product code package operating ambient temperature lead-free u3 u5 -40 c to 85 c -20 c to 85 c table 1.6 product code (flash memory version, m16c/26a) (mask rom version, m16c/26a) note 1: the lead contained products, d3, d5, d7 and d9, are put together with u3, u5, u7 and u9 respectively. lead-free (sn-cu plating) products can be mounted by both conventional sn-pb paste and lead-free paste. 1. overview page 8 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 0260f8a a u3 xxxxx (1) flash memory version, 48p6q, m16c/26a m30263f8afp a u3 xxxxxxx (2) flash memory version, 42p2r, m16c/26a 0260m8a 001a u3 xxxxx (3) mask rom version, 48p6q, m16c/26a m30263m8a-001fp a u3 xxxxxxx (4) mask rom version, 42p2r, m16c/26a product name : indicates m30260f8agp chip version and product code: a : indicates chip version the first edition is shown to be blank and continues with a and b. u3 : indicates product code (see table 1.6 product code ) date code (5 digits) ? indicates manufacturing management code product name : indicates m30260m8agp rom number, chip version and product code: 001: indicates rom number a : indicates chip version the first edition is shown to be blank and continues with a and b. u3 : indicates product code (see table 1.6 product code ) date code (5 digits) ? indicates manufacturing management code product name : indicates m30263f8afp chip version and product code: a : indicates chip version the first edition is shown to be blank and continues with a and b. u3 : indicates product code (see table 1.6 product code ) date code (7 digits) ? indicates manufacturing management code product name and rom number m30263m8a and fp are indicated of produnct name 001 is indicated of rom number chip version and product code: a : indicates chip version the first edition is shown to be blank and continues with a and b. u3 : indicates product code (see table 1.6 product code ) date code (7 digits) ? indicates manufacturing management code figure 1.4 marking diagram (top vier, m16c/26a) 1. overview page 9 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 24 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 36 35 34 33 32 31 30 29 28 27 26 25 48 47 46 45 44 43 42 41 40 39 38 37 p9 2 /tb2 in /an 32 p9 1 /tb1 in /an 31 cnv ss p1 7 /int 5 /idu p1 6 /int 4 /idw p1 5 /int 3 /ad trg /idv p10 7 /an 7 /ki 3 p7 0 /txd 2 /ta 0out /sda 2 /cts 1 /rts 1 /cts 0 /clks 1 x out v ss x in p8 5 /nmi/sd v cc p6 7 /txd 1 p6 6 /rxd 1 p6 5 /clk 1 reset p7 1 /rxd 2 /ta0 in /scl 2 /clk 1 p7 2 /clk 2 /ta1 out /v/rxd 1 p7 3 /cts 2 /rts 2 /ta1 in /v/txd 1 p7 4 /ta2 out /w p7 5 /ta2 in /w p7 6 /ta3 out p7 7 /ta3 in p8 0 /ta4 out /u p8 1 /ta4 in /u p8 2 /int 0 p8 3 /int 1 p6 4 /cts 1 /rts 1 /cts 0 /clks 1 p6 3 /txd 0 p6 2 /rxd 0 p6 1 /clk 0 p6 0 /cts 0 /rts 0 p9 0 /tb0 in /an 30 /clk out p8 7 /x cin p8 6 /x cout p10 6 /an 6 /ki 2 p10 5 /an 5 /ki 1 p10 4 /an 4 /ki 0 p10 3 /an 3 p10 2 /an 2 p10 1 /an 1 av ss p10 0 /an 0 v ref av cc p9 3 /an 24 p8 4 /int 2 /zp note. set pacr2 to pacr0 bit in the pacr register to "100 2 " before you input and output it after resetting to each pin. when the pacr register isn't set up, the input and output function of some of the p ins are disabled. package: 48p6q figure 1.5. pin configuration (top view) of m16c/26a group, 48-pin package pin configuration (top view)(note) 1.5 pin configuration figures 1.5 and 1.6 show the pin configurations (top view). 1. overview page 10 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 1.6. pin configuration (top view) of m16c/26a group, 42-pin package pin configuration (top view)(note) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 reset av ss p10 0 /an 0 v ref x in x out v ss v cc p8 6 /x cout p6 5 /clk 1 p8 3 /int 1 p8 2 /int 0 p8 1 /ta4 in /u p8 0 /ta4 out /u p7 7 /ta3 in p7 6 /ta3 out p7 5 /ta2 in /w p7 4 /ta2 out /w p6 4 /cts 1 /rts 1 /cts 0 /clks 1 p7 0 /txd 2 /sda 2 /ta0 out /cts 1 /rts 1 /cts 0 /clks 1 p7 1 /rxd 2 /scl 2 /ta0 in /clk 1 p7 2 /clk 2 /ta1 out /v/rxd 1 p7 3 /cts 2 /rts 2 /ta1 in /v/txd 1 av cc p9 1 /tb1 in /an 31 p9 0 /tb0 in /an 30 /clk out cnv ss p8 7 /x cin p6 6 /rxd 1 p6 7 /txd 1 p8 5 /nmi/sd p8 4 /int 2 /zp p1 7 /int 5 /idu p1 6 /int 4 /idw p1 5 /int 3 /ad trg /idv p10 7 /an 7 /ki 3 p10 6 /an 6 /ki 2 p10 5 /an 5 /ki 1 p10 4 /an 4 /ki 0 p10 3 /an 3 p10 2 /an 2 p10 1 /an 1 note. set pacr2 to pacr0 bit in the pacr register to "001 2 " before you input and output it after resetting to each pin. when the pacr register isn't set up, the input and output function of some of the p ins are disabled. package: 42p2r 1. overview page 11 ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r table 1.7. pin description(1) 1.6 pin description table 1.7 and 1.8 describes the available pins. pin name signal name i/o type function v cc ,v ss power supply apply 0v to the vss pin, and the following voltage to the vcc pin. input 2.7 to 5.5v (m16c/26a) 3.0 to 5.5v (m16c/26t t-ver.) 4.2 to 5.5v (m16c/26t v-ver.) cnv ss cnv ss input connect this pin to vss. ____________ reset reset input input "l" on this input resets the microcomputer. x in clock input input these pins are provided for the main clock generating circuit input/output. x out clock output output connect a ceramic resonator or crystal between the x in and the x out pins. to use an externally derived clock, input it to the x in pin and leave the x out pin open. if x in is not used (for external oscillator or external clock) connect x in pin to v cc and leave x out pin open. av cc analog power this pin is a power supply input for the a/d converter. connect this supply input pin to v cc . av ss analog power this pin is a power supply input for the a/d converter. connect this supply input pin to v ss . v ref reference input this pin is a reference voltage input for the a/d converter. voltage input p1 5 ~p1 7 i/o port p1 input/ this is an 3-bit cmos i/o port. it has an input/output port direction output register that allows the user to set each pin for input or output individually. when used for input, a pull-up resister option can be selected for the entire group of three pins. additional software selectable secondary ______ functions are: 1) p1 5 to p1 7 can be configured as external int interrupt pins; 2) p1 5 to p1 7 can be configured as position-data-retain function input pins,and; 3) p1 5 can input a trigger for the a/d converter. p6 0 ~p6 7 i/o port p6 input/ this is an 8-bit cmos i/o port. it has an input/output port direction output register that allows the user to set each pin for input or output individually. when used for input, a pull-up resister option can be selected for the entire group of four pins. pins in this port also function as uart0 and uart1 i/o, as selected by software. p6 0 to p6 3 are not available in the 42 pin version. p7 0 ~p7 7 i/o port p7 input/ this is an 8-bit i/o port equivalent to p6. p7 can also function as i/o for output timer a0 to a3, as selected by software. additional programming options are: p7 0 to p7 3 can assume uart1 i/o or uart2 i/o capabilities, and p7 2 to p7 5 can function as output pins for the three-phase motor control timer. 1. overview page 12 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m table 1.8. pin description(2) pin name signal name i/o type function p8 0 ~p8 7 i/o port p8 input/ this is an 8-bit i/o port equivalent to p6. additional software-selectable output secondary functions are: 1) p8 0 and p8 1 can act as either i/o for timer a4, or as output pins for the three-phase motor control timer; 2) p8 2 to ______ p8 4 can be configured as external int interrupt pins. p8 4 can be used for _______ _____ timer a zphase function; 3) p8 5 can be used as nmi/sd. p8 5 can not be used as i/o port while the three-phase motor control is enabled. apply a stable "h" to p8 5 after setting the direction register for p8 5 to "0" when the three-phase motor control is enabled, and; 4) p8 6 and p8 7 can serve as i/o pins for the sub-clock generation circuit. in this latter case, a quartz oscillator must be connented between p8 6 (x cout pin) and p8 7 (x cin pin). p9 0 ~p9 3 i/o port p9 input/ this is an 4-bit i/o port equivalent to p6. additional software-selectable output secondary functions are: 1) p9 0 to p9 2 can act as timer b0 to b2 input pins, and; 2) p9 0 to p9 3 can act as a/d converter input pins. p9 0 outputs a no-divide, divide-by-8 or divide-by-32 clock of x in or a clock of the same frequency as x cin as selected by program. p9 2 to p9 3 are not available in the 42 pin version. p10 0 ~p10 7 i/o port p10 input/ this is an 8-bit i/o port equivalent to p6. this port can also function as output a/d converter input pins, as selected by software. furthermore, p10 4 to p10 7 can also function as input pins for the key input interrupt function. 2. central processing unit(cpu) page 13 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 2. central processing unit (cpu) figure 2.1 shows the cpu registers. the cpu has 13 registers. of these, r0, r1, r2, r3, a0, a1 and fb comprise a register bank. there are two register banks. figure 2.1. central processing unit register 2.1 data registers (r0, r1, r2 and r3) the r0 register consists of 16 bits, and is used mainly for transfers and arithmetic/logic operations. r1 to r3 are the same as r0. the r0 register can be separated between high (r0h) and low (r0l) for use as two 8-bit data registers. r1h and r1l are the same as r0h and r0l. conversely, r2 and r0 can be combined for use as a 32- bit data register (r2r0). r3r1 is the same as r2r0. 2.2 address registers (a0 and a1) the register a0 consists of 16 bits, and is used for address register indirect addressing and address register relative addressing. they also are used for transfers and arithmetic/logic operations. a1 is the same as a0. in some instructions, registers a1 and a0 can be combined for use as a 32-bit address register (a1a0). data registers (note) address registers (note) frame base registers (note) program counter interrupt table register user stack pointer interrupt stack pointer static base register flag register note: these registers comprise a register bank. there are two register banks. r0h(r0's high bits) b15 b8 b7 b0 r3 intbh usp isp sb aa aa a a aa aa aa aa aaaaaa aaaaaa aa aa aa aa aa aa a a aa aa c d z s b o i u ipl r0l(r0's low bits) r1h(r1's high bits) r1l(r1's low bits) r2 b31 r3 r2 a1 a0 fb b19 intbl b15 b0 pc b19 b0 b15 b0 flg b15 b0 b15 b0 b7 b8 reserved area carry flag debug flag zero flag sign flag register bank select flag overflow flag interrupt enable flag stack pointer select flag reserved area processor interrupt priority level the upper 4 bits p g intb are intbh and the lower 16 bits of intb are intbl. 2. central processing unit(cpu) page 14 ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r 2.3 frame base register (fb) fb is configured with 16 bits, and is used for fb relative addressing. 2.4 interrupt table register (intb) intb is configured with 20 bits, indicating the start address of an interrupt vector table. 2.5 program counter (pc) pc is configured with 20 bits, indicating the address of an instruction to be executed. 2.6 user stack pointer (usp) and interrupt stack pointer (isp) stack pointer (sp) comes in two types: usp and isp, each configured with 16 bits. your desired type of stack pointer (usp or isp) can be selected by the u flag of flg. 2.7 static base register (sb) sb is configured with 16 bits, and is used for sb relative addressing. 2.8 flag register (flg) flg consists of 11 bits, indicating the cpu status. 2.8.1 carry flag (c flag) this flag retains a carry, borrow, or shift-out bit that has occurred in the arithmetic/logic unit. 2.8.2 debug flag (d flag) the d flag is used exclusively for debugging purpose. during normal use, it must be set to 0 . 2.8.3 zero flag (z flag) this flag is set to 1 when an arithmetic operation resulted in 0; otherwise, it is 0 . 2.8.4 sign flag (s flag) this flag is set to 1 when an arithmetic operation resulted in a negative value; otherwise, it is 0 . 2.8.5 register bank select flag (b flag) register bank 0 is selected when this flag is 0 ; register bank 1 is selected when this flag is 1 . 2.8.6 overflow flag (o flag) this flag is set to 1 when the operation resulted in an overflow; otherwise, it is 0 . 2.8.7 interrupt enable flag (i flag) this flag enables a maskable interrupt. maskable interrupts are disabled when the i flag is 0 , and are enabled when the i flag is 1 . the i flag is cleared to 0 when the interrupt request is accepted. 2.8.8 stack pointer select flag (u flag) isp is selected when the u flag is 0 ; usp is selected when the u flag is 1 . the u flag is cleared to 0 when a hardware interrupt request is accepted or an int instruction for software interrupt nos. 0 to 31 is executed. 2.8.9 processor interrupt priority level (ipl) ipl is configured with three bits, for specification of up to eight processor interrupt priority levels from level 0 to level 7. if a requested interrupt has priority greater than ipl, the interrupt is enabled. 2.8.10 reserved area when write to this bit, write "0". when read, its content is indeterminate. 3. memory page 15 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 3. memory figure 3.1 is a memory map. the linear address space of 1m bytes extends from address 00000 16 to fffff 16 . the internal rom is allocated in a lower address direction beginning with address fffff 16 . for example, a 64-kbyte internal rom is allocated to the address from f0000 16 to fffff 16 . in the flash memory version, internal rom area (data area) contain two blocks of flash rom as data area to store data. these two blocks of 2k bytes are located from 0f000 16 to 0ffff 16 . the fixed interrupt vector table is allocated to the address from fffdc 16 to fffff 16 . therefore store the start address of each interrupt routine here. for details, refer to the "interrupt". the internal ram is allocated in an upper address direction beginning with address 00400 16 . for example, a 1-kbyte internal ram is allocated to the address from 00400 16 to 007ff 16 . in addition to storing data, the internal ram also stores the stack used when calling subroutines and when interrupts are generated. the sfr is allocated to the address from 00000 16 to 003ff 16 . peripheral function control registers are located here. of the sfr, any area which has no functions allocated is reserved for future use and cannot be used by users. the special page vector table is allocated to the addresses from ffe00 16 to fffdb 16 . this vector is used by the jmps or jsrs instruction. for details, refer to the "m16c/60 and m16c/20 series software manual". figure 3.1. memory map sfr internal ram reserved area internal rom (program area) (note 2) reset watchdog timer single step address match brk instruction overflow undefined instruction special page vector table 00000 16 00400 16 xxxxx 16 yyyyy 16 fffff 16 fffff 16 fffdc 16 ffe00 16 dbc nmi internal rom (data area) (note 1) 0f000 16 0ffff 16 reserved area note 1: shown here is a block a (2k bytes) and block b (2k bytes). (in the flash memory version) note 2: when using the masked rom version, write nothing to internal rom area. size address yyyyy 16 size address xxxxx 16 internal ram intrnal rom 2k byte 00bff 16 48k byte f4000 16 64k byte f0000 16 1k byte 007ff 16 24k byte fa000 16 4. special function register (sfr) page 16 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 4. special function register (sfr) sfr(special function register) is the control register of peripheral functions. table 4.1 to 4.6 list the sfr information. table 4.1 sfr information (1) processor mode register 0 pm0 00 16 processor mode register 1 pm1 00001000 2 system clock control register 0 cm0 01001000 2 (m16c/26a) 01101000 2 (m16c/26t) system clock control register 1 cm1 00100000 2 address match interrupt enable register aier xxxxxx00 2 protect register pbcr xx000000 2 oscillation stop detection register (note 2) cm2 0x000010 2 watchdog timer start register wdts xx 16 watchdog timer control register wdc 00xxxxxx 2 (note3) address match interrupt register 0 rmad0 00 16 00 16 x0 16 address match interrupt register 1 rmad1 00 16 00 16 x0 16 voltage detection register 1 (note 4,5) vcr1 00001000 2 voltage detection register 2 (note 4,5) vcr2 00 16 pll control register 0 plc0 0001x010 2 processor mode register 2 pm2 xxx00000 2 voltage down detection interrupt register (note 5) d4int 00 16 dma0 source pointer sar0 xx 16 xx 16 xx 16 dma0 destination pointer dar0 xx 16 xx 16 xx 16 dma0 transfer counter tcr0 xx 16 xx 16 dma0 control register dm0con 00000x00 2 dma1 source pointer sar1 xx 16 xx 16 xx 16 dma1 destination pointer dar1 xx 16 xx 16 xx 16 dma1 transfer counter tcr1 xx 16 xx 16 dma1 control register dm1con 00000x00 2 note 1: blank spaces are reserved. no access is allowed. note 2: the cm20, cm21 and cm27 bits do not change at oscillation stop detection reset.. note 3: the wdc5 bit is "0" (cold start) immediately after power-on. it can only be set to "1" in a program. the wdc5 bit is not supported for m16c/26t. note 4: this register does not change at software reset, watchdog timer reset and oscillation stop detection reset. note 5: this register is not supported for m16c/26t. x : indeterminate 0000 16 0001 16 0002 16 0003 16 0004 16 0005 16 0006 16 0007 16 0008 16 0009 16 000a 16 000b 16 000c 16 000d 16 000e 16 000f 16 0010 16 0011 16 0012 16 0013 16 0014 16 0015 16 0016 16 0017 16 0018 16 0019 16 001a 16 001b 16 001c 16 001d 16 001e 16 001f 16 0020 16 0021 16 0022 16 0023 16 0024 16 0025 16 0026 16 0027 16 0028 16 0029 16 002a 16 002b 16 002c 16 002d 16 002e 16 002f 16 0030 16 0031 16 0032 16 0033 16 0034 16 0035 16 0036 16 0037 16 0038 16 0039 16 003a 16 003b 16 003c 16 003d 16 003e 16 003f 16 address register symbol after reset 4. special function register (sfr) page 17 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m note 1: blank spaces are reserved. no access is allowed. x : indeterminate 0040 16 0041 16 0042 16 0043 16 0044 16 0045 16 0046 16 0047 16 0048 16 0049 16 004a 16 004b 16 004c 16 004d 16 004e 16 004f 16 0050 16 0051 16 0052 16 0053 16 0054 16 0055 16 0056 16 0057 16 0058 16 0059 16 005a 16 005b 16 005c 16 005d 16 005e 16 005f 16 0060 16 0061 16 0062 16 0063 16 0064 16 0065 16 0066 16 0067 16 0068 16 0069 16 006a 16 006b 16 006c 16 006d 16 006e 16 006f 16 0070 16 0071 16 0072 16 0073 16 0074 16 0075 16 0076 16 0077 16 0078 16 0079 16 007a 16 007b 16 007c 16 007d 16 007e 16 007f 16 address register symbol after reset int3 interrupt control register int3ic xx00x000 2 int5 interrupt control register int5ic xx00x000 2 int4 interrupt control register int4ic xx00x000 2 uart2 bus collision detection interrupt control register bcnic xxxxx000 2 dma0 interrupt control register dm0ic xxxxx000 2 dma1 interrupt control register dm1ic xxxxx000 2 key input interrupt control register kupic xxxxx000 2 a/d conversion interrupt control register adic xxxxx000 2 uart2 transmit interrupt control register s2tic xxxxx000 2 uart2 receive interrupt control register s2ric xxxxx000 2 uart0 transmit interrupt control register s0tic xxxxx000 2 uart0 receive interrupt control register s0ric xxxxx000 2 uart1 transmit interrupt control register s1tic xxxxx000 2 uart1 receive interrupt control register s1ric xxxxx000 2 timera0 interrupt control register ta0ic xxxxx000 2 timera1 interrupt control register ta1ic xxxxx000 2 timera2 interrupt control register ta2ic xxxxx000 2 timera3 interrupt control register ta3ic xxxxx000 2 timera4 interrupt control register ta4ic xxxxx000 2 timerb0 interrupt control register tb0ic xxxxx000 2 timerb1 interrupt control register tb1ic xxxxx000 2 timerb2 interrupt control register tb2ic xxxxx000 2 int0 interrupt control register int0ic xx00x000 2 int1 interrupt control register int1ic xx00x000 2 int2 interrupt control register int2ic xx00x000 2 table 4.2 sfr information (2) (1) 4. special function register (sfr) page 18 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 0080 16 0081 16 0082 16 0083 16 0084 16 0085 16 0086 16 01b0 16 01b1 16 01b2 16 01b3 16 01b4 16 01b5 16 01b6 16 01b7 16 01b8 16 01b9 16 01ba 16 01bb 16 01bc 16 01bd 16 01be 16 01bf 16 0250 16 0251 16 0252 16 0253 16 0254 16 0255 16 0256 16 0257 16 0258 16 0259 16 025a 16 025b 16 025c 16 025d 16 025e 16 025f 16 0330 16 0331 16 0332 16 0333 16 0334 16 0335 16 0336 16 0337 16 0338 16 0339 16 033a 16 033b 16 033c 16 033d 16 033e 16 033f 16 note 1: blank spaces are reserved. no access is allowed. note 2: this register is included in the flash memory version. x : indeterminate address register symbol after reset flash memory control register 4 (note 2) fmr4 01000000 2 flash memory control register 1 (note 2) fmr1 000xxx0x 2 flash memory control register 0 (note 2) fmr0 01 16 three phase protect control register tprc 00 16 on-chip oscillator control register rocr 00000101 2 pin assignment control register pacr 00 16 peripheral clock select register pclkr 00000011 2 nmi digital debounce register nddr ff 16 port1 7 digital debounce register p17ddr ff 16 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ table 4.3 sfr information (3) (1) 4. special function register (sfr) page 19 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m address register symbol after reset 0340 16 0341 16 0342 16 0343 16 0344 16 0345 16 0346 16 0347 16 0348 16 0349 16 034a 16 034b 16 034c 16 034d 16 034e 16 034f 16 0350 16 0351 16 0352 16 0353 16 0354 16 0355 16 0356 16 0357 16 0358 16 0359 16 035a 16 035b 16 035c 16 035d 16 035e 16 035f 16 0360 16 0361 16 0362 16 0363 16 0364 16 0365 16 0366 16 0367 16 0368 16 0369 16 036a 16 036b 16 036c 16 036d 16 036e 16 036f 16 0370 16 0371 16 0372 16 0373 16 0374 16 0375 16 0376 16 0377 16 0378 16 0379 16 037a 16 037b 16 037c 16 037d 16 037e 16 037f 16 note 1 : blank spaces are reserved. no access is allowed. x : indeterminate timer a1-1 register ta11 xx 16 xx 16 timer a2-1 register ta21 xx 16 xx 16 timer a4-1 register ta41 xx 16 xx 16 three phase pwm control register 0 invc0 00 16 three phase pwm control register 1 invc1 00 16 three phase output buffer register 0 idb0 3f 16 three phase output buffer register 1 idb1 3f 16 dead time timer dtt xx 16 timer b2 interrupt occurrence frequency set counter ictb2 xx 16 position-data-retain function control register pdrf xxxx0000 2 port function control register pfcr 00111111 2 interrupt request cause select register 2 ifsr2a xxxxxxx0 2 interrupt request cause select register ifsr 00 16 uart2 special mode register 4 u2smr4 00 16 uart2 special mode register 3 u2smr3 000x0x0x 2 uart2 special mode register 2 u2smr2 x0000000 2 uart2 special mode register u2smr x0000000 2 uart2 transmit/receive mode register u2mr 00 16 uart2 bit rate register u2brg xx 16 uart2 transmit buffer register u2tb xxxxxxxx 2 xxxxxxxx 2 uart2 transmit/receive control register 0 u2c0 00001000 2 uart2 transmit/receive control register 1 u2c1 00000010 2 uart2 receive buffer register u2rb xxxxxxxx 2 xxxxxxxx 2 table 4.3 sfr information (4) (1) 4. special function register (sfr) page 20 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 0380 16 0381 16 0382 16 0383 16 0384 16 0385 16 0386 16 0387 16 0388 16 0389 16 038a 16 038b 16 038c 16 038d 16 038e 16 038f 16 0390 16 0391 16 0392 16 0393 16 0394 16 0395 16 0396 16 0397 16 0398 16 0399 16 039a 16 039b 16 039c 16 039d 16 039e 16 039f 16 03a0 16 03a1 16 03a2 16 03a3 16 03a4 16 03a5 16 03a6 16 03a7 16 03a8 16 03a9 16 03aa 16 03ab 16 03ac 16 03ad 16 03ae 16 03af 16 03b0 16 03b1 16 03b2 16 03b3 16 03b4 16 03b5 16 03b6 16 03b7 16 03b8 16 03b9 16 03ba 16 03bb 16 03bc 16 03bd 16 03be 16 03bf 16 note 1 : blank spaces are reserved. no access is allowed. x : indeterminate address register symbol after reset count start flag tabsr 00 16 clock prescaler reset flag cpsrf 0xxxxxxx 2 one-shot start flag onsf 00 16 trigger select register trgsr 00 16 up-dowm flag udf 00 16 timer a0 register ta0 xx 16 xx 16 timer a1 register ta1 xx 16 xx 16 timer a2 register ta2 xx 16 xx 16 timer a3 register ta3 xx 16 xx 16 timer a4 register ta4 xx 16 xx 16 timer b0 register tb0 xx 16 xx 16 timer b1 register tb1 xx 16 xx 16 timer b2 register tb2 xx 16 xx 16 timer a0 mode register ta0mr 00 16 timer a1 mode register ta1mr 00 16 timer a2 mode register ta2mr 00 16 timer a3 mode register ta3mr 00 16 timer a4 mode register ta4mr 00 16 timer b0 mode register tb0mr 00xx0000 2 timer b1 mode register tb1mr 00xx0000 2 timer b2 mode register tb2mr 00xx0000 2 timer b2 special mode register tb2sc x0000000 2 uart0 transmit/receive mode register u0mr 00 16 uart0 bit rate register u0brg xx 16 uart0 transmit buffer register u0tb xxxxxxxx 2 xxxxxxxx 2 uart0 transmit/receive control register 0 u0c0 00001000 2 uart0 transmit/receive control register 1 u0c1 00000010 2 uart0 receive buffer register u0rb xxxxxxxx 2 xxxxxxxx 2 uart1 transmit/receive mode register u1mr 00 16 uart1 bit rate register u1brg xx 16 uart1 transmit buffer register u1tb xxxxxxxx 2 xxxxxxxx 2 uart1 transmit/receive control register 0 u1c0 00001000 2 uart1 transmit/receive control register 1 u1c1 00000010 2 uart1 receive buffer register u1rb xxxxxxxx 2 xxxxxxxx 2 uart transmit/receive control register 2 ucon x0000000 2 crc snoop address register crcsar xx 16 00xxxxxx 2 crc mode register crcmr 0xxxxxx0 2 dma0 request cause select register dm0sl 00 16 dma1 request cause select register dm1sl 00 16 crc data register crcd xx 16 xx 16 crc input register crcin xx 16 table 4.3 sfr information (5) (1) 4. special function register (sfr) page 21 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 03c0 16 03c1 16 03c2 16 03c3 16 03c4 16 03c5 16 03c6 16 03c7 16 03c8 16 03c9 16 03ca 16 03cb 16 03cc 16 03cd 16 03ce 16 03cf 16 03d0 16 03d1 16 03d2 16 03d3 16 03d4 16 03d5 16 03d6 16 03d7 16 03d8 16 03d9 16 03da 16 03db 16 03dc 16 03dd 16 03de 16 03df 16 03e0 16 03e1 16 03e2 16 03e3 16 03e4 16 03e5 16 03e6 16 03e7 16 03e8 16 03e9 16 03ea 16 03eb 16 03ec 16 03ed 16 03ee 16 03ef 16 03f0 16 03f1 16 03f2 16 03f3 16 03f4 16 03f5 16 03f6 16 03f7 16 03f8 16 03f9 16 03fa 16 03fb 16 03fc 16 03fd 16 03fe 16 03ff 16 note 1 : blank spaces are reserved. no access is allowed. x : indeterminate register symbol after reset a/d register 0 ad0 xxxxxxxx 2 xxxxxxxx 2 a/d register 1 ad1 xxxxxxxx2 xxxxxxxx 2 a/d register 2 ad2 xxxxxxxx 2 xxxxxxxx 2 a/d register 3 ad3 xxxxxxxx 2 xxxxxxxx 2 a/d register 4 ad4 xxxxxxxx 2 xxxxxxxx 2 a/d register 5 ad5 xxxxxxxx 2 xxxxxxxx 2 a/d register 6 ad6 xxxxxxxx 2 xxxxxxxx 2 a/d register 7 ad7 xxxxxxxx 2 xxxxxxxx 2 a/d trigger control register adtrgcon 00 16 a/d status register 0 adstat0 00000x00 2 a/d control register 2 adcon2 00 16 a/d control register 0 adcon0 00000xxx 2 a/d control register 1 adcon1 00 16 port p1 register p1 xx 16 port p1 direction register pd1 00 16 port p6 register p6 xx 16 port p7 register p7 xx 16 port p6 direction register pd6 00 16 port p7 direction register pd7 00 16 port p8 register p8 xx 16 port p9 register p9 xxxxxxxx 2 port p8 direction register pd8 00 16 port p9 direction register pd9 xxxx0000 2 port p10 register p10 xx 16 port p10 direction register pd10 00 16 pull-up control register 0 pur0 00 16 pull-up control register 1 pur1 00 16 pull-up control register 2 pur2 00 16 port control register pcr 00 16 address table 4.3 sfr information (6) (1) 5. reset page 22 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 5. reset there are four types of resets: a hardware reset, a software reset, an watchdog timer reset, and an oscilla- tion stop detection reset. 5.1 hardware reset there are two types of hardware resets: a hardware reset 1 and a hardware reset 2. 5.1.1 hardware reset 1 ____________ ____________ a reset is applied using the reset pin. when an ??signal is applied to the reset pin while the power supply voltage is within the recommended operating condition, the pins are initialized (see ____________ table 5.1.1.1 pin status when reset pin level is ??. the internal on-chip oscillator is initialized and used as sysem clock. ____________ when the input level at the reset pin is released from ??to ?? the cpu and sfr are initialized, and the program is executed starting from the address indicated by the reset vector. the internal ram ____________ is not initialized. if the reset pin is pulled ??while writing to the internal ram, the internal ram becomes indeterminate. figure 5.1.1.1 shows the example reset circuit. figure 5.1.1.2 shows the reset sequence. table ____________ 5.1.1.1 shows the status of the other pins while the reset pin is ?? figure 5.1.1.3 shows the cpu register status after reset. refer to ?fr map?for sfr status after reset. 1. when the power supply is stable ____________ (1) apply an ??signal to the reset pin. (2) wait td(roc) or more. ____________ (3) apply an ??signal to the reset pin. 2. power on ____________ (1) apply an ??signal to the reset pin. (2) let the power supply voltage increase until it meets the recommended operating condition. (3) wait td(p-r) or more until the internal power supply stabilizes. (4) wait td(roc) or more. ____________ (5) apply an ??signal to the reset pin. 5.1.2 hardware reset 2 note m16c/26t does not use this function. this reset is generated by the microcomputer? internal voltage detection circuit. the voltage detec- tion circuit monitors the voltage supplied to the v cc pin. if the vc26 bit in the vcr2 register is set to ??(reset level detection circuit enabled), the microcom- puter is reset when the voltage at the v cc input pin drops below vdet3. conversely, when the input voltage at the v cc pin rises to vdet3r or more, the pins and the cpu and sfr are initialized, and the program is executed starting from the address indicated by the reset vector. it takes about td(s-r) before the program starts running after vdet3r is detected. the initialized pins and registers and the status thereof are the same as in hardware reset 1. the microcomputer cannot exit stop mode by voltage down detection reset (hardware reset 2). 5. reset page 23 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 5.2 software reset when the pm03 bit in the pm0 register is set to 1 (microcomputer reset), the microcomputer has its pins, cpu, and sfr initialized. then the program is executed starting from the address indicated by the reset vector. the device will reset using on-chip oscillator as the system clock. at software reset, some sfr s are not initialized. refer to sfr . 5.3 watchdog timer reset when the pm12 bit in the pm1 register is 1 (reset when watchdog timer underflows), the microcomputer initializes its pins, cpu and sfr if the watchdog timer underflows. the device will reset using on-chip oscillator as the system clock. then the program is executed starting from the address indicated by the reset vector. at watchdog timer reset, some sfr s are not initialized. refer to sfr . 5.4 oscillation stop detection reset when the cm20 bit in the cm2 register is set to 1 (oscillation stop, re-oscillation detection function enabled) and the cm27 bit is set to 0 (reset at oscillation stop detection), the microcomputer initializes its pins, cpu and sfr, coming to a halt if it detects main clock oscillation circuit stop. refer to the section oscillation stop, re-oscillation detection function . at oscillation stop detection reset, some sfr s are not initialized. refer to the section sfr . figure 5.1.1.1. example reset circuit reset v cc reset v cc 0v 0v more than td(roc) + td(p-r) equal to or less than 0.2v cc equal to or less than 0.2v cc recommended operating voltage 5. reset page 24 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m ____________ table 5.1.1.1. pin status when reset pin level is ? status pin name p1, p6 to p10 input port (high impedance) figure 5.1.1.3. cpu register status after reset b15 b0 data register(r0) address register(a0) frame base register(fb) program counter(pc) interrupt table register(intb) user stack pointer(usp) interrupt stack pointer(isp) static base register(sb) flag register(flg) 0000 16 0000 16 0000 16 aa aa a a aa aa aa aa aaaaaa aaaaaa aa aa aa aa aa aa a a aa aa c d z s b o i u ipl 0000 16 0000 16 0000 16 0000 16 0000 16 b19 b0 content of addresses ffffe 16 to ffffc 16 b15 b0 b15 b0 b15 b0 b7 b8 00000 16 data register(r1) data register(r2) data register(r3) address register(a1) 0000 16 0000 16 0000 16 figure 5.1.1.2. reset sequence td(p-r) more than td(roc) cpu clock address roc reset content of reset vector cpu clock 28cycles ffffe 16 ffffc 16 v cc 5. reset page 25 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 5.5.1. voltage detection circuit block b 7 b 6 v c r 2 r e g i s t e r r e s e t cm10 bit=1 (stop mode) + v d e t 3 + vdet4 e noise rejection v o l t a g e d o w n d e t e c t s i g n a l b3 v c r 1 r e g i s t e r v c 1 3 b i t write to wdc register s r q w a r m / c o l d >t q 1 s h o t internal reset signal ( l active) w d c 5 b i t e ( c o l d s t a r t , w a r m s t a r t ) v c c internal power on reset t d ( s - r ) voltage down detect reset (hardware reset 2 release wait time) 5.5 voltage detection circuit note using the voltage detection circuit with v cc =5v is assumed. the m16c/26t do not use this function. the voltage detection circuit has circuits to monitor the input voltage at the v cc pin, each checking the input voltage with respect to vdet3, and vdet4, respectively. use the vc26 to vc27 bits in the vcr2 register to select whether or not to enable these circuits. use the reset level detection circuit for hardware reset 2. the voltage down detection circuit can be set to detect whether the input voltage is equal to or greater than vdet4 or less than vdet4 by monitoring the vc13 bit in the vcr1 register. furthermore, a voltage down detection interrupt can be generated. 5. reset page 26 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 5.5.2. vcr1 register, vcr2 register, and d4int register v c 1 3 v o l t a g e d e t e c t i o n r e g i s t e r 1 symbol address after reset (note 2) vcr1 0019 16 00001000 2 v o l t a g e d o w n m o n i t o r f l a g ( n o t e 1 ) bit name function b i t s y m b o l rw b 7b 6b 5b 4b 3b2b 1b 0 note 1: the vc13 bit is useful when the vc27 bit of vcr2 register is set to 1 (voltage down detection circuit enable). the vc13 bit is always 1 (v cc vdet4) when the vc27 bit in the vcr2 register is set to 0 (voltage down detection circuit disable). note 2: this register does not change at software reset, watchdog timer reset and oscillation stop detection reset. 0 : v c c < v d e t 4 1 : v c c v d e t 4 ro 0000 000 rw rw reserved bit reserved bit m u s t se t t o 0 m u s t s e t t o 0 v o l t a g e d e t e c t i o n r e g i s t e r 2 ( n o t e 1 ) symbol address after reset (note 5) vcr2 001a 16 00 16 bit name b i t s y m b o l b 7b 6b 5b 4b 3b2b 1b 0 note 1: write to this register after setting the prc3 bit in the prcr register to 1 (write enable). note 2: when not in stop mode, to use hardware reset 2, set the vc26 bit to 1 (reset level detection circuit enable). note 3: vc26 bit is disabled in stop mode. (the microcomputer is not reset even if the voltage input to vcc pin becomes lower than vdet3.) note 4: when the vc13 bit in the vcr1 register and d42 bit in the d4int register are used or the d40 bit is set to 1 (voltage down detection interrupt enable), set the vc27 bit to 1 (voltage down detection circuit enable). note 5: this register does not change at software reset, watchdog timer reset and oscillation stop detection reset. note 6: the detection circuit does not start operation until td(e-a) elapses after the vc26 bit, or vc27 bit are set to 1 . v c 2 6 v c 2 7 rw rw rw rw 00000 function reserved bit m u s t s e t t o 0 re s e t l e v e l m o n i t o r b i t ( n o t e s 2 , 3 , 6 ) 0: disable reset level detection circuit 1: enable reset level detection circuit v o l t a g e d o w n m o n i t o r b i t ( n o t e 4 , 6 ) 0: disable voltage down detection circuit 1: enable voltage down detection circuit ( b 2 - b 0 ) ( b 7 - b 4 ) ( b 5 - b 0 ) 0 d40 v o l t a g e d o w n d e t e c t i o n i n t e r r u p t r e g i s t e r ( n o t e 1 ) symbol address after reset d4int 001f 16 00 16 v o l t a g e d o w n d e t e c t i o n i n t e r r u p t e n a b l e b i t ( n o t e 5 ) bit name b i t s y m b o l b 7 b 6 b 5 b 4 b 3 b 2 b 1 b 0 0 : disable 1 : enable d41 s t o p m o d e d e a c t i v a t i o n c o n t r o l b i t ( n o t e 4 ) 0 : d i s a b l e ( d o n o t u s e t h e v o l t a g e d o w n d e t e c t i o n i n t e r r u p t t o g e t o u t o f s t o p m o d e ) 1 : e n a b l e ( u s e t h e v o l t a g e d o w n d e t e c t i o n i n t e r r u p t t o g e t o u t o f s t o p m o d e ) d42 v o l t a g e c h a n g e d e t e c t i o n f l a g ( n o t e 2 ) 0: not detected 1: vdet4 passing detection d43 w d t o v e r f l o w d e t e c t f l a g 0: not detected 1: detected df0 s a m p l i n g c l o c k s e l e c t b i t 00 : cpu clock divided by 8 01 : cpu clock divided by 16 10 : cpu clock divided by 32 11 : cpu clock divided by 64 df1 note 1: write to this register after setting the prc3 bit in the prcr register to 1 (write enable). note 2: useful when the vc27 bit in the vcr2 register is set to 1 (voltage down detection circuit enabled). if the vc27 bit is set to 0 (voltage down detection circuit disable), the d42 bit is set to 0 (not detect). note 3: this bit is set to 0 by writing a 0 in a program. (writing a 1 has no effect.) note 4: if the voltage down detection interrupt needs to be used to get out of stop mode again after once used for that purpose, reset the d41 bit by writing a 0 and then a 1 . note 5: the d40 bit is effective when the vc27 bit in the vcr2 register is set to 1 . to set the d40 bit to 1 , follow the procedure described below. (1) set the vc27 bit to 1 . (2) wait for td(e-a) until the detection circuit is actuated. (3) wait for the sampling time (refer to table 5.5.1.2 sampling clock periods ). (4) set the d40 bit to 1 . b 5 b 4 rw rw rw rw ( n o t e 3 ) rw r w r w (b7-b6) function ( n o t e 3 ) n o t h i n g i s a s s i g n e d . w h e n w r i t e , s e t t o 0 . w h e n r e a d , i t s c o n t e n t i s 0 . 5. reset page 27 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 5.5.3. typical operation of hardware reset 2 vdet4 vdet3 5.0v 5.0v vcc internal reset signal vc13 bit in vcr1 register vc26 bit in vcr2 register (1) vc27 bit in vcr2 register set to 1 by program (reset level detect circuit enable) set to 1 by program (voltage down detect circuit enable) vss indefinite indefinite indefinite reset vdet3s vdet3r notes : 1. vc26 bit is invalid (the microcomputer is not reset even if input voltage of vcc pin becomes lower than vdet3). 5. reset page 28 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 5.5.1 voltage down detection interrupt if the d40 bit in the d4int register is set to ??(voltage down detection interrupt enabled), the voltage down detection interrupt request is generated when the voltage applied to the vcc pin crosses the vdet4 voltage level. the voltage down detection interrupt shares the same interrupt vector with the watchdog timer interrupt and oscillation stop, re-oscillation detection interrupt. set the d41 bit in the d4int register to ??(enabled) to use the voltage down detection interrupt to exit stop mode. the d42 bit in the d4int register is set to ??as soon as the voltage applied to the vcc pin reaches vdet4 due to the voltage rise and voltage drop. when the d42 bit changes ??to ?? the voltage down detection interrupt request is generated. set the d42 bit to ??by program. however, when the d41 bit is set to ??and the microcomputer is in stop mode, the voltage down detection interrupt request is generated regardless of the d42 bit state if the voltage applied to the vcc pin is detected to be above vdet4. the microcomputer then exits stop mode. table 5.5.1.1 shows how the voltage down detection interrupt request is generated. the df1 to df0 bits in the d4int register determine the sampling period that detects the voltage applied to the vcc pin reaches vdet4. table 5.5.1.2 shows the sampling periods. cpu clock (mhz) df1 to df0=00 (cpu clock divided by 8) sampling period ( s) 16 3.0 6.0 12.0 24.0 df1 to df0=01 (cpu clock divided by 16) df1 to df0=10 (cpu clock divided by 32) df1 to df0=11 (cpu clock divided by 64) table 5.5.1.1 voltage down detection interrupt request generation conditions d41 bit vc27 bit operation mode d40 bit d42 bit cm02 bit vc13 bit normal operation mode (1) wait mode (2) stop mode (2) notes: 1. the status except the wait mode and stop mode is handled as the normal mode.(refer to 7. clock generating circuit ) 2. refer to 5.5.2 limitations on stop mode , 5.5.3 limitations on wait mode . 3. an interrupt request for voltage reduction is generated a sampling time after the value of the vc13 bit has changed. see the figure 5.5.1.2 voltage down detection interrupt generation circuit operation example for details. 0 to 1 (3) 1 0 1 1 0 1 to 0 (3) 0 to 1 (3) 1 to 0 (3) 0 to 1 0 to 1 0 to 1 0 to 1 1 : 0 or 1 table 5.5.1.2 sampling periods 5. reset page 29 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 5.5.1.1 power supply down detection interrupt generation block figure 5.5.1.2 power supply down detection interrupt generation circuit operation example output of the digital filter (2) d42 bit in d4int register notes : 1. d40 bit in the d4int register is set to 1 (voltage down detection interrupt enabled). 2. output of the digital filter is shown in figure 5.5.1.1. voltage down detection interrupt signal no voltage down detection interrupt signals are generated when the d42 bit is h . sampling vc13 bit in vcr1 register vcc sampling sampling sampling set to 0 by program (not detected) voltage down detection interrupt generation circuit watchdog timer interrupt signal vc27 vc13 voltage down detection circuit d4int clock(the clock with which it operates also in wait mode) d42 df1, df0 1/2 00b 01b 10b 11b 1/2 1/2 1/8 non-maskable interrupt signal oscillation stop, re-oscillation detection interrupt signal voltage down detection interrupt signal watchdog timer block this bit is set to 0 (not detected) by program. watchdog timer underflow signal d43 d41 cm02 wait instruction(wait mode) d40 vcc vref + - noise rejection (rejection range:200 ns) voltage down detection signal the voltage down detection signal becomes h when the vc27 bit is set to 0 (disabled) noise rejection circuit digital filter cm10 the d42 bit is set to 0 (not detected) by program. the vc27 bit is set to 0 (voltage down detect circuit disabled), the d42 bit is set to 0 . 5. reset page 30 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 5.5.2 limitations on exiting stop mode the voltage down detection interrupt is immediately generated and the microcomputer exits stop mode if the cm10 bit in the cm1 register is set to 1 under the conditions below. ? the vc27 bit in the vcr2 register is set to 1 (voltage down detection circuit enabled), ? the d40 bit in the d4int register is set to 1 (voltage down detection interrupt enabled), ? the d41 bit in the d4int register is set to 1 (voltage down detection interrupt is used to exit stop mode), and ? the voltage applied to the vcc pin is higher than vdet4 (the vc13 bit in the vcr1 register is 1 ) if the microcomputer is set to enter stop mode when the voltage applied to the vcc pin drops below vdet4 and to exit stop mode when the voltage applied rises to vdet4 or above, set the cm10 bit to 1 when vc13 bit is 0 (vcc < vdet4). 5.5.3 limitations on exiting wait mode the voltage down detection interrupt is immediately generated and the microcomputer exits wait mode if wait instruction is executed under the conditions below. ? the cm02 bit in the cm0 register is set to 1 (stop peripheral function clock), ? the vc27 bit in the vcr2 register is set to 1 (voltage down detection circuit enabled), ? the d40 bit in the d4int register is set to 1 (voltage down detection interrupt enabled), ? the d41 bit in the d4int register is set to 1 (voltage down detection interrupt is used to exit wait mode), and ? the voltage applied to the vcc pin is higher than vdet4 (the vc13 bit in the vcr1 register is 1 ) if the microcomputer is set to enter wait mode when the voltage applied to the vcc pin drops below vdet4 and to exit wait mode when the voltage applied rises to vdet4 or above, perform wait instruc- tion when vc13 bit is 0 (vcc < vdet4). 6. processor mode page 31 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 6. processor mode this device functions in single-chip mode only. figures 6.1 and 6.2 detail the associated registers. figure 6.2. pm1 register processor mode register 1 (note 1) symbol address after reset pm1 0005 16 0000100 0 2 bit name function bit symbol rw b7 b6 b5 b4 b3 b2 b1 b0 flash data block access bit (note 2) 0: disabled 1: enabled (note 3) pm10 rw pm17 wait bit (note 5) 0 : no wait state 1 : with wait state (1 wait) 0 : watchdog timer interrupt 1 : watchdog timer reset (note 4) watchdog timer function select bit pm12 rw rw rw rw rw note 1: write to this register after setting the prc1 bit in the prcr register to "1" (write enable). note 2: to access the two 2k-byte data areas in data block a and data block b, this bit must be set to "1". note 3: when cpu rewrite mode (fmr01="1"), this bit is automatically set to "1" during that time. note 4: pm12 bit is set to 1 by writing a 1 in a program. (writing a 0 has no effect.) note 5: when pm17 bit is set to "1" (with wait state), one wait state is inserted when accessing the internal ram or the internal rom. should be set to "0". (b1) reserved bit should be set to "1". reserved bit should be set to "0". (b6-b4) reserved bit (b3) 0 10 00 figure 6.1. pm0 register processor mode register 0 (note) symbol address after reset pm0 0004 16 0000000 0 2 bit name function bit symbol rw b7 b6 b5 b4 b3 b2 b1 b0 setting this bit to "1" resets the microcomputer. when read, its content is "0". software reset bit pm03 rw rw rw note: write to this register after setting the prc1 bit in the prcr register to "1" (write enable). should be set to "0". (b2-b0) reserved bit should be set to "0". (b7-b4) reserved bit 000 0 000 7. clock generation circuit page 32 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m ? cpu clock source ? peripheral function clock source use of clock main clock oscillation circuit sub clock oscillation circuit item ? cpu clock source ? timer a, b s clock source clock frequency 0 to 20 mhz 32.768 khz ? ceramic oscillator ? crystal oscillator usable oscillator ? crystal oscillator x in , x out pins to connect oscillator x cin , x cout presence oscillation stop, restart function presence oscillating(m16c/26a) stopped(m16c/26t) oscillator status after reset stopped externally derived clock can be input other pll frequency synthesizer 10 to 20 mhz presence stopped on-chip oscillator ? cpu clock source ? peripheral function clock source ? cpu and peripheral function clock sources when the main clock stops oscillating ? selectable source frequency: f 1(roc) , f 2(roc) , f 3(roc) ? selectable divider: by 2, by 4, by 8 presence oscillating ? cpu clock source ? peripheral function clock source (cpu clock source) 7. clock generation circuit the clock generation circuit contains four oscillator circuits as follows: (1) main clock oscillation circuit (2) sub clock oscillation circuit (3) on-chip oscillator (available at reset, oscillation stop detect function) (4) pll frequency synthesizer table 7.1 lists the clock generation circuit specifications. figure 7.1 shows the clock generation circuit. figures 7.2 to 7.6 show the clock-related registers. table 7.1. clock generation circuit specifications 7. clock generation circuit page 33 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m f c3 2 cm00, cm01, cm02, cm04, cm05, cm06, cm07: cm0 register bits cm10, cm11, cm16, cm17: cm1 register bits pclk0, pclk1, pclk5: pclkr register bits cm21, cm27 : cm2 register bits 1/32 main clock generating circuit f c cm02 cm04 cm10=1(stop mode) q s r wait instruction cm05 q s r nmi interrupt request level judgment output reset software reset f c cpu clock cm07 = 0 cm07 = 1 a d 1/2 1/2 1/2 1/2 cm06=0 cm17-cm16=00 2 cm06=0 cm17-cm16=01 2 cm06=0 cm17-cm16=10 2 cm06=1 cm06=0 cm17-cm16=11 2 d a details of divider sub-clock generating circuit x cin x cout x out x in f 8 f 32 c b b 1/2 c f 32sio f 8s i o f ad f 1 e e 1/2 1/4 1/8 1/16 1/32 p c lk 0 = 1 pll frequency s y nt h es i z e r 0 1 c m21= 1 c m11 c m21= 0 pl l cloc k sub-clock o n-chi p oscillato r cloc k p c lk 0 = 0 f 2 f 1 s i o p c lk1=1 p c lk1= 0 f 2 s i o main clock oscillation stop, re- oscillation detection circuit d4int clock clk out i/o ports pclk5=0,cm01-cm00=00 2 pclk5=0,cm01-cm00=01 2 pclk5=1, cm01-cm00=00 2 pclk5=0, cm01-cm00=10 2 pclk5=0, cm01-cm00=11 2 cm21 figure 7.1. clock generation circuit phase comparator charge pump voltage control oscillator (vco) pll clock main clock 1/2 programmable counter internal low- pass filter pll frequency synthesizer pulse generation circuit for clock edge detection and charge, discharge control charge, discharge circuit reset generating circuit oscillation stop, re-oscillation detection interrupt generating circuit main clock oscillation stop detection reset cm27=0 cm21 switch signal oscillation stop, re-oscillation detection signal oscillation stop, re-oscillation detection circuit cm27=1 1/2 1/2 1/2 rocr3-rocr2=11 2 on-chip oscillator clock 1/8 1/4 1/2 rocr3-rocr2=10 2 rocr3-rocr2=01 2 rocr1-rocr0=00 2 f 1(roc) f 2(roc) f 3(roc) rocr1-rocr0=01 2 rocr1-rocr0=11 2 on-chip oscillator 7. clock generation circuit page 34 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m system clock control register 0 (note 1) symbol address after reset cm0 0006 16 01001000 2 (m16c/26a) bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 cm07 cm05 cm04 cm03 cm02 cm06 wait peripheral function clock stop bit (note 10) 1 : stop peripheral function clock in wait mode (note 8) x cin -x cout drive capacity select bit (note 2) 1 : high main clock stop bit (notes 3, 10, 12, 13) 0 : on 1 : off (note 4, note5) main clock division select bit 0 (notes 7, 13, 14) 0 : cm16 and cm17 valid 1 : division by 8 mode system clock select bit (notes 6, 10, 11, 12) 0 : main clock, pll clock, or ring oscillator clock 1 : sub-clock note 1: write to this register after setting the prc0 bit in the prcr register to "1" (write enable). note 2: the cm03 bit is set to "1" (high) when the cm04 bit is set to "0" (i/o port) or the microcomputer goes to a stop mode. note 3: this bit is provided to stop the main clock when the low power dissipation mode or ring oscillator low power dissipatio n mode is selected. this bit cannot be used for detection as to whether the main clock stopped or not. to stop the main clock, the following setting is required: (1) set the cm07 bit to "1" (sub-clock select) or the cm21 bit in the cm2 register to "1" (ring oscillator select) with the sub-clock stably oscillating. (2) set the cm20 bit in cm2 register to "0" (oscillation stop, re-oscillation detection function disabled). (3) set the cm05 bit to "1" (stop). note 4: during external clock input, only the clock oscillation buffer is turned off and clock input is accepted. note 5: when cm05 bit is set to "1", the x out pin goes h ? . furthermore, because the internal feedback resistor remains connected, the x in pin is pulled "h" to the same level as x out via the feedback resistor. note 6: after setting the cm04 bit to "1" (x cin -x cout oscillator function), wait until the sub-clock oscillates stably before switching the cm07 bit from "0" to "1" (sub-clock). note 7: when entering stop mode from high or middle speed mode, ring oscillator mode or ring oscillator low power mode, the cm0 6 bit is set to "1" (divide-by-8 mode). note 8: the f c32 clock does not stop. during low speed or low power dissipation mode, do not set this bit to "1" (peripheral clock turned off when in wait mode). note 9: to use a sub-clock, set this bit to "1". also make sure ports p8 6 and p8 7 are directed for input, with no pull-ups. note 10: when the pm21 bit of pm2 register is set to "1" (clock modification disable), writing to the cm02, cm05, and cm07 bits has no effect. note 11: if the pm21 bit needs to be set to "1", set the cm07 bit to "0"(main clock) before setting it. note 12: to use the main clock as the clock source for the cpu clock, follow the procedure below. (1) set the cm05 bit to "0" (oscillate). (2) wait until td(m-l) elapses or the main clock oscillation stabilizes, whichever is longer. (3) set the cm11, cm21 and cm07 bits all to "0". note 13: when the cm21 bit is set to "0" (ring oscillaor turned off) and the cm05 bit is set to "1" (main clock turned off), th e cm06 bit is fixed to "1" (divide-by-8 mode) and the cm15 bit is fixed to "1" (drive capability high). note 14: to return from ring oscillator mode to high-speed or middle-speed mode set the cm06 and cm15 bits both to "1". rw port x c select bit (note 2) rw rw rw rw rw rw rw refer to table 7.5.3.1 function of the clkout pin 01101000 2 (m16c/26t) cm00 cm01 clock output function select bit 0 : do not stop peripheral function clock in wait mode 0 : low 0 : i/o port p8 6 , p8 7 1 : x cin -x cout generation function (note 9) rw figure 7.2. cm0 register 7. clock generation circuit page 35 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m system clock control register 1 (note 1) symbol address after reset cm1 0007 16 00100000 2 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 cm10 all clock stop control bit (notes 4, 6) 0 : clock on 1 : all clocks off (stop mode) note 1: write to this register after setting the prc0 bit in the prcr register to 1 (write enable). note 2: when entering stop mode from high or middle speed mode, or when the cm05 bit is set to 1 (main clock turned off) in low speed mode, the cm15 bit is set to 1 (drive capability high). note 3: effective when the cm06 bit is 0 (cm16 and cm17 bits enable). note 4: if the cm10 bit is 1 (stop mode), x out goes h and the internal feedback resistor is disconnected. the x cin and x cout pins are placed in the high-impedance state. when the cm11 bit is set to 1 (pll clock), or the cm20 bit in the cm2 register is set to 1 (oscillation stop, re-oscillation detection function enabled), do not set the cm10 bit to 1 . note 5: after setting the plc07 bit in the plc0 register to 1 (pll operation), wait until tsu (pll) elapses before setting the cm11 bit to 1 (pll clock). note 6: when the pm21 bit in the pm2 register is set to 1 (clock modification disable), writing to the cm10, cm011 bits has no effect. when the pm22 bit in the pm2 register is set to 1 (watchdog timer count source is on-chip oscillator clock), writing to the cm10 bit has no effect. note 7: effective when cm07 bit is 0 and cm21 bit is 0 . cm15 x in -x out drive capacity select bit (note 2) 0 : low 1 : high rw cm16 cm17 reserved bit must set to 0 main clock division select bits (note 3) 0 0 : no division mode 0 1 : division by 2 mode 1 0 : division by 4 mode 1 1 : division by 16 mode b7 b6 0 00 cm11 system clock select bit 1 (notes 6, 7) 0 : main clock 1 : pll clock (note 5) rw rw rw rw rw rw (b4-b2) figure 7.3. cm1 register figure 7.4. rocr register b7 b6 b5 b4 b3 b2 b1 b0 rw rocr0 rocr1 on-chip oscillator control register (note 1) symbol address after reset rocr 025c 16 00000101 2 bit name function bit symbol frequency select bits rw rw reserved bit when write, set to 0 . when read, its content is 0 . ro 00 00 0 0 : f 1 (roc) 0 1 : f 2 (roc) 1 0 : not supported 1 1 : f 3 (roc) b1 b0 rocr2 rocr3 divider select bits rw rw 0 0 : not supported 0 1 : divide by 2 1 0 : divide by 4 1 1 : divide by 8 b3 b2 note 1 : write to this register after setting the prc0 bit in the prcr register to "1" (write enable). (b5-b4) reserved bit set to 0 . rw (b6) reserved bit when write, set to 0 . when read, its content is indeterminate. ro (b7) 7. clock generation circuit page 36 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m b7 b6 b5 b4 b3 b2 b1 b0 rw cm20 cm21 oscillation stop detection register (note 1) symbol address after reset cm2 000c 16 0x000010 2 (note 11) bit name function bit symbol system clock select bit 2 (notes 2, 3, 6, 8, 11, 12 ) 0: oscillation stop, re-oscillation detection function disabled 1: oscillation stop, re-oscillation detection function enabled 0: main clock or pll clock 1: on-chip oscillator clock (on-chip oscillator oscillating) oscillation stop, re- oscillation detection bit (notes 7, 9, 10, 11) note 1: write to this register after setting the prc0 bit in the prcr register to 1 (write enable). note 2: when the cm20 bit is set to 1 (oscillation stop, re-oscillation detection function enabled), the cm27 bit is set to 1 (oscillation stop, re-oscillation detection interrupt), and the cpu clock source is the main clock, the cm21 bit is automatically set to 1 (on-chip oscillator clock) if the main clock stop is detected. note 3: if the cm20 bit is set to 1 and the cm23 bit is set to 1 (main clock not oscillating), do not set the cm21 bit to 0 . note 4: this flag is set to 1 when the main clock is detected to have stopped or when the main clock is detected to have restarted oscillating. when this flag changes state from 0 to 1 , an oscillation stop, reoscillation detection interrupt is generated. use this flag in an interrupt routine to discriminate the causes of interrupts between the oscillation stop, reoscillation detection interrupts and the watchdog timer interrupt. the flag is cleared to 0 by writing a 0 in a program. (writing a 1 has no effect. nor is it cleared to 0 by an oscillation stop or an oscillation restart detection interrupt request acknowledged.) if when the cm22 bit is set to "1" an oscillation stop or an oscillation restart is detected, no oscillation stop, reoscillatio n detection interrupts are generated. note 5: read the cm23 bit in an oscillation stop, re-oscillation detection interrupt handling routine to determine the main clo ck status. note 6: effective when the cm07 bit in the cm0 register is set to 0 . note 7: when the pm21 bit in the pm2 register is 1 (clock modification disabled), writing to the cm20 bit has no effect. note 8: when the cm20 bit is set to 1 (oscillation stop, re-oscillation detection function enabled), the cm27 bit is set to 1 (oscillation stop, re-oscillation detection interrupt), and the cm11 bit is set to 1 (the cpu clock source is pll clock), the cm21 bit remains unchanged even when main clock stop is detected. if the cm22 bit is set to 0 under these conditions, oscillation stop, re-oscillation detection interrupt occur at main clock stop detection; it is, therefore, necessary to set the cm21 bit to 1 (on-chip oscillator clock) inside the interrupt routine. note 9: set the cm20 bit to 0 (disable) before entering stop mode. after exiting stop mode, set the cm20 bit back to 1 (enable). note 10: set the cm20 bit to 0 (disable) before setting the cm05 bit in the cm0 register. note 11: the cm20, cm21 and cm27 bits do not change at oscillation stop detection reset. note 12: when the cm21 bit is set to "0" (on-chip oscillator turned off) and the cm05 bit is set to "1" (main clock turned off) , the cm06 bit is fixed to 1 (divide-by-8 mode) and the cm15 bit is fixed to 1 (drive capability high). cm22 cm23 oscillation stop, re- oscillation detection flag 0: main clock stop or re-oscillation not detected 1: main clock stop or re-oscillation detected 0: main clock oscillating 1: main clock not oscillating x in monitor flag (note 4) cm27 0: oscillation stop detection reset 1: oscillation stop, re-oscillation detection interrupt nothing is assigned. when write, set to 0 . when read, its content is indeterminate. operation select bit (when an oscillation stop, re-oscillation is detected) (note 11) rw rw rw rw ro (b6) (note 5) reserved bit (b5-b4) must set to 0 rw 00 figure 7.5. cm2 register 7. clock generation circuit page 37 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 7.6. pclkr register and pm2 register function bit symbol bit name peripheral clock select register (note) symbol address when reset pclkr 025e 16 00000011 2 rw b7 b6 b5 b4 b3 b2 b1 b0 pclk0 timers a, b clock select bit (clock source for the timers a, b, and the dead timer) 0 : f 2 1 : f 1 000 reserved bit must set to ? note: write to this register after setting the prc0 bit in the prcr register to ??(write enable). 00 pclk1 si/o clock select bit (clock source for uart0 to uart2) 0 : f 2sio 1 : f 1sio rw rw rw (b4-b2) reserved bit must set to ? rw (b7-b6) rw pclk5 clock output function expansion select bit refer to table 7.5.3.1 function of clkout pin function bit symbol bit name processeor mode register 2 (note 1) symbol address when reset pm2 001e 16 xxx00000 2 rw b7 b6 b5 b4 b3 b2 b1 b0 pm20 specifying wait when accessing sfr at pll operation 0 : 2 wait 1 : 1 wait 0 nothing is assigned. when write, set to 0 . when read, its content is indeterminate. pm21 system clock protective bit 0 : clock is protected by prcr register 1 : clock modification disabled rw rw rw (b7-b5) pm22 pm24 (b3) wdt count source protective bit reserved bit 0 : cpu clock is used for the watchdog timer count source 1 : on-chip oscillator clock is used for the watchdog timer count source must set to 0 p8 5 /nmi configuration bit rw rw (note 2) (note 3,4) (note 3,5) (note 6,7) note 1: write to this register after setting the prc1 bit in the prcr register to 1 (write enable). note 2: this bit can only be rewritten while the plc07 bit is 0 (pll turned off). also, set the pm20 bit to 0 (2 wait) when pll clock > 16mhz. note that if the clock source for the cpu clock is to be changed from pll clock to another, the plc07 bit must be set to "0" before setting the pm20 bit. note 3: once this bit is set to 1 , it cannot be cleared to 0 in a program. note 4: if the pm21 bit is set to 1 , writing to the following bits has no efftect: cm02 bit in the cm0 register cm05 bit in the cm0 register (main clock is not halted) cm07 bit in the cm0 register (cpu clock source does not change) cm10 bit in the cm1 register (stop mode is not entered) cm11 bit in the cm1 register (cpu clock source does not change) cm20 bit in the cm2 register (oscillation stop, re-oscillation detection function settings do not change) all bits in the plc0 register (pll frequency synthesizer setting do not change) be aware that the wait instruction cannot be executed when the pm21 bit is set to "1". note 5: setting the pm22 bit to 1 results in the following conditions: the on-chip oscillator starts oscillating, and the on-chip oscillator clock becomes the watchdog timer count source. the cm10 bit in the cm1 register is disabled against write. (writing a 1 has no effect, nor is stop mode entered.) the watchdog timer does not stop when in wait mode. note 6: for nmi function, the pm24 bit must be set to 1 (nmi function) in first instruction after rest. once this bit is set to 1 , it cannot be cleared to 0 in a program. when the pm24 bit is set to 1 , the p85 direction register must be 0 (input mode). note 7: sd input is valid regardless of the pm24 setting. 0 : p8 5 function (nmi disable) 1 : nmi function 7. clock generation circuit page 38 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 7.7. plc0 register plc00 plc01 plc02 plc07 (note 3) (note 4) function note 1: write to this register after setting the prc0 bit in the prcr register to "1" (write enable). note 2: when the pm21 bit in the pm2 register is "1" (clock modification disable), writing to this register has no effect. note 3: these three bits can only be modified when the plc07 bit is set to "0" (pll turned off). the value once written to this bit cannot be modified. note 4: before setting this bit to "1" , set the cm07 bit to "0" (main clock), set the cm17 and cm16 bits to "00 2 " (main clock undivided mode), and set the cm06 bit to "0" (cm16 and cm17 bits enable). pll control register 0 (note 1, note 2) pll multiplying factor select bit nothing is assigned. when write, set to "0". when read, its content is indeterminate. reserved bit operation enable bit 0 0 0: 0 0 1: multiply by 2 0 1 0: multiply by 4 0 1 1: 1 0 0: 1 0 1: 1 1 0: 1 1 1: 0: pll off 1: pll on must set to "1" bit name bit symbol symbol address after reset plc0 001c 16 0001 x010 2 rw b1b0 b2 reserved bit must set to "0" do not set rw rw rw rw rw rw do not set (b4) (b6-b5) (b3) b7 b6 b5 b4 b3 b2 b1 b0 0 1 0 7. clock generation circuit page 39 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m microcomputer (built-in feedback resistor) x in x out externally derived clock open v cc vss microcomputer (built-in feedback resistor) x in x out r d c in c out (note) note: insert a damping resistor if required. the resistance will vary depending on the oscillator and the oscillation drive capacity setting. use the value recommended by the maker of the oscillator. when the oscillation drive capacity is set to low, check that oscillation is stable. also, if the oscillator manufacturer's data sheet specifies that a feedback resistor be added external to the chip, insert a feedback resistor between x in and x out following the instruction. figure 7.1.1. examples of main clock connection circuit the following describes the clocks generated by the clock generation circuit. 7.1 main clock the main clock is generated by the main clock oscillation circuit. this clock is used as the clock source for the cpu and peripheral function clocks. the main clock oscillator circuit is configured by connecting a resonator between the x in and x out pins. the main clock oscillator circuit contains a feedback resistor, which is disconnected from the oscillator circuit during stop mode in order to reduce the amount of power consumed in the chip. the main clock oscillator circuit may also be configured by feeding an externally generated clock to the x in pin. figure 7.1.1 shows the examples of main clock connection circuit. the main clock after reset oscillates in the m16c/26a, but stop in the m16c/26t. the power consumption in the chip can be reduced by setting the cm05 bit in the cm0 register to 1 (main clock oscillator circuit turned off) after switching the clock source for the cpu clock to a sub clock or on-chip oscillator clock. in this case, x out goes h . furthermore, because the internal feedback resistor remains on, x in is pulled h to x out via the feedback resistor. during stop mode, all clocks including the main clock are turned off. refer to 7.6 power control . if the main clock is not used, it is recommended to connect the xin pin to vcc to reduce power consump- tion during reset. 7. clock generation circuit page 40 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m microcomputer (built-in feedback resistor) x cin x cout externally derived clock open vss note: insert a damping resistor if required. the resistance will vary depending on the oscillator and the oscillation drive capacity setting. use the value recommended by the maker of the oscillator. when the oscillation drive capacity is set to low, check that oscillation is stable. also, if the oscillator manufacturer's data sheet specifies that a feedback resistor be added external to the chip, insert a feedback resistor between x cin and x cout following the instruction. microcomputer (built-in feedback resistor) x cin x cout (note) c cin c cout r cd v cc figure 7.2.1. examples of sub clock connection circuit 7.2 sub clock the sub clock is generated by the sub clock oscillation circuit. this clock is used as the clock source for the cpu clock, as well as the timer a and timer b count sources. the sub clock oscillator circuit is configured by connecting a crystal resonator between the x cin and x cout pins. the sub clock oscillator circuit contains a feedback resistor, which is disconnected from the oscillator circuit during stop mode in order to reduce the amount of power consumed in the chip. the sub clock oscillator circuit may also be configured by feeding an externally generated clock to the x cin pin. figure 7.2.1 shows the examples of sub clock connection circuit. after reset, the sub clock is turned off. at this time, the feedback resistor is disconnected from the oscillator circuit. to use the sub clock for the cpu clock, set the cm07 bit in the cm0 register to 1 (sub clock) after the sub clock becomes oscillating stably. during stop mode, all clocks including the sub clock are turned off. refer to 7.6 power control . 7. clock generation circuit page 41 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.3 on-chip oscillator clock this clock is supplied by a on-chip oscillator. this clock is used as the clock source for the cpu and peripheral function clocks. in addition, if the pm22 bit in the pm2 register is 1 (on-chip oscillator clock for the watchdog timer count source), this clock is used as the count source for the watchdog timer (refer to 10.1 count source protective mode ). the on-chip oscillator clock after reset oscillates. the on-chip oscillator clock f 2(roc) divided by 16 is used for the cpu clock. it can also be turned off by setting the cm21 bit in the cm2 register to 0 (main clock or pll clock). if the main clock stops oscillating when the cm20 bit in the cm2 register is 1 (oscillation stop, re-oscillation detection function enabled) and the cm27 bit is 1 (oscillation stop, re-oscillation detection interrupt), the on-chip oscillator automatically starts operating, supplying the necessary clock for the micro- computer. 7.4 pll clock the pll clock is generated from the main clock by a pll frequency synthesizer. this clock is used as the clock source for the cpu and peripheral function clocks. after reset, the pll clock is turned off. the pll frequency synthesizer is activated by setting the plc07 bit to 1 (pll operation). when the pll clock is used as the clock source for the cpu clock, wait t su (pll) for the pll clock to be stable, and then set the cm11 bit in the cm1 register to 1 . before entering wait mode or stop mode, be sure to set the cm11 bit to 0 (cpu clock source is the main clock). furthermore, before entering stop mode, be sure to set the plc07 bit in the plc0 register to 0 (pll stops). figure 7.4.1 shows the procedure for using the pll clock as the clock source for the cpu. the pll clock frequency is determined by the equation below. pll clock frequency=f(x in ) x (multiplying factor set by the plc02 to plc00 bits in the plc0 register (however, 10 mhz pll clock frequency 20 mhz) the plc02 to plc00 bits can be set only once after reset. table 7.4.1 shows the example for setting pll clock frequencies. x in (mhz) plc02 plc01 plc00 multiplying factor pll clock (mhz)(note) 10 0 0 1 2 20 50 1 0 4 note: 10mhz pll clock frequency 20mhz. table 7.4.1. example for setting pll clock frequencies 7. clock generation circuit page 42 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 7.4.1. procedure to use pll clock as cpu clock source start set the cm07 bit to 0 (main clock), the cm17 to cm16 bits to 00 2 (main clock undivided), and the cm06 bit to 0 (cm16 and cm17 bits enabled). (note) set the plc02 to plc00 bits (multiplying factor). (to select a 16 mhz < pll clock) set the pm20 bit to 0 (2-wait states). set the plc07 bit to 1 (pll operation). wait until the pll clock becomes stable (t su (pll)). set the cm11 bit to 1 (pll clock for the cpu clock source). end note : pll operation mode can be entered from high speed mode. 7. clock generation circuit page 43 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.5 cpu clock and peripheral function clock the cpu clock is used to operate the cpu and peripheral function clocks are used to operate the periph- eral functions. 7.5.1 cpu clock this is the operating clock for the cpu and watchdog timer. the clock source for the cpu clock can be chosen to be the main clock, sub clock, on-chip oscillator clock or the pll clock. if the main clock or on-chip oscillator clock is selected as the clock source for the cpu clock, the selected clock source can be divided by 1 (undivided), 2, 4, 8 or 16 to produce the cpu clock. use the cm06 bit in cm0 register and the cm17 to cm16 bits in cm1 register to select the divide-by-n value. when the pll clock is selected as the clock source for the cpu clock, the cm06 bit should be set to 0 and the cm17 and cm16 bits to 00 2 (undivided). after reset, the on-chip oscillator clock divided by 16 provides the cpu clock. note that when entering stop mode from high or middle speed mode, on-chip oscillator mode or on-chip oscillator low power dissipation mode, or when the cm05 bit in the cm0 register is set to 1 (main clock turned off) in low-speed mode, the cm06 bit in the cm0 register is set to 1 (divide-by-8 mode). 7.5.2 peripheral function clock(f 1 , f 2 , f 8 , f 32 , f 1sio , f 2sio , f 8sio , f 32sio , f ad , f c32 ) these are operating clocks for the peripheral functions. of these, fi (i = 1, 2, 8, 32) and fi sio are derived from the main clock, pll clock or on-chip oscillator clock by dividing them by i. the clock fi is used for timers a and b, and fi sio is used for serial i/o. the f ad clock is produced from the main clock, pll clock or on-chip oscillator clock, and is used for the a/ d converter. when the wait instruction is executed after setting the cm02 bit in the cm0 register to 1 (peripheral function clock turned off during wait mode), or when the microcomputer is in low power dissipation mode, the fi, fi sio and f ad clocks are turned off. the f c32 clock is produced from the sub clock, and is used for timers a and b. this clock can only be used when the sub clock is on. 7.5.3 clockoutput function the f 1 , f 8 , f 32 or f c clock can be output from the clk out pin. use the pclk5 bit in the pclkr register and cm01 to cm00 bits in the cm0 register to select. table 7.5.3.1 shows the function of the clk out pin. table 7.5.3.1 the function of the clk out pin pc lk5 cm01 cm00 the function of the clk out pin 0 0 0 i/o port p9 0 001f c 010f 8 011f 32 100f 1 1 0 1 do not set 1 1 0 do not set 1 1 1 do not set 7. clock generation circuit page 44 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.6 power control there are three power control modes. for convenience sake, all modes other than wait and stop modes are referred to as normal operation mode here. 7.6.1 normal operation mode normal operation mode is further classified into seven modes. in normal operation mode, because the cpu clock and the peripheral function clocks both are on, the cpu and the peripheral functions are operating. power control is exercised by controlling the cpu clock frequency. the higher the cpu clock frequency, the greater the processing capability. the lower the cpu clock frequency, the smaller the power consumption in the chip. if the unnecessary oscillator circuits are turned off, the power consumption is further reduced. before the clock sources for the cpu clock can be switched over, the new clock source to which switched must be oscillating stably. if the new clock source is the main clock, sub clock or pll clock, allow a sufficient wait time in a program until it becomes oscillating stably. note that operation modes cannot be changed directly from low speed or low power dissipation mode to on-chip oscillator or on-chip oscillator low power dissipation mode. nor can operation modes be changed directly from on-chip oscillator or on-chip oscillator low power dissipation mode to low speed or low power dissipation mode. when the cpu clock source is changed from the on-chip oscillator to the main clock, change the operation mode to the medium speed mode (divided by 8 mode) after the clock was divided by 8 (the cm06 bit in the cm0 register was set to 1 ) in the on-chip oscillator mode. 7.6.1.1 high-speed mode the main clock divided by 1 provides the cpu clock. if the sub clock is on, f c32 can be used as the count source for timers a and b. 7.6.1.2 pll operation mode the main clock multiplied by 2 or 4 provides the pll clock, and this pll clock serves as the cpu clock. if the sub clock is on, f c32 can be used as the count source for timers a and b. pll operation mode can be entered from high speed mode. if pll operation mode is to be changed to wait or stop mode, first go to high speed mode before changing. 7.6.1.3 medium-speed mode the main clock divided by 2, 4, 8 or 16 provides the cpu clock. if the sub clock is on, f c32 can be used as the count source for timers a and b. 7.6.1.4 low-speed mode the sub clock provides the cpu clock. the main clock is used as the clock source for the peripheral function clock when the cm21 bit is set to 0 (on-chip oscillator turned off), and the on-chip oscillator clock is used when the cm21 bit is set to 1 (on-chip oscillator oscillating). the f c32 clock can be used as the count source for timers a and b. 7.6.1.5 low power dissipation mode in this mode, the main clock is turned off after being placed in low speed mode. the sub clock provides the cpu clock. the f c32 clock can be used as the count source for timers a and b. peripheral function clock can use only f c32 . simultaneously when this mode is selected, the cm06 bit in the cm0 register becomes 1 (divided by 8 mode). in the low power dissipation mode, do not change the cm06 bit. consequently, the medium speed (divided by 8) mode is to be selected when the main clock is operated next. 7. clock generation circuit page 45 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.6.1.6 on-chip oscillator mode the selected on-chip oscillator clock divided by 1 (undivided), 2, 4, 8 or 16 provides the cpu clock. the on-chip oscillator clock is also the clock source for the peripheral function clocks. if the sub clock is on, f c32 can be used as the count source for timers a and b. the on-chip oscillator frequency can be selected rocr3 to rocr0 bits in rocr register. when the operation mode is returned to the high and medium speed modes, set the cm06 bit to 1 (divided by 8 mode). 7.6.1.7 on-chip oscillator low power dissipation mode the main clock is turned off after being placed in on-chip oscillator mode. the cpu clock can be selected as in the on-chip oscillator mode. the on-chip oscillator clock is the clock source for the peripheral function clocks. if the sub clock is on, f c32 can be used as the count source for timers a and b. 1(note 1) modes cm2 register cm21 cm1 register cm11 cm17, cm16 cm0 register cm07 cm06 cm05 cm04 pll operation mode 0100 2 00 high-speed mode 0 0 00 2 00 0 medium- speed mode 0001 2 00 0 0010 2 00 0 divided by 2 00 01 0 0011 2 00 0 low-speed mode 1 0 1 low power dissipation mode 11 on-chip oscillator mode (note 3) 1 divided by 4 divided by 8 divided by 16 on-chip oscillator low power dissipation mode note 1: when the cm05 bit is set to 1 (main clock turned off) in low-speed mode, the mode goes to low power dissipation mode and cm06 bit is set to 1 (divided by 8 mode) simultaneously. note 2: the divide-by-n value can be selected the same way as in on-chip oscillator mode. 0 0 101 2 000 110 2 000 110 111 2 00 0 100 2 00 0 (note 2) divided by 2 divided by 4 divided by 8 divided by 16 divided by 1 1(note 1) (note 2) 1 note 3: on-chip oscillator frequency can be any of those described in the section 7.6.1.6 on-chip oscillator mode . 0 0 7.6.2 wait mode in wait mode, the cpu clock is turned off, so are the cpu (because operated by the cpu clock) and the watchdog timer. however, if the pm22 bit in the pm2 register is 1 (on-chip oscillator clock for the watch- dog timer count source), the watchdog timer remains active. because the main clock, sub clock, on-chip oscillator clock and pll clock all are on, the peripheral functions using these clocks keep operating. 7.6.2.1 peripheral function clock stop function if the cm02 bit is 1 (peripheral function clocks turned off during wait mode), the f 1 , f 2 , f 8 , f 32 , f 1sio , f 8sio , f 32sio and f ad clocks are turned off when in wait mode, with the power consumption reduced that much. however, f c32 remains on. 7.6.2.2 entering wait mode the microcomputer is placed into wait mode by executing the wait instruction. when the cm11 bit is set to 1 (cpu clock source is the pll clock), be sure to clear the cm11 bit to 0 (cpu clock source is the main clock) before going to wait mode. the power consumption of the chip can be reduced by clearing the plc07 bit to 0 (pll stops). table 7.6.1.1. setting clock related bit and modes 7. clock generation circuit page 46 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m interrupt cm02=0 cm02=1 nmi interrupt can be used serial i/o interrupt can be used when operating with internal or external clock can be used when operating with external clock key input interrupt can be used can be used a/d conversion interrupt can be used in one-shot mode or single sweep mode timer a interrupt can be used in all modes can be used in event counter mode or when the count source is fc32 timer b interrupt int interrupt can be used can be used (do not use) can be used table 7.6.2.4.1. interrupts to exit wait mode 7.6.2.3 pin status during wait mode table 7.6.2.3.1 lists pin status during wait mode. table 7.6.2.3.1 pin status in wait mode pin status i/o ports retains status before wait mode when fc selected does not stop clk out when f1, f8, f32 selected does not stop when the cm02 bit is set to 0 . retains status before wait mode when the cm02 bit is set to 1 . 7.6.2.4 exiting wait mode ______ the microcomputer is moved out of wait mode by a hardware reset, nmi interrupt or peripheral func- tion interrupt. ______ if the microcomputer is to be moved out of exit wait mode by a hardware reset or nmi interrupt, set the peripheral function interrupt priority ilvl2 to ilvl0 bits to 000 2 (interrupts disabled) before execut- ing the wait instruction. the peripheral function interrupts are affected by the cm02 bit. if the cm02 bit is set to 0 (peripheral function clocks not turned off during wait mode), all peripheral function interrupts can be used to exit wait mode. if the cm02 bit is set to 1 (peripheral function clocks turned off during wait mode), the peripheral functions using the peripheral function clocks stop operating, so that only the peripheral functions clocked by external signals can be used to exit wait mode. table 7.6.2.4.1 lists the interrupts to exit wait mode. if the microcomputer is to be moved out of wait mode by a peripheral function interrupt, set up the following before executing the wait instruction. 1. in the ilvl2 to ilvl0 bits in the interrupt control register, set the interrupt priority level of the periph eral function interrupt to be used to exit wait mode. also, for all of the peripheral function interrupts not used to exit wait mode, set the ilvl2 to ilvl0 bits to 000 2 (interrupt disable). 2. set the i flag to 1 . 3. enable the peripheral function whose interrupt is to be used to exit wait mode. in this case, when an interrupt request is generated and the cpu clock is thereby turned on, an interrupt routine is executed. the cpu clock turned on when exiting wait mode by a peripheral function interrupt is the same cpu clock that was on when the wait instruction was executed. 7. clock generation circuit page 47 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.6.3 stop mode in stop mode, all oscillator circuits are turned off, so are the cpu clock and the peripheral function clocks. therefore, the cpu and the peripheral functions clocked by these clocks stop operating. the least amount of power is consumed in this mode. if the voltage applied to vcc pin is v ram or more, the internal ram is retained. when applying 2.7 or less voltage to vcc pin, make sure vcc v ram . however, the peripheral functions clocked by external signals keep operating. the following interrupts can be used to exit stop mode. ______ ? nmi interrupt ? key interrupt ______ ? int interrupt ? timer a, timer b interrupt (when counting external pulses in event counter mode) ? serial i/o interrupt (when external clock is selected) ? voltage down detection interrupt (refer to 5.5.1 voltage down detection interrupt for an operating condition) 7.6.3.1 entering stop mode the microcomputer is placed into stop mode by setting the cm10 bit in the cm1 register to 1 (all clocks turned off). at the same time, the cm06 bit in the cm0 register is set to 1 (divide-by-8 mode) and the cm15 bit in the cm10 register is set to 1 (main clock oscillator circuit drive capability high). before entering stop mode, set the cm20 bit to 0 (oscillation stop, re-oscillation detection function disable). also, if the cm11 bit is 1 (pll clock for the cpu clock source), set the cm11 bit to 0 (main clock for the cpu clock source) and the plc07 bit to 0 (pll turned off) before entering stop mode. 7.6.3.2 pin status during stop mode the i/o pins retain their status held just prior to entering stop mode. 7.6.3.3 exiting stop mode ______ the microcomputer is moved out of stop mode by a hardware reset, nmi interrupt or peripheral func- tion interrupt. ______ if the microcomputer is to be moved out of stop mode by a hardware reset or nmi interrupt, set the peripheral function interrupt priority ilvl2 to ilvl0 bits to 000 2 (interrupts disable) before setting the cm10 bit to 1 . if the microcomputer is to be moved out of stop mode by a peripheral function interrupt, set up the following before setting the cm10 bit to 1 . 1. in the ilvl2 to ilvl0 bits in the interrupt control register, set the interrupt priority level of the peripheral function interrupt to be used to exit stop mode. also, for all of the peripheral function interrupts not used to exit stop mode, set the ilvl2 to ilvl0 bits to 000 2 . 2. set the i flag to 1 . 3. enable the peripheral function whose interrupt is to be used to exit stop mode. in this case, when an interrupt request is generated and the cpu clock is thereby turned on, an interrupt service routine is executed. ______ which cpu clock will be used after exiting stop mode by a peripheral function or nmi interrupt is determined by the cpu clock that was on when the microcomputer was placed into stop mode as follows: if the cpu clock before entering stop mode was derived from the sub clock : sub clock if the cpu clock before entering stop mode was derived from the main clock : main clock divide-by-8 if the cpu clock before entering stop mode was derived from the on-chip oscillator clock: on-chip oscillator clock divide-by-8 7. clock generation circuit page 48 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 7.6.1. state transition to stop mode and wait mode reset medium-speed mode (divided-by-8 mode) high-speed, medium- speed mode stop mode wait mode interrupt cm10=1 interrupt low-speed, low power dissipation mode cm10=1 stop mode interrupt wait mode interrupt cm10=1 stop mode all oscillators stopped interrupt wait mode wait instruction interrupt cpu operation stopped when low- speed mode when low power dissipation mode pll operation mode notes 1, 2 : arrow shows mode can be changed. do not change mode to another mode when no arrow is shown. note 1: do not go directly from pll operation mode to wait or stop mode. note 2: pll operation mode can be entered from high speed mode. similarly, pll operation mode can be changed back to high speed mode. note 3: when the pm21 bit is set to "0" (system clock protective function unused). note 4: the on-chip oscillator clock divided by 8 provides the cpu clock. note 5: write to the cm0 register and cm1 register simultaneously by accessing in word units while cm21 bit is set to "1" (on- chip oscillator turned off). when the clock generated externally is input to the x cin pin, transit to stop mode with this process. note 6: before entering stop mode, be sure to clear the cm20 bit in the cm2 register to "0" (oscillation stop and oscillation r estart detection function disabled). wait mode interrupt cm10=1 interrupt (note 4) stop mode wait instruction wait instruction wait instruction on-chip oscillator mode (selectable frequency) on-chip oscillator mode (f 2 (roc) /16) normal operation mode cm21=1 cm21=0 cm07=0 cm06=1 cm05=0 cm11=0 cm10=1 (note 5) on-chip oscillator low power dissipation mode cm10=1 stop mode interrupt wait mode interrupt wait instruction figure 7.6.1 shows the state transition from normal operation mode to stop mode and wait mode. figure 7.6.1.1 shows the state transition in normal operation mode. table 7.6.1 shows a state transition matrix describing allowed transition and setting. the vertical line shows current state and horizontal line shows state after transition. 7. clock generation circuit page 49 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 7.6.1.1. state transition in normal mode cm04=0 cpu clock: f(pll) cm07=0 cm06=0 cm17=0 cm16=0 pll operation mode cm07=0 cm06=0 cm17=0 cm16=0 cm07=0 cm17=0 cm06=0 cm16=0 cm07=0 cm17=0 cm06=0 cm16=1 cm07=0 cm17=1 cm06=0 cm16=0 cm07=0 cm06=1 cm07=0 cm17=1 cm06=0 cm16=1 high-speed mode cm07=0 cm17=0 cm06=0 cm16=0 cm07=0 cm17=0 cm06=0 cm16=1 cm07=0 cm17=1 cm06=0 cm16=0 cm07=0 cm06=1 cm07=0 cm17=1 cm06=0 cm16=1 cm07=0 low-speed mode cm07=0 low power dissipation mode cm06=1 cm15=1 on-chip oscillator mode cpu clock on-chip oscillator mode cpu clock cpu clock on-chip oscillator low power dissipation mode cpu clock cm07=0 low-speed mode plc07=1 cm11=1 (note 6) plc07=0 cm11=0 (note 7) cm04=0 plc07=1 cm11=1 plc07=0 cm11=0 cm04=0 cm04=1 cm04=1 cm04=1 cm04=0 cm04=1 cm07=0 (note 2, note 4) cm07=1 (note 3) cm05=1 (note 1, note 9) cm05=0 cm21=0 (note 8) cm21=1 cm21=0 (note 8) cm21=1 cm21=0 cm21=1 main clock oscillation on-chip oscillator clock oscillation sub clock oscillation f(ring) f(ring)/2 f(ring)/4 f(ring)/8 f(ring)/16 f(ring) f(ring)/2 f(ring)/4 f(ring)/8 f(ring)/16 f(ring) f(ring)/2 f(ring)/4 f(ring)/8 f(ring)/16 f(ring) f(ring)/2 f(ring)/4 f(ring)/8 f(ring)/16 pll operation mode cpu clock: f(pll) cpu clock: f(x in ) high-speed mode middle-speed mode (divide by 2) cpu clock: f(x in )/2 cpu clock: f(x in )/4 cpu clock: f(x in )/8 cpu clock: f(x in )/16 cpu clock: f(x cin ) cpu clock: f(x cin ) cpu clock: f(x cin ) cm05=0 m0 m cm05=1 (note 1) cm05=1 (note 1) cm05=0 (note 6) (note 7) middle-speed mode (divide by 4) middle-speed mode (divide by 8) middle-speed mode (divide by 16) middle-speed mode (divide by 2) middle-speed mode (divide by 4) middle-speed mode (divide by 8) middle-speed mode (divide by 16) cpu clock: f(x in ) cpu clock: f(x in )/2 cpu clock: f(x in )/4 cpu clock: f(x in )/8 cpu clock: f(x in )/16 on-chip oscillator low power dissipation mode notes: : arrow shows mode can be changed. do not change mode to another mode when no arrow is shown. 1: avoid making a transition when the cm20 bit is set to 1 (oscillation stop, re-oscillation detection function enabled). set the cm20 bit to 0 (oscillation stop, re-oscillation detection function disabled) before transiting. 2: wait for the main clock oscillation stabilization time before switching over. 3: switch clock after oscillation of sub-clock is sufficiently stable. 4: change cm17 and cm16 before changing cm06. 5: transit in accordance with arrow. 6: pll operation mode can only be entered from high speed mode. also, wait until the pll clock is sufficiently stable before c hanging operation modes. to select pll clock > 16mhz, set the pm20 bit to 0 (sfr accessed with two wait states) before setting plc07 to 1 (pll operation). 7: pll operation mode can only be changed to high speed mode. if the pm20 bit is set to "0" (sfr accessed with two wait states ), set plc07 to 0 (pll turned off) before setting the pm20 bit to 1 (sfr accessed with one wait state). 8: set the cm06 bit to 1 (division by 8 mode) before changing back the operation mode from on-chip oscillator mode to high- or middle-speed mode. 9: when the cm21 bit is set to "0" (on-chip oscillator turned off) and the cm05 bit is set to "1" (main clock turned off), th e cm06 bit is fixed to 1 (divide-by-8 mode) and the cm15 bit is fixed to 1 (drive capability high). 7. clock generation circuit page 50 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m table 7.6.1. allowed transition and setting high-speed mode, middle-speed mode on-chip oscillator mode stop mode wait mode on-chip oscillator low power dissipation mode pll operation mode 2 low power dissipation mode low-speed mode 2 current state state after transition see table a 8 -- (8) (18) 5 (9) 7 -- (10) (11) 1, 6 (12) 3 (14) 4 -- -- -- -- -- (13) 3 (15) -- -- -- -- -- -- -- (10) -- -- -- -- -- -- -- -- (18) (18) -- -- (16) 1 (17) (16) 1 (17) (16) 1 (17) (16) 1 (17) (16) 1 (17) -- -- (18) 5 (18) 5 (18) (18) (18) (18) (18) (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) setting operation cm04 = 0 sub clock turned off cm04 = 1 sub clock oscillating cm06 = 0, cpu clock no division mode cm17 = 0 , cm16 = 0 cm06 = 0, cpu clock division by 2 mode cm17 = 0 , cm16 = 1 cm06 = 0, cpu clock division by 4 mode cm17 = 1 , cm16 = 0 cm06 = 1 cpu clock division by 8 mode cm06 = 0, cpu clock division by 16 mode cm17 = 1 , cm16 = 1 cm07 = 0 main clock, pll clock, or on-chip oscillator clock selected cm07 = 1 sub clock selected cm05 = 0 main clock oscillating cm05 = 1 main clock turned off plc07 = 0, cm11 = 0 main clock selected plc07 = 1, cm11 = 1 pll clock selected cm21 = 0 main clock or pll clock selected cm21 = 1 on-chip oscillator clock selected cm10 = 1 transition to stop mode wait instruction transition to wait mode hardware interrupt exit stop mode or wait mode notes: 1. avoid making a transition when the cm21 bit is set to 1 (oscillation stop, re-oscillation detection function enabled). set the cm21 bit to 0 (oscillation stop, re-oscillation detection function disabled) before transiting. 2. on-chip oscillator clock oscillates and stops in low-speed mode. in this mode, the on-chip oscillator can be used as periphe ral function clock. sub clock oscillates and stops in pll operation mode. in this mode, sub clock can be used as peripheral function clock. 3. pll operation mode can only be entered from and changed to high-speed mode. 4. set the cm06 bit to 1 (division by 8 mode) before transiting from on-chip oscillator mode to high- or middle-speed mode. 5. when exiting stop mode, the cm06 bit is set to 1 (division by 8 mode). 6. if the cm05 bit is set to 1 (main clock stop), then the cm06 bit is set to 1 (division by 8 mode). 7. a transition can be made only when sub clock is oscillating. 8. state transitions within the same mode (divide-by-n values changed or subclock oscillation turned on or off) are shown in th e table below. --: cannot transit (11) 1 high-speed mode, middle-speed mode on-chip oscillator mode stop mode wait mode on-chip oscillator low power dissipation mode pll operation mode 2 low power dissipation mode low-speed mode 2 see table a 8 see table a 8 (3) (3) (3) (3) (4) (4) (4) (4) (5) (7) (7) (5) (5) (5) (7) (7) (6) (6) (6) (6) no division divided by 2 (3) (3) (3) (3) (4) (4) (4) (4) (5) (5) (5) (5) (7) (7) (7) (7) (6) (6) (6) (6) (1) (1) (1) (1) (1) (2) (2) (2) (2) (2) -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- sub clock oscillating sub clock turned off --: cannot transit divided by 4 divided by 8 divided by 16 no division divided by 2 divided by 4 divided by 8 divided by 16 no division divided by 4 sub clock oscillating sub clock turned off divided by 8 divided by 16 divided by 2 no division divided by 4 divided by 8 divided by 16 divided by 2 9. ( ) : setting method. refer to following table. cm04, cm05, cm06, cm07 : bits in the cm0 register cm10, cm11, cm16, cm17 : bits in the cm1 register cm20, cm21 : bits in the cm2 register plc07 : bit in the plc0 register 7. clock generation circuit page 51 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.7 system clock protective function when the main clock is selected for the cpu clock source, this function protects the clock from modifica- tions in order to prevent the cpu clock from becoming halted by run-away. if the pm21 bit in the pm2 register is set to 1 (clock modification disabled), the following bits are protected against writes: ? cm02, cm05, and cm07 bits in cm0 register ? cm10, cm11 bits in cm1 register ? cm20 bit in cm2 register ? all bits in plc0 register before the system clock protective function can be used, the following register settings must be made while the cm05 bit in the cm0 register is 0 (main clock oscillating) and cm07 bit is 0 (main clock selected for the cpu clock source): (1) set the prc1 bit in the prcr register to 1 (enable writes to pm2 register). (2) set the pm21 bit in the pm2 register to 1 (disable clock modification). (3) set the prc1 bit in the prcr register to 0 (disable writes to pm2 register). do not execute the wait instruction when the pm21 bit is set to 1 . 7.8 oscillation stop and re-oscillation detect function the oscillation stop and re-oscillation detect function allows the detection of main clock oscillation stop and reoscillation. at oscillation stop or re-oscillation detection, reset or oscillation stop, re-oscillation detection interrupt are generated. depending on the cm27 bit in the cm2 register. the oscillation stop detection function can be enabled and disabled by the cm20 bit in the cm2 register. table 7.8.1 lists a specification overview of the oscillation stop and re-oscillation detect function. table 7.8.1. specification overview of oscillation stop and re-oscillation detect function item specification oscillation stop detectable clock and f(x in ) 2 mhz frequency bandwidth enabling condition for oscillation stop, set the cm20 bit to 1 (enable) re-oscillation detection function operation at oscillation stop, ? reset occurs (when the cm27 bit is set to "0") re-oscillation detection ? oscillation stop, re-oscillation detection interrupt occurs(when the cm27 bit is set to "1") 7. clock generation circuit page 52 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.8.1 operation when the cm27 bit is set to "0" (oscillation stop detection reset) when main clock stop is detected when the cm20 bit is 1 (oscillation stop, re-oscillation detection function enabled), the microcomputer is initialized, coming to a halt (oscillation stop reset; refer to 4. sfr , 5. reset ). this status is reset with hardware reset 1 or hardware reset 2. also, even when re-oscillation is detected, the microcomputer can be initialized and stopped; it is, however, necessary to avoid such usage. (during main clock stop, do not set the cm20 bit to 1 and the cm27 bit to 0 .) 7.8.2 operation when the cm27 bit is set to "1" (oscillation stop and re-oscillation detect interrupt) when the main clock corresponds to the cpu clock source and the cm20 bit is 1 (oscillation stop and re-oscillation detect function enabled), the system is placed in the following state if the main clock comes to a halt: ? oscillation stop and re-oscillation detect interrupt request occurs. ? the on-chip oscillator starts oscillation, and the on-chip oscillator clock becomes the cpu clock and clock source for peripheral functions in place of the main clock. ? cm21 bit is set to "1" (on-chip oscillator clock for cpu clock source) ? cm22 bit is set to "1" (main clock stop detected) ? cm23 bit is set to "1" (main clock stopped) when the pll clock corresponds to the cpu clock source and the cm20 bit is 1 , the system is placed in the following state if the main clock comes to a halt: since the cm21 bit remains unchanged, set it to 1 (on-chip oscillator clock) inside the interrupt routine. ? oscillation stop and re-oscillation detect interrupt request occurs. ? cm22 bit is set to "1" (main clock stop detected) ? cm23 bit is set to "1" (main clock stopped) ? cm21 bit remains unchanged when the cm20 bit is 1 , the system is placed in the following state if the main clock re-oscillates from the stop condition: ? oscillation stop and re-oscillation detect interrupt request occurs. ? cm22 bit is set to "1" (main clock re-oscillation detected) ? cm23 bit is set to "0" (main clock oscillation) ? cm21 bit remains unchanged 7. clock generation circuit page 53 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 7.8.3 how to use oscillation stop and re-oscillation detect function ? the oscillation stop and re-oscillation detect interrupt shares the vector with the watchdog timer inter- rupt. if the oscillation stop, re-oscillation detection and watchdog timer interrupts both are used, read the cm22 bit in an interrupt routine to determine which interrupt source is requesting the interrupt. ? where the main clock re-oscillated after oscillation stop, return the main clock to the cpu clock and peripheral function clock source in the program. figure 7.8.3.1 shows the procedure for switching the clock source from the on-chip oscillator to the main clock. ? simultaneously with oscillation stop, re-oscillation detection interrupt occurrence, the cm22 bit be- comes 1 . when the cm22 bit is set at 1 , oscillation stop, re-oscillation detection interrupt are dis- abled. by setting the cm22 bit to 0 in the program, oscillation stop, re-oscillation detection interrupt are enabled. ? if the main clock stops during low speed mode where the cm20 bit is 1 , an oscillation stop, re-oscilla- tion detection interrupt request is generated. at the same time, the on-chip oscillator starts oscillating. in this case, although the cpu clock is derived from the sub clock as it was before the interrupt oc- curred, the peripheral function clocks now are derived from the on-chip oscillator clock. ? to enter wait mode while using the oscillation stop, re-oscillation detection function, set the cm02 bit to 0 (peripheral function clocks not turned off during wait mode). ? since the oscillation stop, re-oscillation detection function is provided in preparation for main clock stop due to external factors, set the cm20 bit to 0 (oscillation stop, re-oscillation detection function dis- abled) where the main clock is stopped or oscillated in the program, that is where the stop mode is selected or the cm05 bit is altered. ? this function cannot be used if the main clock frequency is 2 mhz or less. in that case, set the cm20 bit to 0 . figure 7.8.3.1. procedure to switch clock source from on-chip oscillator to main clock main clock switch inspect the cm23 bit do this check a number of times set the cm22 bit to 0 (main clock stop, re-oscillation not detected). set the cm21 bit to 0 (main clock for the cpu clock source)(note) 1(main clock stop) 0(main clock oscillation) the main clock is confirmed to be active a number of times. all of cm21-23 are the cm2 register bits end note: if the clock source for cpu clock is to be changed to pll clock, set to pll operation mode after set to high-speed mode. 8. protection page 54 ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r 8. protection note the m16c/26t do not use the prc3 bit in the prcr register. in the event that a program runs out of control, this function protects the important registers so that they will not be rewritten easily. figure 8.1 shows the prcr register. the following lists the registers protected by the prcr register. ? registers protected by prc0 bit: cm0, cm1, cm2, plc0, rocr and pclkr registers ? registers protected by prc1 bit: pm0, pm1, pm2, tb2sc, invc0 and invc1 registers ? registers protected by prc2 bit: pd9, pacr and nddr registers ? registers protected by prc3 bit: vcr2 and d4int registers set the prc2 bit to 1 (write enabled) and then write to any address, and the prc2 bit will be cleared to 0 (write protected). the registers protected by the prc2 bit should be changed in the next instruction after setting the prc2 bit to 1 . make sure no interrupts or dma transfers will occur between the instruction in which the prc2 bit is set to 1 and the next instruction. the prc0, prc1 and prc3 bits are not automati- cally cleared to 0 by writing to any address. they can only be cleared in a program. protect register symbol address after reset prcr 000a 16 xx000000 2 bit name bit symbol b7 b6 b5 b4 b3 b2 b1 b0 0 : write protected 1 : write enabled prc1 prc0 prc2 function rw note: the prc2 bit is set to "0" by writing to any address after setting it to "1". other bits are not set to "0" by writing to any address, and must therefore be set in a program. 0 rw rw rw nothing is assigned. when write, set to "0". when read, its content is indeterminate. reserved bit must set to "0" rw protect bit 0 protect bit 1 protect bit 2 enable write to cm0, cm1, cm2, rocr, plc0 and pclkr registers 0 : write protected 1 : write enabled enable write to pm0, pm1, pm2, tb2sc, invc0 and invc1 registers 0 : write protected 1 : write enabled enable write to pd9, pacr and nddr registers prc3 rw protect bit 3 0 : write protected 1 : write enabled enable write to vcr2 and d4int registers (b5-b4) (b7-b6) 0 figure 8.1. prcr register 9. interrupt page 55 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m ? maskable interrupt: an interrupt which can be enabled (disabled) by the interrupt enable flag (i flag) or whose interrupt priority can be changed by priority level. ? non-maskable interrupt: an interrupt which cannot be enabled (disabled) by the interrupt enable flag (i flag) or whose interrupt priority cannot be changed by priority level. figure 9.1.1. interrupts interrupt ? ? ? ? ? ? ? ? ? ? ? software (non-maskable interrupt) hardware ? ? ? ? ? ? ? ? special (non-maskable interrupt) peripheral function (note 1) (maskable interrupt) ? ? ? ? ? undefined instruction (und instruction) overflow (into instruction) brk instruction int instruction ? ? ? ? ? ? ? ? ? _______ nmi ________ dbc (note 2) watchdog timer oscillation stop and re-oscillation detection voltage down detection single step (note 2) address match note 1: peripheral function interrupts are generated by the microcomputer's internal functions. note 2: do not normally use this interrupt because it is provided exclusively for use by development support tools. 9. interrupt note m16c/26a(42-pin version) do not use uart0 transmission interrupt and uart0 reception interrupt of peripheral function. m16c/26t do not use voltage down detection interrupt. 9.1 type of interrupts figure 9.1.1 shows types of interrupts. 9. interrupt page 56 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 9.1.1 software interrupts a software interrupt occurs when executing certain instructions. software interrupts are non-maskable interrupts. 9.1.1.1 undefined instruction interrupt an undefined instruction interrupt occurs when executing the und instruction. 9.1.1.2 overflow interrupt an overflow interrupt occurs when executing the into instruction with the o flag set to 1 (the opera- tion resulted in an overflow). the following are instructions whose o flag changes by arithmetic: abs, adc, adcf, add, cmp, div, divu, divx, neg, rmpa, sbb, sha, sub 9.1.1.3 brk interrupt a brk interrupt occurs when executing the brk instruction. 9.1.1.4 int instruction interrupt an int instruction interrupt occurs when executing the int instruction. software interrupt nos. 0 to 63 can be specified for the int instruction. because software interrupt nos. 4, 8 to 31 are assigned to peripheral function interrupts, the same interrupt routine as for peripheral function interrupts can be executed by executing the int instruction. in software interrupt nos. 0 to 31, the u flag is saved to the stack during instruction execution and is cleared to 0 (isp selected) before executing an interrupt sequence. the u flag is restored from the stack when returning from the interrupt routine. in software interrupt nos. 32 to 63, the u flag does not change state during instruction execution, and the sp then selected is used. 9. interrupt page 57 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 9.1.2 hardware interrupts hardware interrupts are classified into two types special interrupts and peripheral function interrupts. 9.1.2.1 special interrupts special interrupts are non-maskable interrupts. _______ 9.1.2.1.1 nmi interrupt _______ _______ an nmi interrupt is generated when input on the nmi pin changes state from high to low. for details _______ _______ about the nmi interrupt, refer to the section 9.7 nmi interrupt . ________ 9.1.2.1.2 dbc interrupt this interrupt is exclusively for debugger, do not use in any other circumstances. 9.1.2.1.3 watchdog timer interrupt generated by the watchdog timer. once a watchdog timer interrupt is generated, be sure to initialize the watchdog timer. for details about the watchdog timer, refer to the section 10. watchdog timer . 9.1.2.1.4 oscillation stop and re-oscillation detection interrupt generated by the oscillation stop and re-oscillation detection function. for details about the oscilla- tion stop and re-oscillation detection function, refer to the section 7. clock generating circuit . 9.1.2.1.5 voltage down detection interrupt generated by the voltage detection circuit. for details about the voltage detection circuit, refer to the section 5.5 voltage detection circuit . 9.1.2.1.6 single-step interrupt do not normally use this interrupt because it is provided exclusively for use by development support tools. 9.1.2.1.7 address match interrupt an address match interrupt is generated immediately before executing the instruction at the address indicated by the rmad0 or rmad1 register, if the corresponding enable bit (the aier0 or aier1 bit in the aier register) is set to 1 . for details about the address match interrupt, refer to the section 9.9 address match interrupt . 9.1.2.2 peripheral function interrupts peripheral function interrupts are maskable interrupts and generated by the microcomputer's internal functions. the interrupt sources for peripheral function interrupts are listed in table 9.2.2.1 relocatable vector tables . for details about the peripheral functions, refer to the description of each peripheral function in this manual. 9. interrupt page 58 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m interrupt source vector table addresses remarks reference address (l) to address (h) undefined instruction fffdc 16 to fffdf 16 interrupt on und instruction m16c/60, m16c/20 overflow fffe0 16 to fffe3 16 interrupt on into instruction serise software brk instruction fffe4 16 to fffe7 16 maual address match fffe8 16 to fffeb 16 address match interrupt single step (note1) fffec 16 to fffef 16 watchdog timer ffff0 16 to ffff3 16 watchdog timer oscillation stop and re-oscillation detection clock generating circuit voltage down detection voltage detection circuit ________ dbc (note1) ffff4 16 to ffff7 16 _______ nmi ffff8 16 to ffffb 16 _______ nmi interrupt reset (note 2) ffffc 16 to fffff 16 reset note 1: do not normally use this interrupt because it is provided exclusively for use by development support tools. note 2: the b3 to b0 in address 0fffff 16 are reserve bits. set these bits to 1111 2 . figure 9.2.1. interrupt vector aaaaaaaaa aaaaaaaaa mid address aaaaaaaaa aaaaaaaaa low address aaaaaaaaa aaaaaaaaa 0 0 0 0 high address aaaaaaaaa aaaaaaaaa 0 0 0 0 0 0 0 0 vector address (l) lsb msb vector address (h) 9.2 interrupts and interrupt vector one interrupt vector consists of 4 bytes. set the start address of each interrupt routine in the respective interrupt vectors. when an interrupt request is accepted, the cpu branches to the address set in the corresponding interrupt vector. figure 9.2.1 shows the interrupt vector. table 9.2.1.1. fixed vector tables if the contents of address fffe7 16 is ff 16 , program ex- ecution starts from the address shown by the vector in the relocatable vector table. 9.2.1 fixed vector tables the fixed vector tables are allocated to the addresses from fffdc 16 to fffff 16 . table 9.2.1.1 lists the fixed vector tables. in the flash memory version of microcomputer, the vector addresses (h) of fixed vectors are used by the id code check function. for details, refer to the section 17.3 flash memory rewrite disabling function . 9. interrupt page 59 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m table 9.2.2.1. relocatable vector tables software interrupt number reference note 1: address relative to address in intb. note 2: set the ifsr6 and ifsr7 bits in the ifsr register. note 3: during i 2 c bus mode, nack and ack interrupts comprise the interrupt source. note 4: these interrupts cannot be disabled using the i flag. note 5: bus collision detection : during iebus mode, this bus collision detection constitutes the cause of an interrupt. during i 2 c bus mode, however, a start condition or a stop condition detection constitutes the cause of an interrupt. vector address (note 1) address (l) to address (h) 0 11 12 13 14 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 63 to 10 15 16 5 to 7 8 4 9 1 to 3 interrupt source brk instruction int3 int4 int5 (note 2) (note 2) dma0 dma1 key input interrupt a/d uart0 transmit uart0 receive uart1 transmit uart1 receive timer a0 timer a1 timer a2 timer a3 timer a4 timer b0 timer b1 timer b2 int0 int1 int2 software interrupt uart 2 bus collision detection uart2 transmit, nack2 (note 3) uart2 receive, ack2 (note 3) m16c/60, m16c/20 series software manual int interrupt int interrupt serial i/o dmac key input interrupt a/d convertor serial i/o timer int interrupt m16c/60, m16c/20 series software manual (note 4) (reserved) +0 to +3 (0000 16 to 0003 16 ) +44 to +47 (002c 16 to 002f 16 ) +48 to +51 (0030 16 to 0033 16 ) +52 to +55 (0034 16 to 0037 16 ) +56 to +59 (0038 16 to 003b 16 ) +68 to +71 (0044 16 to 0047 16 ) +72 to +75 (0048 16 to 004b 16 ) +76 to +79 (004c 16 to 004f 16 ) +80 to +83 (0050 16 to 0053 16 ) +84 to +87 (0054 16 to 0057 16 ) +88 to +91 (0058 16 to 005b 16 ) +92 to +95 (005c 16 to 005f 16 ) +96 to +99 (0060 16 to 0063 16 ) +100 to +103 (0064 16 to 0067 16 ) +104 to +107 (0068 16 to 006b 16 ) +108 to +111 (006c 16 to 006f 16 ) +112 to +115 (0070 16 to 0073 16 ) +116 to +119 (0074 16 to 0077 16 ) +120 to +123 (0078 16 to 007b 16 ) +124 to +127 (007c 16 to 007f 16 ) +128 to +131 (0080 16 to 0083 16 ) +252 to +255 (00fc 16 to 00ff 16 ) +40 to +43 (0028 16 to 002b 16 ) +60 to +63 (003c 16 to 003f 16 ) +64 to +67 (0040 16 to 0043 16 ) +32 to +35 (0020 16 to 0023 16 ) +16 to +19 (0010 16 to 0013 16 ) +36 to +39 (0024 16 to 0027 16 ) to (note 4) (note 5) (reserved) 9.2.2 relocatable vector tables the 256 bytes beginning with the start address set in the intb register comprise a reloacatable vector table area. table 9.2.2.1 lists the relocatable vector tables. setting an even address in the intb register results in the interrupt sequence being executed faster than in the case of odd addresses. 9. interrupt page 60 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 9.3 interrupt control the following describes how to enable/disable the maskable interrupts, and how to set the priority in which order they are accepted. what is explained here does not apply to nonmaskable interrupts. use the i flag in the flg register, ipl, and the ilvl2 to ilvl0 bits in the each interrupt control register to enable/disable the maskable interrupts. whether an interrupt is requested is indicated by the ir bit in each interrupt control register. figure 9.3.1 shows the interrupt control registers. figure 9.3.2 shows the ifsr, ifsr2a registers. 9. interrupt page 61 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 9.3.1. interrupt control registers symbol address after reset int3ic 0044 16 xx00x000 2 int5ic 0048 16 xx00x000 2 int4ic 0049 16 xx00x000 2 int0ic to int2ic 005d 16 to 005f 16 xx00x000 2 bit name function bit symbol b7 b6 b5 b4 b3 b2 b1 b0 a aa ilvl0 ir pol no functions are assigned. when writing to these bits, write 0 . the values in these bits when read are indeterminate. interrupt priority level select bit interrupt request bit polarity select bit reserved bit 0: interrupt not requested 1: interrupt requested 0 : selects falling edge (notes 3, 4) 1 : selects rising edge must always be set to 0 ilvl1 ilvl2 note 1: this bit can only be reset by writing 0 (do not write 1 ). note 2: to rewrite the interrupt control register, do so at a point that does not generate the interrupt request for that register. for details, see the precautions for interrupts of the usage notes reference book. note 3: if the ifsri bit (i = 0 to 5) in the ifsr register is 1 (both edges), set the pol bit in the intiic register to 0 (falling edge). (note 1) interrupt control register (note 2) b7 b6 b5 b4 b3 b2 b1 b0 a a aa aa a a aa aa bit name function bit symbol rw symbol address after reset bcnic 004a 16 xxxxx000 2 dm0ic, dm1ic 004b 16 , 004c 16 xxxxx000 2 kupic 004d 16 xxxxx000 2 adic 004e 16 xxxxx000 2 s0tic to s2tic 0051 16 , 0053 16 , 004f 16 xxxxx000 2 s0ric to s2ric 0052 16 , 0054 16 , 0050 16 xxxxx000 2 ta0ic to ta4ic 0055 16 to 0059 16 xxxxx000 2 tb0ic to tb2ic 005a 16 to 005c 16 xxxxx000 2 ilvl0 ir interrupt priority level select bit interrupt request bit 0 : interrupt not requested 1 : interrupt requested ilvl1 ilvl2 no functions are assigned. when writing to these bits, write 0 . the values in these bits when read are indeterminate. (note 1) note 1: this bit can only be reset by writing 0 (do not write 1 ). note 2: to rewrite the interrupt control registers, do so at a point that does not generate the interrupt request for that register. for details, see the precautions for interrupts of the usage notes reference book. 0 0 0 : level 0 (interrupt disabled) 0 0 1 : level 1 0 1 0 : level 2 0 1 1 : level 3 1 0 0 : level 4 1 0 1 : level 5 1 1 0 : level 6 1 1 1 : level 7 b2 b1 b0 0 0 0 : level 0 (interrupt disabled) 0 0 1 : level 1 0 1 0 : level 2 0 1 1 : level 3 1 0 0 : level 4 1 0 1 : level 5 1 1 0 : level 6 1 1 1 : level 7 b2 b1 b0 0 rw rw rw rw (b7-b4) rw rw rw rw rw rw rw rw (b7-b6) (b5) 9. interrupt page 62 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 9.3.2. ifsr register and ifsr2a register interrupt request cause select register bit name function bit symbol rw symbol address after reset ifsr 035f 16 00 16 ifsr0 b7 b6 b5 b4 b3 b2 b1 b0 aa aa a a aa aa a a int0 interrupt polarity switching bit 0 : reserved 1 : int4 0 : reserved 1 : int5 0 : one edge 1 : both edges 0 : one edge 1 : both edges 0 : one edge 1 : both edges 0 : one edge 1 : both edges 0 : one edge 1 : both edges int1 interrupt polarity switching bit int2 interrupt polarity switching bit int3 interrupt polarity switching bit int4 interrupt polarity switching bit int5 interrupt polarity switching bit 0 : one edge 1 : both edges interrupt request cause select bit interrupt request cause select bit ifsr1 ifsr2 ifsr3 ifsr4 ifsr5 ifsr6 ifsr7 rw rw rw rw rw rw rw rw (note 1) (note 1) (note 1) (note 1) (note 1) (note 1) note 1: when setting this bit to 1 (= both edges), make sure the pol bit in the int0ic to int5ic register is set to 0 (= falling edge). interrupt request cause select register 2 bit name function bit symbol rw symbol address after reset ifsr2a 035e 16 xxxxxxx0 2 b7 b6 b5 b4 b3 b2 b1 b0 aa aa a a aa aa aa aa must be set to 1 . (b7-b1) nothing is assigned. when write, set to 0 . when read, their contents are indeterminate. ifsr20 1 reserved bit rw (note 1) note 1: set this bit to "1" before you enable interrupt after resetting. 9. interrupt page 63 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 9.3.1 i flag the i flag enables or disables the maskable interrupt. setting the i flag to 1 (= enabled) enables the maskable interrupt. setting the i flag to 0 (= disabled) disables all maskable interrupts. 9.3.2 ir bit the ir bit is set to 1 (= interrupt requested) when an interrupt request is generated. then, when the interrupt request is accepted and the cpu branches to the corresponding interrupt vector, the ir bit is cleared to 0 (= interrupt not requested). the ir bit can be cleared to 0 in a program. note that do not write 1 to this bit. 9.3.3 ilvl2 to ilvl0 bits and ipl interrupt priority levels can be set using the ilvl2 to ilvl0 bits. table 9.3.3.1 shows the settings of interrupt priority levels and table 9.3.3.2 shows the interrupt priority levels enabled by the ipl. the following are conditions under which an interrupt is accepted: i flag is set to 1 ir bit is set to 1 interrupt priority level > ipl the i flag, ir bit, ilvl2 to ilvl0 bits and ipl are independent of each other. in no case do they affect one another. table 9.3.3.2. interrupt priority levels enabled by ipl table 9.3.3.1. settings of interrupt priority levels ilvl2 to ilvl0 bits interrupt priority level priority order 000 2 001 2 010 2 011 2 100 2 101 2 110 2 111 2 level 0 (interrupt disabled) level 1 level 2 level 3 level 4 level 5 level 6 level 7 low high enabled interrupt priority levels interrupt levels 1 and above are enabled interrupt levels 2 and above are enabled interrupt levels 3 and above are enabled interrupt levels 4 and above are enabled interrupt levels 5 and above are enabled interrupt levels 6 and above are enabled interrupt levels 7 and above are enabled all maskable interrupts are disabled ipl 000 2 001 2 010 2 011 2 100 2 101 2 110 2 111 2 9. interrupt page 64 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 9.4 interrupt sequence an interrupt sequence (the devicebehavior from the instant an interrupt is accepted to the instant the inter- rupt routine is executed) is described here. if an interrupt occurs during execution of an instruction, the processor determines its priority when the execution of the instruction is completed, and transfers control to the interrupt sequence from the next cycle. if an interrupt occurs during execution of either the smovb, smovf, sstr or rmpa instruction, the processor temporarily suspends the instruction being executed, and transfers control to the interrupt sequence. the cpu behavior during the interrupt sequence is described below. figure 9.4.1 shows time required for executing the interrupt sequence. (1) the cpu gets interrupt information (interrupt number and interrupt request priority level) by reading the address 00000 16 . then it clears the ir bit for the corresponding interrupt to 0 (interrupt not requested). (2) the flg register immediately before entering the interrupt sequence is saved to the cpu s internal temporary register (note) . (3) the i, d and u flags in the flg register become as follows: the i flag is cleared to 0 (interrupts disabled). the d flag is cleared to 0 (single-step interrupt disabled). the u flag is cleared to 0 (isp selected). however, the u flag does not change state if an int instruction for software interrupt nos. 32 to 63 is executed. (4) the cpu s internal temporary register (note) is saved to the stack. (5) the pc is saved to the stack. (6) the interrupt priority level of the accepted interrupt is set in the ipl. (7) the start address of the relevant interrupt routine set in the interrupt vector is stored in the pc. after the interrupt sequence is completed, the processor resumes executing instructions from the start address of the interrupt routine. note: this register cannot be used by user. indeterminate (1) 123456789 1011 12 13 14 15 16 17 18 indeterminate (1) sp-2 contents sp-4 contents vec contents vec+2 contents interrupt information address 0000 16 indeterminate (1) sp-2 sp-4 vec vec+2 pc cpu clock address bus data bus wr (2) rd (2) notes: 1. the indeterminate state depends on the instruction queue buffer. a read cycle occurs when the instruction queue buffer is ready to accept instructions. 2. rd is the internal signal which is set to l when the internal memory is read out and wr is the internal signal which is set to l when the internal memory is written. figure 9.4.1. time required for executing interrupt sequence 9. interrupt page 65 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m interrupt sources 7 level that is set to ipl _______ watchdog timer, nmi, oscillation stop and re-oscillation detection, voltage down detection _________ software, address match, dbc, single-step not changed 9.4.2 variation of ipl when interrupt request is accepted when a maskable interrupt request is accepted, the interrupt priority level of the accepted interrupt is set in the ipl. when a software interrupt or special interrupt request is accepted, one of the interrupt priority levels listed in table 9.4.2.1 is set in the ipl. shown in table 9.4.2.1 are the ipl values of software and special interrupts when they are accepted. table 9.4.2.1. ipl level that is set to ipl when a software or special interrupt is accepted instruction interrupt sequence instruction in interrupt routine time interrupt response time (a) (b) interrupt request acknowledged interrupt request generated (a) the time from when an interrupt request is generated till when the instruction then executing is completed. the length of this time varies with the instruction being executed. the divx instruction requires the longest time, which is equal to 30 cycles (without wait state, the divisor being a register). (b) the time during which the interrupt sequence is executed. for details, see the table below. note, however, that the values in this table must be increased 2 cycles for the dbc interrupt and 1 cycle for the address match and single-step interrupts. interrupt vector address even even odd odd sp value even odd even odd without wait 18 cycles 19 cycles 19 cycles 20 cycles figure 9.4.1.1. interrupt response time 9.4.1 interrupt response time figure 9.4.1.1 shows the interrupt response time. the interrupt response or interrupt acknowledge time denotes the time from when an interrupt request is generated till when the first instruction in the interrupt routine is executed. specifically, it consists of the time from when an interrupt request is generated till when the instruction then executing is completed ((a) in figure 9.4.1.1) and the time during which the interrupt sequence is executed ((b) in figure 9.4.1.1). 9. interrupt page 66 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 9.4.3 saving registers in the interrupt sequence, the flg register and pc are saved to the stack. at this time, the 4 high-order bits of the pc and the 4 high-order (ipl) and 8 low-order bits in the flg register, 16 bits in total, are saved to the stack first. next, the 16 low-order bits of the pc are saved. figure 9.4.3.1 shows the stack status before and after an interrupt request is accepted. the other necessary registers must be saved in a program at the beginning of the interrupt routine. use the pushm instruction, and all registers except sp can be saved with a single instruction. address content of previous stack stack [sp] sp value before interrupt request is accepted. m m C 1 m C 2 m C 3 m C 4 stack status before interrupt request is acknowledged stack status after interrupt request is acknowledged content of previous stack m + 1 msb lsb m m C 1 m C 2 m C 3 m C 4 address flg l content of previous stack stack flg h pc h [sp] new sp value content of previous stack m + 1 msb lsb pc l pc m figure 9.4.3.1. stack status before and after acceptance of interrupt request 9. interrupt page 67 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 9.4.3.2. operation of saving register (2) sp contains odd number [sp] (odd) [sp] C 1 (even) [sp] C 2(odd) [sp] C 3 (even) [sp] C 4(odd) [sp] C 5 (even) address sequence in which order registers are saved (2) (1) finished saving registers in four operations. (3) (4) (1) sp contains even number [sp] (even) [sp] C 1(odd) [sp] C 2 (even) [sp] C 3(odd) [sp] C 4 (even) [sp] C 5 (odd) note: [sp] denotes the initial value of the sp when interrupt request is acknowledged. after registers are saved, the sp content is [sp] minus 4. address pc m stack flg l pc l sequence in which order registers are saved (2) saved simultaneously, all 16 bits (1) saved simultaneously, all 16 bits finished saving registers in two operations. pc m stack flg l pc l saved, 8 bits at a time flg h pc h flg h pc h the operation of saving registers carried out in the interrupt sequence is dependent on whether the sp (note) , at the time of acceptance of an interrupt request, is even or odd. if the stack pointer (note) is even, the flg register and the pc are saved, 16 bits at a time. if odd, they are saved in two steps, 8 bits at a time. figure 9.4.3.2 shows the operation of the saving registers. note: when any int instruction in software numbers 32 to 63 has been executed, this is the sp indicated by the u flag. otherwise, it is the isp. 9. interrupt page 68 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 9.5 interrupt priority if two or more interrupt requests are generated while executing one instruction, the interrupt request that has the highest priority is accepted. for maskable interrupts (peripheral functions), any desired priority level can be selected using the ilvl2 to ilvl0 bits. however, if two or more maskable interrupts have the same priority level, their interrupt priority is resolved by hardware, with the highest priority interrupt accepted. the watchdog timer and other special interrupts have their priority levels set in hardware. figure 9.5.1 shows the priorities of hardware interrupts. software interrupts are not affected by the interrupt priority. if an instruction is executed, control branches invariably to the interrupt routine. 9.4.4 returning from an interrupt routine the flg register and pc in the state in which they were immediately before entering the interrupt se- quence are restored from the stack by executing the reit instruction at the end of the interrupt routine. thereafter the cpu returns to the program which was being executed before accepting the interrupt request. return the other registers saved by a program within the interrupt routine using the popm or similar instruction before executing the reit instruction. 9.5.1 interrupt priority resolution circuit the interrupt priority resolution circuit is used to select the interrupt with the highest priority among those requested. figure 9.5.1.1 shows the circuit that judges the interrupt priority level. figure 9.5.1. hardware interrupt priority reset watchdog timer, oscillation stop and re-oscillation detection, voltage down detection peripheral function single step address match high low nmi dbc 9. interrupt page 69 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m figure 9.5.1.1. interrupts priority select circuit timer b2 timer b0 timer a3 timer a1 timer b1 timer a4 timer a2 uart1 reception uart0 reception uart2 reception, ack2 a/d conversion dma1 uart 2 bus collision timer a0 uart1 transmission uart0 transmission uart2 transmission, nack2 key input interrupt dma0 ipl i flag int1 int2 int0 watchdog timer dbc nmi interrupt request accepted level 0 (initial value) priority level of each interrupt highest lowest priority of peripheral function interrupts (if priority levels are same) int3 int5 int4 address match interrupt request level resolution output to clock generating circuit (fig.7.1.) oscillation stop and re-oscillation detection voltage down detection 9. interrupt page 70 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m ______ 9.6 int interrupt _______ inti interrupt (i=0 to 5) is triggered by the edges of external inputs. the edge polarity is selected using the ifsri bit in the ifsr register. ________ ________ ________ to use the int4 interrupt, set the ifsr6 bit in the ifsr register to "1" (=int4). to use the int5 interrupt, set ________ the ifsr7 bit in the ifsr register to "1" (=int5). after modifiying the ifsr6 or ifsr7 bit, clear the corresponding ir bit to "0" (=interrupt not requested) before enabling the interrupt. ________ the int5 input has an effective digital debounce function for a noize rejection. refer to 16.6 digital debounce function for this detail. figure 9.6.1 shows the ifsr register. figure 9.6.1. ifsr register interrupt request cause select register bit name function bit symbol rw symbol address after reset ifsr 035f 16 00 16 ifsr0 b7 b6 b5 b4 b3 b2 b1 b0 aa aa a a aa aa a a int0 interrupt polarity switching bit 0 : reserved 1 : int4 0 : reserved 1 : int5 0 : one edge 1 : both edges 0 : one edge 1 : both edges 0 : one edge 1 : both edges 0 : one edge 1 : both edges 0 : one edge 1 : both edges int1 interrupt polarity switching bit int2 interrupt polarity switching bit int3 interrupt polarity switching bit int4 interrupt polarity switching bit int5 interrupt polarity switching bit 0 : one edge 1 : both edges interrupt request cause select bit interrupt request cause select bit ifsr1 ifsr2 ifsr3 ifsr4 ifsr5 ifsr6 ifsr7 rw rw rw rw rw rw rw rw (note 1) (note 1) (note 1) (note 1) (note 1) (note 1) note 1: when setting this bit to 1 (= both edges), make sure the pol bit in the int0ic to int5ic register is set to 0 (= falling edge). 9. interrupt page 71 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m interrupt control circuit kupic register key input interrupt request ki 3 ki 2 ki 1 ki 0 pu25 bit j o u i f pd10 register pd10_7 bit j o u i f pd10 register pull-up transistor pd10_7 bit j o u i f pd10 register pd10_6 bit j o u i f pd10 register pd10_5 bit j o u i f pd10 register pd10_4 bit j o u i f pd10 register pull-up transistor pull-up transistor pull-up transistor figure 9.8.1. key input interrupt ______ 9.7 nmi interrupt _______ _______ an nmi interrupt request is generated when input on the nmi pin changes state from high to low, after the _______ ______ nmi interrupt was enabled by writing a ??to pm24 bit in the pm2 register. the nmi interrupt is a non- maskable interrupt, once it is enabled. _______ the input level of this nmi interrupt input pin can be read by accessing the p8_5 bit in the p8 register. _______ nmi is disabled by default after reset (the pin is a gpio pin, p8 5 ) and can be enabled using pm24 bit in the pm2 register. once enabled, it can only be disabled by a reset signal. _______ the nmi input has an effective digital debounce function for a noise rejection. refer to 16.6 digital debounce function for this detail. 9.8 key input interrupt of p10 4 to p10 7 , a key input interrupt is generated when input on any of the p10 4 to p10 7 pins which has had the pd10_4 to pd10_7 bits in the pd10 register set to ??(= input) goes low. key input interrupts can be used as a key-on wakeup function, the function which gets the microcomputer out of wait or stop mode. however, if you intend to use the key input interrupt, do not use p10 4 to p10 7 as analog input ports. figure 9.8.1 shows the block diagram of the key input interrupt. note, however, that while input on any pin which has had the pd10_4 to pd10_7 bits set to ??(= input mode) is pulled low, inputs on all other pins of the port are not detected as interrupts. 9. interrupt page 72 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m table 9.9.2. relationship between address match interrupt sources and associated registers address match interrupt sources address match interrupt enable bit address match interrupt register address match interrupt 0 aier0 rmad0 address match interrupt 1 aier1 rmad1 9.9 address match interrupt an address match interrupt request is generated immediately before executing the instruction at the ad- dress indicated by the rmadi register (i=0 to 1). set the start address of any instruction in the rmadi register. use the aier register s aier0 and aier1 bits to enable or disable the interrupt. note that the address match interrupt is unaffected by the i flag and ipl. for address match interrupts, the value of the pc that is saved to the stack area varies depending on the instruction being executed (refer to saving registers ). (the value of the pc that is saved to the stack area is not the correct return address.) therefore, follow one of the methods described below to return from the address match interrupt. ? rewrite the content of the stack and then use the reit instruction to return. ? restore the stack to its previous state before the interrupt request was accepted by using the pop or similar other instruction and then use a jump instruction to return. table 9.9.1 shows the value of the pc that is saved to the stack area when an address match interrupt request is accepted. figure 9.9.1 shows the aier, rmad0 and rmad1 registers. ? 16-bit op-code instruction ? instruction shown below among 8-bit operation code instructions add.b:s #imm8,dest sub.b:s #imm8,dest and.b:s #imm8,dest or.b:s #imm8,dest mov.b:s #imm8,dest stz.b:s #imm8,dest stnz.b:s #imm8,dest stzx.b:s #imm81,#imm82,dest cmp.b:s #imm8,dest pushm src popm dest jmps #imm8 jsrs #imm8 mov.b:s #imm,dest (however, dest=a0 or a1) instructions other than the above instruction at the address indicated by the rmadi register value of the pc that is saved to the stack area the address indicated by the rmadi register +2 the address indicated by the rmadi register +1 value of the pc that is saved to the stack area : refer to saving registers . table 9.9.1. value of the pc that is saved to the stack area when an address match interrupt request is accepted. 9. interrupt page 73 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m bit name bit symbol symbol address after reset aier 0009 16 xxxxxx00 2 address match interrupt enable register function rw aaaaaaaaaaaaaa a aaaaaaaaaaaa a aaaaaaaaaaaaaa aaaaaaaaaaaaaa a aaaaaaaaaaaa a aaaaaaaaaaaaaa address match interrupt 0 enable bit 0 : interrupt disabled 1 : interrupt enabled aier0 address match interrupt 1 enable bit aier1 symbol address after reset rmad0 0012 16 to 0010 16 x00000 16 rmad1 0016 16 to 0014 16 x00000 16 b7 b6 b5 b4 b3 b2 b1 b0 address setting register for address match interrupt function setting range address match interrupt register i (i = 0 to 1) 00000 16 to fffff 16 0 : interrupt disabled 1 : interrupt enabled b0 b7 b0 b3 (b19) (b16) b7 b0 (b15) (b8) b7 (b23) rw rw (b7-b2) rw rw nothing is assigned. when write, set to 0 . when read, their contents are indeterminate. nothing is assigned. when write, set to 0 . when read, their contents are indeterminate. figure 9.9.1. aier register, rmad0 and rmad1 registers 10. watchdog timer page 74 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 10. watchdog timer the watchdog timer is the function of detecting when the program is out of control. therefore, we recom- mend using the watchdog timer to improve reliability of a system. the watchdog timer contains a 15-bit counter which counts down the clock derived by dividing the cpu clock using the prescaler. whether to generate a watchdog timer interrupt request or apply a watchdog timer reset as an operation to be per- formed when the watchdog timer underflows after reaching the terminal count can be selected using the pm12 bit in the pm1 register. the pm12 bit can only be set to 1 (reset). once this bit is set to 1 , it cannot be set to 0 (watchdog timer interrupt) in a program. refer to 5.3 watchdog timer reset for the details of watchdog timer reset. when the main clock source is selected for cpu clock, on-chip oscillator clock, pll clock, the wdc7 bit value in the wdc register for prescaler can be chosen to be 16 or 128. if a sub-clock is selected for cpu clock, the prescaler is always 2 no matter how the wdc7 bit is set. the period of watchdog timer can be calculated as given below. the period of watchdog timer is, however, subject to an error due to the prescaler. for example, when cpu clock = 16 mhz and the divide-by-n value for the prescaler= 16, the watchdog timer period is approx. 32.8 ms. the watchdog timer is initialized by writing to the wdts register. the prescaler is initialized after reset. note that the watchdog timer and the prescaler both are inactive after reset, so that the watchdog timer is activated to start counting by writing to the wdts register. in stop mode, wait mode and when erase/program opration is excuting in ew1 mode without erase sus- pend requeired, the watchdog timer and prescaler are stopped. counting is resumed from the held value when the modes or state are released. figure 10.1 shows the block diagram of the watchdog timer. figure 10.2 shows the watchdog timer-related registers. with main clock source chosen for cpu clock, on-chip oscillator clock, pll clock watchdog timer period = with sub-clock chosen for cpu clock watchdog timer period = prescaler dividing (16 or 128) x watchdog timer count (32768) cpu clock prescaler dividing (2) x watchdog timer count (32768) cpu clock figure 10.1. watchdog timer block diagram cpu clock write to wdts register reset pm12 = 0 watchdog timer set to 7fff 16 1/128 1/16 cm07 = 0 wdc7 = 1 cm07 = 0 wdc7 = 0 cm07 = 1 1/2 prescaler pm12 = 1 watchdog timer interrupt request reset pm22 = 0 pm22 = 1 on-chip oscillator clock 10. watchdog timer page 75 8 2 3 f o 5 0 0 2 , 5 1 . r a m 0 0 . 1 . v e r 0 0 1 0 - 2 0 2 0 b 9 0 j e r ) t 6 2 / c 6 1 m , a 6 2 / c 6 1 m ( p u o r g a 6 2 / c 6 1 m 10.1 count source protective mode in this mode, a on-chip oscillator clock is used for the watchdog timer count source. the watchdog timer can be kept being clocked even when cpu clock stops as a result of run-away. before this mode can be used, the following register settings are required: (1) set the prc1 bit in the prcr register to ??(enable writes to pm1 and pm2 registers). (2) set the pm12 bit in the pm1 register to ??(reset when the watchdog timer underflows). (3) set the pm22 bit in the pm2 register to ??(on-chip oscillator clock used for the watchdog timer count source). (4) set the prc1 bit in the prcr register to ??(disable writes to pm1 and pm2 registers). (5) write to the wdts register (watchdog timer starts counting). setting the pm22 bit to ??results in the following conditions ?the on-chip oscillator starts oscillating, and the in-chip oscillator clock becomes the watchdog timer count source. ?the cm10 bit in the cm1 register is disabled against write. (writing a ??has no effect, nor is stop mode entered.) ?the watchdog timer does not stop when in wait mode. figure 10.2 wdc register and wdts register watchdog timer start register (note) symbol address after reset wdts 000e 16 indeterminate wo b7 b0 function the watchdog timer is initialized and starts counting after a write instruction to this register. the watchdog timer value is always initialized to 7fff 16 regardless of whatever value is written. rw note : write to the wdts register after the watchdog timer interrupt occurs. watchdog timer control register symbol address after reset wdc 000f 16 00xxxxxx 2 (note 2) function bit symbol rw b7 b6 b5 b4 b3 b2 b1 b0 high-order bit of watchdog timer wdc7 bit name prescaler select bit 0 : divided by 16 1 : divided by 128 reserved bit must set to 0 0 ro rw rw rw cold start / warm start discrimination flag (note 1,2,3) 0 : cold start 1 : warm start wdc5 note 1: writing to the wdc register causes the wdc5 bit to be set to 1 (warm start). * g u i f w p m u b h f b q q m j f e u p 7 d d j t m f t t u i b o 7 f j u i f s x s j u f u p u i j t s f h j t u f s x i f o u i f $ 1 6 d m p d l g s f r v f o d z j t . ) [ p s x s j u f u x j d f / p u f 5 i f 8 % $ c j u j t t f u u p d p m e t u b s u |